皮肤:武将、时装表修改
This commit is contained in:
@@ -3,7 +3,7 @@ import { handleCost, addItems, unlockFigure, createHeroes, createHero, CheckMete
|
||||
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
|
||||
import { resResult, deepCopy } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { HeroModel, Connect, HeroSkin, HeroUpdate } from '../../../db/Hero';
|
||||
import { HeroModel, Connect, HeroSkin, HeroUpdate, EPlace } from '../../../db/Hero';
|
||||
import { CURRENCY_BY_TYPE, CURRENCY_TYPE, CONSUME_TYPE, HERO_GROW_MAX, HERO_SYSTEM_TYPE, ABI_STAGE, DEBUG_MAGIC_WORD, HERO_INITIAL_QUALITY, REDIS_KEY, TASK_TYPE } from '../../../consts';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { ItemModel } from '../../../db/Item';
|
||||
@@ -11,11 +11,14 @@ import { gameData, getHeroExpByLv, getHeroStarByQuality, getHeroWakeByQuality, g
|
||||
import { ItemInter, RewardInter } from '../../../pubUtils/interface';
|
||||
import { getDropItems, FIGURE_UNLOCK_CONDITION } from '../../../consts/constModules/itemConst'
|
||||
import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService';
|
||||
import { calculatetopLineup } from '../../../pubUtils/playerCe';
|
||||
import { calculatetopLineup, calEquipSeids } from '../../../pubUtils/playerCe';
|
||||
import { PvpDefenseModel } from '../../../db/PvpDefense';
|
||||
import { checkTaskWithHero, checkTask, checkActivityTask } from '../../../services/taskService';
|
||||
import { addSkin } from '../../../pubUtils/itemUtils';
|
||||
import Skin from '../../../db/Skin';
|
||||
import { EquipModel, EquipType } from '../../../db/Equip';
|
||||
import { checkEquipCanPut } from '../../../services/equipService';
|
||||
import { pick } from 'underscore';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -550,11 +553,13 @@ export class HeroHandler {
|
||||
async heroWearSkin(msg: { id: number }, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
let sid: string = session.get('sid');
|
||||
let serverId: number = session.get('serverId');
|
||||
|
||||
let { id } = msg;
|
||||
let skinInfo = gameData.fashion.get(id);
|
||||
// console.log('*****', id, skinInfo)
|
||||
if (!skinInfo) return resResult(STATUS.HERO_SKIN_NOT_FIND);
|
||||
let hero = await HeroModel.findByHidAndRole(skinInfo.actorId, roleId);
|
||||
let dicSkin = gameData.fashion.get(id);
|
||||
// console.log('*****', id, dicSkin)
|
||||
if (!dicSkin) return resResult(STATUS.HERO_SKIN_NOT_FIND);
|
||||
let hero = await HeroModel.findByHidAndRoleWithEquip(dicSkin.actorId, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
|
||||
let newHeroSkins: HeroSkin[] = [];
|
||||
@@ -569,17 +574,42 @@ export class HeroHandler {
|
||||
result = true;
|
||||
} else {
|
||||
if (!!skin.enable) {
|
||||
lastSkinId = skin.id;
|
||||
lastSkinId = skin.skinId;
|
||||
}
|
||||
|
||||
newHeroSkins.push({ ...skin, enable: false });
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
return resResult(STATUS.HERO_SKIN_NOT_FIND);
|
||||
}
|
||||
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.SKIN, sid, roleId, hero, { skins: newHeroSkins }, [id, lastSkinId]);
|
||||
return resResult(STATUS.SUCCESS, { curHero: { hid: hero.hid, skins: hero.skins } });
|
||||
let oldEquipSeids = calEquipSeids(hero);
|
||||
let dicHero = gameData.hero.get(dicSkin.heroId);
|
||||
let dicMyJob = gameData.job.get(hero.job);
|
||||
let dicNewJob = getJobByGradeAndClass(dicHero.jobClass, dicMyJob.grade);
|
||||
|
||||
let newEplace: EPlace[] = [], heroPutNum = 0, curEquips: {seqId: number, id: number, hid: number, ePlaceId: number}[] = [];
|
||||
for(let { id, equip, lv, refineLv } of hero.ePlace) {
|
||||
let e = <EquipType>equip;
|
||||
if(equip && !checkEquipCanPut(hero, e.id)) {
|
||||
await EquipModel.putOnOrOff(e._id, 0);
|
||||
heroPutNum -= 1;
|
||||
newEplace.push({ id, equip: null, lv, refineLv});
|
||||
curEquips.push({ seqId: e.seqId, id: e.id, hid: 0, ePlaceId: id });
|
||||
} else {
|
||||
newEplace.push({ id, equip: e?e._id: null, lv, refineLv});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(heroPutNum < 0) {
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP, sid, roleId, hero, {}, oldEquipSeids);
|
||||
await checkTask(roleId, sid, TASK_TYPE.EQUIP_SUM, heroPutNum, true, {});
|
||||
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUM, heroPutNum);
|
||||
await checkTaskWithHero(roleId, sid, TASK_TYPE.EQUIP_BY_HERO, hero, [heroPutNum]);
|
||||
}
|
||||
|
||||
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']), curEquips });
|
||||
}
|
||||
|
||||
// ! debug接口 一键全武将
|
||||
|
||||
@@ -23,6 +23,13 @@ export class CeAttrData {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public copyFromHero(data: CeAttrData) {
|
||||
this.base = data.base;
|
||||
this.ratioUp = data.ratioUp;
|
||||
this.fixUp = data.fixUp;
|
||||
this.equipUp = data.equipUp;
|
||||
}
|
||||
|
||||
public updateAttr(update: { inc?: CeAttrUpdate, set?: CeAttrUpdate }) {
|
||||
if(update.inc) {
|
||||
let { base, equipUp, fixUp, ratioUp } = update.inc;
|
||||
@@ -55,6 +62,8 @@ export class Connect {
|
||||
export class HeroSkin {
|
||||
@prop({ required: true })
|
||||
id: number;
|
||||
@prop({ required: true })
|
||||
skinId: number; // fashions表的heroId字段
|
||||
@prop({ ref: 'Skin', type: mongoose.Schema.Types.ObjectId })
|
||||
skin: Ref<Skin>;
|
||||
@prop({ required: true })
|
||||
@@ -145,6 +154,8 @@ export default class Hero extends BaseModel {
|
||||
job: number; // 职业
|
||||
@prop({ required: true, default: 0 })
|
||||
jobStage: number; // 职阶
|
||||
@prop({ required: true, default: 0 })
|
||||
skinId: number; // 当前皮肤id,fashions表的heroId字段
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
favour: number; // 好感度
|
||||
|
||||
@@ -10,19 +10,21 @@ export default class Skin extends BaseModel {
|
||||
roleName: string; // 角色名称
|
||||
|
||||
@prop({ required: true, default: '' })
|
||||
id: number; // 皮肤id
|
||||
id: number; // 皮肤id,fashions表的goodId字段
|
||||
@prop({ required: true, default: '' })
|
||||
skinId: number; // fashions表的heroId字段
|
||||
@prop({ required: true, default: '', select: false})
|
||||
skinName: string; // 皮肤名称
|
||||
@prop({ required: true, default: 0 })
|
||||
hid: number;
|
||||
hid: number; // 原始武将id
|
||||
|
||||
public static async findbyRole(roleId: string) {
|
||||
const rec: SkinType[] = await SkinModel.find({ roleId }, {_id: 0}).select('id skinName hid').lean();
|
||||
const rec: SkinType[] = await SkinModel.find({ roleId }, {_id: 0}).select('id skinId skinName hid').lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async findbyRoleAndHid(roleId: string, hid: number) {
|
||||
const rec: SkinType[] = await SkinModel.find({ roleId, hid }).select('id').lean();
|
||||
const rec: SkinType[] = await SkinModel.find({ roleId, hid }).select('id skinId').lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
@@ -35,7 +37,7 @@ export default class Skin extends BaseModel {
|
||||
return items;
|
||||
}
|
||||
|
||||
public static async increaseSkin(roleId: string, id: number, info: { roleId: string, roleName: string, id: number, skinName: string, hid: number }, lean = true) {
|
||||
public static async increaseSkin(roleId: string, id: number, info: { roleId: string, roleName: string, id: number, skinName: string, hid: number, skinId: number }, lean = true) {
|
||||
const doc = new SkinModel();
|
||||
const setOnInsert = Object.assign(doc.toJSON(), info);
|
||||
const items: SkinType = await SkinModel.findOneAndUpdate({ roleId, id }, { $setOnInsert: setOnInsert }, { new: true, upsert: true }).lean(lean);
|
||||
|
||||
@@ -102,8 +102,12 @@ export class CalHeroCe {
|
||||
|
||||
// 计算基础属性
|
||||
private calBaseAbility() {
|
||||
let { star, starStage, quality, colorStar, colorStarStage, lv } = this.heroInfo;
|
||||
const dicHero = gameData.hero.get(this.hid);
|
||||
let { star, starStage, quality, colorStar, colorStarStage, lv, skinId } = this.heroInfo;
|
||||
const dicHero = gameData.hero.get(skinId);
|
||||
if(!dicHero) {
|
||||
console.error(`not found hero: ${skinId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
for (let stage = ABI_STAGE.START + 1; stage <= ABI_STAGE.END; stage++) {
|
||||
let attrId = ABI_STAGE_TO_TYPE.get(stage);
|
||||
@@ -113,8 +117,7 @@ export class CalHeroCe {
|
||||
if(starStage < stage) star--;
|
||||
if(colorStarStage < stage) colorStar--;
|
||||
|
||||
const dicJob = gameData.job.get(dicHero.jobid);
|
||||
const dicStar = isWake ? getHeroWakeByQuality(dicJob.job_class, dicHero.quality, colorStar) : getHeroStarByQuality(dicJob.job_class, quality, star); // 星级表
|
||||
const dicStar = isWake ? getHeroWakeByQuality(dicHero.jobClass, dicHero.quality, colorStar) : getHeroStarByQuality(dicHero.jobClass, quality, star); // 星级表
|
||||
|
||||
let heroAttr = dicHero.baseAbilityArr.get(attrId); // 武将表hp等
|
||||
let heroUpAttr = dicHero.baseAbilityUpArr.get(attrId); // 武将表hp_up等
|
||||
@@ -123,7 +126,7 @@ export class CalHeroCe {
|
||||
starUp = dicStar.ceAttr.get(stage);
|
||||
}
|
||||
let base = heroAttr + (lv - 1) * (heroUpAttr + starUp);
|
||||
this.getSingleAttrObj(attrId).updateAttr({ inc: { base } });
|
||||
this.getSingleAttrObj(attrId).updateAttr({ set: { base } });
|
||||
};
|
||||
}
|
||||
|
||||
@@ -144,15 +147,11 @@ export class CalHeroCe {
|
||||
|
||||
// 计算皮肤属性
|
||||
private calSkinSeid() {
|
||||
let { skins, star: _star, colorStar: _colorStar } = this.heroInfo;
|
||||
let curSkin = skins.find(cur => cur.enable);
|
||||
let fashionid = curSkin.id;
|
||||
let { skinId, star: _star, colorStar: _colorStar } = this.heroInfo;
|
||||
|
||||
let seidList = new Map<number, number>(); // type => seid
|
||||
if (!gameData.fashion.has(fashionid)) return
|
||||
|
||||
let { skillId } = gameData.fashion.get(fashionid);
|
||||
let { starSeidArr, colorStarSeidArr } = gameData.heroSkill.get(skillId);
|
||||
let dicHero = gameData.hero.get(skinId);
|
||||
let { starSeidArr, colorStarSeidArr } = gameData.heroSkill.get(dicHero.skill);
|
||||
for (let { star, value, type } of starSeidArr) {
|
||||
if (_star >= star) {
|
||||
seidList.set(type, value);
|
||||
|
||||
@@ -19,7 +19,7 @@ import { dicWar, dicWarPvp, dicDailyWarByType, loadWar } from "./dictionary/DicW
|
||||
import { dicWarJson, loadWarJson } from "./dictionary/DicWarJson";
|
||||
import { dicXunbao, loadXunbao } from "./dictionary/DicXunbao";
|
||||
import { AUCTION_TIME, SPECIAL_ATTR } from "../consts";
|
||||
import { dicFashions, loadFashions } from "./dictionary/DicFashions";
|
||||
import { dicFashions, dicFashionsByHeroId, loadFashions } from "./dictionary/DicFashions";
|
||||
import { friendShips, friendShipHidAandIds, loadFriendShip } from "./dictionary/DicFriendShip";
|
||||
import { maxFriendShipLv, dicFriendShipLevelMap, loadFriendShipLevel } from "./dictionary/DicFriendShipLevel";
|
||||
import { dicHeroQualityUp, loadHeroQualityUp } from "./dictionary/DicHeroQualityUp";
|
||||
@@ -130,6 +130,7 @@ export const gameData = {
|
||||
blueprtToWar: new Map<number, number>(),
|
||||
blueprt: blueprt,
|
||||
fashion: dicFashions,
|
||||
fashionBySkinId: dicFashionsByHeroId,
|
||||
friendShips: friendShips,
|
||||
friendShipHidAandIds: friendShipHidAandIds,
|
||||
maxFriendShipLv: maxFriendShipLv,
|
||||
|
||||
@@ -1,31 +1,39 @@
|
||||
// 时装表
|
||||
import { decodeArrayListStr, readFileAndParse } from '../util';
|
||||
import { FILENAME } from '../../consts';
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface DicFashions {
|
||||
// 时装id
|
||||
readonly id: number;
|
||||
// 皮肤装名
|
||||
readonly name: string;
|
||||
// 指向heroSkill表
|
||||
readonly skillId: number;
|
||||
// 全局加成
|
||||
readonly globalAttr: Array<{id: number, number: number}>;
|
||||
// 单体加成
|
||||
readonly actorAttr: Array<{id: number, number: number}>;
|
||||
// 角色id
|
||||
// 即武将表里的heroId
|
||||
readonly heroId: number;
|
||||
// 原武将id,300以内的武将id
|
||||
readonly actorId: number;
|
||||
}
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicFashionsKeys: KeysEnum<DicFashions> = { id: true, name: true, globalAttr: true, actorAttr: true, heroId: true, actorId: true};
|
||||
|
||||
export const dicFashions = new Map<number, DicFashions>();
|
||||
export const dicFashionsByHeroId = new Map<number, DicFashions>();
|
||||
export function loadFashions() {
|
||||
dicFashions.clear();
|
||||
dicFashionsByHeroId.clear();
|
||||
let arr = readFileAndParse(FILENAME.DIC_FASHIONS);
|
||||
|
||||
arr.forEach(o => {
|
||||
o.id = o.goodId;
|
||||
o.globalAttr = parseAttr(o.globalAttr);
|
||||
o.actorAttr = parseAttr(o.actorAttr);
|
||||
dicFashions.set(o.id, o);
|
||||
dicFashions.set(o.id, _.pick(o, Object.keys(DicFashionsKeys)));
|
||||
dicFashionsByHeroId.set(o.heroId, _.pick(o, Object.keys(DicFashionsKeys)));
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
@@ -39,6 +47,6 @@ function parseAttr(str: string) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({id: parseInt(id), number: parseInt(number)});
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -13,8 +13,10 @@ export interface DicHero {
|
||||
readonly quality: number;
|
||||
// 阵营
|
||||
readonly camp: number;
|
||||
// 兵种
|
||||
readonly jobid: number;
|
||||
// 兵种大类
|
||||
readonly jobClass: number;
|
||||
// 兵种初始阶层
|
||||
readonly jobid: number;
|
||||
// 技能
|
||||
readonly skill: number;
|
||||
// 武将碎片
|
||||
@@ -34,7 +36,7 @@ export interface DicHero {
|
||||
}
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicHeroKeys: KeysEnum<DicHero> = {heroId: true, name: true, quality: true, camp: true, jobid: true, skill: true, pieceId: true, initialStars: true, pieceCount: true, baseAbilityArr: true, baseAbilityUpArr: true, initialSkin: true, recruit: true, face_id: true};
|
||||
const DicHeroKeys: KeysEnum<DicHero> = {heroId: true, name: true, quality: true, camp: true, jobClass: true, jobid: true, skill: true, pieceId: true, initialStars: true, pieceCount: true, baseAbilityArr: true, baseAbilityUpArr: true, initialSkin: true, recruit: true, face_id: true};
|
||||
export const dicMyHeroes = new Array<number>();
|
||||
export const dicHero = new Map<number, DicHero>();
|
||||
export function loadHero() {
|
||||
|
||||
@@ -28,7 +28,7 @@ export async function increaseSkin(roleId:string, roleName: string, skinId: numb
|
||||
let dicSkin = gameData.fashion.get(skinId);
|
||||
if (!dicSkin) return false;
|
||||
|
||||
let skin = await SkinModel.increaseSkin(roleId, skinId, { roleId, roleName, id: skinId, skinName: dicSkin.name, hid: dicSkin.actorId });
|
||||
let skin = await SkinModel.increaseSkin(roleId, skinId, { roleId, roleName, id: skinId, skinName: dicSkin.name, hid: dicSkin.actorId, skinId: dicSkin.heroId });
|
||||
if(!skin) return false; // 插入失败
|
||||
return skin
|
||||
}
|
||||
@@ -52,7 +52,7 @@ export async function addSkin(roleId: string, roleName: string, skinId: number,
|
||||
|
||||
if (hero) { // 有武将的,将皮肤链接到武将上
|
||||
if (!findWhere(hero.skins, { id: skinId })) {
|
||||
hero.skins.push({ id: skinId, skin: skin._id, enable });
|
||||
hero.skins.push({ id: skinId, skin: skin._id, enable, skinId: skin.skinId });
|
||||
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
|
||||
}
|
||||
return { hero, figureInfo, calAllHeroResult };
|
||||
|
||||
@@ -104,9 +104,6 @@ export async function reCalAllHeroCe(type: number, roleId: string, update: RoleU
|
||||
async function reCalRoleAttr(type: number, heros: Array<HeroType>, role: RoleType, update: RoleUpdate, args: Array<number>) {
|
||||
let { attr: roleAttrs } = role;
|
||||
switch (type) {
|
||||
case HERO_SYSTEM_TYPE.INIT:
|
||||
roleAttrs = calRoleInit(role);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.ADD_SKIN:
|
||||
roleAttrs = calHeroAddSkin(role, args);
|
||||
break;
|
||||
@@ -143,9 +140,6 @@ export function calPlayerCe(hero: HeroType, update: HeroUpdate, type: number, ar
|
||||
let removeSeidList = new Array<number>();
|
||||
|
||||
switch (type) {
|
||||
case HERO_SYSTEM_TYPE.INIT:
|
||||
heroAttrs = calHeroInitIncAttr(hero, addSeidList, removeSeidList); // args: 升的星盘
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.STAR:
|
||||
case HERO_SYSTEM_TYPE.LVUP:
|
||||
case HERO_SYSTEM_TYPE.COLORSTAR:
|
||||
@@ -159,7 +153,7 @@ export function calPlayerCe(hero: HeroType, update: HeroUpdate, type: number, ar
|
||||
heroAttrs = calHeroJobStageUpIncAttr(hero, update, addSeidList, removeSeidList);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.SKIN:
|
||||
heroAttrs = calHeroWearSkinIncAttr(hero, args[0], args[1], addSeidList, removeSeidList);
|
||||
heroAttrs = calHeroWearSkinIncAttr(hero, update, addSeidList, removeSeidList);
|
||||
break;
|
||||
case HERO_SYSTEM_TYPE.FAVOUR:
|
||||
heroAttrs = calHeroFavourUpIncAttr(hero, update);
|
||||
@@ -241,41 +235,6 @@ export async function calculatetopLineup(role: RoleType, hid?: number, ce?: numb
|
||||
return { topLineup, topLineupCe };
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {HeroType} hero 武将数据
|
||||
* @param {number[]} addSeidList 用于更新被动
|
||||
* @param {number[]} removeSeidList 用于更新被动
|
||||
*/
|
||||
export function calHeroInitIncAttr(hero: HeroType, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||
// try{
|
||||
delete hero._id;
|
||||
let heroAttrs = calHeroStarIncAttr(hero, hero, HERO_SYSTEM_TYPE.INIT, addSeidList, removeSeidList);
|
||||
heroAttrs = calHeroWearSkinIncAttr(hero, gameData.hero.get(hero.hid)?.initialSkin||0, 0, addSeidList, removeSeidList, true);
|
||||
heroAttrs = calHeroJobAttr(hero, hero, addSeidList, removeSeidList);
|
||||
return heroAttrs;
|
||||
// }catch(e) {
|
||||
// console.error(e);
|
||||
// return [];
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始全局加成
|
||||
* @param args
|
||||
* @param ceAttr
|
||||
*/
|
||||
function calRoleInit(role: RoleType) {
|
||||
let { attr: roleAttrs, teraphs } = role;
|
||||
delete role._id;
|
||||
roleAttrs = calTitle({...role, title: 0}, role); // 计算初始爵位带来的全局
|
||||
for(let {id} of teraphs) {
|
||||
roleAttrs = calTeraphMainAttr({ ...role, teraphs: [] }, role, id);
|
||||
}
|
||||
role.attr = roleAttrs;
|
||||
return roleAttrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加皮肤全局加成
|
||||
* @param args
|
||||
@@ -304,11 +263,10 @@ function calHeroAddSkin(role: RoleType, skinIds: Array<number>) {
|
||||
* @param {number[]} removeSeidList 用于更新被动
|
||||
*/
|
||||
export function calHeroStarIncAttr(originHero: HeroType, update: HeroUpdate, type: number, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
||||
let isInit = type == HERO_SYSTEM_TYPE.INIT;
|
||||
let { hid, star: originStar, starStage: originStarStage, quality: originQuality, colorStar: originColorStar, colorStarStage: originColorStarStage, attr: heroAttrs, skins, lv: oldLv } = originHero;
|
||||
let { star = originStar, starStage = originStarStage, quality = originQuality, colorStar = originColorStar, colorStarStage = originColorStarStage, lv = oldLv } = update;
|
||||
let { star: originStar, starStage: originStarStage, quality: originQuality, colorStar: originColorStar, colorStarStage: originColorStarStage, attr: heroAttrs, skinId: originSkinId, lv: oldLv } = originHero;
|
||||
let { star = originStar, starStage = originStarStage, quality = originQuality, colorStar = originColorStar, colorStarStage = originColorStarStage, skinId = originSkinId, lv = oldLv } = update;
|
||||
|
||||
const dicHero = gameData.hero.get(hid);
|
||||
const dicHero = gameData.hero.get(skinId);
|
||||
|
||||
const isWake = colorStar > 0; // 是否觉醒,只要激活了觉醒,彩星就会 > 1
|
||||
const isFirstWake = colorStar > 0 && originColorStar <= 0; // 是否是初次觉醒
|
||||
@@ -317,14 +275,11 @@ export function calHeroStarIncAttr(originHero: HeroType, update: HeroUpdate, typ
|
||||
if(starStage == ABI_STAGE.START) star--;
|
||||
if(colorStarStage == ABI_STAGE.START) colorStar--;
|
||||
|
||||
const dicJob = gameData.job.get(dicHero.jobid);
|
||||
const dicStar = isWake ? getHeroWakeByQuality(dicJob.job_class, dicHero.quality, colorStar) : getHeroStarByQuality(dicJob.job_class, quality, star); // 星级表
|
||||
const dicStar = isWake ? getHeroWakeByQuality(dicHero.jobClass, dicHero.quality, colorStar) : getHeroStarByQuality(dicHero.jobClass, quality, star); // 星级表
|
||||
|
||||
|
||||
let stages = new Array<number>(); // 需要升级的阶
|
||||
if (type == HERO_SYSTEM_TYPE.INIT) {
|
||||
stages = getAllAttrStage();
|
||||
} else if (type == HERO_SYSTEM_TYPE.LVUP) {
|
||||
if (type == HERO_SYSTEM_TYPE.LVUP) {
|
||||
stages = getAllAttrStage();
|
||||
} else if (type == HERO_SYSTEM_TYPE.STAR) {
|
||||
let end = isUpStar? ABI_STAGE.END: starStage;
|
||||
@@ -350,6 +305,8 @@ export function calHeroStarIncAttr(originHero: HeroType, update: HeroUpdate, typ
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (type == HERO_SYSTEM_TYPE.SKIN) {
|
||||
stages = getAllAttrStage();
|
||||
}
|
||||
for (let stage of stages) {
|
||||
|
||||
@@ -364,23 +321,19 @@ export function calHeroStarIncAttr(originHero: HeroType, update: HeroUpdate, typ
|
||||
updateHeroAttr(heroAttrs, targetAttrId, { set: { base: newBase } });
|
||||
}
|
||||
|
||||
// 武将被动技能,初始时候还没有皮肤,就先不算被动
|
||||
if(skins.length > 0) {
|
||||
let curSkin = skins.find(cur => cur.enable);
|
||||
let curSeidList = getSeidListOfFashion(curSkin.id, star, colorStar);
|
||||
let preSeidList = getSeidListOfFashion(curSkin.id, isInit ? 0 : originStar, isInit ? 0 : originColorStar);
|
||||
|
||||
curSeidList.forEach((seid, type) => {
|
||||
if (!preSeidList.has(type)) {
|
||||
addSeidList.push(seid, 0);
|
||||
}
|
||||
});
|
||||
preSeidList.forEach((seid, type) => {
|
||||
if (!curSeidList.has(type)) {
|
||||
removeSeidList.push(seid, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
let curSeidList = getSeidListOfFashion(skinId, star, colorStar);
|
||||
let preSeidList = getSeidListOfFashion(originSkinId, originStar, originColorStar);
|
||||
|
||||
curSeidList.forEach((seid, type) => {
|
||||
if (!preSeidList.has(type)) {
|
||||
addSeidList.push(seid, 0);
|
||||
}
|
||||
});
|
||||
preSeidList.forEach((seid, type) => {
|
||||
if (!curSeidList.has(type)) {
|
||||
removeSeidList.push(seid, 0);
|
||||
}
|
||||
});
|
||||
|
||||
originHero.attr = heroAttrs;
|
||||
return heroAttrs;//属性增量可以是多个
|
||||
@@ -434,16 +387,15 @@ function updateRoleAttr(roleAttrs: CeAttrDataRole[], id: number, update: { inc?:
|
||||
}
|
||||
/**
|
||||
* 获取皮肤上的seid
|
||||
* @param fashionid
|
||||
* @param skinId
|
||||
* @param originStar
|
||||
* @param originColorStar
|
||||
*/
|
||||
function getSeidListOfFashion(fashionid: number, originStar: number, originColorStar: number) {
|
||||
function getSeidListOfFashion(skinId: number, originStar: number, originColorStar: number) {
|
||||
let seidList = new Map<number, number>(); // type => seid
|
||||
if (!gameData.fashion.has(fashionid)) return seidList;
|
||||
let dicHero = gameData.hero.get(skinId);
|
||||
|
||||
let { skillId } = gameData.fashion.get(fashionid);
|
||||
let { starSeidArr, colorStarSeidArr } = gameData.heroSkill.get(skillId);
|
||||
let { starSeidArr, colorStarSeidArr } = gameData.heroSkill.get(dicHero.skill);
|
||||
for (let { star, value, type } of starSeidArr) {
|
||||
if (originStar >= star) {
|
||||
seidList.set(type, value);
|
||||
@@ -558,10 +510,13 @@ export function calHeroJobAttr(originHero: HeroType, hero: HeroUpdate, addSeidLi
|
||||
* @param {number[]} removeSeidList 用于更新被动
|
||||
* @param {boolean} isInit 是否是计算初始战力
|
||||
*/
|
||||
export function calHeroWearSkinIncAttr(originHero: HeroType, wearSkinId: number, pullSkinId: number, addSeidList: number[], removeSeidList: number[], isInit: boolean = false) {
|
||||
let { attr: heroAttrs } = originHero;
|
||||
let addSkin = gameData.fashion.get(wearSkinId);
|
||||
let delSkin = gameData.fashion.get(pullSkinId);
|
||||
export function calHeroWearSkinIncAttr(originHero: HeroType, update: HeroUpdate, addSeidList: number[], removeSeidList: number[]) {
|
||||
let { attr: heroAttrs, skinId: originSkinId } = originHero;
|
||||
let { skinId = originSkinId } = update;
|
||||
calHeroStarIncAttr(originHero, update, HERO_SYSTEM_TYPE.SKIN, addSeidList, removeSeidList);
|
||||
|
||||
let addSkin = gameData.fashionBySkinId.get(skinId);
|
||||
let delSkin = gameData.fashionBySkinId.get(originSkinId);
|
||||
|
||||
if (delSkin) {
|
||||
for (let attr of delSkin.actorAttr) {
|
||||
@@ -573,23 +528,6 @@ export function calHeroWearSkinIncAttr(originHero: HeroType, wearSkinId: number,
|
||||
let fixUp = attr.number * HERO_CE_RATIO;
|
||||
updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp } });
|
||||
}
|
||||
|
||||
if (!isInit) { // 初始的时候,这一段技能在calHeroStarIncAttr里计算了,不用重复算
|
||||
let { star, colorStar } = originHero;
|
||||
|
||||
let curSeidList = getSeidListOfFashion(wearSkinId, star, colorStar);
|
||||
let preSeidList = getSeidListOfFashion(pullSkinId, star, colorStar);
|
||||
curSeidList.forEach((seid, type) => {
|
||||
if (!preSeidList.has(type)) {
|
||||
removeSeidList.push(seid, 0);
|
||||
}
|
||||
});
|
||||
preSeidList.forEach((seid, type) => {
|
||||
if (!curSeidList.has(type)) {
|
||||
addSeidList.push(seid, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
originHero.attr = heroAttrs;
|
||||
return heroAttrs;
|
||||
}
|
||||
|
||||
@@ -114,11 +114,15 @@ export function getInitRoleInfo() {
|
||||
// 皮肤
|
||||
let skin = new SkinModel();
|
||||
let dicFashion = gameData.fashion.get(initialSkin);
|
||||
let skinInfo = { ...skin.toJSON(), id: initialSkin, hid, skinName: dicFashion.name };
|
||||
if(!dicFashion) {
|
||||
console.log(`not found skin: ${initialSkin} of ${hid}`);
|
||||
continue;
|
||||
}
|
||||
let skinInfo = { ...skin.toJSON(), id: initialSkin, hid, skinName: dicFashion.name, skinId: dicFashion.heroId };
|
||||
initSkins.push(skinInfo);
|
||||
// 武将
|
||||
let hero = new HeroModel();
|
||||
let heroInfo = {...hero.toJSON(), hid, star, quality, hName, job, skins: [{ id: initialSkin, skin: skinInfo._id, enable: true }], lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0 };
|
||||
let heroInfo = {...hero.toJSON(), hid, star, quality, hName, job, skins: [{ id: initialSkin, skin: skinInfo._id, enable: true }], skinId: skinInfo.skinId, lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0 };
|
||||
let calHeroCe = new CalHeroCe(hid, heroInfo);
|
||||
let heroAttr = calHeroCe.cal(HERO_SYSTEM_TYPE.INIT);
|
||||
let ce = calHeroCe.getCalculatedCe(roleAttr);
|
||||
@@ -261,9 +265,9 @@ export class CreateHeroes extends UpdateHeroes {
|
||||
let allSkins = isInit? []: await SkinModel.findbyRoleAndHid(this.roleId, hid);
|
||||
let skin = await SkinModel.insertSkins(this.roleId, this.roleName, [initSkinInfo]);
|
||||
if(skin) allSkins.push(...skin);
|
||||
let skins: { id: number, skin: string, enable: boolean }[] = [];
|
||||
let skins: { id: number, skin: string, enable: boolean, skinId: number }[] = [];
|
||||
for(let skin of allSkins) {
|
||||
skins.push({ id: skin.id, skin: skin._id, enable: skin.id == initSkinInfo.id });
|
||||
skins.push({ id: skin.id, skin: skin._id, enable: skin.id == initSkinInfo.id, skinId: skin.skinId });
|
||||
}
|
||||
return skins
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user