🦄 refactor(热更新): 分割状态代码和功能代码
This commit is contained in:
57
game-server/app/services/memoryCache/comBattleData.ts
Normal file
57
game-server/app/services/memoryCache/comBattleData.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user