战力
This commit is contained in:
@@ -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,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) {
|
||||||
|
|||||||
@@ -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,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 武将上限
|
// 武将上限
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
// 升级消耗
|
// 升级消耗
|
||||||
|
|||||||
+118
-72
@@ -6,75 +6,88 @@ 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) {
|
||||||
|
case HERO_SYSTEM_TYPE.INIT:
|
||||||
reIncAttr = calHeroInitIncAttr(hero, addSeidList, removeSeidList); // args: 升的星盘
|
reIncAttr = calHeroInitIncAttr(hero, addSeidList, removeSeidList); // args: 升的星盘
|
||||||
} else if (type == HERO_SYSTEM_TYPE.STAR || type == HERO_SYSTEM_TYPE.LVUP || type == HERO_SYSTEM_TYPE.COLORSTAR || type == HERO_SYSTEM_TYPE.QUALITY) {
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.STAR:
|
||||||
|
case HERO_SYSTEM_TYPE.LVUP:
|
||||||
|
case HERO_SYSTEM_TYPE.COLORSTAR:
|
||||||
|
case HERO_SYSTEM_TYPE.QUALITY:
|
||||||
reIncAttr = calHeroStarIncAttr(hero, type, args.shift(), args, addSeidList, removeSeidList); // args: 升的星盘
|
reIncAttr = calHeroStarIncAttr(hero, type, args.shift(), args, addSeidList, removeSeidList); // args: 升的星盘
|
||||||
} else if (type == HERO_SYSTEM_TYPE.TRAIN) {
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.TRAIN:
|
||||||
reIncAttr = calHeroTrainIncAttr(hero);
|
reIncAttr = calHeroTrainIncAttr(hero);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.STAGEUP) {
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.STAGEUP:
|
||||||
reIncAttr = calHeroJobStageUpIncAttr(hero, args, addSeidList, removeSeidList);
|
reIncAttr = calHeroJobStageUpIncAttr(hero, args, addSeidList, removeSeidList);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.SKIN) {
|
|
||||||
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.SKIN:
|
||||||
reIncAttr = calHeroWearSkinIncAttr(hero, args, addSeidList, removeSeidList);
|
reIncAttr = calHeroWearSkinIncAttr(hero, args, addSeidList, removeSeidList);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.FAVOUR) {
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.FAVOUR:
|
||||||
reIncAttr = calHeroFavourUpIncAttr(hero, args);
|
reIncAttr = calHeroFavourUpIncAttr(hero, args);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.CONNECT) {
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.CONNECT:
|
||||||
reIncAttr = calHeroConectIncAttr(hero, args);
|
reIncAttr = calHeroConectIncAttr(hero, args);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.EQUIP) {
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.EQUIP:
|
||||||
reIncAttr = calEquipPutOnOffIncAttr(hero, args, addSeidList, removeSeidList);
|
reIncAttr = calEquipPutOnOffIncAttr(hero, args, addSeidList, removeSeidList);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.EQUIP_BASE) {
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.EQUIP_BASE:
|
||||||
reIncAttr = calHeroEquipIncAttr(hero);
|
reIncAttr = calHeroEquipIncAttr(hero);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.RESTRENGTHEN) {
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.RESTRENGTHEN:
|
||||||
reIncAttr = calRestrengthenIncAttr(hero, args.shift(), args, addSeidList, removeSeidList);
|
reIncAttr = calRestrengthenIncAttr(hero, args.shift(), args, addSeidList, removeSeidList);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.JEWEL_ON) {//宝石穿戴
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.JEWEL_ON:
|
||||||
reIncAttr = calHeroCeWhenJewelOn(hero, args);
|
reIncAttr = calHeroCeWhenJewelOn(hero, args);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.JEWEL_OFF) {//宝石卸下
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.JEWEL_OFF:
|
||||||
reIncAttr = calHeroCeWhenJewelOff(hero, args);
|
reIncAttr = calHeroCeWhenJewelOff(hero, args);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.SCROLL) { // 名将谱初次激活增加好感度
|
break;
|
||||||
|
case HERO_SYSTEM_TYPE.SCROLL:
|
||||||
reIncAttr = calHeroCeScrollIncAttr(hero, args[0], args[1]);
|
reIncAttr = calHeroCeScrollIncAttr(hero, args[0], args[1]);
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
reIncAttr = hero.ceAttr;
|
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();
|
|
||||||
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();
|
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;
|
||||||
|
hero.ce = heroCe;
|
||||||
if (hero.historyCe < hero.ce) hero.historyCe = hero.ce;
|
if (hero.historyCe < hero.ce) hero.historyCe = hero.ce;
|
||||||
return incCe;
|
return incCe;
|
||||||
}
|
}
|
||||||
@@ -82,34 +95,13 @@ export function calPlayerCe(globalCeAttr: CeAttrRole, hero: HeroType, type: numb
|
|||||||
//修改并下发战力
|
//修改并下发战力
|
||||||
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);
|
||||||
@@ -119,11 +111,6 @@ export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>,
|
|||||||
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 }
|
||||||
@@ -424,9 +411,9 @@ export function calEquipPutOnOffIncAttr(hero: HeroType, args: Array<number>, add
|
|||||||
}
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,9 +449,9 @@ export function calEquipSeids(hero: HeroType) {
|
|||||||
}
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -649,6 +636,7 @@ 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) {
|
||||||
@@ -664,31 +652,23 @@ function calHeroCeWhenJewelOff(hero: HeroType, args: Array<number>) {
|
|||||||
}
|
}
|
||||||
//全局属性加成
|
//全局属性加成
|
||||||
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) });
|
||||||
@@ -848,3 +828,69 @@ function calHeroCeScrollIncAttr(hero: HeroType, hid: number, preFavourLv: number
|
|||||||
}
|
}
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user