mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 10:20:16 +01:00
refactoed backend code to split team and admin messagin logic
This commit is contained in:
27
traque-back/penalty_controller.js
Normal file
27
traque-back/penalty_controller.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { game } from ".";
|
||||
import { sendUpdatedTeamInformations, teamBroadcast } from "./team_socket";
|
||||
|
||||
export class PenaltyController {
|
||||
constructor(game) {
|
||||
|
||||
}
|
||||
|
||||
addPenalty(teamId) {
|
||||
let team = game.getTeam(teamId);
|
||||
if(team.captured) {
|
||||
return;
|
||||
}
|
||||
team.penalties++;
|
||||
if(team.penalties == game.MAX_PENALTIES) {
|
||||
game.requestCapture(team.chased);
|
||||
sendUpdatedTeamInformations(teamId);
|
||||
sendUpdatedTeamInformations(team.chased);
|
||||
teamBroadcast(teamId, "warning", "You have been eliminated (reason: too many penalties)")
|
||||
teamBroadcast(team.chased, "success", "The team you are chasing has changed")
|
||||
}
|
||||
}
|
||||
|
||||
watchZone() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user