/* @Packet name Cannonballs @Packet identifier 153 @Description Sends the @Data pId, (ammunitionId, damage, amount), selectedAmmunition @Structure - */ module.exports = function (data) { const { ammunition, selected } = data; const packetLength = ammunition.length * 6 + 2 + 1; const buffer = new ArrayBuffer(packetLength); const view = new DataView(buffer); view.setUint8(0, 153); view.setUint8(1, packetLength); for (let i = 0; i < ammunition.length; i++) { const ammo = ammunition[i]; view.setUint8(i * 6 + 2, ammo.id); view.setUint8(i * 6 + 3, 0); view.setUint32(i * 6 + 4, ammo.amount); }; view.setUint8(2 + ammunition.length * 6, selected); return buffer; };