添加处理seid方法
This commit is contained in:
@@ -4,8 +4,8 @@ import { calPlayerCeAndSave } from '../../../services/playerCeService';
|
|||||||
import { resResult, getItems, decodeStr } from '../../../pubUtils/util';
|
import { resResult, getItems, decodeStr } from '../../../pubUtils/util';
|
||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
import {HeroModel} from '../../../db/Hero';
|
import {HeroModel} from '../../../db/Hero';
|
||||||
import {CURRENCY_BY_TYPE, CURRENCY_TYPE, ITID, CONSUME_TYPE, HERO_GROW_MAX} from '../../../consts/consts';
|
import {CURRENCY_BY_TYPE, CURRENCY_TYPE, ITID, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE} from '../../../consts/consts';
|
||||||
import {getJobInfoById, getMaxGradeByjobClass, getHidAndLevelByShipId, getHeroInfoById, getGoodById, getHeroExpByLv, getGamedata, getJobByGradeAndClass, getFriendShipById, getFriendShipLevels, getFashionsById} from '../../../pubUtils/gamedata';
|
import {getJobInfoById, getMaxGradeByjobClass, getHidAndLevelByShipId, getHeroInfoById, getGoodById, getHeroExpByLv, getGamedata, getJobByGradeAndClass, getFriendShipById, getFriendShipLevels, getFashionsById, getHeroLvByExp} from '../../../pubUtils/gamedata';
|
||||||
import { ABI_STAGE } from '../../../consts/abilityConst';
|
import { ABI_STAGE } from '../../../consts/abilityConst';
|
||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ export class HeroHandler {
|
|||||||
let curHero = await HeroModel.createHero({
|
let curHero = await HeroModel.createHero({
|
||||||
roleId, serverId, roleName, hid, hName, star, quality, job
|
roleId, serverId, roleName, hid, hName, star, quality, job
|
||||||
}, false);
|
}, false);
|
||||||
await calPlayerCeAndSave(sid, roleId, [curHero]);
|
await calPlayerCeAndSave(sid, roleId, [curHero], HERO_SYSTEM_TYPE.STAR);
|
||||||
return resResult(STATUS.SUCCESS, {curHero});
|
return resResult(STATUS.SUCCESS, {curHero});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,22 +97,10 @@ export class HeroHandler {
|
|||||||
let {lv: oldLv, exp: oldExp} = hero;
|
let {lv: oldLv, exp: oldExp} = hero;
|
||||||
if(oldLv + addLv > playerLv ) return resResult(STATUS.ROLE_HERO_LV_OVER);
|
if(oldLv + addLv > playerLv ) return resResult(STATUS.ROLE_HERO_LV_OVER);
|
||||||
oldExp += allExp;
|
oldExp += allExp;
|
||||||
let newExp = oldExp + allExp; // 不考虑主公等级,还会剩多少经验
|
let newExp = oldExp + allExp; // 加上经验书可以达到的经验
|
||||||
let newLv = oldLv; // 不考虑主公等级,这些经验可以升几级
|
let newLv = getHeroLvByExp(newExp);
|
||||||
let curExp = newExp; // 考虑到主公等级,还剩多少经验
|
|
||||||
for(;;) {
|
|
||||||
let exp = getHeroExpByLv(newLv);
|
|
||||||
|
|
||||||
if(exp < newExp) {
|
if(newLv < oldLv + addLv) {
|
||||||
newExp -= exp;
|
|
||||||
if(newLv < playerLv) curExp -= exp;
|
|
||||||
newLv ++;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(oldLv + addLv > newLv) {
|
|
||||||
return resResult(STATUS.ROLE_EXP_NOT_ENOUGH);
|
return resResult(STATUS.ROLE_EXP_NOT_ENOUGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,9 +108,9 @@ export class HeroHandler {
|
|||||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||||
|
|
||||||
hero.lv = playerLv > newLv?newLv: playerLv;
|
hero.lv = playerLv > newLv?newLv: playerLv;
|
||||||
hero.exp = curExp;
|
hero.exp = newExp;
|
||||||
|
|
||||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero]);
|
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR);
|
||||||
const curHero = {
|
const curHero = {
|
||||||
hid, lv : heros[0].lv, exp : heros[0].exp
|
hid, lv : heros[0].lv, exp : heros[0].exp
|
||||||
}
|
}
|
||||||
@@ -163,7 +151,7 @@ export class HeroHandler {
|
|||||||
hero.star = isUpStar? oldStar + 1: oldStar;
|
hero.star = isUpStar? oldStar + 1: oldStar;
|
||||||
hero.starStage = isUpStar? ABI_STAGE.START: oldStarStage + 1;
|
hero.starStage = isUpStar? ABI_STAGE.START: oldStarStage + 1;
|
||||||
|
|
||||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero]);
|
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR);
|
||||||
const curHero = {
|
const curHero = {
|
||||||
hid,
|
hid,
|
||||||
star : heros[0].star,
|
star : heros[0].star,
|
||||||
@@ -208,7 +196,7 @@ export class HeroHandler {
|
|||||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||||
|
|
||||||
hero.quality ++;
|
hero.quality ++;
|
||||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero]);
|
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR);
|
||||||
const curHero = {
|
const curHero = {
|
||||||
hid,
|
hid,
|
||||||
quality : heros[0].quality
|
quality : heros[0].quality
|
||||||
@@ -218,12 +206,6 @@ export class HeroHandler {
|
|||||||
|
|
||||||
// 武将觉醒
|
// 武将觉醒
|
||||||
public async wakeUp(msg: { hid: number, colorStar: number, colorStarStage: number}, session: BackendSession) {
|
public async wakeUp(msg: { hid: number, colorStar: number, colorStarStage: number}, session: BackendSession) {
|
||||||
// 根据dic_hero 获得 碎片id
|
|
||||||
// 根据dic_zyz_hero_wake 获得需要花费的碎片和材料
|
|
||||||
// 特殊处理,初次觉醒fireStage传0,保存为 colorStar = 1, colorStarStage = 0,花费的材料取的0星的
|
|
||||||
// 检查品质是否是橙色
|
|
||||||
// 升星阶,满6自动升星
|
|
||||||
// handleCost
|
|
||||||
|
|
||||||
let roleId: string = session.get('roleId');
|
let roleId: string = session.get('roleId');
|
||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
@@ -264,7 +246,7 @@ export class HeroHandler {
|
|||||||
hero.colorStar = isUpStar? oldColorStar + 1: oldColorStar;
|
hero.colorStar = isUpStar? oldColorStar + 1: oldColorStar;
|
||||||
hero.colorStarStage = isUpStar? ABI_STAGE.START: oldColorStarStage + 1;
|
hero.colorStarStage = isUpStar? ABI_STAGE.START: oldColorStarStage + 1;
|
||||||
|
|
||||||
let heros = await calPlayerCeAndSave(sid, roleId, [hero]);
|
let heros = await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.STAR);
|
||||||
const curHero = {
|
const curHero = {
|
||||||
hid,
|
hid,
|
||||||
star : heros[0].star,
|
star : heros[0].star,
|
||||||
|
|||||||
@@ -11,24 +11,33 @@ import Hero from '../db/Hero';
|
|||||||
import { RoleModel } from '../db/Role';
|
import { RoleModel } from '../db/Role';
|
||||||
import { getJobInfoById, getJobByGradeAndClass, getHeroInfoById, getHeroStar, getHeroWake } from '../pubUtils/gamedata';
|
import { getJobInfoById, getJobByGradeAndClass, getHeroInfoById, getHeroStar, getHeroWake } from '../pubUtils/gamedata';
|
||||||
import { HEROTARIN, CE_RATIO, ABI_TYPE_TO_STAGE, ABI_STAGE} from '../consts/abilityConst';
|
import { HEROTARIN, CE_RATIO, ABI_TYPE_TO_STAGE, ABI_STAGE} from '../consts/abilityConst';
|
||||||
import { CeAttrData } from '../db/BaseModel';
|
import { CeAttrData, CeAttr } from '../db/BaseModel';
|
||||||
const HERO_CE_RATIO = 100;
|
const HERO_CE_RATIO = 100;
|
||||||
//战力计算TODO
|
//战力计算TODO
|
||||||
export function calPlayerCe(hero: any, type: number, args: Array<number>) {
|
export function calPlayerCe(hero: any, type: number, args: Array<number>) {
|
||||||
let incCe = 0;
|
let incCe = 0;
|
||||||
let incArr = {};
|
let incArr = {};
|
||||||
let reIncAttr; // {"hp": {"base": number, "fixUp": number, "ratioUp": number}}
|
let reIncAttr; // {"hp": {"base": number, "fixUp": number, "ratioUp": number}}
|
||||||
|
|
||||||
|
let addSeidList = new Array<number>();
|
||||||
|
let removeSeidList = new Array<number>();
|
||||||
|
|
||||||
if (type == HERO_SYSTEM_TYPE.STAR) {
|
if (type == HERO_SYSTEM_TYPE.STAR) {
|
||||||
reIncAttr = calHeroStarIncAttr(hero, args); // 返回 计算后的值
|
reIncAttr = calHeroStarIncAttr(hero, addSeidList, removeSeidList); // 返回 计算后的值
|
||||||
} else if (type == HERO_SYSTEM_TYPE.TRAIN) {
|
} else if (type == HERO_SYSTEM_TYPE.TRAIN) {
|
||||||
reIncAttr = calHeroTrainIncAttr(hero);
|
reIncAttr = calHeroTrainIncAttr(hero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addSeidEffect(reIncAttr, addSeidList, removeSeidList); // 处理加值
|
||||||
|
|
||||||
|
if(!hero.ceAttr) hero.ceAttr = new CeAttr();
|
||||||
for (let attrName in reIncAttr) {
|
for (let attrName in reIncAttr) {
|
||||||
let originalAttrData: CeAttrData = hero.ceAttr[attrName];
|
let originalAttrData: CeAttrData = hero.ceAttr[attrName]||new CeAttrData();
|
||||||
let oldCe = originalAttrData.fixUp * HERO_CE_RATIO + originalAttrData.base *(HERO_CE_RATIO + originalAttrData.ratioUp)
|
let oldCe = originalAttrData.fixUp * HERO_CE_RATIO + originalAttrData.base *(HERO_CE_RATIO + originalAttrData.ratioUp)
|
||||||
|
|
||||||
|
if(!hero.ceAttr[attrName]) hero.ceAttr[attrName] = new CeAttrData();
|
||||||
for (let attrKey in reIncAttr[attrName]) {
|
for (let attrKey in reIncAttr[attrName]) {
|
||||||
hero.CeAttr[attrName][attrKey] = parseInt(reIncAttr[attrName][attrKey]);
|
hero.ceAttr[attrName][attrKey] = parseInt(reIncAttr[attrName][attrKey]);
|
||||||
}
|
}
|
||||||
incArr[attrName] = reIncAttr[attrName].fixUp * HERO_CE_RATIO + reIncAttr[attrName].base *(HERO_CE_RATIO + reIncAttr[attrName].ratioUp) - oldCe; //计算属性
|
incArr[attrName] = reIncAttr[attrName].fixUp * HERO_CE_RATIO + reIncAttr[attrName].base *(HERO_CE_RATIO + reIncAttr[attrName].ratioUp) - oldCe; //计算属性
|
||||||
incCe += incArr[attrName] * CE_RATIO[attrName];
|
incCe += incArr[attrName] * CE_RATIO[attrName];
|
||||||
@@ -61,7 +70,7 @@ export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Arr
|
|||||||
return heros;
|
return heros;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calHeroStarIncAttr (hero: Hero, _args: Array<number>) {
|
export function calHeroStarIncAttr (hero: Hero, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||||
let {star, starStage, quality, colorStar, colorStarStage, ceAttr} = hero;
|
let {star, starStage, quality, colorStar, colorStarStage, ceAttr} = hero;
|
||||||
let res = {};
|
let res = {};
|
||||||
const dicHero = getHeroInfoById(hero.hid);
|
const dicHero = getHeroInfoById(hero.hid);
|
||||||
@@ -98,7 +107,7 @@ export function calHeroStarIncAttr (hero: Hero, _args: Array<number>) {
|
|||||||
let starUp = dicStar.ceAttr.get(stage);
|
let starUp = dicStar.ceAttr.get(stage);
|
||||||
let newBase = heroAttr + hero.lv * (heroUpAttr + starUp);
|
let newBase = heroAttr + hero.lv * (heroUpAttr + starUp);
|
||||||
let field = WAR_JSON_ATTRIBUTE_TYPE[targetAttrId];
|
let field = WAR_JSON_ATTRIBUTE_TYPE[targetAttrId];
|
||||||
let ceAttrData: CeAttrData = ceAttr[field]; // 存表中的属性下的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
|
||||||
}
|
}
|
||||||
@@ -131,3 +140,8 @@ function getFieldByStage(stage: number, jobid: number) {
|
|||||||
return targetAttrId(dicJob.type);
|
return targetAttrId(dicJob.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addSeidEffect(reIncAttr: CeAttr, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,42 +26,42 @@ export default class BaseModel extends TimeStamps {
|
|||||||
|
|
||||||
export class CeAttrData {
|
export class CeAttrData {
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
base?: number;
|
base?: number = 0;
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
ratioUp: number;
|
ratioUp: number = 0;
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
fixUp: number;
|
fixUp: number = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CeAttr {
|
export class CeAttr {
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
hp: CeAttrData;
|
hp?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
atk: CeAttrData;
|
atk?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
matk: CeAttrData;
|
matk?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
def: CeAttrData;
|
def?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
mdef: CeAttrData;
|
mdef?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
agi: CeAttrData;
|
agi?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
luk: CeAttrData;
|
luk?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
hit: CeAttrData;
|
hit?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
cri: CeAttrData;
|
cri?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
flee: CeAttrData;
|
flee?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
antCri: CeAttrData;
|
antCri?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
damageIncrease: CeAttrData;
|
damageIncrease?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
damageDecrease: CeAttrData;
|
damageDecrease?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
defIngnore: CeAttrData;
|
defIngnore?: CeAttrData;
|
||||||
@prop({ required: true })
|
@prop({ required: false })
|
||||||
bloodSuck: CeAttrData;
|
bloodSuck?: CeAttrData;
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ export default class Hero extends BaseModel {
|
|||||||
ce: number; // 武将战力
|
ce: number; // 武将战力
|
||||||
@prop({ required: true, default: 0 })
|
@prop({ required: true, default: 0 })
|
||||||
historyCe: number; // 武将历史最高战力
|
historyCe: number; // 武将历史最高战力
|
||||||
@prop({required: true })
|
@prop({required: true, default: new CeAttr() })
|
||||||
ceAttr: CeAttr; // 影响战力的属性
|
ceAttr: CeAttr; // 影响战力的属性
|
||||||
|
|
||||||
@prop({ required: true, default: 1 })
|
@prop({ required: true, default: 1 })
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export default class Role extends BaseModel {
|
|||||||
lv: number; // 主公等级
|
lv: number; // 主公等级
|
||||||
@prop({ required: true, default: 0 })
|
@prop({ required: true, default: 0 })
|
||||||
ce: number; // 总战力
|
ce: number; // 总战力
|
||||||
@prop({ required: true, default: {} })
|
@prop({ required: true, default: new CeAttr() })
|
||||||
globalCeAttr: CeAttr; // 总战力
|
globalCeAttr: CeAttr; // 总战力
|
||||||
@prop({ required: true, default: 0 })
|
@prop({ required: true, default: 0 })
|
||||||
topFiveCe: number; // 最强5人战力
|
topFiveCe: number; // 最强5人战力
|
||||||
|
|||||||
@@ -146,9 +146,11 @@ function parseLevelInfo() {
|
|||||||
function parseHeroLevelInfo() {
|
function parseHeroLevelInfo() {
|
||||||
const jobFile = 'dic_zyz_charexp';
|
const jobFile = 'dic_zyz_charexp';
|
||||||
const levelData = gamedata['jsons'][jobFile] || [];
|
const levelData = gamedata['jsons'][jobFile] || [];
|
||||||
|
let exp = 0;
|
||||||
levelData.forEach(elem => {
|
levelData.forEach(elem => {
|
||||||
if (elem && elem.level) {
|
if (elem && elem.level) {
|
||||||
heroLevelInfo.set(elem.level, elem.exp);
|
exp += elem.exp;
|
||||||
|
heroLevelInfo.set(elem.level, exp);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -448,6 +450,17 @@ export function getExpByLv(lv: number) {
|
|||||||
return levelInfos.get(lv);
|
return levelInfos.get(lv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getHeroLvByExp(exp: number) {
|
||||||
|
let curLv = 0;
|
||||||
|
let entries = heroLevelInfo.entries();
|
||||||
|
for (let [lv, sum] of entries) {
|
||||||
|
curLv = lv;
|
||||||
|
if(exp < sum) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return curLv;
|
||||||
|
}
|
||||||
|
|
||||||
export function getHeroExpByLv(lv: number) {
|
export function getHeroExpByLv(lv: number) {
|
||||||
return heroLevelInfo.get(lv);
|
return heroLevelInfo.get(lv);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user