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