战力显示缩小

This commit is contained in:
luying
2020-12-24 10:53:23 +08:00
parent cc1a91ed09
commit 4bfc92f8cf
6 changed files with 66 additions and 28 deletions

View File

@@ -6,9 +6,9 @@ import { GMUserModel } from '../../../db/GMUser';
import { Application, Session } from 'pinus';
import {FrontendSession} from 'pinus';
import { HeroModel } from './../../../db/Hero';
import { resResult } from '../../../pubUtils/util';
import { resResult, returnHeroCeRatio, reduceCe } from '../../../pubUtils/util';
import { startEvent } from '../../../services/eventSercive';
import { EVENT_START_LV, FUNC_OPT_TYPE } from '../../../consts';
import { EVENT_START_LV, FUNC_OPT_TYPE, HERO_CE_RATIO } from '../../../consts';
import { getAp } from '../../../services/actionPointService';
import Actor from '../../../pubUtils/actor';
import { ItemModel } from '../../../db/Item';
@@ -79,17 +79,13 @@ export class EntryHandler {
let equips = await EquipModel.findbyRole(role.roleId);
let items = await ItemModel.findbyRole(role.roleId);
// for(let i of heros) {
// for(let j of i.ePlace) {
// console.log(j.equip)
// }
// }
role['heros'] = heros;
role['heros'] = heros.map(cur => returnHeroCeRatio(cur));
role['equips'] = equips;
role['consumeGoods'] = items;
let apJson = await getAp(Date.now(), role.roleId);
role['apJson'] = apJson;
role['ce'] = reduceCe(role.ce);
await switchOnFunc(role.roleId, FUNC_OPT_TYPE.LEVEL_UP, role.lv, self.app, session);
return resResult(STATUS.SUCCESS, { role });

View File

@@ -1,10 +1,8 @@
import { Application, BackendSession } from "pinus";
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, GOOD_TYPE, HERO_GROW_MAX } from "../../../consts";
import { ItemInter } from "../../../pubUtils/interface";
import { resResult, parseGoodStr, getRandomByLen, deepCopy, mergeSameGoods, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
import { resResult, parseGoodStr, getRandomByLen, deepCopy, getRandValueByMinMax, getRandEelm } from "../../../pubUtils/util";
import { addItems, handleCost } from "../../../services/rewardService";
import { checkMaterialEnough } from "../../../services/equipService";
import { EquipModel, RandSe } from "../../../db/Equip";
import { HeroModel, EPlace } from "../../../db/Hero";
import { ItemModel } from "../../../db/Item";
@@ -444,7 +442,7 @@ export class EquipHandler {
if (jewelInfo.itid != equipJewel)
return resResult(STATUS.EQUIP_NOT_MATCH_JEWEL);
let index = _.findIndex(equip.holes, { id });
if (index > 0)
if (index < 0)
return resResult(STATUS.EQUIP_HOLE_NOT_FIND);
if (!equip.holes[index].isOpen)
return resResult(STATUS.EQUIP_HOLE_IS_NOT_DUG);
@@ -467,27 +465,55 @@ export class EquipHandler {
return resResult(STATUS.SUCCESS, { curEquip: { seqId: eid, holes: equip.holes } });
}
//宝石合成(一键放入type:1, 合成type:2)
public async composeJewel(msg: { jewel: number, count: number, consumes: Array<{ id: number, count: number }>, type: number }, session: BackendSession) {
let { count, consumes, jewel, type } = msg;
//宝石合成
public async composeJewel(msg: { jewel: number, count: number, consumes: Array<{ id: number, count: number }>, speConsumes: Array<{ id: number, count: number }> }, session: BackendSession) {
let { count, consumes, jewel, speConsumes } = msg;
let roleId: string = session.get('roleId');
let roleName: string = session.get('roleName');
let sid: string = session.get('sid');
let goodInfo = getGoodById(jewel);
let good = ITID.get(goodInfo.itid);
if (good.type != CONSUME_TYPE.JEWEL)
let { type } = ITID.get(goodInfo.itid);
if (type != CONSUME_TYPE.JEWEL)
return resResult(STATUS.WRONG_PARMS);
//检查宝石消耗是否合法TODO
let needConsumes = checkMaterialEnough(consumes, jewel, count);
if (!needConsumes)
let comJewelMap = {};
let ways = [deepCopy(speConsumes)];
for (let { id, count } of consumes) {
let jewelInfo = getJewelById(id);
if (!jewelInfo) {
return resResult(STATUS.WRONG_PARMS);
}
count = Math.floor((count + (comJewelMap[jewelInfo.good_id] || 0)) / jewelInfo.count);
if (count < 1) {
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
}
let speCount = jewelInfo.specialMaterial.count * count;
if (jewelInfo.specialMaterial.ids.length) {
let copyWays = deepCopy(ways);
ways = [];
for (let id of jewelInfo.specialMaterial.ids) {
for (let way of copyWays) {
let index = _.findIndex(way, { id });
if (index && way[index].count >= speCount) {
way[index].count = way[index].count - speCount;
ways.push(way);
}
}
}
if (!ways.length)
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
}
delete comJewelMap[jewelInfo.good_id];
comJewelMap[jewelInfo.nextJewelId] = count + (comJewelMap[jewelInfo.nextJewelId] || 0);
}
if (comJewelMap[jewel] != count || Object.keys(comJewelMap).length != 1)
return resResult(STATUS.WRONG_PARMS);
let res = await handleCost(roleId, sid, needConsumes);
let res = await handleCost(roleId, sid, consumes.concat(speConsumes));
if (!res)
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
let result = await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]);
if (type == 1)
return resResult(STATUS.SUCCESS, { goods: result });
return resResult(STATUS.SUCCESS);
return resResult(STATUS.SUCCESS, { goods: result });
}
//宝石卸下
@@ -594,4 +620,5 @@ export class EquipHandler {
}
return resResult(STATUS.SUCCESS, { goods: result });
}
}

View File

@@ -1,10 +1,10 @@
import {Application, BackendSession, ChannelService} from 'pinus';
import { handleCost, addItems } from '../../../services/rewardService';
import { calPlayerCeAndSave } from '../../../services/playerCeService';
import { resResult } from '../../../pubUtils/util';
import { resResult, returnHeroCeRatio } from '../../../pubUtils/util';
import { STATUS } from '../../../consts/statusCode';
import {HeroModel} from '../../../db/Hero';
import {CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE, ITID, ABI_STAGE} from '../../../consts';
import {CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE, ITID, ABI_STAGE, HERO_CE_RATIO} from '../../../consts';
import { RoleModel } from '../../../db/Role';
import { ItemModel } from '../../../db/Item';
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getFriendShipById } from '../../../pubUtils/data';
@@ -77,7 +77,7 @@ export class HeroHandler {
roleId, serverId, roleName, hid, hName, star, quality, job, skins:[{id: initialSkin, enable: true}]
});
await calPlayerCeAndSave(sid, roleId, [curHero], HERO_SYSTEM_TYPE.INIT);
return resResult(STATUS.SUCCESS, {curHero});
return resResult(STATUS.SUCCESS, {curHero: returnHeroCeRatio(curHero)});
}
// 武将升级

View File

@@ -27,4 +27,7 @@ export const HERO_GROW_MAX = {
export const JOB_TYPE = {
PHYSIC: 1,
MAGIC: 2
}
}
// 武将战力放大系数
export const HERO_CE_RATIO = 100;

View File

@@ -70,6 +70,7 @@ export function calPlayerCe(globalCeAttr: CeAttr, hero: HeroType, type: number,
incCe += incArr[attrName] * getAttrCeRatio(attrName);
}
hero.ce += incCe;
if(hero.historyCe < hero.ce) hero.historyCe = hero.ce;
return incCe;
}

View File

@@ -1,7 +1,7 @@
import { STATUS } from './../consts/statusCode';
import { getGamedata } from './gamedata';
import { HeroModel } from '../db/Hero';
import { HeroModel, HeroType } from '../db/Hero';
import { RoleModel } from '../db/Role';
import { PvpDefenseModel } from '../db/PvpDefense';
import Actor from './actor';
@@ -9,6 +9,7 @@ import Actor from './actor';
import fs = require('fs');
import path = require('path');
import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool';
import { HERO_CE_RATIO } from '../consts';
const _ = require('underscore');
const moment = require('moment');
@@ -516,4 +517,14 @@ export function mergeSameGoods(goods: Array<{id: number, count: number}>) {
}
}
return resGoods;
}
export function returnHeroCeRatio(hero: HeroType) {
let ce = reduceCe(hero.ce);
return Object.assign(hero, { ce });
}
// 缩小战力
export function reduceCe(ce: number = 0) {
return Math.floor(ce/HERO_CE_RATIO/HERO_CE_RATIO)
}