武将:职业天赋接口
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import { ChannelUser } from './../domain/ChannelUser';
|
||||
import { Channel, pinus } from 'pinus';
|
||||
import { getRandValueByMinMax, getRandEelm, decodeIdCntArrayStr } from '../pubUtils/util';
|
||||
import { DEFAULT_HEROES, ROLE_SELECT, TERAPH_RANDOM } from "../consts";
|
||||
import { DEFAULT_HEROES, ROLE_SELECT, TALENT_RELATION_TYPE, TERAPH_RANDOM } from "../consts";
|
||||
import { DicTeraph } from '../pubUtils/dictionary/DicTeraph';
|
||||
import { Teraph, RoleModel, RoleType, RoleUpdate } from '../db/Role';
|
||||
import { SCHOOL } from '../pubUtils/dicParam';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { gameData, getHeroInitTalent } from '../pubUtils/data';
|
||||
import { SchoolModel } from '../db/School';
|
||||
import { SclResultInter, SclPosInter, RewardInter, ItemInter } from '../pubUtils/interface';
|
||||
import { HeroUpdate } from '../db/Hero';
|
||||
import { HeroSkin, HeroUpdate, Talent } from '../db/Hero';
|
||||
import { SkinUpdate } from '../db/Skin';
|
||||
import { Figure } from '../domain/dbGeneral';
|
||||
import { pick } from 'underscore';
|
||||
@@ -172,4 +172,83 @@ export function addConsumeToHero(oldConsume: Reward[] = [], consumes: ItemInter[
|
||||
newConsume.push({ id, count });
|
||||
}
|
||||
return newConsume;
|
||||
}
|
||||
|
||||
export function checkUnlockTalentCondition(hid: number, id: number, talents: Talent[], usedTalentPoint: number) {
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
let dicHeroTalent = gameData.heroTalent.get(id);
|
||||
if(!dicHeroTalent) return false;
|
||||
|
||||
if(dicHero.talentId != dicHeroTalent.talentId) return false;
|
||||
|
||||
// 累计消耗n点天赋点
|
||||
if(dicHeroTalent.preTotalPoint > usedTalentPoint) return false;
|
||||
// 互斥的天赋没有被解锁
|
||||
for(let { type, ids } of dicHeroTalent.relation) {
|
||||
if(type == TALENT_RELATION_TYPE.CONFLICT) {
|
||||
let hasTalent = talents.find(talent => ids.indexOf(talent.id) != -1);
|
||||
if(hasTalent) return false;
|
||||
}
|
||||
}
|
||||
// 前置节点
|
||||
let orFlag = false; // 只要其中一个满足就可以
|
||||
let maxPrecost = 0; // 前置节点最多的消耗
|
||||
for(let arr of dicHeroTalent.prepositionId) {
|
||||
let andFlag = true; // arr内所有节点都需要满足
|
||||
for(let id of arr) {
|
||||
let curTalent = talents.find(cur => cur.id == id);
|
||||
if(curTalent) {
|
||||
let dic = gameData.heroTalent.get(id);
|
||||
if(dic) {
|
||||
let allCost = 0;
|
||||
for(let { lv, cost } of dic.level) {
|
||||
if(curTalent.level >= lv) allCost += cost;
|
||||
}
|
||||
if(allCost > maxPrecost) maxPrecost = allCost;
|
||||
}
|
||||
} else {
|
||||
andFlag = false;
|
||||
}
|
||||
}
|
||||
if(andFlag) orFlag = true;
|
||||
}
|
||||
if(!orFlag) return false;
|
||||
// 在前置节点中消耗至少n点天赋点(在有多个前置节点时,取最高的1个)
|
||||
if(dicHeroTalent.preSinglePoint > maxPrecost) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
export function updateSkinTalent(skins: HeroSkin[], newTalent: Talent, usedTalentPoint: number) {
|
||||
let newSkins: HeroSkin[] = [];
|
||||
let newTalents: Talent[] = [];
|
||||
for(let skin of skins) {
|
||||
if(skin.enable) {
|
||||
let hasNewTalent = false;
|
||||
for(let talent of skin.talent) {
|
||||
if(talent.id == newTalent.id) {
|
||||
newTalents.push(newTalent);
|
||||
hasNewTalent = true;
|
||||
} else {
|
||||
newTalents.push(talent);
|
||||
}
|
||||
}
|
||||
if(!hasNewTalent) newTalents.push(newTalent);
|
||||
newSkins.push({...skin, talent: newTalents, usedTalentPoint })
|
||||
} else {
|
||||
newSkins.push(skin);
|
||||
}
|
||||
}
|
||||
return { newSkins, newTalents };
|
||||
}
|
||||
|
||||
export function initSkinTalent(skins: HeroSkin[]) {
|
||||
let newSkins: HeroSkin[] = [];
|
||||
for(let skin of skins) {
|
||||
if(skin.enable) {
|
||||
newSkins.push({ ...skin, talent: getHeroInitTalent(skin.skinId), usedTalentPoint: 0 });
|
||||
} else {
|
||||
newSkins.push(skin);
|
||||
}
|
||||
}
|
||||
return newSkins
|
||||
}
|
||||
Reference in New Issue
Block a user