underscore读取,排行榜保护

This commit is contained in:
mamengke01
2021-01-12 14:12:19 +08:00
parent 58f3e94fc0
commit 22f2eed34e
16 changed files with 53 additions and 51 deletions

View File

@@ -1,6 +1,6 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose';
const _ = require('underscore');
import { findIndex } from 'underscore';
// const Transaction = require("mongoose-transactions");
@index({ roleId: 1, id: 1 })
@index({ seqId: 1 })
@@ -60,7 +60,7 @@ export default class Item extends BaseModel {
rec = await ItemModel.findOneAndUpdate({ roleId, id }, { $inc: { count: ratio * count } }, { new: true, upsert: true }).lean(lean);
}
if (!!rec) {
let index = _.findIndex(result,{id})
let index = findIndex(result,{id})
if (!!result[index]) {
result[index] = { id: rec.id, count: rec.count }
} else {

View File

@@ -3,7 +3,7 @@ import {decodeArrayListStr, readJsonFile, parseGoodStr, parseNumberList, decodeA
import { FILENAME, IT_TYPE, ABI_TYPE , GOOD_TYPE} from '../../consts'
import { RewardInter } from '../interface';
const _ = require('lodash');
const underscore = require('underscore');
import { findWhere } from 'underscore';
export interface SpecialMaterial {
readonly ids: number[];
@@ -107,7 +107,7 @@ arr.forEach(o => {
} else if (o.goodType == GOOD_TYPE.JEWEL) {
let material = o.composeMaterial[0];
if (!!material && !!material.id) {
let lastJewel = underscore.findWhere(arr,{good_id:material.id});
let lastJewel = findWhere(arr,{good_id:material.id});
if (!!lastJewel) {
lastJewel.count = material.count;
lastJewel.nextJewelId = o.good_id;

View File

@@ -8,7 +8,7 @@ import { gameData } from './data';
import { RANDOM_SE_COUNT, FIX_ATTRIBUTES_RAN, ITID } from '../consts';
import { getRandValueByMinMax, getRandEelm } from './util';
const _ = require('underscore');
import { findWhere } from 'underscore';
export async function addSkins(roleId: string, id: number) {
let skinInfo = gameData.fashion.get(id);
@@ -17,7 +17,7 @@ export async function addSkins(roleId: string, id: number) {
let hero = await HeroModel.findByHidAndRole(skinInfo.actorId, roleId);
if (!hero)
return false;
if (!!_.findWhere(hero.skins, { id }))
if (!!findWhere(hero.skins, { id }))
return false;
hero.skins.push({ id, enable: false });
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);

View File

@@ -16,9 +16,9 @@ import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool';
import { getGoodById } from './gamedata';
import { SchoolModel } from '../db/School';
import { getTeraphAttr, HEROTARIN } from '../consts/constModules/abilityConst'
// import { PvpDefenseModel } from '../db/PvpDefense';
import { PvpDefenseModel } from '../db/PvpDefense';
const HERO_CE_RATIO = 100;
const _ = require('underscore');
import { findIndex } from 'underscore';
//战力计算TODO
export function calPlayerCe(globalCeAttr: CeAttrRole, hero: HeroType, type: number, args: Array<number> = []) {
let heroCe = 0;
@@ -108,7 +108,7 @@ export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>,
incPlayerCe += incHeroCe;
await calculateTopFive(role, hero.hid, hero.ce, hero._id); // 计算更新最强五人战力
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
//await PvpDefenseModel.updateCe(roleId, hero.hid, hero.ce); // 更新pvp防守阵最强五人战力
await PvpDefenseModel.updateCe(roleId, hero.hid, hero.ce); // 更新pvp防守阵战力
pushHeros.push({
hid: hero.hid,
ce: reduceCe(hero.ce),
@@ -294,13 +294,13 @@ export function calHeroJobStageUpIncAttr(hero: HeroType, args: Array<number>, ad
let lastJob = gameData.job.get(args[0]) || { seid: [] };
let currentJob = gameData.job.get(hero.job);
for (let seid of currentJob.seid) {
let index = _.findIndex(lastJob.seid, seid);
let index = findIndex(lastJob.seid, seid);
if (index < 0) {
addSeidList.push(seid, 0);
}
}
for (let seid of lastJob.seid) {
let index = _.findIndex(currentJob.seid, seid);
let index = findIndex(currentJob.seid, seid);
if (index < 0) {
removeSeidList.push(seid, 0);
}

View File

@@ -7,7 +7,7 @@ import path = require('path');
import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool';
import { HERO_CE_RATIO, ABI_STAGE } from '../consts';
const _ = require('underscore');
import { uniq, findWhere, findIndex } from 'underscore';
const moment = require('moment');
@@ -475,7 +475,7 @@ export function parseNumberList(str: string) {
export function mergeSameGoods(goods: Array<{ id: number, count: number }>) {
let resGoods = [];
for (let { id, count } of goods) {
let index = _.findIndex(resGoods, { id });
let index = findIndex(resGoods, { id });
if (index > -1) {
resGoods[index].count += count;
} else {