27 lines
835 B
JavaScript
27 lines
835 B
JavaScript
/*
|
|
@Packet name StatusPoints
|
|
@Packet identifier 157
|
|
@Description Sends points data (pirate, elite, fishing levels)
|
|
@Data pId, experience
|
|
@Structure -
|
|
*/
|
|
|
|
module.exports = function (data) {
|
|
const { statusPoints } = data;
|
|
const statusPointsSize = statusPoints.length * 5;
|
|
const packetLength = 1 + 1 + statusPointsSize;
|
|
const buffer = new ArrayBuffer(packetLength);
|
|
const view = new DataView(buffer);
|
|
|
|
view.setUint8(0, 157);
|
|
view.setUint8(1, packetLength);
|
|
|
|
for (let i = 0, length = statusPoints.length; i < length; i++) {
|
|
const statusPoint = statusPoints[i];
|
|
|
|
view.setUint8(2 + i * 5, statusPoint.id);
|
|
view.setUint32(2 + i * 5 + 1, statusPoint.amount);
|
|
};
|
|
|
|
return buffer;
|
|
}; |