mirror of
https://github.com/MaciejkaG/statki.git
synced 2024-11-30 03:22:54 +01:00
Minor changes
- Fixed critical error (undefined value causing a crash when player leaves) - Fixed hit registration ghosting problem causing fake ships to appear to the opponent
This commit is contained in:
parent
284c74b746
commit
44f13469cf
2
index.js
2
index.js
@ -29,7 +29,6 @@ const io = new Server(server);
|
|||||||
const redis = createClient();
|
const redis = createClient();
|
||||||
redis.on('error', err => console.log('Redis Client Error', err));
|
redis.on('error', err => console.log('Redis Client Error', err));
|
||||||
await redis.connect();
|
await redis.connect();
|
||||||
// redis.flushDb();
|
|
||||||
|
|
||||||
const GInfo = new bships.GameInfo(redis, io);
|
const GInfo = new bships.GameInfo(redis, io);
|
||||||
|
|
||||||
@ -325,6 +324,7 @@ io.on('connection', async (socket) => {
|
|||||||
const playerGame = await GInfo.getPlayerGameData(socket);
|
const playerGame = await GInfo.getPlayerGameData(socket);
|
||||||
if (playerGame !== null) {
|
if (playerGame !== null) {
|
||||||
AFKEnd(playerGame.id);
|
AFKEnd(playerGame.id);
|
||||||
|
await GInfo.resetTimer(playerGame.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -217,8 +217,7 @@ export function checkHit(ships, posX, posY) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let l = !ship.type ? ship.type + 1 : ship.type + 2;
|
for (let i = 0; i <= ship.type; i++) {
|
||||||
for (let i = 0; i < l; i++) {
|
|
||||||
let x = clamp(ship.posX + multips[0] * i, 0, 9);
|
let x = clamp(ship.posX + multips[0] * i, 0, 9);
|
||||||
let y = clamp(ship.posY + multips[1] * i, 0, 9);
|
let y = clamp(ship.posY + multips[1] * i, 0, 9);
|
||||||
|
|
||||||
@ -265,7 +264,7 @@ export function validateShipPosition(ships, type, posX, posY, rot) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < ship.type + 1; i++) {
|
for (let i = 0; i <= ship.type; i++) {
|
||||||
boardRender[ship.posX + multips[0] * i][ship.posY + multips[1] * i] = true;
|
boardRender[ship.posX + multips[0] * i][ship.posY + multips[1] * i] = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user