34 lines
852 B
JavaScript
34 lines
852 B
JavaScript
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);
|
|
}; |