underscore读取,排行榜保护

This commit is contained in:
mamengke01
2021-01-12 14:13:30 +08:00
parent 58f3e94fc0
commit 22f2eed34e
16 changed files with 53 additions and 51 deletions
+3 -3
View File
@@ -7,7 +7,7 @@ import { calPlayerCeAndSave } from "./playerCeService";
import { HERO_SYSTEM_TYPE } from "../consts";
import { EquipType } from "../db/Equip";
import { calEquipSeids } from '../pubUtils/playerCe';
const _ = require('underscore');
import { indexOf, findIndex } from 'underscore';
export function checkMaterialEnough(consumes:Array<{id: number, count: number}>, jewel: number, jewelCount: number) {
let comJewelMap = {};
consumes = mergeSameGoods(consumes);
@@ -51,7 +51,7 @@ export async function changeEquip(roleId: string, sid: string, equip: EquipType,
let { jobid } = gameData.hero.get(hid);
let { job_class } = getHeroJob(jobid);
let { classId } = getHeroEquipByClassId(goodInfo.itid);
if (_.indexOf(classId, job_class) < 0)
if (indexOf(classId, job_class) < 0)
return takeOffEquip(equip.seqId);
return dressEquip(roleId, sid, hero, equip);
} else {
@@ -63,7 +63,7 @@ export async function changeEquip(roleId: string, sid: string, equip: EquipType,
}
export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, seqId: number, hero:HeroType, id: number ) {
let index = _.findIndex(hero.ePlace, { id });
let index = findIndex(hero.ePlace, { id });
if (index < 0)
return;
await EquipModel.updateEquipInfo(seqId, { hid: 0 });
@@ -8,7 +8,6 @@ import { STATUS } from '../consts/statusCode';
import { resResult, reduceCe } from '../pubUtils/util';
import { calPlayerCeAndSave as pubCalPlayerCeAndSave, reCalAllHeroCe } from '../pubUtils/playerCe';
import { HeroType } from '../db/Hero';
const _ = require('underscore');
import { defaultHeroes } from './pvpService';
//修改并下发战力
+4 -4
View File
@@ -18,7 +18,7 @@ import { HeroModel, HeroType } from '../db/Hero';
import { CeAttrNumber, CeAttr, CeAttrRole } from '../db/generalField';
import { DicWarJson } from '../pubUtils/dictionary/DicWarJson';
import { OutliningSpanKind } from 'typescript';
const _ = require('underscore');
import { findWhere, findIndex } from 'underscore';
export async function initPvpInfo(role: RoleType) {
@@ -251,7 +251,7 @@ export async function defaultHeroes ( role:RoleType, challengeCnt?:number, chall
return b.ce - b.dataId - a.ce + a.dataId;
});
for (let hero of heroes) {
if (!!hero.order&& !!hero.hero && _.findIndex(role.topFive, {hid: hero.actorId}) != -1) {
if (!!hero.order&& !!hero.hero && findIndex(role.topFive, {hid: hero.actorId}) != -1) {
let index = orders.indexOf(hero.order);
orders.splice(index, 1);
}
@@ -260,14 +260,14 @@ export async function defaultHeroes ( role:RoleType, challengeCnt?:number, chall
let num = 0;
for (let i = 0; i < role.topFive.length; i++) {
let item = role.topFive[i];
let index = _.findIndex(heroes, {actorId: item.hid});
let index = findIndex(heroes, {actorId: item.hid});
if (index == -1) {
for (let j = num; j < heroes.length; j++) {
let hero = heroes[j];
if (num >= 5) {
break;
}
if (!!_.findWhere(role.topFive, {hid: hero.actorId})) {
if (!!findWhere(role.topFive, {hid: hero.actorId})) {
continue;
}
if (!orders[0]) {
+3
View File
@@ -39,6 +39,9 @@ export async function initRank(serverId: number) {
let pvpRank = await PvpDefenseModel.getRank();
for(let {roleId, role: _role, score, updatedAt } of pvpRank) {
let role = <RoleType>_role;
if (!role) {
continue;
}
let { roleName, headHid, sHid, title, lv, vLv } = role;
await client.zaddAsync(getKeyName(REDIS_KEY.PVP_RANK), encodeScoreWithTime(score, updatedAt?updatedAt.getTime():0), roleId);
+5 -5
View File
@@ -11,7 +11,7 @@ import { pinus } from 'pinus';
import { addEquips, addBags, addSkins } from '../pubUtils/itemUtils';
import { EquipInter, ItemInter, BagInter } from '../pubUtils/interface';
import { gameData } from '../pubUtils/data';
const _ = require('underscore');
import { indexOf, findIndex } from 'underscore';
export async function handleFixedReward(roleId: string, roleName: string, sid: string, rewardStr: string, multi: number) {
let reward = parseGoodStr(rewardStr);
@@ -79,7 +79,7 @@ function sortConsumes(goods: Array<ItemInter>, bags: Array<ItemInter>, currencys
return false;
}
} else if (table == ITEM_TABLE.ITEM) {
let index = _.indexOf(bags, {id: good.id});
let index = indexOf(bags, {id: good.id});
if (index > 0) {
bags[index].count = bags[index].count + good.count;
} else {
@@ -177,7 +177,7 @@ function sortItems (goods: Array<ItemInter>, bags: Array<BagInter>, skins: Array
}
} else if (table == ITEM_TABLE.ITEM) {
let index = _.indexOf(bags, {id: good.id});
let index = findIndex(bags, {id: good.id});
if (index > 0) {
bags[index].count = bags[index].count + good.count;
} else {
@@ -186,7 +186,7 @@ function sortItems (goods: Array<ItemInter>, bags: Array<BagInter>, skins: Array
} else if (table == ITEM_TABLE.HERO) {
if (type == CONSUME_TYPE.SKIN) {
let index = _.indexOf(skins, good.id);
let index = indexOf(skins, good.id);
if (index == -1) {
skins.push(good.id);
}
@@ -196,7 +196,7 @@ function sortItems (goods: Array<ItemInter>, bags: Array<BagInter>, skins: Array
if (!!isCurrency) {
let curname = getCurNameById(goodInfo.good_id);
if (!!curname) {
let index = _.findIndex(showItems, {id: good.id});
let index = findIndex(showItems, {id: good.id});
if (index > 0) {
showItems[index].count = showItems[index].count + good.count;
} else {
+4 -4
View File
@@ -1,6 +1,6 @@
import { getRandNum, getRandomArr } from '../pubUtils/util';
import { TERAPH_RANDOM } from "../consts/consts";
const _ = require('underscore');
import { indexOf } from 'underscore';
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
export function checkMaterialEnough(count: number, attrs:Array<any>, teraphInfo: any, teraph: any) {
let res = {};
@@ -22,7 +22,7 @@ export function checkMaterialEnough(count: number, attrs:Array<any>, teraphInfo:
res[attrName] = teraphInfo[attrName] * criEffect;
if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) {
res[attrName] = teraphInfo[attrNameMax] - teraph[attrName];
let attrIndex = _.indexOf(attrs, attrName);
let attrIndex = indexOf(attrs, attrName);
attrs.splice(attrIndex, 1);
}
}
@@ -35,7 +35,7 @@ export function checkMaterialEnough(count: number, attrs:Array<any>, teraphInfo:
break;
}
let criEffect = 1;
let index = _.indexOf(criticalArr, {item});
let index = indexOf(criticalArr, {item});
if (index > 0) {
criEffect = teraphInfo.criEffect;
}
@@ -46,7 +46,7 @@ export function checkMaterialEnough(count: number, attrs:Array<any>, teraphInfo:
let attrNameMax = attrName+'Max';
if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) {
res[attrName] = teraphInfo[attrNameMax] - teraph[attrName];
let attrIndex = _.indexOf(attrs, attrName);
let attrIndex = indexOf(attrs, attrName);
attrs.splice(attrIndex, 1);
}
}
+2 -2
View File
@@ -16,7 +16,7 @@ import { RankParam } from '../pubUtils/interface';
import { RoleModel } from '../db/Role';
import { MailModel, MailType } from '../db/Mail';
import { pinus } from 'pinus';
const _ = require('underscore');
import { indexOf } from 'underscore';
const PER_SECOND = 1 * 1000;
const PER_DAY = 24 * 60 * 60;
const SETTLE_DIFF = 29 * 60;
@@ -133,7 +133,7 @@ export async function resetPvpWarId() {
console.log('resetPvpWarId');
let systemConfig = await SystemConfigModel.findSystemConfig();
let warIds = deepCopy(getPvpGkWarIds());
let index = _.indexOf(warIds, systemConfig.warId);
let index = indexOf(warIds, systemConfig.warId);
if (index != -1) {
warIds.splice(index, 1);
}