underscore读取,排行榜保护
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {Application, BackendSession} from 'pinus';
|
||||
const _ = require('underscore');
|
||||
import { uniq, findWhere, findIndex } from 'underscore';
|
||||
import { gameData, getPvpBoxs } from '../../../pubUtils/data';
|
||||
import { refreshEnemies, getEnemies, getLvByScore, defaultHeroes, comsumeChallengeCnt, refresh, findPvpDefByRoleId, checkRoleIsRobot, getRefOppCnt, findPvpDefAllByRoleId, generPVPOppRecInfo, generMyRecInfo, getRobotLineup, getPlayerLineup } from '../../../services/pvpService';
|
||||
import { RoleModel, RoleType } from '../../../db/Role';
|
||||
@@ -63,7 +63,7 @@ export class PvpHandler {
|
||||
|
||||
async getData (msg: {}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let {pvpDefense, warId} = await findPvpDefAllByRoleId(roleId);
|
||||
let { pvpDefense, warId } = await findPvpDefAllByRoleId(roleId);
|
||||
let oppPlayers = await getEnemies(pvpDefense.oppPlayers, pvpDefense.winStreakNum);
|
||||
let { isDefaultHero, heroes, score, pLv, winStreakNum, refOppCnt, challengeCnt, challengeRefTime, receivedBox, hisScore, heroScores, isFirstEntry, seasonNum, seasonEndTime } = pvpDefense;
|
||||
if (isFirstEntry) {
|
||||
@@ -262,7 +262,7 @@ export class PvpHandler {
|
||||
if (heroes.length > 5) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
heroes = _.uniq(heroes, function(item) {
|
||||
heroes = uniq(heroes, function(item) {
|
||||
return item.order;
|
||||
});
|
||||
let { heroes: defHeros, seasonEndTime, challengeCnt: lastChallengeCnt, challengeRefTime: lastChallengeRefTime } = await PvpDefenseModel.findByRoleId(roleId);
|
||||
@@ -275,8 +275,8 @@ export class PvpHandler {
|
||||
return resResult(STATUS.SUCCESS, { heroes: resHeroes, challengeCnt, challengeRefTime, isDefaultHero} );
|
||||
} else {
|
||||
for (let dataId = PVP_HERO_POS.START; dataId <= PVP_HERO_POS.END; dataId++) {
|
||||
let index = _.findIndex(heroes, {dataId});
|
||||
let defIndex = _.findIndex(defHeros, {dataId});
|
||||
let index = findIndex(heroes, {dataId});
|
||||
let defIndex = findIndex(defHeros, {dataId});
|
||||
if (defIndex == -1) {
|
||||
defIndex = defHeros.length;
|
||||
defHeros.push({actorId:0, order:0,ce:0, hero:null,dataId});
|
||||
@@ -396,7 +396,7 @@ export class PvpHandler {
|
||||
let roleName = session.get('roleName');
|
||||
let { hisScore, receivedBox, challengeCnt: lastChallengeCnt, challengeRefTime: lastChallengeRefTime, seasonEndTime } = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
|
||||
let pvpBoxs = getPvpBoxs();
|
||||
let pvpBox = _.findWhere(pvpBoxs, {id})
|
||||
let pvpBox = findWhere(pvpBoxs, {id});
|
||||
if (hisScore < pvpBox.score) {
|
||||
return resResult(STATUS.PVP_NOT_REACH_BOX_SCORE);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import { EQUIP } from "../../../pubUtils/dicParam";
|
||||
import { ITID, SPEICAL_ITEM, RANDOM_SE_COUNT } from "../../../consts/constModules/itemConst";
|
||||
import { changeEquip, dressEquip, checkMaterialEnough, takeOffEquipAndCalPlayerCe } from "../../../services/equipService";
|
||||
|
||||
const _ = require('underscore');
|
||||
import { indexOf, findIndex } from 'underscore';
|
||||
|
||||
export default function (app: Application) {
|
||||
return new EquipHandler(app);
|
||||
@@ -433,9 +433,9 @@ export class EquipHandler {
|
||||
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 resResult(STATUS.EQUIP_NOT_EQUIPED_HERO);
|
||||
let index = _.findIndex(hero.ePlace, { id });
|
||||
let index = findIndex(hero.ePlace, { id });
|
||||
if (index < 0)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let equipOffInfo = <EquipType>hero.ePlace[index].equip;
|
||||
@@ -460,7 +460,7 @@ export class EquipHandler {
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let equip = await EquipModel.getEquip(eid);
|
||||
let index = _.findIndex(equip.holes, { id });
|
||||
let index = findIndex(equip.holes, { id });
|
||||
if (index < 0)
|
||||
return resResult(STATUS.EQUIP_HOLE_NOT_FIND);
|
||||
if (equip.holes[index].isOpen)
|
||||
@@ -494,7 +494,7 @@ export class EquipHandler {
|
||||
let jewelInfo = getGoodById(jewel);
|
||||
if (jewelInfo.itid != equipJewel)
|
||||
return resResult(STATUS.EQUIP_NOT_MATCH_JEWEL);
|
||||
let index = _.findIndex(equip.holes, { id });
|
||||
let index = findIndex(equip.holes, { id });
|
||||
if (index < 0)
|
||||
return resResult(STATUS.EQUIP_HOLE_NOT_FIND);
|
||||
if (!equip.holes[index].isOpen)
|
||||
@@ -549,7 +549,7 @@ export class EquipHandler {
|
||||
let sid: string = session.get('sid');
|
||||
let goods: Array<{ id: number, count: number }> = [];
|
||||
let equip = await EquipModel.getEquip(eid);
|
||||
let index = _.findIndex(equip.holes, { id });
|
||||
let index = findIndex(equip.holes, { id });
|
||||
if (index > 0)
|
||||
return resResult(STATUS.EQUIP_HOLE_NOT_FIND);
|
||||
let jewel = equip.holes[index].jewel;
|
||||
@@ -623,7 +623,7 @@ export class EquipHandler {
|
||||
let equip;
|
||||
if (!!eid) {
|
||||
equip = await EquipModel.getEquip(eid);
|
||||
let index = _.findIndex(equip.holes,{id});
|
||||
let index = findIndex(equip.holes,{id});
|
||||
if (!!equip.holes[index] && equip.holes[index].jewel == goodInfo.composeMaterial[0].id) {
|
||||
oldJewel = equip.holes[index].jewel;
|
||||
equip.holes[index].jewel = jewel;
|
||||
|
||||
@@ -7,7 +7,7 @@ import { handleCost } from '../../../services/rewardService';
|
||||
import { getTitle, getTeraph, gameData, getScollByStar } from '../../../pubUtils/data';
|
||||
import { SCHOOL, SCROLL } from '../../../pubUtils/dicParam';
|
||||
import { getTeraphAttr, getAtrrNameById } from '../../../consts/constModules/abilityConst'
|
||||
const _ = require('underscore');
|
||||
import { findIndex } from 'underscore';
|
||||
import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
|
||||
import { SchoolModel } from '../../../db/School';
|
||||
import { checkMaterialEnough } from '../../../services/roleService'
|
||||
@@ -103,7 +103,7 @@ export class RoleHandler {
|
||||
let roleId = session.get('roleId');
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let sid: string = session.get('sid');
|
||||
let index = _.findIndex(role.teraphs, {id});
|
||||
let index = findIndex(role.teraphs, {id});
|
||||
if (index < 0)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let teraph = role.teraphs[index];
|
||||
@@ -138,7 +138,7 @@ export class RoleHandler {
|
||||
let roleId = session.get('roleId');
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let sid: string = session.get('sid');
|
||||
let index = _.findIndex(role.teraphs, {id});
|
||||
let index = findIndex(role.teraphs, {id});
|
||||
if (index < 0)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let teraph = role.teraphs[index];
|
||||
|
||||
Reference in New Issue
Block a user