action = ({ dispatch }, _package) => { const qty = _package.getByte(3); const list = []; const cities = []; if (qty < 5 || qty > 7) { throw 'character count in 0xA9 is not valid. it should be in (5, 6, 7)'; } for(let i = 0; i < qty; i++) { list.push({ name : _package.getString(4 + i * 60, 30), password : _package.getString(34 + i * 60, 30) }); } const qtyCities = _package.getByte(4 + (qty * 60)); const offset = 4 + (qty * 60); for(let i = 0; i < qtyCities; i++) { cities.push({ index : _package.getByte(offset + (1 + i * 63)), name : _package.getString(offset + (2 + i * 63), 30), tavern : _package.getString(offset + (33 + i * 63), 30) }) } dispatch(character.list({ list, cities })); }
action = ({ dispatch }, _package) => { const code = _package.getByte(1); dispatch( character.removeError({ code, message : this.message[code] || this.message[100] }) ); }