57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { pinus } from "pinus";
|
|
import { MemComBtlTeam } from "../../domain/battleField/ComBattleTeamField";
|
|
|
|
let teamMap = new Map<string, MemComBtlTeam>();
|
|
let teamDisTimer = new Map<string, NodeJS.Timer>();
|
|
let robotHurtTimer = new Map<string, NodeJS.Timer>();
|
|
|
|
|
|
export function addComTeam(teamCode: string, team: MemComBtlTeam) {
|
|
teamMap.set(teamCode, team);
|
|
pinus.app.set('teamMap', teamMap);
|
|
return teamMap
|
|
}
|
|
|
|
export function getTeamMap() {
|
|
return teamMap;
|
|
}
|
|
|
|
export function getComTeamByCode(teamCode: string) {
|
|
return teamMap.get(teamCode);
|
|
}
|
|
|
|
export function deleteComBattle(teamCode: string) {
|
|
let rmSt = teamMap.delete(teamCode);
|
|
return rmSt
|
|
}
|
|
|
|
export function getComTeamTimerByCode(teamCode: string) {
|
|
return teamDisTimer.get(teamCode)
|
|
}
|
|
|
|
export function setComTeamTimer(teamCode: string, timer: NodeJS.Timer) {
|
|
teamDisTimer.set(teamCode, timer);
|
|
pinus.app.set('teamDisTimer', teamDisTimer);
|
|
}
|
|
|
|
export function clearComBtlTimer(teamCode: string) {
|
|
let timer = getComTeamTimerByCode(teamCode);
|
|
if (timer) {
|
|
clearTimeout(timer);
|
|
teamDisTimer.delete(teamCode)
|
|
}
|
|
pinus.app.set('teamDisTimer', teamDisTimer);
|
|
}
|
|
|
|
export function getRobotHurtTimer(teamCode: string, roleId: string) {
|
|
const timerKey = `${teamCode}_${roleId}`;
|
|
return robotHurtTimer.get(timerKey);
|
|
}
|
|
|
|
export function setRobotHurtTimerIfNotExist(teamCode: string, roleId: string, robotTimer: NodeJS.Timer) {
|
|
const timerKey = `${teamCode}_${roleId}`;
|
|
if(!robotHurtTimer.has(timerKey)) {
|
|
robotHurtTimer.set(timerKey, robotTimer);
|
|
pinus.app.set('robotHurtTimer', robotHurtTimer);
|
|
}
|
|
} |