Riskless/static/js/packet.js

60 lines
1.2 KiB
JavaScript
Raw Normal View History

class Packet {
static _createBase(name) {
return {
type: name,
id: window.crypto.randomUUID(),
author: ID,
};
}
static createAnnounce() {
return {
...this._createBase("ANNOUNCE"),
name: "",
};
}
static createDisconnect() {
return this._createBase("DISCONNECT");
}
static createKeepAlive() {
return this._createBase("KEEPALIVE");
}
static createSetReady(nowReady) {
return {
...this._createBase("READY"),
ready: nowReady,
};
}
static createBarrierSignal() {
return this._createBase("BARRIER");
}
2023-02-06 11:04:37 +00:00
static createRegionClaim(region) {
return {
2023-02-10 15:47:21 +00:00
...this._createBase("ACT"),
region: region,
};
}
2023-02-17 12:46:21 +00:00
static createAction(action, startRegion, endRegion, amount) {
2023-02-10 15:47:21 +00:00
return {
...this._createBase("ACT"),
2023-02-17 12:46:21 +00:00
startRegion: startRegion,
endRegion: endRegion,
strength: amount,
action: action,
2023-02-06 11:04:37 +00:00
};
}
2023-02-16 09:38:03 +00:00
static createEndTurn() {
return {
...this._createBase("ACT"),
action: "END",
};
}
}