Initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
@Packet name Quests
|
||||
@Packet identifier 147
|
||||
@Description Sends the quests' data
|
||||
@Data pId
|
||||
@Structure -
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
init: () => {
|
||||
const buffer = new ArrayBuffer(512);
|
||||
const view = new DataView(buffer);
|
||||
view.setUint8(0, 147);
|
||||
view.setUint8(1, 0);
|
||||
|
||||
let i = 0;
|
||||
|
||||
return {
|
||||
update: d => {
|
||||
const { id, progression } = d;
|
||||
|
||||
view.setUint16(2 + i, id);
|
||||
view.setUint8(2 + i + 2, progression.length);
|
||||
progression.forEach((p, j) => view.setUint32(2 + i + 3 + j * 4, p.amount));
|
||||
|
||||
i += 3 + progression.length * 4;
|
||||
},
|
||||
get: () => {
|
||||
view.setUint8(1, i + 2);
|
||||
return buffer.slice(0, i + 2);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user