✨ feat(重生): 重生不重置星级
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { Channel, pinus } from 'pinus';
|
||||
import { getRandValueByMinMax, getRandEelm, decodeIdCntArrayStr } from '../pubUtils/util';
|
||||
import { DEFAULT_HEROES, LINEUP_NUM, ROLE_SELECT, TALENT_RELATION_TYPE, TERAPH_RANDOM, SYSTEM_OPEN_ID, GuideUnloadNum } from "../consts";
|
||||
import { DEFAULT_HEROES, LINEUP_NUM, ROLE_SELECT, TALENT_RELATION_TYPE, TERAPH_RANDOM, SYSTEM_OPEN_ID, GuideUnloadNum, CHECK_HERO_CONSUME, ABI_STAGE } from "../consts";
|
||||
import { DicTeraph } from '../pubUtils/dictionary/DicTeraph';
|
||||
import { Teraph, RoleModel, RoleType, RoleUpdate } from '../db/Role';
|
||||
import { SCHOOL } from '../pubUtils/dicParam';
|
||||
import { gameData, getHeroInitTalent } from '../pubUtils/data';
|
||||
import { gameData, getHeroInitTalent, getHeroStarByQuality } from '../pubUtils/data';
|
||||
import { SchoolModel } from '../db/School';
|
||||
import { SclResultInter, SclPosInter, RewardInter, ItemInter } from '../pubUtils/interface';
|
||||
import { Connect, HeroModel, HeroSkin, HeroUpdate, Talent } from '../db/Hero';
|
||||
import { Connect, HeroModel, HeroSkin, HeroType, HeroUpdate, Talent } from '../db/Hero';
|
||||
import { SkinUpdate } from '../db/Skin';
|
||||
import { Figure } from '../domain/dbGeneral';
|
||||
import { pick } from 'underscore';
|
||||
@@ -314,3 +314,44 @@ export async function checkServerIsOpen(serverId: number, ip: string, uid: numbe
|
||||
let serverTime = await getServerCreateTime(serverId);
|
||||
return serverTime <= nowSeconds();
|
||||
}
|
||||
|
||||
export function calStarUpConsume(hero: HeroType) {
|
||||
let originConsumes = hero.consumes||[];
|
||||
if(CHECK_HERO_CONSUME) {
|
||||
let dicHero = gameData.hero.get(hero.hid);
|
||||
let dicJob = gameData.job.get(dicHero?.jobid);
|
||||
if(dicHero && dicJob) {
|
||||
let decrease = 0;
|
||||
for(let star = dicHero.initialStar; star < hero.star; star++) {
|
||||
let curDicHeroStar = getHeroStarByQuality(dicJob.job_class, dicHero.quality, star);
|
||||
if(!curDicHeroStar) continue;
|
||||
let max = star == hero.star ? hero.starStage: ABI_STAGE.END;
|
||||
for (let i = 0; i < max; i++) {
|
||||
decrease += curDicHeroStar.advanceUpFragmentNum;
|
||||
}
|
||||
}
|
||||
for(let quality = dicHero.quality; quality < hero.quality; quality++) {
|
||||
let curDicHeroQualityUp = gameData.heroQualityUp.get(quality);
|
||||
if (!curDicHeroQualityUp) continue;
|
||||
decrease += curDicHeroQualityUp.fragmentNum;
|
||||
}
|
||||
|
||||
return decreaseConsume(originConsumes, dicHero.pieceId, decrease);
|
||||
}
|
||||
}
|
||||
return { consumes: originConsumes, newConsumes: [] };
|
||||
}
|
||||
|
||||
// 从原始消耗里减去消耗
|
||||
function decreaseConsume(origin: Reward[], pieceId: number, decrease: number) {
|
||||
let consumes: Reward[] = [], newConsumes: Reward[] = [];
|
||||
for(let { id, count } of origin) {
|
||||
if(id == pieceId) {
|
||||
consumes.push({ id, count: count - decrease > 0? count - decrease: 0 });
|
||||
newConsumes.push({ id, count: decrease });
|
||||
} else {
|
||||
consumes.push({ id, count });
|
||||
}
|
||||
}
|
||||
return { consumes, newConsumes };
|
||||
}
|
||||
Reference in New Issue
Block a user