Initial commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
const game = require("../Game/Game");
|
||||
const { players } = game;
|
||||
|
||||
const SpyResultPacket = require("../Packets/SpyResult");
|
||||
|
||||
module.exports = function (ws, message, player) {
|
||||
const spyID = message.getUint32(1);
|
||||
const spiedPlayer = players[spyID];
|
||||
|
||||
let spiedPlayerLocation = {};
|
||||
|
||||
if (!spiedPlayer) {
|
||||
spiedPlayerLocation = {
|
||||
mapID: 255,
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
} else if (spiedPlayer.isAlive) {
|
||||
spiedPlayerLocation = {
|
||||
mapID: spiedPlayer.map.id,
|
||||
x: spiedPlayer.position.x,
|
||||
y: spiedPlayer.position.y
|
||||
};
|
||||
} else {
|
||||
spiedPlayerLocation = {
|
||||
mapID: 0,
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
};
|
||||
|
||||
const packet = SpyResultPacket(spiedPlayerLocation);
|
||||
ws.send(packet, true, true);
|
||||
};
|
||||
Reference in New Issue
Block a user