将扩展的Map.inc方法改为zinc

This commit is contained in:
zhl 2021-03-25 13:50:20 +08:00
parent f349f827f0
commit b898391648
3 changed files with 10 additions and 10 deletions

View File

@ -888,11 +888,11 @@ interface Map<K, V> {
* @param key * @param key
* @param value * @param value
*/ */
inc?(key: K, value: V): this; zinc?(key: K, value: V): this;
} }
Object.defineProperties(Map.prototype, { Object.defineProperties(Map.prototype, {
inc: { zinc: {
value: function<K, V> (key: K, value: V) { value: function<K, V> (key: K, value: V) {
if (typeof value == 'number') { if (typeof value == 'number') {
this.set(key, (this.get(key) || 0) + value ); this.set(key, (this.get(key) || 0) + value );

View File

@ -57,8 +57,8 @@ export default class MatchController extends BaseController {
} }
await BagItem.addItems(accountid, items, 'game_left', roomid) await BagItem.addItems(accountid, items, 'game_left', roomid)
// 更新逃跑次数 // 更新逃跑次数
user.season_data.inc('escape', 1) user.season_data.zinc('escape', 1)
user.season_data.inc('loss', 1) user.season_data.zinc('loss', 1)
const fc = global.$cfg.get(BaseConst.FORMULA) const fc = global.$cfg.get(BaseConst.FORMULA)
let oldScore = user.season_score let oldScore = user.season_score
user.season_score = Math.max((user.season_score + scoreChange) | 0, fc.get(70002).number) user.season_score = Math.max((user.season_score + scoreChange) | 0, fc.get(70002).number)

View File

@ -59,9 +59,9 @@ export async function parsePlayerMatchDate(player: GamePlayer, user: any, winner
*/ */
if (!player.escape) { if (!player.escape) {
if (winner == player.team) { if (winner == player.team) {
user.season_data.inc('win', 1) user.season_data.zinc('win', 1)
} else { } else {
user.season_data.inc('loss', 1) user.season_data.zinc('loss', 1)
} }
let statData = player.statdata let statData = player.statdata
let honorp = 0 let honorp = 0
@ -75,9 +75,9 @@ export async function parsePlayerMatchDate(player: GamePlayer, user: any, winner
let val = Number(statData[key]) let val = Number(statData[key])
honorp += val * scores[numKey] honorp += val * scores[numKey]
if (numKey == 4 || numKey == 5) { if (numKey == 4 || numKey == 5) {
user.season_data.inc(key + '_total', val) user.season_data.zinc(key + '_total', val)
} else { } 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 + '')) { 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.set(key + '', val)
} }
} }
user.season_data.inc('honor_ap', honorp) user.season_data.zinc('honor_ap', honorp)
user.season_data.inc('mvp_ap', player.mvpscore) user.season_data.zinc('mvp_ap', player.mvpscore)
} }
/** /**
* end of * end of