mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 02:10:18 +01:00
chagned format of the penalty for not sending location
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { isInCircle } from "./map_utils.js";
|
||||
import { sendUpdatedTeamInformations } from "./team_socket.js";
|
||||
import { ZoneManager } from "./zone_manager.js";
|
||||
|
||||
export const GameState = {
|
||||
@@ -56,7 +57,7 @@ export default class Game {
|
||||
chased: null,
|
||||
currentLocation: null,
|
||||
lastSentLocation: null,
|
||||
lastSentLocationDate: null,
|
||||
locationSendDeadline: null,
|
||||
enemyLocation: null,
|
||||
captureCode: this.createCaptureCode(),
|
||||
sockets: [],
|
||||
@@ -140,6 +141,8 @@ export default class Game {
|
||||
initLastSentLocations() {
|
||||
for(let team of this.teams) {
|
||||
team.lastSentLocation = team.currentLocation;
|
||||
team.locationSendDeadline = Number(new Date()) + process.env.ALLOWED_TIME_BETWEEN_POSITION_UPDATE_IN_MINUTES * 60 * 1000;
|
||||
sendUpdatedTeamInformations(team.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +151,7 @@ export default class Game {
|
||||
if(team == undefined) {
|
||||
return false;
|
||||
}
|
||||
team.lastSentLocationDate = new Date();
|
||||
team.locationSendDeadline = Number(new Date()) + process.env.ALLOWED_TIME_BETWEEN_POSITION_UPDATE_IN_MINUTES * 60 * 1000;
|
||||
team.lastSentLocation = team.currentLocation;
|
||||
if(this.getTeam(team.chasing) != null) {
|
||||
team.enemyLocation = this.getTeam(team.chasing).lastSentLocation;
|
||||
|
||||
@@ -78,11 +78,11 @@ export class PenaltyController {
|
||||
this.game.teams.forEach((team) => {
|
||||
//If the team has not sent their location for more than the allowed period, automatically send it and add a penalty
|
||||
if (team.captured) { return }
|
||||
if(team.lastSentLocationDate == null) {
|
||||
team.lastSentLocationDate = new Date();
|
||||
if(team.locationSendDeadline == null) {
|
||||
team.locationSendDeadline = Number(new Date()) + process.env.ALLOWED_TIME_BETWEEN_POSITION_UPDATE_IN_MINUTES * 60 * 1000;
|
||||
return;
|
||||
}
|
||||
if (new Date() - team.lastSentLocationDate > process.env.ALLOWED_TIME_BETWEEN_POSITION_UPDATE_IN_MINUTES * 60 * 1000) {
|
||||
if (new Date() > team.locationSendDeadline) {
|
||||
this.addPenalty(team.id);
|
||||
this.game.sendLocation(team.id);
|
||||
sendUpdatedTeamInformations(team.id);
|
||||
|
||||
@@ -42,7 +42,7 @@ export function sendUpdatedTeamInformations(teamId) {
|
||||
enemyLocation: team.enemyLocation,
|
||||
currentLocation: team.currentLocation,
|
||||
lastSentLocation: team.lastSentLocation,
|
||||
lastSentLocationDate: team.lastSentLocationDate,
|
||||
locationSendDeadline: team.locationSendDeadline,
|
||||
captureCode: team.captureCode,
|
||||
startingArea: team.startingArea,
|
||||
ready: team.ready,
|
||||
@@ -104,7 +104,7 @@ export function initTeamSocket() {
|
||||
return;
|
||||
}
|
||||
game.updateTeamChasing();
|
||||
teamBroadcast(teamId, "update_team", { enemyLocation: team.enemyLocation });
|
||||
teamBroadcast(teamId, "update_team", { enemyLocation: team.enemyLocation,locationSendDeadline: team.locationSendDeadline });
|
||||
});
|
||||
|
||||
socket.on('capture', (captureCode) => {
|
||||
|
||||
Reference in New Issue
Block a user