武将:天赋
This commit is contained in:
@@ -22,6 +22,7 @@ import { CalHeroCe } from '../../../domain/roleField/calCe';
|
||||
import { HERO, REBORN } from '../../../pubUtils/dicParam';
|
||||
import { createHero, createHeroes } from '../../../services/role/createHero';
|
||||
import { CheckMeterial } from '../../../services/role/checkMaterial';
|
||||
import { HeroParam } from '../../../domain/roleField/hero';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -57,7 +58,7 @@ export class HeroHandler {
|
||||
let { heroes, resultHeroes } = await createHero(roleId, roleName, sid, serverId, { hid, count: 1 });
|
||||
|
||||
pushComposeOrangeHero(roleId, roleName, serverId, resultHeroes[0]);
|
||||
return resResult(STATUS.SUCCESS, { curHero: resultHeroes[0], addHeros: heroes });
|
||||
return resResult(STATUS.SUCCESS, { curHero: new HeroParam(resultHeroes[0]), addHeros: heroes });
|
||||
}
|
||||
|
||||
// 武将升级
|
||||
@@ -613,7 +614,8 @@ export class HeroHandler {
|
||||
let { newEplace } = updateEplaces(oldEplace, eplaceIds);
|
||||
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.SKIN, sid, roleId, hero, { skins: newHeroSkins, skinId: dicSkin.heroId, job: dicNewJob.jobid, ePlace: newEplace });
|
||||
return resResult(STATUS.SUCCESS, { curHero: {...pick(hero, ['hid', 'skins', 'skinId', 'job']), ePlace: newEplace }});
|
||||
let resultHero = new HeroParam(hero);
|
||||
return resResult(STATUS.SUCCESS, { curHero: {...pick(resultHero, ['hid', 'skins', 'skinId', 'job', 'talent', 'usedTalentPoint']), ePlace: newEplace }});
|
||||
}
|
||||
|
||||
public async previewRebirth(msg: { hid: number }, session: BackendSession) {
|
||||
@@ -649,9 +651,10 @@ export class HeroHandler {
|
||||
let dicHero = gameData.hero.get(skinId);
|
||||
let dicJob = getJobByGradeAndClass(dicHero.jobClass, 0);
|
||||
|
||||
let newSkins = initSkinTalent(skins);
|
||||
let dicHeroScroll = getScollByStar(dicHero.quality, dicHero.initialStars, dicHero.quality, 0);
|
||||
let initInfo = HeroModel.getInitInfo({
|
||||
job: dicJob.jobid, skins, skinId, ce,
|
||||
job: dicJob.jobid, skins: newSkins, skinId, ce,
|
||||
star: dicHero.initialStars, quality: dicHero.quality,
|
||||
scrollActive: scrollActive,
|
||||
scrollId: scrollActive? dicHeroScroll.id: 0,
|
||||
@@ -682,7 +685,8 @@ export class HeroHandler {
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, consumes, ITEM_CHANGE_REASON.REBIRTH);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { curHero: { ...curHero, ce: reduceCe(curHero.ce) }, curJewels, goods });
|
||||
const heroResult = new HeroParam(curHero);
|
||||
return resResult(STATUS.SUCCESS, { curHero: heroResult, curJewels, goods });
|
||||
}
|
||||
|
||||
// 解锁天赋
|
||||
@@ -715,10 +719,12 @@ export class HeroHandler {
|
||||
return resResult(STATUS.TALENT_POINT_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
let { newSkins, newTalents } = updateSkinTalent(skins, new Talent(id), usedTalentPoint + needTalentPoint);
|
||||
let { newSkins } = updateSkinTalent(skins, new Talent(id), usedTalentPoint + needTalentPoint);
|
||||
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.TALENT, sid, roleId, hero, { skins: newSkins });
|
||||
return resResult(STATUS.SUCCESS, { curHero: {...pick(hero, ['hid', 'skins', 'skinId']) }});
|
||||
|
||||
const heroResult = new HeroParam(hero);
|
||||
return resResult(STATUS.SUCCESS, { curHero: {...pick(heroResult, ['hid', 'talent', 'usedTalentPoint']) }});
|
||||
|
||||
}
|
||||
|
||||
@@ -750,10 +756,12 @@ export class HeroHandler {
|
||||
return resResult(STATUS.TALENT_POINT_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
let { newSkins, newTalents } = updateSkinTalent(skins, new Talent(id, talent.level + 1), usedTalentPoint + needTalentPoint);
|
||||
let { newSkins } = updateSkinTalent(skins, new Talent(id, talent.level + 1), usedTalentPoint + needTalentPoint);
|
||||
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.TALENT, sid, roleId, hero, { skins: newSkins });
|
||||
return resResult(STATUS.SUCCESS, { curHero: {...pick(hero, ['hid', 'skins', 'skinId']) }});
|
||||
|
||||
const heroResult = new HeroParam(hero);
|
||||
return resResult(STATUS.SUCCESS, { curHero: {...pick(heroResult, ['hid', 'talent', 'usedTalentPoint']) }});
|
||||
}
|
||||
|
||||
// 洗点
|
||||
@@ -776,7 +784,9 @@ export class HeroHandler {
|
||||
|
||||
let newSkins = initSkinTalent(skins);
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.TALENT, sid, roleId, hero, { skins: newSkins });
|
||||
return resResult(STATUS.SUCCESS, { curHero: {...pick(hero, ['hid', 'skins', 'skinId']) }});
|
||||
|
||||
const heroResult = new HeroParam(hero);
|
||||
return resResult(STATUS.SUCCESS, { curHero: {...pick(heroResult, ['hid', 'talent', 'usedTalentPoint']) }});
|
||||
}
|
||||
|
||||
// ! debug接口 一键全武将
|
||||
@@ -879,11 +889,11 @@ export class HeroHandler {
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if(!hero) {
|
||||
let { resultHeroes } = await createHero(roleId, roleName, sid, serverId, { hid, count: 1, ...params });
|
||||
hero = resultHeroes[0];
|
||||
return resResult(STATUS.SUCCESS, { hero: resultHeroes[0] });
|
||||
} else {
|
||||
hero = await HeroModel.updateHeroInfo(roleId, hid, params);
|
||||
return resResult(STATUS.SUCCESS, { hero: new HeroParam(hero) });
|
||||
}
|
||||
hero = await HeroModel.updateHeroInfo(roleId, hid, params);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { hero });
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import { HeroModel } from '../db/Hero';
|
||||
import { JewelModel } from '../db/Jewel';
|
||||
import { SkinModel } from '../db/Skin';
|
||||
import { getAp } from './actionPointService';
|
||||
import { HeroParam } from '../domain/roleField/hero';
|
||||
|
||||
/**
|
||||
* init: 初始的时候是否推送 true-推 false-不推
|
||||
@@ -111,7 +112,7 @@ async function getModuleData(type: string, data: { role: RoleType, session: Fron
|
||||
let items = await ItemModel.findbyRole(role.roleId);
|
||||
let skins = await SkinModel.findbyRole(role.roleId);
|
||||
|
||||
role['heros'] = heros;
|
||||
role['heros'] = heros.map(hero => new HeroParam(hero));
|
||||
role['jewels'] = jewels;
|
||||
role['consumeGoods'] = items;
|
||||
role['skins'] = skins;
|
||||
|
||||
@@ -13,7 +13,7 @@ import { nowSeconds } from "../../pubUtils/timeUtil";
|
||||
import { saveCeChangeLog } from "../../pubUtils/logUtil";
|
||||
import { getRandSingleEelm, reduceCe, resResult } from "../../pubUtils/util";
|
||||
import { AttributeCal } from "../../domain/roleField/attribute";
|
||||
import { CreateHeroParam, HeroShowParam } from "../../domain/roleField/hero";
|
||||
import { CreateHeroParam, HeroParam, HeroShowParam } from "../../domain/roleField/hero";
|
||||
import { pinus } from "pinus";
|
||||
import { Rank } from "../rankService";
|
||||
import { checkTaskInCreateHero } from "../task/taskService";
|
||||
@@ -202,7 +202,7 @@ export class CreateHeroes extends UpdateHeroes {
|
||||
}
|
||||
|
||||
public getResultHeroes() {
|
||||
return this.resultHeroes.map(cur => ({...cur, ce: reduceCe(cur.ce)}))
|
||||
return this.resultHeroes;
|
||||
}
|
||||
|
||||
public getShowHeroes() {
|
||||
|
||||
@@ -241,10 +241,10 @@ export function updateSkinTalent(skins: HeroSkin[], newTalent: Talent, usedTalen
|
||||
return { newSkins, newTalents };
|
||||
}
|
||||
|
||||
export function initSkinTalent(skins: HeroSkin[]) {
|
||||
export function initSkinTalent(skins: HeroSkin[], isAll = false) {
|
||||
let newSkins: HeroSkin[] = [];
|
||||
for(let skin of skins) {
|
||||
if(skin.enable) {
|
||||
if(isAll || skin.enable) {
|
||||
newSkins.push({ ...skin, talent: getHeroInitTalent(skin.skinId), usedTalentPoint: 0 });
|
||||
} else {
|
||||
newSkins.push(skin);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
|
||||
import { HeroType, HeroUpdate } from '../../db/Hero';
|
||||
import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Talent } from '../../db/Hero';
|
||||
import { gameData } from '../../pubUtils/data';
|
||||
import { reduceCe } from '../../pubUtils/util';
|
||||
export interface CreateHeroParam extends HeroUpdate {
|
||||
hid: number;
|
||||
count: number;
|
||||
@@ -17,4 +19,91 @@ export class HeroShowParam {
|
||||
this.skinId = hero.skinId;
|
||||
this.quality = hero.quality;
|
||||
}
|
||||
}
|
||||
|
||||
class HeroSKinParam {
|
||||
id: number;
|
||||
skinId: number; // fashions表的heroId字段
|
||||
enable: boolean;
|
||||
constructor(heroSkin: HeroSkin) {
|
||||
this.id = heroSkin.id;
|
||||
this.skinId = heroSkin.skinId;
|
||||
this.enable = heroSkin.enable;
|
||||
}
|
||||
}
|
||||
|
||||
// 传给客户端的武将数据
|
||||
export class HeroParam {
|
||||
hid: number; // 武将 id
|
||||
hName: string; // 武将名
|
||||
seqId: number; // 武将表自增 id
|
||||
|
||||
exp: number; // 经验值
|
||||
lv: number; // 武将等级
|
||||
ce: number; // 武将战力
|
||||
historyCe: number; // 武将历史最高战力
|
||||
star: number; // 星级
|
||||
starStage: number; // 星级六维阶段
|
||||
colorStar: number; // 觉醒, 彩星
|
||||
colorStarStage: number; // 觉醒六维阶段
|
||||
quality: number; // 品质
|
||||
|
||||
scrollActive: boolean; // 是否在名将谱中激活
|
||||
scrollId: number; // 名将谱id
|
||||
scrollStar: number; // 名将谱中保存的星级
|
||||
scrollColorStar: number; // 名将谱中保存的觉醒等级
|
||||
scrollQuality: number; // 名将谱中保存的品质
|
||||
|
||||
job: number; // 职业
|
||||
jobStage: number; // 职阶
|
||||
skinId: number; // 当前皮肤id,fashions表的heroId字段
|
||||
|
||||
favour: number; // 好感度
|
||||
favourLv: number; // 好感等级
|
||||
connections: Connect[]; // 羁绊
|
||||
skins: HeroSKinParam[] = []; // 皮肤
|
||||
ePlace: EPlace[]; // 武将装备引用数组
|
||||
|
||||
talent: Talent[];
|
||||
usedTalentPoint: number;
|
||||
totalTalentPoint: number;
|
||||
|
||||
constructor(hero: HeroType) {
|
||||
this.hid = hero.hid;
|
||||
this.hName = hero.hName;
|
||||
this.exp = hero.exp;
|
||||
this.lv = hero.lv;
|
||||
if(hero.isReducedCe) {
|
||||
this.ce = hero.ce;
|
||||
this.historyCe = hero.historyCe;
|
||||
} else {
|
||||
this.ce = reduceCe(hero.ce);
|
||||
this.historyCe = reduceCe(hero.historyCe);
|
||||
}
|
||||
this.star = hero.star;
|
||||
this.starStage = hero.starStage;
|
||||
this.colorStar = hero.colorStar;
|
||||
this.colorStarStage = hero.colorStarStage;
|
||||
this.quality = hero.quality;
|
||||
this.scrollActive = hero.scrollActive;
|
||||
this.scrollId = hero.scrollId;
|
||||
this.scrollStar = hero.scrollStar;
|
||||
this.scrollColorStar = hero.scrollColorStar;
|
||||
this.scrollQuality = hero.scrollQuality;
|
||||
this.job = hero.job;
|
||||
this.totalTalentPoint = gameData.talentPointOfJob.get(hero.job)||0;
|
||||
this.jobStage = hero.jobStage;
|
||||
this.skinId = hero.skinId;
|
||||
this.favour = hero.favour;
|
||||
this.favourLv = hero.favourLv;
|
||||
this.connections = hero.connections;
|
||||
for(let skin of hero.skins) {
|
||||
this.skins.push(new HeroSKinParam(skin));
|
||||
if(skin.enable) {
|
||||
this.talent = skin.talent;
|
||||
this.usedTalentPoint = skin.usedTalentPoint;
|
||||
}
|
||||
}
|
||||
this.ePlace = hero.ePlace;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user