diff --git a/src/common/Extend.ts b/src/common/Extend.ts index 6a3726f..1121ad8 100644 --- a/src/common/Extend.ts +++ b/src/common/Extend.ts @@ -888,11 +888,11 @@ interface Map { * @param key * @param value */ - inc?(key: K, value: V): this; + zinc?(key: K, value: V): this; } Object.defineProperties(Map.prototype, { - inc: { + zinc: { value: function (key: K, value: V) { if (typeof value == 'number') { this.set(key, (this.get(key) || 0) + value ); diff --git a/src/controllers/MatchController.ts b/src/controllers/MatchController.ts index dd1d721..8582ee1 100644 --- a/src/controllers/MatchController.ts +++ b/src/controllers/MatchController.ts @@ -57,8 +57,8 @@ export default class MatchController extends BaseController { } await BagItem.addItems(accountid, items, 'game_left', roomid) // 更新逃跑次数 - user.season_data.inc('escape', 1) - user.season_data.inc('loss', 1) + user.season_data.zinc('escape', 1) + user.season_data.zinc('loss', 1) const fc = global.$cfg.get(BaseConst.FORMULA) let oldScore = user.season_score user.season_score = Math.max((user.season_score + scoreChange) | 0, fc.get(70002).number) diff --git a/src/dao/RecordDao.ts b/src/dao/RecordDao.ts index 31cdde9..9e258f5 100644 --- a/src/dao/RecordDao.ts +++ b/src/dao/RecordDao.ts @@ -59,9 +59,9 @@ export async function parsePlayerMatchDate(player: GamePlayer, user: any, winner */ if (!player.escape) { if (winner == player.team) { - user.season_data.inc('win', 1) + user.season_data.zinc('win', 1) } else { - user.season_data.inc('loss', 1) + user.season_data.zinc('loss', 1) } let statData = player.statdata let honorp = 0 @@ -75,9 +75,9 @@ export async function parsePlayerMatchDate(player: GamePlayer, user: any, winner let val = Number(statData[key]) honorp += val * scores[numKey] if (numKey == 4 || numKey == 5) { - user.season_data.inc(key + '_total', val) + user.season_data.zinc(key + '_total', val) } else { - user.season_data.inc(key + '_total', val * scores[numKey]) + user.season_data.zinc(key + '_total', val * scores[numKey]) } if (user.season_data.has(key + '')) { @@ -86,8 +86,8 @@ export async function parsePlayerMatchDate(player: GamePlayer, user: any, winner user.season_data.set(key + '', val) } } - user.season_data.inc('honor_ap', honorp) - user.season_data.inc('mvp_ap', player.mvpscore) + user.season_data.zinc('honor_ap', honorp) + user.season_data.zinc('mvp_ap', player.mvpscore) } /** * end of 处理比赛统计信息