皮肤:武将、时装表修改
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user