This commit is contained in:
mamengke01
2020-12-28 17:11:53 +08:00
parent 1e246ecb72
commit 8cad1f80d4
9 changed files with 359 additions and 282 deletions
@@ -9,6 +9,7 @@ import { RoleModel } from '../../../db/Role';
import { ItemModel } from '../../../db/Item'; import { ItemModel } from '../../../db/Item';
import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getFriendShipById } from '../../../pubUtils/data'; import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, getHeroLvByExp, getMaxGradeByjobClass, getJobByGradeAndClass, getFriendShipById } from '../../../pubUtils/data';
import { RewardInter } from '../../../pubUtils/interface'; import { RewardInter } from '../../../pubUtils/interface';
import { getDropItems } from '../../../consts/constModules/itemConst'
export default function(app: Application) { export default function(app: Application) {
return new HeroHandler(app); return new HeroHandler(app);
@@ -44,7 +45,14 @@ export class HeroHandler {
let {id, count} = msg; let {id, count} = msg;
//let result = await handleCost(roleId, sid, [{id, count}] ); //let result = await handleCost(roleId, sid, [{id, count}] );
let result = await addItems(roleId, roleName, sid, [{id, count}] ); let items = [{id, count}];
if (id == 999999) {
items = getDropItems();
let role = await RoleModel.findByRoleId(roleId);
role.lv = 60;
await RoleModel.updateRoleInfo(roleId, role);
}
let result = await addItems(roleId, roleName, sid, items );
if(!result) { if(!result) {
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH); return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
} }
@@ -92,6 +92,7 @@ export class RoleHandler {
if (!result) if (!result)
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH); return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
await RoleModel.updateRoleInfo(roleId, { title }); await RoleModel.updateRoleInfo(roleId, { title });
await calAllHeroCe( sid, roleId, 2, [title]);
return resResult(STATUS.SUCCESS, { roleId, title }); return resResult(STATUS.SUCCESS, { roleId, title });
} }
@@ -284,7 +285,6 @@ export class RoleHandler {
}); });
} }
// 激活/升级名将谱 // 激活/升级名将谱
async activeHeroScroll(msg: { hid: number }, session: BackendSession) { async activeHeroScroll(msg: { hid: number }, session: BackendSession) {
let roleId = session.get('roleId'); let roleId = session.get('roleId');
+1 -1
View File
@@ -21,7 +21,7 @@ export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Arr
} }
export async function calAllHeroCe(sid: string, roleId: string, type?:number, args?:Array<number>) { export async function calAllHeroCe(sid: string, roleId: string, type?:number, args?:Array<number>) {
let {ce, pushHeros}= await reCalAllHeroCe(roleId,type, args); let {ce, pushHeros}= await reCalAllHeroCe(roleId, type, args);
let uids = [{ uid: roleId, sid }]; let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(ce), heros: pushHeros, topFiveCe: 0 }), uids); pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(ce), heros: pushHeros, topFiveCe: 0 }), uids);
return; return;
-6
View File
@@ -1,11 +1,5 @@
import { getRandNum, getRandomArr } from '../pubUtils/util'; import { getRandNum, getRandomArr } from '../pubUtils/util';
import { EquipModel } from "../db/Equip";
import { HeroModel, EPlace } from "../db/Hero";
import { ITID } from "../consts/constModules/itemConst";
import { getHeroJob, getGoodById, gameData, getJewelById, getHeroEquipByClassId } from "../pubUtils/data";
import { calPlayerCeAndSave } from "./playerCeService";
import { TERAPH_RANDOM } from "../consts/consts"; import { TERAPH_RANDOM } from "../consts/consts";
import { getTeraphAttr } from '../consts/constModules/abilityConst';
const _ = require('underscore'); const _ = require('underscore');
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; 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) { export function checkMaterialEnough(count: number, attrs:Array<any>, teraphInfo: any, teraph: any) {
+2 -1
View File
@@ -17,7 +17,8 @@ export const HERO_SYSTEM_TYPE = {
JEWEL_OFF: 14, JEWEL_OFF: 14,
ADD_SKIN: 15, ADD_SKIN: 15,
SCHOOL: 16, SCHOOL: 16,
SCROLL: 17 SCROLL: 17,
TITLE:18,
}; };
// 武将上限 // 武将上限
+26
View File
@@ -190,3 +190,29 @@ export function getCurNameById(gid) {
return 'expeditionPoint'; return 'expeditionPoint';
} }
} }
export function getDropItems() {
let items = [
{ id:25 ,count: 1 },{ id:225 ,count: 1 },{ id:625 ,count: 1 },{ id:2025 ,count: 1 },{ id:3025 ,count: 1 },{ id:4025 ,count: 1 },{ id:5025 ,count: 1 },{ id:6025 ,count: 1 },
{ id:1 ,count: 1 },{ id:2 ,count: 1 },{ id:101 ,count: 1 },{ id:102 ,count: 1 },{ id:201 ,count: 1 },{ id:202 ,count: 1 },{ id:301 ,count: 1 },{ id:302 ,count: 1 },
{ id:401 ,count: 1 },{ id:501 ,count: 1 },{ id:601 ,count: 1 },{ id:602 ,count: 1 },{ id:701 ,count: 1 },{ id:702 ,count: 1 },{ id:2001 ,count: 1 },{ id:2002 ,count: 1 },
{ id:2101 ,count: 1 },{ id:2102 ,count: 1 },{ id:2201 ,count: 1 },{ id:2202 ,count: 1 },{ id:3001 ,count: 1 },{ id:3002 ,count: 1 },{ id:3101 ,count: 1 },{ id:3102 ,count: 1 },
{ id:3201 ,count: 1 },{ id:3202 ,count: 1 },{ id:4001 ,count: 1 },{ id:4002 ,count: 1 },{ id:4101 ,count: 1 },{ id:4102 ,count: 1 },{ id:4201 ,count: 1 },{ id:4202 ,count: 1 },
{ id:5001 ,count: 1 },{ id:5002 ,count: 1 },{ id:5101 ,count: 1 },{ id:5102 ,count: 1 },{ id:5201 ,count: 1 },{ id:5202 ,count: 1 },{ id:6001 ,count: 1 },{ id:6002 ,count: 1 },
{ id:6101 ,count: 1 },{ id:6102 ,count: 1 },{ id:11001 ,count: 10000},{ id:11002 ,count: 10000 },{ id:11003,count: 10000 },{ id:11004 ,count: 100000 },{ id:11011 ,count: 100000 },
{ id:11012 ,count: 100000 },{ id:11013 ,count: 100000 },{ id:11014 ,count: 100000 },{ id:11015 ,count: 100000 },{ id:11016 ,count: 100000 },{ id:11017 ,count: 100000 },
{ id:17001 ,count: 100000 },{ id:17002 ,count: 100000 },{ id:17003 ,count: 100000 },{ id:17004 ,count: 100000 },{ id:17005 ,count: 100000 },{ id:17006 ,count: 100000 },
{ id:17007 ,count: 100000 },{ id:17008 ,count: 100000 },{ id:17009 ,count: 100000 },{ id:17010 ,count: 100000 },{ id:17011 ,count: 100000 },{ id:17012 ,count: 100000 },
{ id:17013 ,count: 100000 },{ id:17014 ,count: 100000 },{ id:17015 ,count: 100000 },{ id:17016 ,count: 100000 },{ id:17016 ,count: 100000 },{ id:17017 ,count: 100000 },
{ id:17018 ,count: 100000 },{ id:17019 ,count: 100000 },{ id:17020 ,count: 100000 },{ id:17021 ,count: 100000 },{ id:17022 ,count: 100000 },{ id:17023 ,count: 100000 },
{ id:17024 ,count: 100000 },{ id:17025 ,count: 100000 },{ id:17026 ,count: 100000 },{ id:17027 ,count: 100000 },{ id:17028 ,count: 100000 },{ id:17029 ,count: 100000 },
{ id:17030 ,count: 100000 },{ id:17031 ,count: 100000 },{ id:17032 ,count: 100000 },{ id:17033 ,count: 100000 },{ id:17034 ,count: 100000 },{ id:17035 ,count: 100000 },
{ id:17036 ,count: 100000 },{ id:17037 ,count: 100000 },{ id:17038 ,count: 100000 },{ id:17039 ,count: 100000 },{ id:17040 ,count: 100000 },{ id:17041 ,count: 100000 },
{ id:17042 ,count: 100000 },{ id:17043 ,count: 100000 },{ id:17044 ,count: 100000 },{ id:17045 ,count: 100000 },{ id:17046 ,count: 100000 },{ id:17047 ,count: 100000 },
{ id:21001 ,count: 100000 },{ id:21002 ,count: 100000 },{ id:31001 ,count: 100000 },{ id:31002 ,count: 100000 },{ id:31003 ,count: 100000 },{ id:33001 ,count: 100000 },
{ id:33002 ,count: 100000 },{ id:33003 ,count: 100000 },{ id:40001 ,count: 100000 },{ id:40002 ,count: 100000 },{ id:42001 ,count: 100000 },{ id:42002 ,count: 100000 },
{ id:50009 ,count: 100000 },{ id:50010 ,count: 100000 },{ id:60001 ,count: 100000 },{ id:60002 ,count: 100000 },{ id:60060 ,count: 100000 }
]
return items;
}
+2
View File
@@ -5,6 +5,7 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
import User from './User'; import User from './User';
import { shouldRefresh } from '../pubUtils/util'; import { shouldRefresh } from '../pubUtils/util';
import { HeroModel } from './Hero'; import { HeroModel } from './Hero';
import { initRoleAtrr } from '../pubUtils/playerCe';
interface roleUpdate { interface roleUpdate {
ce?: number; ce?: number;
_id?:number; _id?:number;
@@ -227,6 +228,7 @@ export default class Role extends BaseModel {
if (!user) return null; if (!user) return null;
const doc = new RoleModel(); const doc = new RoleModel();
const update = Object.assign(doc.toJSON(), roleInfo, { userInfo: user, serverType: user.serverType, serverId }); const update = Object.assign(doc.toJSON(), roleInfo, { userInfo: user, serverType: user.serverType, serverId });
initRoleAtrr(update);
const role: RoleType = await RoleModel.findOneAndUpdate({ 'userInfo.uid': uid, serverId }, update, { upsert: true, new: true }).lean(lean); const role: RoleType = await RoleModel.findOneAndUpdate({ 'userInfo.uid': uid, serverId }, update, { upsert: true, new: true }).lean(lean);
return role; return role;
} }
+1 -1
View File
@@ -17,7 +17,7 @@ export interface DicTitle {
readonly mdef: number; readonly mdef: number;
readonly agi: number; readonly agi: number;
readonly luk: number; readonly luk: number;
readonly assiAttrValue: Map<number, number>; readonly assiAttrValue: Array<{id: number, number: number}>;
// 等级现在 // 等级现在
readonly lvLimited: number; readonly lvLimited: number;
// 升级消耗 // 升级消耗
+300 -254
View File
@@ -6,127 +6,114 @@ import { HERO_SYSTEM_TYPE, ABI_TYPE, JEWEL_ATTR } from '../consts';
import { deepCopy, getAllAttrStage, reduceCe } from './util'; import { deepCopy, getAllAttrStage, reduceCe } from './util';
import { HeroModel, HeroType } from '../db/Hero'; import { HeroModel, HeroType } from '../db/Hero';
import { RoleModel } from '../db/Role'; import { RoleModel, RoleType } from '../db/Role';
import { CeAttrData, CeAttr, CeAttrRole, CeAttrNumber, CeAttrDataRole } from '../db/generalField'; import { CeAttrData, CeAttr, CeAttrRole, CeAttrNumber, CeAttrDataRole } from '../db/generalField';
import { getAttrNameByJobStage, getAttrCeRatio, getAtrrNameById, ABI_STAGE, SEID_TYPE} from '../consts'; import { getAttrNameByJobStage, getAttrCeRatio, getAtrrNameById, ABI_STAGE, SEID_TYPE } from '../consts';
import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById, getSchoolRateByStar, getScollByStar, getFieldByStage } from './data'; import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById, getSchoolRateByStar, getScollByStar, getFieldByStage } from './data';
import { Attributes } from './interface';
import { DicSe } from './dictionary/DicSe'; import { DicSe } from './dictionary/DicSe';
import { EquipType } from '../db/Equip'; import { EquipType } from '../db/Equip';
import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool'; import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool';
import { getGoodById } from './gamedata'; import { getGoodById } from './gamedata';
import { SchoolModel } from '../db/School'; import { SchoolModel } from '../db/School';
import { getTeraphAttr } from '../consts/constModules/abilityConst'
const HERO_CE_RATIO = 100; const HERO_CE_RATIO = 100;
const _ = require('underscore'); const _ = require('underscore');
//战力计算TODO //战力计算TODO
export function calPlayerCe(globalCeAttr: CeAttrRole, hero: HeroType, type: number, args: Array<number> = []) { export function calPlayerCe(globalCeAttr: CeAttrRole, hero: HeroType, type: number, args: Array<number> = []) {
let incCe = 0; let heroCe = 0;
let incArr: Attributes = {};
let reIncAttr: CeAttr = {}; // {"hp": {"base": number, "fixUp": number, "ratioUp": number}} let reIncAttr: CeAttr = {}; // {"hp": {"base": number, "fixUp": number, "ratioUp": number}}
let addSeidList = new Array<number>(); let addSeidList = new Array<number>();
let removeSeidList = new Array<number>(); let removeSeidList = new Array<number>();
if (type == HERO_SYSTEM_TYPE.INIT) { switch (type) {
reIncAttr = calHeroInitIncAttr(hero, addSeidList, removeSeidList); // args: 升的星盘 case HERO_SYSTEM_TYPE.INIT:
} else if (type == HERO_SYSTEM_TYPE.STAR || type == HERO_SYSTEM_TYPE.LVUP || type == HERO_SYSTEM_TYPE.COLORSTAR || type == HERO_SYSTEM_TYPE.QUALITY) { reIncAttr = calHeroInitIncAttr(hero, addSeidList, removeSeidList); // args: 升的星盘
reIncAttr = calHeroStarIncAttr(hero, type, args.shift(), args, addSeidList, removeSeidList); // args: 升的星盘 break;
} else if (type == HERO_SYSTEM_TYPE.TRAIN) { case HERO_SYSTEM_TYPE.STAR:
reIncAttr = calHeroTrainIncAttr(hero); case HERO_SYSTEM_TYPE.LVUP:
} else if (type == HERO_SYSTEM_TYPE.STAGEUP) { case HERO_SYSTEM_TYPE.COLORSTAR:
reIncAttr = calHeroJobStageUpIncAttr(hero, args, addSeidList, removeSeidList ); case HERO_SYSTEM_TYPE.QUALITY:
} else if (type == HERO_SYSTEM_TYPE.SKIN) { reIncAttr = calHeroStarIncAttr(hero, type, args.shift(), args, addSeidList, removeSeidList); // args: 升的星盘
reIncAttr = calHeroWearSkinIncAttr(hero, args, addSeidList, removeSeidList ); break;
} else if (type == HERO_SYSTEM_TYPE.FAVOUR) { case HERO_SYSTEM_TYPE.TRAIN:
reIncAttr = calHeroFavourUpIncAttr(hero, args); reIncAttr = calHeroTrainIncAttr(hero);
} else if (type == HERO_SYSTEM_TYPE.CONNECT) { break;
reIncAttr = calHeroConectIncAttr(hero, args); case HERO_SYSTEM_TYPE.STAGEUP:
} else if (type == HERO_SYSTEM_TYPE.EQUIP) { reIncAttr = calHeroJobStageUpIncAttr(hero, args, addSeidList, removeSeidList);
reIncAttr = calEquipPutOnOffIncAttr(hero, args, addSeidList, removeSeidList);
} else if (type == HERO_SYSTEM_TYPE.EQUIP_BASE) {
reIncAttr = calHeroEquipIncAttr(hero);
} else if (type == HERO_SYSTEM_TYPE.RESTRENGTHEN) {
reIncAttr = calRestrengthenIncAttr(hero, args.shift(), args, addSeidList, removeSeidList);
} else if (type == HERO_SYSTEM_TYPE.JEWEL_ON) {//宝石穿戴
reIncAttr = calHeroCeWhenJewelOn(hero, args);
} else if (type == HERO_SYSTEM_TYPE.JEWEL_OFF) {//宝石卸下
reIncAttr = calHeroCeWhenJewelOff(hero, args);
} else if (type == HERO_SYSTEM_TYPE.SCROLL) { // 名将谱初次激活增加好感度
reIncAttr = calHeroCeScrollIncAttr(hero, args[0], args[1]);
} else {
reIncAttr = hero.ceAttr;
}
break;
case HERO_SYSTEM_TYPE.SKIN:
reIncAttr = calHeroWearSkinIncAttr(hero, args, addSeidList, removeSeidList);
break;
case HERO_SYSTEM_TYPE.FAVOUR:
reIncAttr = calHeroFavourUpIncAttr(hero, args);
break;
case HERO_SYSTEM_TYPE.CONNECT:
reIncAttr = calHeroConectIncAttr(hero, args);
break;
case HERO_SYSTEM_TYPE.EQUIP:
reIncAttr = calEquipPutOnOffIncAttr(hero, args, addSeidList, removeSeidList);
break;
case HERO_SYSTEM_TYPE.EQUIP_BASE:
reIncAttr = calHeroEquipIncAttr(hero);
break;
case HERO_SYSTEM_TYPE.RESTRENGTHEN:
reIncAttr = calRestrengthenIncAttr(hero, args.shift(), args, addSeidList, removeSeidList);
break;
case HERO_SYSTEM_TYPE.JEWEL_ON:
reIncAttr = calHeroCeWhenJewelOn(hero, args);
break;
case HERO_SYSTEM_TYPE.JEWEL_OFF:
reIncAttr = calHeroCeWhenJewelOff(hero, args);
break;
case HERO_SYSTEM_TYPE.SCROLL:
reIncAttr = calHeroCeScrollIncAttr(hero, args[0], args[1]);
break;
default:
reIncAttr = hero.ceAttr;
}
addSeidEffect(reIncAttr, hero.ceAttr, addSeidList, removeSeidList); // 处理加值 addSeidEffect(reIncAttr, hero.ceAttr, addSeidList, removeSeidList); // 处理加值
if(!hero.ceAttr) hero.ceAttr = new CeAttr(); if (!hero.ceAttr) hero.ceAttr = new CeAttr();
for (let attrName in reIncAttr) { for (let attrName in reIncAttr) {
if(!reIncAttr[attrName] || attrName == '_id') continue; if (!reIncAttr[attrName] || attrName == '_id') continue;
let originalAttrData: CeAttrData = hero.ceAttr[attrName]||new CeAttrData(); let globalAttrData: CeAttrDataRole = globalCeAttr[attrName] || new CeAttrDataRole();
let originalGlobalAttrData: CeAttrDataRole = globalCeAttr[attrName]||new CeAttrDataRole(); if (!hero.ceAttr[attrName]) hero.ceAttr[attrName] = new CeAttrData();
let oldCe = (originalAttrData.fixUp + (originalAttrData.equipUp||0)) * HERO_CE_RATIO + originalAttrData.base *(HERO_CE_RATIO + originalAttrData.ratioUp + originalGlobalAttrData.ratioUp);
if(!hero.ceAttr[attrName]) hero.ceAttr[attrName] = new CeAttrData();
for (let attrKey in reIncAttr[attrName]) { for (let attrKey in reIncAttr[attrName]) {
if(attrKey == '_id') continue; if (attrKey == '_id') continue;
hero.ceAttr[attrName][attrKey] = parseInt(reIncAttr[attrName][attrKey]||0); hero.ceAttr[attrName][attrKey] = parseInt(reIncAttr[attrName][attrKey] || 0);
} }
incArr[attrName] = (reIncAttr[attrName].fixUp + (reIncAttr[attrName].equipUp||0)) * HERO_CE_RATIO + reIncAttr[attrName].base *(HERO_CE_RATIO + reIncAttr[attrName].ratioUp + originalGlobalAttrData.ratioUp) - oldCe; //计算属性 let attrNumber = (hero.ceAttr[attrName].fixUp + (hero.ceAttr[attrName].equipUp || 0) + globalAttrData.fixUp) * HERO_CE_RATIO + hero.ceAttr[attrName].base * (HERO_CE_RATIO + hero.ceAttr[attrName].ratioUp + globalAttrData.ratioUp);
incCe += incArr[attrName] * getAttrCeRatio(attrName); heroCe += attrNumber * getAttrCeRatio(attrName);
} }
hero.ce += incCe; let incCe = heroCe - hero.ce;
if(hero.historyCe < hero.ce) hero.historyCe = hero.ce; hero.ce = heroCe;
if (hero.historyCe < hero.ce) hero.historyCe = hero.ce;
return incCe; return incCe;
} }
//修改并下发战力 //修改并下发战力
export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>, type?: number, args?: Array<number>) { export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>, type?: number, args?: Array<number>) {
if(!heros.length) heros = await HeroModel.findByRole(roleId); if (!heros.length) heros = await HeroModel.findByRole(roleId);
let incPlayerCe = 0; let incPlayerCe = 0;
let pushHeros = new Array<{hid: number, ce: number, incHeroCe: number}>(); let pushHeros = new Array<{ hid: number, ce: number, incHeroCe: number }>();
let role = await RoleModel.findByRoleId(roleId); let role = await RoleModel.findByRoleId(roleId);
if(!role.globalCeAttr) role.globalCeAttr = new CeAttrRole(); if (!role.globalCeAttr) role.globalCeAttr = new CeAttr();
let originalAttr = role.globalCeAttr; await reCalRoleAttr(heros, role.globalCeAttr, type, args);
let reIncAttr: CeAttrRole = {}; // role表属性增量
if (type == HERO_SYSTEM_TYPE.INIT) {
reIncAttr = calRoleInitIncAttr(heros, role.globalCeAttr); // 全局变量增
} else if (type == HERO_SYSTEM_TYPE.ADD_SKIN) {
reIncAttr = calHeroAddSkin(args, role.globalCeAttr);
} else if (type == HERO_SYSTEM_TYPE.SCHOOL) {
reIncAttr = calSchoolAddAttr(heros, args[0], args[1], args[2], role.globalCeAttr);
} else if (type == HERO_SYSTEM_TYPE.SCROLL) {
reIncAttr = calScrollAddAttr(heros, args[0], role.globalCeAttr);
} else if (type == HERO_SYSTEM_TYPE.STAR || type == HERO_SYSTEM_TYPE.COLORSTAR || type == HERO_SYSTEM_TYPE.QUALITY) { // 升星时,在百家学宫中部署的武将加成会同时增加
reIncAttr = await calSchoolStarIncAttr(heros, type, args, role.globalCeAttr);
}
for (let hero of heros) { for (let hero of heros) {
let incHeroCe = calPlayerCe(role.globalCeAttr, hero, type, args); let incHeroCe = calPlayerCe(role.globalCeAttr, hero, type, args);
for (let attrName in reIncAttr) {
let oldcCe = originalAttr[attrName].fixUp * HERO_CE_RATIO + hero.ceAttr[attrName].base * (HERO_CE_RATIO + originalAttr[attrName].ratioUp);
let incArr = reIncAttr[attrName].fixUp * HERO_CE_RATIO + hero.ceAttr[attrName].base * (HERO_CE_RATIO + reIncAttr[attrName].ratioUp) - oldcCe;
incHeroCe += incArr * getAttrCeRatio(attrName);
}
incPlayerCe += incHeroCe; incPlayerCe += incHeroCe;
hero.ce += incHeroCe; hero.ce += incHeroCe;
await HeroModel.updateHeroInfo(roleId, hero.hid, hero); await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
pushHeros.push({ pushHeros.push({
hid: hero.hid, hid: hero.hid,
ce: reduceCe(hero.ce), ce: reduceCe(hero.ce),
incHeroCe : reduceCe(incHeroCe), incHeroCe: reduceCe(incHeroCe),
}); });
} }
for (let attrName in reIncAttr) {
role.globalCeAttr[attrName].fixUp = reIncAttr[attrName].fixUp;
role.globalCeAttr[attrName].ratioUp = reIncAttr[attrName].ratioUp;
}
role.ce += incPlayerCe; role.ce += incPlayerCe;
await RoleModel.updateRoleInfo(roleId, {globalCeAttr: role.globalCeAttr, ce: role.ce}); await RoleModel.updateRoleInfo(roleId, { globalCeAttr: role.globalCeAttr, ce: role.ce });
return {pushHeros, role} return { pushHeros, role }
} }
// 初始战力 // 初始战力
@@ -135,7 +122,7 @@ export function calHeroInitIncAttr(hero: HeroType, addSeidList: Array<number>, r
let hero1 = combineHeroCeAttr(hero, res1); let hero1 = combineHeroCeAttr(hero, res1);
let curSkin = hero.skins.find(cur => cur.enable); let curSkin = hero.skins.find(cur => cur.enable);
let res2 = calHeroWearSkinIncAttr(hero1, [curSkin?curSkin.id:0, 0], addSeidList, removeSeidList, true); let res2 = calHeroWearSkinIncAttr(hero1, [curSkin ? curSkin.id : 0, 0], addSeidList, removeSeidList, true);
let hero2 = combineHeroCeAttr(hero, res2); let hero2 = combineHeroCeAttr(hero, res2);
calHeroJobStageUpIncAttr(hero2, [0], addSeidList, removeSeidList); calHeroJobStageUpIncAttr(hero2, [0], addSeidList, removeSeidList);
@@ -149,15 +136,15 @@ export function calHeroInitIncAttr(hero: HeroType, addSeidList: Array<number>, r
function combineAttrResult(target: CeAttr, origin: CeAttr) { function combineAttrResult(target: CeAttr, origin: CeAttr) {
for(let attrName in origin) { for (let attrName in origin) {
for(let attrKey in origin[attrName]) { for (let attrKey in origin[attrName]) {
if(!target.hasOwnProperty(attrName)) { if (!target.hasOwnProperty(attrName)) {
target[attrName] = {}; target[attrName] = {};
} }
if(!target[attrName].hasOwnProperty(attrKey)) { if (!target[attrName].hasOwnProperty(attrKey)) {
target[attrName][attrKey] = 0; target[attrName][attrKey] = 0;
} }
if(origin[attrName][attrKey] > target[attrName][attrKey]) { if (origin[attrName][attrKey] > target[attrName][attrKey]) {
target[attrName][attrKey] = origin[attrName][attrKey]; target[attrName][attrKey] = origin[attrName][attrKey];
} }
} }
@@ -166,8 +153,8 @@ function combineAttrResult(target: CeAttr, origin: CeAttr) {
export function calRoleInitIncAttr(heros: HeroType[], globalCeAttr: CeAttrRole) { export function calRoleInitIncAttr(heros: HeroType[], globalCeAttr: CeAttrRole) {
let args = new Array<number>(); let args = new Array<number>();
for(let hero of heros) { for (let hero of heros) {
for(let skin of hero.skins) { for (let skin of hero.skins) {
args.push(skin.id); args.push(skin.id);
} }
} }
@@ -178,12 +165,12 @@ export function calRoleInitIncAttr(heros: HeroType[], globalCeAttr: CeAttrRole)
// 将hero的ceAttr暂时更新,不更新在originalHero本体上 // 将hero的ceAttr暂时更新,不更新在originalHero本体上
function combineHeroCeAttr(originalHero: HeroType, result: CeAttr) { function combineHeroCeAttr(originalHero: HeroType, result: CeAttr) {
let hero = deepCopy(originalHero); let hero = deepCopy(originalHero);
if(!hero.ceAttr) hero.ceAttr = new CeAttr(); if (!hero.ceAttr) hero.ceAttr = new CeAttr();
for (let attrName in result) { for (let attrName in result) {
if(!result[attrName]) continue; if (!result[attrName]) continue;
if(!hero.ceAttr[attrName]) hero.ceAttr[attrName] = new CeAttrData(); if (!hero.ceAttr[attrName]) hero.ceAttr[attrName] = new CeAttrData();
for (let attrKey in result[attrName]) { for (let attrKey in result[attrName]) {
hero.ceAttr[attrName][attrKey] = parseInt(result[attrName][attrKey]||0); hero.ceAttr[attrName][attrKey] = parseInt(result[attrName][attrKey] || 0);
} }
} }
delete hero._id; delete hero._id;
@@ -199,13 +186,13 @@ function combineHeroCeAttr(originalHero: HeroType, result: CeAttr) {
* @param addSeidList number[] 用于更新被动 * @param addSeidList number[] 用于更新被动
* @param removeSeidList number[] 用于更新被动 * @param removeSeidList number[] 用于更新被动
*/ */
export function calHeroStarIncAttr (hero: HeroType, type: number, hid: number, args: number[], addSeidList: Array<number>, removeSeidList: Array<number>) { export function calHeroStarIncAttr(hero: HeroType, type: number, hid: number, args: number[], addSeidList: Array<number>, removeSeidList: Array<number>) {
let isInit = type == HERO_SYSTEM_TYPE.INIT; let isInit = type == HERO_SYSTEM_TYPE.INIT;
let {star, starStage, quality, colorStar, colorStarStage, ceAttr, skins} = hero; let { star, starStage, quality, colorStar, colorStarStage, ceAttr, skins } = hero;
let originStar = star, originColorStar = colorStar; let originStar = star, originColorStar = colorStar;
let res: CeAttr = {}; let res: CeAttr = {};
if(hero.hid != hid) return res; if (hero.hid != hid) return res;
const dicHero = gameData.hero.get(hero.hid); const dicHero = gameData.hero.get(hero.hid);
@@ -215,25 +202,25 @@ export function calHeroStarIncAttr (hero: HeroType, type: number, hid: number, a
} else { } else {
if(starStage == ABI_STAGE.START && !isInit) originStar = star - 1; if(starStage == ABI_STAGE.START && !isInit) originStar = star - 1;
} }
const dicStar = isWake? getHeroWakeByQuality(quality, originColorStar): getHeroStarByQuality(quality, originStar); // 星级表 const dicStar = isWake ? getHeroWakeByQuality(quality, originColorStar) : getHeroStarByQuality(quality, originStar); // 星级表
let stages = new Array<number>(); // 需要升级的阶 let stages = new Array<number>(); // 需要升级的阶
if(type == HERO_SYSTEM_TYPE.INIT) { if (type == HERO_SYSTEM_TYPE.INIT) {
stages = getAllAttrStage(); stages = getAllAttrStage();
} else if (type == HERO_SYSTEM_TYPE.LVUP) { } else if (type == HERO_SYSTEM_TYPE.LVUP) {
stages = getAllAttrStage(); stages = getAllAttrStage();
} else if (type == HERO_SYSTEM_TYPE.STAR) { } else if (type == HERO_SYSTEM_TYPE.STAR) {
stages = [args[0]? ABI_STAGE.END: starStage]; stages = [args[0] ? ABI_STAGE.END : starStage];
} else if (type == HERO_SYSTEM_TYPE.QUALITY) { } else if (type == HERO_SYSTEM_TYPE.QUALITY) {
stages = getAllAttrStage(); stages = getAllAttrStage();
} else if (type = HERO_SYSTEM_TYPE.COLORSTAR) { } else if (type = HERO_SYSTEM_TYPE.COLORSTAR) {
if(args[1]) { // 首次觉醒 if (args[1]) { // 首次觉醒
stages = getAllAttrStage(); stages = getAllAttrStage();
} else { } else {
stages.push(args[0]? ABI_STAGE.END: hero.colorStarStage) stages.push(args[0] ? ABI_STAGE.END : hero.colorStarStage)
} }
} }
for(let stage of stages) { for (let stage of stages) {
let targetAttrId = getFieldByStage(stage, hero.job); // 转换为17维的属性id let targetAttrId = getFieldByStage(stage, hero.job); // 转换为17维的属性id
let heroAttr = dicHero.baseAbilityArr.get(targetAttrId); // 武将表hp等 let heroAttr = dicHero.baseAbilityArr.get(targetAttrId); // 武将表hp等
@@ -244,23 +231,23 @@ export function calHeroStarIncAttr (hero: HeroType, type: number, hid: number, a
} }
let newBase = (heroAttr + hero.lv * (heroUpAttr + starUp)) * HERO_CE_RATIO; let newBase = (heroAttr + hero.lv * (heroUpAttr + starUp)) * HERO_CE_RATIO;
let field = getAtrrNameById(targetAttrId); let field = getAtrrNameById(targetAttrId);
let ceAttrData: CeAttrData = ceAttr[field]||new CeAttrData(); // 存表中的属性下的base,fixup,ratioup let ceAttrData: CeAttrData = ceAttr[field] || new CeAttrData(); // 存表中的属性下的base,fixup,ratioup
let {ratioUp = 0, fixUp = 0} = ceAttrData; let { ratioUp = 0, fixUp = 0 } = ceAttrData;
res[field] = { base: newBase, ratioUp, fixUp}; // base变动,增量为△base * ratio + 0 res[field] = { base: newBase, ratioUp, fixUp }; // base变动,增量为△base * ratio + 0
} }
// 解锁技能 // 解锁技能
let curSkin = skins.find(cur => cur.enable); let curSkin = skins.find(cur => cur.enable);
let curSeidList = getSeidListOfFashion(curSkin.id, star, colorStar); let curSeidList = getSeidListOfFashion(curSkin.id, star, colorStar);
let preSeidList = getSeidListOfFashion(curSkin.id, isInit?0:originStar, isInit?0:originColorStar); let preSeidList = getSeidListOfFashion(curSkin.id, isInit ? 0 : originStar, isInit ? 0 : originColorStar);
for(let [type, seid] of curSeidList) { for (let [type, seid] of curSeidList) {
if(!preSeidList.has(type)) { if (!preSeidList.has(type)) {
addSeidList.push(seid, 0); addSeidList.push(seid, 0);
} }
} }
for(let [type, seid] of preSeidList) { for (let [type, seid] of preSeidList) {
console.log(type, seid) console.log(type, seid)
if(!curSeidList.has(type)) { if (!curSeidList.has(type)) {
removeSeidList.push(seid, 0); removeSeidList.push(seid, 0);
} }
} }
@@ -270,17 +257,17 @@ export function calHeroStarIncAttr (hero: HeroType, type: number, hid: number, a
function getSeidListOfFashion(fashionid: number, originStar: number, originColorStar: number) { function getSeidListOfFashion(fashionid: number, originStar: number, originColorStar: number) {
let seidList = new Map<number, number>(); // type => seid let seidList = new Map<number, number>(); // type => seid
if(!gameData.fashion.has(fashionid)) return seidList; if (!gameData.fashion.has(fashionid)) return seidList;
let { skillId } = gameData.fashion.get(fashionid); let { skillId } = gameData.fashion.get(fashionid);
let { starSeidArr, colorStarSeidArr } = gameData.heroSkill.get(skillId); let { starSeidArr, colorStarSeidArr } = gameData.heroSkill.get(skillId);
for(let {star, value, type} of starSeidArr) { for (let { star, value, type } of starSeidArr) {
if(originStar >= star) { if (originStar >= star) {
seidList.set(type, value); seidList.set(type, value);
} }
} }
for(let {star, value, type} of colorStarSeidArr) { for (let { star, value, type } of colorStarSeidArr) {
if(originColorStar >= star) { if (originColorStar >= star) {
seidList.set(type, value); seidList.set(type, value);
} }
} }
@@ -291,7 +278,7 @@ function getSeidListOfFashion(fashionid: number, originStar: number, originColor
export function calHeroTrainIncAttr(hero: HeroType) { export function calHeroTrainIncAttr(hero: HeroType) {
let res: CeAttr = {}; let res: CeAttr = {};
let attrName: string = getAttrNameByJobStage(hero.jobStage); let attrName: string = getAttrNameByJobStage(hero.jobStage);
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
let currentJob = gameData.job.get(hero.job); let currentJob = gameData.job.get(hero.job);
if (currentJob.grade > 1) { if (currentJob.grade > 1) {
let jobGradeAndClass = getJobByGradeAndClass(currentJob.job_class, currentJob.grade - 1); let jobGradeAndClass = getJobByGradeAndClass(currentJob.job_class, currentJob.grade - 1);
@@ -306,7 +293,7 @@ export function calHeroTrainIncAttr(hero: HeroType) {
//进阶 //进阶
export function calHeroJobStageUpIncAttr(hero: HeroType, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>) { export function calHeroJobStageUpIncAttr(hero: HeroType, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>) {
let res: CeAttr = {}; let res: CeAttr = {};
let lastJob = gameData.job.get(args[0])||{seid:[]}; let lastJob = gameData.job.get(args[0]) || { seid: [] };
let currentJob = gameData.job.get(hero.job); let currentJob = gameData.job.get(hero.job);
for (let seid of currentJob.seid) { for (let seid of currentJob.seid) {
let index = _.findIndex(lastJob.seid, seid); let index = _.findIndex(lastJob.seid, seid);
@@ -329,31 +316,31 @@ export function calHeroWearSkinIncAttr(hero: HeroType, args: Array<number>, addS
let addSkin = gameData.fashion.get(args[0]); let addSkin = gameData.fashion.get(args[0]);
let delSkin = gameData.fashion.get(args[1]); let delSkin = gameData.fashion.get(args[1]);
let attrName: string; let attrName: string;
if(delSkin) { if (delSkin) {
for (let attr of delSkin.actorAttr) { for (let attr of delSkin.actorAttr) {
attrName = getAtrrNameById(attr.id); attrName = getAtrrNameById(attr.id);
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
res[attrName].fixUp -= attr.number * HERO_CE_RATIO; res[attrName].fixUp -= attr.number * HERO_CE_RATIO;
} }
} }
for (let attr of addSkin.actorAttr) { for (let attr of addSkin.actorAttr) {
attrName = getAtrrNameById(attr.id); attrName = getAtrrNameById(attr.id);
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
res[attrName].fixUp += attr.number * HERO_CE_RATIO; res[attrName].fixUp += attr.number * HERO_CE_RATIO;
} }
if(!isInit) { // 初始的时候,这一段技能在calHeroStarIncAttr里计算了,不用重复算 if (!isInit) { // 初始的时候,这一段技能在calHeroStarIncAttr里计算了,不用重复算
let { star, colorStar } = hero; let { star, colorStar } = hero;
let curSeidList = getSeidListOfFashion(args[0], star, colorStar); let curSeidList = getSeidListOfFashion(args[0], star, colorStar);
let preSeidList = getSeidListOfFashion(args[1], star, colorStar); let preSeidList = getSeidListOfFashion(args[1], star, colorStar);
for(let [type, seid] of curSeidList) { for (let [type, seid] of curSeidList) {
if(!preSeidList.has(type)) { if (!preSeidList.has(type)) {
removeSeidList.push(seid, 0); removeSeidList.push(seid, 0);
} }
} }
for(let [type, seid] of preSeidList) { for (let [type, seid] of preSeidList) {
if(!curSeidList.has(type)) { if (!curSeidList.has(type)) {
addSeidList.push(seid, 0); addSeidList.push(seid, 0);
} }
} }
@@ -372,15 +359,15 @@ export function calHeroConectIncAttr(hero: HeroType, args: Array<number>) {
let currentShip = getFriendShipById(shipId, level); let currentShip = getFriendShipById(shipId, level);
for (let attr of currentShip.attributes) { for (let attr of currentShip.attributes) {
attrName = getAtrrNameById(attr.id); attrName = getAtrrNameById(attr.id);
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
res[attrName].fixUp += attr.number * (HERO_CE_RATIO + fiendShipLevel.add); res[attrName].fixUp += attr.number * (HERO_CE_RATIO + fiendShipLevel.add);
} }
if (level > 1) { if (level > 1) {
let lastShip = getFriendShipById(shipId, level - 1); let lastShip = getFriendShipById(shipId, level - 1);
for (let attr of lastShip.attributes) { for (let attr of lastShip.attributes) {
attrName = getAtrrNameById(attr.id); attrName = getAtrrNameById(attr.id);
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
res[attrName].fixUp -= attr.number * (HERO_CE_RATIO + fiendShipLevel.add); res[attrName].fixUp -= attr.number * (HERO_CE_RATIO + fiendShipLevel.add);
} }
} }
return res; return res;
@@ -400,8 +387,8 @@ export function calHeroFavourUpIncAttr(hero: HeroType, args: Array<number>) {
let heroShip = getFriendShipById(connect.shipId, connect.level); let heroShip = getFriendShipById(connect.shipId, connect.level);
for (let attr of heroShip.attributes) { for (let attr of heroShip.attributes) {
attrName = getAtrrNameById(attr.id); attrName = getAtrrNameById(attr.id);
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
res[attrName].fixUp += attr.number * (HERO_CE_RATIO + difAdd); res[attrName].fixUp += attr.number * (HERO_CE_RATIO + difAdd);
} }
} }
return res; return res;
@@ -416,17 +403,17 @@ export function calEquipPutOnOffIncAttr(hero: HeroType, args: Array<number>, add
let { ePlace } = hero; let { ePlace } = hero;
let suits = new Map<number, number>(); let suits = new Map<number, number>();
for(let { equip } of ePlace) { for (let { equip } of ePlace) {
if(equip) { if (equip) {
let e = <EquipType>equip; let e = <EquipType>equip;
for(let { seid, rand } of e.randSe) { for (let { seid, rand } of e.randSe) {
addSeidList.push(seid, rand); addSeidList.push(seid, rand);
} }
if(e.suitId > 0) { if (e.suitId > 0) {
if(suits.has(e.suitId)) { if (suits.has(e.suitId)) {
suits.set(e.suitId, 1);
} else {
suits.set(e.suitId, suits.get(e.suitId) + 1); suits.set(e.suitId, suits.get(e.suitId) + 1);
} else {
suits.set(e.suitId, 1);
} }
} }
} }
@@ -434,14 +421,14 @@ export function calEquipPutOnOffIncAttr(hero: HeroType, args: Array<number>, add
suits.forEach((suitId, count) => { suits.forEach((suitId, count) => {
let { effect } = gameData.suit.get(suitId); let { effect } = gameData.suit.get(suitId);
for(let e of effect) { for (let e of effect) {
if(count >= e.count) { if (count >= e.count) {
addSeidList.push(e.seid, 0); addSeidList.push(e.seid, 0);
} }
} }
}); });
for(let arg of args) { for (let arg of args) {
removeSeidList.push(arg) removeSeidList.push(arg)
} }
@@ -454,25 +441,25 @@ export function calEquipSeids(hero: HeroType) {
let { ePlace } = hero; let { ePlace } = hero;
let suits = new Map<number, number>(); let suits = new Map<number, number>();
for(let { equip } of ePlace) { for (let { equip } of ePlace) {
if(equip) { if (equip) {
let e = <EquipType>equip; let e = <EquipType>equip;
for(let { seid, rand } of e.randSe) { for (let { seid, rand } of e.randSe) {
seids.push(seid, rand); seids.push(seid, rand);
} }
if(e.suitId > 0) { if (e.suitId > 0) {
if(suits.has(e.suitId)) { if (suits.has(e.suitId)) {
suits.set(e.suitId, 1);
} else {
suits.set(e.suitId, suits.get(e.suitId) + 1); suits.set(e.suitId, suits.get(e.suitId) + 1);
} else {
suits.set(e.suitId, 1);
} }
} }
} }
} }
suits.forEach((suitId, count) => { suits.forEach((suitId, count) => {
let { effect } = gameData.suit.get(suitId); let { effect } = gameData.suit.get(suitId);
for(let e of effect) { for (let e of effect) {
if(count >= e.count) { if (count >= e.count) {
seids.push(e.seid, 0); seids.push(e.seid, 0);
} }
} }
@@ -487,21 +474,21 @@ export function calHeroEquipIncAttr(hero: HeroType) {
let attrResult = new CeAttrNumber(); let attrResult = new CeAttrNumber();
for(let {equip, lv, refineLv} of ePlace) { for (let { equip, lv, refineLv } of ePlace) {
if(equip) { if (equip) {
let e = <EquipType>equip; let e = <EquipType>equip;
let dicGoods = gameData.goods.get(e.id); let dicGoods = gameData.goods.get(e.id);
let {goodsAbility, goodsAbilityUp} = dicGoods; let { goodsAbility, goodsAbilityUp } = dicGoods;
let dicRefine = gameData.refine.get(refineLv); let dicRefine = gameData.refine.get(refineLv);
let jewel = new Map<number, number>(); let jewel = new Map<number, number>();
for(let {jewel: jewelId} of e.holes) { for (let { jewel: jewelId } of e.holes) {
if(jewelId > 0) { if (jewelId > 0) {
let g = gameData.goods.get(jewelId); let g = gameData.goods.get(jewelId);
if(g) { if (g) {
let jGoods = g.goodsAbility; let jGoods = g.goodsAbility;
jGoods.forEach((value, key) => { jGoods.forEach((value, key) => {
if(jewel.has(key)) { if (jewel.has(key)) {
jewel.set(key, value); jewel.set(key, value);
} else { } else {
jewel.set(key, jewel.get(key) + value); jewel.set(key, jewel.get(key) + value);
@@ -511,94 +498,94 @@ export function calHeroEquipIncAttr(hero: HeroType) {
} }
} }
for(let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) { for (let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) {
if(i == ABI_TYPE.ABI_SPEED || i == ABI_TYPE.ABI_AP) continue; if (i == ABI_TYPE.ABI_SPEED || i == ABI_TYPE.ABI_AP) continue;
let attrName = getAtrrNameById(i); let attrName = getAtrrNameById(i);
// console.log('***', i, attrName); // console.log('***', i, attrName);
let value1 = goodsAbility.get(i)||0 * (HERO_CE_RATIO + e.randRange); let value1 = goodsAbility.get(i) || 0 * (HERO_CE_RATIO + e.randRange);
// console.log('基础值', value1); // console.log('基础值', value1);
let valueup = goodsAbilityUp.get(i)||0; let valueup = goodsAbilityUp.get(i) || 0;
// console.log('成长', lv, valueup); // console.log('成长', lv, valueup);
let valueRefine = dicRefine?dicRefine.upPercent:0; let valueRefine = dicRefine ? dicRefine.upPercent : 0;
// console.log('refine', dicRefine?dicRefine.upPercent:0 ); // console.log('refine', dicRefine?dicRefine.upPercent:0 );
let valueJewel = jewel.get(i)||0; let valueJewel = jewel.get(i) || 0;
// console.log('jewel', valueJewel); // console.log('jewel', valueJewel);
let attr = (value1 + lv * valueup) * ( HERO_CE_RATIO + valueRefine) + valueJewel * HERO_CE_RATIO; let attr = (value1 + lv * valueup) * (HERO_CE_RATIO + valueRefine) + valueJewel * HERO_CE_RATIO;
attrResult[attrName] += attr; attrResult[attrName] += attr;
} }
} }
} }
for(let attrName in attrResult) { for (let attrName in attrResult) {
let originalCe = hero.ceAttr[attrName].equipUp||0; let originalCe = hero.ceAttr[attrName].equipUp || 0;
console.log('装备战力:', attrName, attrResult[attrName] * HERO_CE_RATIO, originalCe); console.log('装备战力:', attrName, attrResult[attrName] * HERO_CE_RATIO, originalCe);
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp, equipUp: originalCe}; res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp, equipUp: originalCe };
res[attrName].equipUp += attrResult[attrName] * HERO_CE_RATIO - originalCe; res[attrName].equipUp += attrResult[attrName] * HERO_CE_RATIO - originalCe;
} }
return res; return res;
} }
// 洗炼 // 洗炼
export function calRestrengthenIncAttr (hero: HeroType, ePaceId: number, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>) { export function calRestrengthenIncAttr(hero: HeroType, ePaceId: number, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>) {
let res: CeAttr = {}; let res: CeAttr = {};
let {ePlace} = hero; let { ePlace } = hero;
let curPlace = ePlace.find(cur => cur.id == ePaceId); let curPlace = ePlace.find(cur => cur.id == ePaceId);
if(curPlace && curPlace.equip) { if (curPlace && curPlace.equip) {
let e = <EquipType>curPlace.equip; let e = <EquipType>curPlace.equip;
for(let { seid, rand } of e.randSe) { for (let { seid, rand } of e.randSe) {
addSeidList.push(seid, rand); addSeidList.push(seid, rand);
} }
} }
for(let arg of args) { removeSeidList.push(arg) } for (let arg of args) { removeSeidList.push(arg) }
return res return res
} }
// 添加技能增加的被动属性 // 添加技能增加的被动属性
function addSeidEffect(reIncAttr: CeAttr, heroCeAttr: CeAttr,addSeidList: Array<number>, removeSeidList: Array<number>) { function addSeidEffect(reIncAttr: CeAttr, heroCeAttr: CeAttr, addSeidList: Array<number>, removeSeidList: Array<number>) {
console.log('addSeidList', addSeidList) console.log('addSeidList', addSeidList)
console.log('removeSeidList', removeSeidList) console.log('removeSeidList', removeSeidList)
let otiginalSeidList = [ let otiginalSeidList = [
{list: addSeidList, multi: 1}, { list: addSeidList, multi: 1 },
{list: removeSeidList, multi: -1} { list: removeSeidList, multi: -1 }
]; ];
for(let {list, multi} of otiginalSeidList) { for (let { list, multi } of otiginalSeidList) {
let effectList = new Array<DicSe>(); // any: dic_zyz_se表内容 let effectList = new Array<DicSe>(); // any: dic_zyz_se表内容
for(let ii = 0; ii < list.length; ii += 2 ) { for (let ii = 0; ii < list.length; ii += 2) {
let seid = list[ii]; let seid = list[ii];
let rand = list[ii + 1]||0; let rand = list[ii + 1] || 0;
let dicSeid: DicSe|DicRandomEffectPool = gameData.se.get(seid); let dicSeid: DicSe | DicRandomEffectPool = gameData.se.get(seid);
if(!dicSeid) dicSeid = gameData.randomEffectPool.get(seid); if (!dicSeid) dicSeid = gameData.randomEffectPool.get(seid);
if(dicSeid && dicSeid.id > 0){ if (dicSeid && dicSeid.id > 0) {
addSeid(effectList, dicSeid.id, rand, dicSeid.gainValueArr) addSeid(effectList, dicSeid.id, rand, dicSeid.gainValueArr)
} }
} }
for(let {type, gainValueArr: [ability, value]} of effectList) { for (let { type, gainValueArr: [ability, value] } of effectList) {
let attrName = getAtrrNameById(ability); let attrName = getAtrrNameById(ability);
if(!attrName) continue; if (!attrName) continue;
if(type == SEID_TYPE.TYPE101) { // 加值 if (type == SEID_TYPE.TYPE101) { // 加值
if(!reIncAttr[attrName]) { if (!reIncAttr[attrName]) {
reIncAttr[attrName] = deepCopy(heroCeAttr[attrName]); reIncAttr[attrName] = deepCopy(heroCeAttr[attrName]);
} }
if(!reIncAttr[attrName]) { if (!reIncAttr[attrName]) {
delete reIncAttr[attrName]; delete reIncAttr[attrName];
continue; continue;
} }
reIncAttr[attrName].fixUp += value * multi * HERO_CE_RATIO; reIncAttr[attrName].fixUp += value * multi * HERO_CE_RATIO;
delete reIncAttr[attrName]._id; delete reIncAttr[attrName]._id;
} else if (type == SEID_TYPE.TYPE102) { // 加百分比 } else if (type == SEID_TYPE.TYPE102) { // 加百分比
if(!reIncAttr[attrName]) { if (!reIncAttr[attrName]) {
reIncAttr[attrName] = deepCopy(heroCeAttr[attrName]); reIncAttr[attrName] = deepCopy(heroCeAttr[attrName]);
} }
if(!reIncAttr[attrName]) { if (!reIncAttr[attrName]) {
delete reIncAttr[attrName]; delete reIncAttr[attrName];
continue; continue;
} }
@@ -610,22 +597,22 @@ function addSeidEffect(reIncAttr: CeAttr, heroCeAttr: CeAttr,addSeidList: Array<
} }
// 获取dic_zyz_se内容 // 获取dic_zyz_se内容
function addSeid(effectList: Array<any>, seidId:number, rand: number, seidValue = new Array<number>()){ function addSeid(effectList: Array<any>, seidId: number, rand: number, seidValue = new Array<number>()) {
// console.log('addSeidEffect', seidId, seidValue) // console.log('addSeidEffect', seidId, seidValue)
let curSeid: DicSe|DicRandomEffectPool = gameData.se.get(seidId); let curSeid: DicSe | DicRandomEffectPool = gameData.se.get(seidId);
if(!curSeid) curSeid = gameData.randomEffectPool.get(seidId); if (!curSeid) curSeid = gameData.randomEffectPool.get(seidId);
if(!curSeid) {console.log("seidId not found:"+seidId);return;} if (!curSeid) { console.log("seidId not found:" + seidId); return; }
if(!seidValue) seidValue = curSeid.gainValueArr; if (!seidValue) seidValue = curSeid.gainValueArr;
if(curSeid.type === SEID_TYPE.TYPE999){ if (curSeid.type === SEID_TYPE.TYPE999) {
for(let i = 0;i < seidValue.length;i++){ for (let i = 0; i < seidValue.length; i++) {
addSeid(effectList, seidValue[i], rand); addSeid(effectList, seidValue[i], rand);
} }
return; return;
} }
effectList.push(curSeid); effectList.push(curSeid);
let seid: DicSe|DicRandomEffectPool = deepCopy(curSeid); let seid: DicSe | DicRandomEffectPool = deepCopy(curSeid);
if(curSeid.index > 0) { if (curSeid.index > 0) {
seid.gainValueArr[curSeid.index - 1] = rand; seid.gainValueArr[curSeid.index - 1] = rand;
} }
effectList.push(seid); effectList.push(seid);
@@ -641,7 +628,7 @@ function calHeroCeWhenJewelOn(hero: HeroType, args: Array<number>) {
oldGoodInfo = getGoodById(oldId); oldGoodInfo = getGoodById(oldId);
for (let attrName in JEWEL_ATTR) { for (let attrName in JEWEL_ATTR) {
if (!!goodInfo[attrName]) { if (!!goodInfo[attrName]) {
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
res[attrName].fixUp += goodInfo[attrName]; res[attrName].fixUp += goodInfo[attrName];
if (oldGoodInfo) if (oldGoodInfo)
res[attrName].fixUp -= oldGoodInfo[attrName]; res[attrName].fixUp -= oldGoodInfo[attrName];
@@ -649,13 +636,14 @@ function calHeroCeWhenJewelOn(hero: HeroType, args: Array<number>) {
} }
return res; return res;
} }
function calHeroCeWhenJewelOff(hero: HeroType, args: Array<number>) { function calHeroCeWhenJewelOff(hero: HeroType, args: Array<number>) {
let res: CeAttr = {}; let res: CeAttr = {};
for (let id of args) { for (let id of args) {
let goodInfo = getGoodById(id); let goodInfo = getGoodById(id);
for (let attrName in JEWEL_ATTR) { for (let attrName in JEWEL_ATTR) {
if (!!goodInfo[attrName]) { if (!!goodInfo[attrName]) {
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp };
res[attrName].fixUp -= goodInfo[attrName]; res[attrName].fixUp -= goodInfo[attrName];
} }
} }
@@ -663,49 +651,41 @@ function calHeroCeWhenJewelOff(hero: HeroType, args: Array<number>) {
return res; return res;
} }
//全局属性加成 //全局属性加成
export async function reCalAllHeroCe(roleId: string, type: number, args:Array<number>) { export async function reCalAllHeroCe(roleId: string, type: number, args: Array<number>) {
let reIncAttr: CeAttrRole = {};
let role = await RoleModel.findByRoleId(roleId); let role = await RoleModel.findByRoleId(roleId);
if(!role.globalCeAttr) role.globalCeAttr = new CeAttrRole(); if (!role.globalCeAttr) role.globalCeAttr = new CeAttr();
let pushHeros:Array<{hid:number, ce:number, incHeroCe:number}> = [] let pushHeros: Array<{ hid: number, ce: number, incHeroCe: number }> = []
if (type == 1) {//获得皮肤
reIncAttr = calHeroAddSkin(args, role.globalCeAttr);
}
for (let attrName in reIncAttr) {
role.globalCeAttr[attrName].fixUp = reIncAttr[attrName].fixUp;
role.globalCeAttr[attrName].ratioUp = reIncAttr[attrName].ratioUp;
}
role.ce = 0;
let heros = await HeroModel.findByRole(roleId); let heros = await HeroModel.findByRole(roleId);
await reCalRoleAttr(heros, role.globalCeAttr, type, args);
role.ce = 0;
for (let hero of heros) { for (let hero of heros) {
let incHeroCe = 0;
let heroCe = 0; let heroCe = 0;
for (let attrName in role.globalCeAttr) { for (let attrName in role.globalCeAttr) {
if (attrName == '_id') if (attrName == '_id')
continue; continue;
let heroAttrData: CeAttrData = hero.ceAttr[attrName]||new CeAttrData(); let heroAttrData: CeAttrData = hero.ceAttr[attrName] || new CeAttrData();
let globalAttrData: CeAttrDataRole = role.globalCeAttr[attrName]; let globalAttrData: CeAttrData = role.globalCeAttr[attrName];
let attrNumber = (heroAttrData.fixUp + (heroAttrData.equipUp||0) + globalAttrData.fixUp) * HERO_CE_RATIO + heroAttrData.base *(HERO_CE_RATIO + heroAttrData.ratioUp + globalAttrData.ratioUp) ; let attrNumber = (heroAttrData.fixUp + (heroAttrData.equipUp || 0) + globalAttrData.fixUp) * HERO_CE_RATIO + heroAttrData.base * (HERO_CE_RATIO + heroAttrData.ratioUp + globalAttrData.ratioUp);
heroCe += attrNumber * getAttrCeRatio(attrName); heroCe += attrNumber * getAttrCeRatio(attrName);
} }
incHeroCe = heroCe - hero.ce; let incHeroCe = heroCe - hero.ce;
hero.ce = heroCe; hero.ce = heroCe;
role.ce += hero.ce; role.ce += hero.ce;
pushHeros.push({ hid: hero.hid, ce: reduceCe(hero.ce), incHeroCe: reduceCe(incHeroCe) }); pushHeros.push({ hid: hero.hid, ce: reduceCe(hero.ce), incHeroCe: reduceCe(incHeroCe) });
await HeroModel.updateHeroInfo(roleId, hero.hid, {ce: hero.ce}); await HeroModel.updateHeroInfo(roleId, hero.hid, { ce: hero.ce });
} }
await RoleModel.updateRoleInfo(roleId, {globalCeAttr: role.globalCeAttr, ce: role.ce}); await RoleModel.updateRoleInfo(roleId, { globalCeAttr: role.globalCeAttr, ce: role.ce });
return {pushHeros, ce: role.ce} return { pushHeros, ce: role.ce }
} }
function calHeroAddSkin(args:Array<number>, ceAttr: CeAttrRole){ function calHeroAddSkin(args: Array<number>, ceAttr: CeAttrRole) {
let res: CeAttrRole = {}; let res: CeAttrRole = {};
for (let arg of args) { for (let arg of args) {
let addSkin = gameData.fashion.get(arg); let addSkin = gameData.fashion.get(arg);
let attrName: string; let attrName: string;
for (let attr of addSkin.globalAttr) { for (let attr of addSkin.globalAttr) {
attrName = getAtrrNameById(attr.id); attrName = getAtrrNameById(attr.id);
res[attrName] = {fixUp: ceAttr[attrName].fixUp, ratioUp: ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: ceAttr[attrName].fixUp, ratioUp: ceAttr[attrName].ratioUp };
res[attrName].fixUp += attr.number * HERO_CE_RATIO; res[attrName].fixUp += attr.number * HERO_CE_RATIO;
} }
} }
@@ -720,22 +700,22 @@ function calHeroAddSkin(args:Array<number>, ceAttr: CeAttrRole){
* @param preHid 撤下的武将 * @param preHid 撤下的武将
* @param ceAttr * @param ceAttr
*/ */
function calSchoolAddAttr(heros: HeroType[], schoolId: number, hid: number, preHid: number, ceAttr: CeAttrRole){ function calSchoolAddAttr(heros: HeroType[], schoolId: number, hid: number, preHid: number, ceAttr: CeAttrRole) {
let res: CeAttrRole = {}; let res: CeAttrRole = {};
let school = gameData.school.get(schoolId); let school = gameData.school.get(schoolId);
let preHero = heros.find(cur => cur.hid == preHid); let preHero = heros.find(cur => cur.hid == preHid);
let curHero = heros.find(cur => cur.hid == hid); let curHero = heros.find(cur => cur.hid == hid);
if(!school ) return res; if (!school) return res;
let defaultPercent = {mainAttrAPerent: 0, assiAttrAddValue: 0}; let defaultPercent = { mainAttrAPerent: 0, assiAttrAddValue: 0 };
let preRate = preHero?getSchoolRateByStar(preHero.star, preHero.colorStar, preHero.quality):defaultPercent; let preRate = preHero ? getSchoolRateByStar(preHero.star, preHero.colorStar, preHero.quality) : defaultPercent;
let curRate = curHero?getSchoolRateByStar(curHero.star, curHero.colorStar, curHero.quality):defaultPercent; let curRate = curHero ? getSchoolRateByStar(curHero.star, curHero.colorStar, curHero.quality) : defaultPercent;
let attrName: string; let attrName: string;
for(let attrId of school.upAttribute) { for (let attrId of school.upAttribute) {
attrName = getAtrrNameById(attrId); attrName = getAtrrNameById(attrId);
res[attrName] = {fixUp: ceAttr[attrName].fixUp, ratioUp: ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: ceAttr[attrName].fixUp, ratioUp: ceAttr[attrName].ratioUp };
if(attrId < ABI_TYPE.ABI_SPEED) { // 主属性 if (attrId < ABI_TYPE.ABI_SPEED) { // 主属性
res[attrName].ratioUp += curRate.mainAttrAPerent - preRate.mainAttrAPerent; res[attrName].ratioUp += curRate.mainAttrAPerent - preRate.mainAttrAPerent;
} else { // 次级属性 } else { // 次级属性
res[attrName].fixUp += (curRate.assiAttrAddValue - preRate.assiAttrAddValue) * HERO_CE_RATIO; res[attrName].fixUp += (curRate.assiAttrAddValue - preRate.assiAttrAddValue) * HERO_CE_RATIO;
@@ -757,24 +737,24 @@ async function calSchoolStarIncAttr(heros: HeroType[], type: number, args: numbe
let [hid, isStarUp] = args; // 是否升星,是否初次觉醒 let [hid, isStarUp] = args; // 是否升星,是否初次觉醒
let needCal = false; let needCal = false;
let roleId: string = ''; let roleId: string = '';
for(let hero of heros) { for (let hero of heros) {
if(hero.hid != hid) { if (hero.hid != hid) {
continue; continue;
} }
if((type == HERO_SYSTEM_TYPE.STAR || type == HERO_SYSTEM_TYPE.COLORSTAR) && !isStarUp) { if ((type == HERO_SYSTEM_TYPE.STAR || type == HERO_SYSTEM_TYPE.COLORSTAR) && !isStarUp) {
continue; continue;
} }
roleId = hero.roleId; roleId = hero.roleId;
let curHeroInSchool = await SchoolModel.findByHid(roleId, hid); let curHeroInSchool = await SchoolModel.findByHid(roleId, hid);
if(!curHeroInSchool) continue; if (!curHeroInSchool) continue;
let preStar = hero.star, preColorStar = hero.colorStar, preQuality = hero.quality; let preStar = hero.star, preColorStar = hero.colorStar, preQuality = hero.quality;
if( type == HERO_SYSTEM_TYPE.STAR && isStarUp) { if (type == HERO_SYSTEM_TYPE.STAR && isStarUp) {
preStar --; preStar--;
} else if ( type == HERO_SYSTEM_TYPE.QUALITY ) { } else if (type == HERO_SYSTEM_TYPE.QUALITY) {
preQuality --; preQuality--;
} else if ( type == HERO_SYSTEM_TYPE.COLORSTAR ) { } else if (type == HERO_SYSTEM_TYPE.COLORSTAR) {
preColorStar --; preColorStar--;
} else { } else {
continue; continue;
} }
@@ -783,10 +763,10 @@ async function calSchoolStarIncAttr(heros: HeroType[], type: number, args: numbe
let curRate = getSchoolRateByStar(hero.star, hero.colorStar, hero.quality); let curRate = getSchoolRateByStar(hero.star, hero.colorStar, hero.quality);
let attrName: string; let attrName: string;
for(let attrId of school.upAttribute) { for (let attrId of school.upAttribute) {
attrName = getAtrrNameById(attrId); attrName = getAtrrNameById(attrId);
res[attrName] = {fixUp: ceAttr[attrName].fixUp, ratioUp: ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: ceAttr[attrName].fixUp, ratioUp: ceAttr[attrName].ratioUp };
if(attrId < ABI_TYPE.ABI_SPEED) { // 主属性 if (attrId < ABI_TYPE.ABI_SPEED) { // 主属性
res[attrName].ratioUp += curRate.mainAttrAPerent - preRate.mainAttrAPerent; res[attrName].ratioUp += curRate.mainAttrAPerent - preRate.mainAttrAPerent;
} else { // 次级属性 } else { // 次级属性
res[attrName].fixUp += (curRate.assiAttrAddValue - preRate.assiAttrAddValue) * HERO_CE_RATIO; res[attrName].fixUp += (curRate.assiAttrAddValue - preRate.assiAttrAddValue) * HERO_CE_RATIO;
@@ -796,10 +776,10 @@ async function calSchoolStarIncAttr(heros: HeroType[], type: number, args: numbe
} }
if(needCal) { if (needCal) {
const allHeros = await HeroModel.findByRole(roleId); const allHeros = await HeroModel.findByRole(roleId);
for(let hero of allHeros) { for (let hero of allHeros) {
if(hero.hid != hid) heros.push(hero); if (hero.hid != hid) heros.push(hero);
} }
} }
return res; return res;
@@ -811,25 +791,25 @@ async function calSchoolStarIncAttr(heros: HeroType[], type: number, args: numbe
* @param hid 激活的武将 * @param hid 激活的武将
* @param ceAttr * @param ceAttr
*/ */
function calScrollAddAttr(heros: HeroType[], hid: number, ceAttr: CeAttrRole){ function calScrollAddAttr(heros: HeroType[], hid: number, ceAttr: CeAttrRole) {
let res: CeAttrRole = {}; let res: CeAttrRole = {};
let curHero = heros.find(cur => cur.hid == hid); let curHero = heros.find(cur => cur.hid == hid);
let dicHero = gameData.hero.get(hid); let dicHero = gameData.hero.get(hid);
if(!curHero|| ! dicHero) return res; if (!curHero || !dicHero) return res;
let { quality } = dicHero; let { quality } = dicHero;
let { star, quality: curQuality, colorStar, job } = curHero; let { star, quality: curQuality, colorStar, job } = curHero;
let heroScroll = getScollByStar(quality, star, curQuality, colorStar); let heroScroll = getScollByStar(quality, star, curQuality, colorStar);
if(!heroScroll) return res; if (!heroScroll) return res;
let preScroll = gameData.preHeroScroll.get(heroScroll.id); let preScroll = gameData.preHeroScroll.get(heroScroll.id);
heroScroll.ceAttr.forEach((add, id) => { heroScroll.ceAttr.forEach((add, id) => {
let attId = getFieldByStage(id, job); let attId = getFieldByStage(id, job);
let attrName = getAtrrNameById(attId); let attrName = getAtrrNameById(attId);
let preAdd = preScroll?preScroll.ceAttr.get(id): 0; let preAdd = preScroll ? preScroll.ceAttr.get(id) : 0;
res[attrName] = {fixUp: ceAttr[attrName].fixUp, ratioUp: ceAttr[attrName].ratioUp}; res[attrName] = { fixUp: ceAttr[attrName].fixUp, ratioUp: ceAttr[attrName].ratioUp };
res[attrName].fixUp += (add - preAdd) * HERO_CE_RATIO; res[attrName].fixUp += (add - preAdd) * HERO_CE_RATIO;
}); });
return res; return res;
@@ -843,8 +823,74 @@ function calScrollAddAttr(heros: HeroType[], hid: number, ceAttr: CeAttrRole){
*/ */
function calHeroCeScrollIncAttr(hero: HeroType, hid: number, preFavourLv: number) { function calHeroCeScrollIncAttr(hero: HeroType, hid: number, preFavourLv: number) {
let res: CeAttr = {}; let res: CeAttr = {};
if(hero.hid == hid && hero.favourLv != preFavourLv) { if (hero.hid == hid && hero.favourLv != preFavourLv) {
res = calHeroFavourUpIncAttr(hero, [preFavourLv]); res = calHeroFavourUpIncAttr(hero, [preFavourLv]);
} }
return res; return res;
} }
function calTitle(args: Array<number>, ceAttr: CeAttrRole) {
let res: CeAttrRole = {};
let titleId = args[0];
let titleInfo = gameData.title.get(titleId);
for (let attrName in getTeraphAttr()) {
res[attrName] = { fixUp: ceAttr[attrName].fixUp, ratioUp: ceAttr[attrName].ratioUp };
res[attrName].fixUp += titleInfo[attrName] * HERO_CE_RATIO;
}
for (let attr of titleInfo.assiAttrValue) {
let attrName = getAtrrNameById(attr.id);
res[attrName] = res[attrName] || { fixUp: ceAttr[attrName].fixUp, ratioUp: ceAttr[attrName].ratioUp };
res[attrName].ratioUp += attr.number * HERO_CE_RATIO;
}
return res;
}
export function initRoleAtrr(role: RoleType) {
if (!role.globalCeAttr) role.globalCeAttr = new CeAttr();
let titleId = role.title;
let titleInfo = gameData.title.get(titleId);
if (!!titleInfo) {
for (let attrName in getTeraphAttr()) {
if (!attrName) continue;
role.globalCeAttr[attrName].fixUp += titleInfo[attrName] * HERO_CE_RATIO;
}
for (let attr of titleInfo.assiAttrValue) {
let attrName = getAtrrNameById(attr.id);
if (!attrName) continue;
role.globalCeAttr[attrName].ratioUp += attr.number * HERO_CE_RATIO;
}
}
return;
}
async function reCalRoleAttr(heros:Array<HeroType>, ceAttr: CeAttrRole, type: number, args: Array<number>) {
let reIncAttr: CeAttrRole = {}; // role表属性增量
switch (type) {
case HERO_SYSTEM_TYPE.INIT:
reIncAttr = calRoleInitIncAttr(heros, ceAttr); // 全局变量增
break;
case HERO_SYSTEM_TYPE.ADD_SKIN:
reIncAttr = calHeroAddSkin(args, ceAttr);
break;
case HERO_SYSTEM_TYPE.SCHOOL:
reIncAttr = calSchoolAddAttr(heros, args[0], args[1], args[2], ceAttr);
break;
case HERO_SYSTEM_TYPE.SCROLL:
reIncAttr = calScrollAddAttr(heros, args[0], ceAttr);
break;
case HERO_SYSTEM_TYPE.STAR:
case HERO_SYSTEM_TYPE.COLORSTAR:
case HERO_SYSTEM_TYPE.QUALITY:
reIncAttr = await calSchoolStarIncAttr(heros, type, args, ceAttr);
break;
case HERO_SYSTEM_TYPE.TITLE:
reIncAttr = calTitle(args, ceAttr);
}
for (let attrName in reIncAttr) {
if (attrName == '_id') continue;
let globalAttrData: CeAttrDataRole = reIncAttr[attrName] || new CeAttrDataRole();
for (let key in globalAttrData) {
ceAttr[attrName][key] += parseInt(globalAttrData[key] || 0);
}
}
}