From b898391648382b8f3009a55ea0d39b6c548d6319 Mon Sep 17 00:00:00 2001 From: zhl Date: Thu, 25 Mar 2021 13:50:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=89=A9=E5=B1=95=E7=9A=84Map.inc?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=94=B9=E4=B8=BAzinc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/Extend.ts | 4 ++-- src/controllers/MatchController.ts | 4 ++-- src/dao/RecordDao.ts | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) 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 处理比赛统计信息