战力:整理
This commit is contained in:
@@ -9,174 +9,32 @@ import { gameData, getEquipQualityIdByEquipIdAndPoint, getEquipStarAttrByStage,
|
|||||||
import { DicRandomEffectPool } from "../../pubUtils/dictionary/DicRandomEffectPool";
|
import { DicRandomEffectPool } from "../../pubUtils/dictionary/DicRandomEffectPool";
|
||||||
import { DicSe } from "../../pubUtils/dictionary/DicSe";
|
import { DicSe } from "../../pubUtils/dictionary/DicSe";
|
||||||
import { addToMap, deepCopy } from "../../pubUtils/util";
|
import { addToMap, deepCopy } from "../../pubUtils/util";
|
||||||
|
|
||||||
export class CalCe {
|
export class CalCe {
|
||||||
roleId: string;
|
roleId: string;
|
||||||
globalAttrs: Map<number, GlobalMainAttr|GlobalSubAttr> = new Map(); // attrId => GlobalAttr
|
|
||||||
heroAttrs: Map<string, HeroMainAttr|HeroSubAttr> = new Map(); // hid+attrId => HeroAttr
|
|
||||||
heroAttrsByHid: Map<number, string[]> = new Map(); // hid => [hid+attrId]
|
|
||||||
equipAttrs: Map<string, EquipMainAttr|EquipSubAttr> = new Map(); // hid+eplaceId+attrId => EquipAttr
|
|
||||||
equipAttrsByHid: Map<number, string[]> = new Map(); // hid => [hid+eplaceId+attrId]
|
|
||||||
equipAttrsByHidAndEplace: Map<string, { hid: number, eplaceId: number, keys: string[]}> = new Map(); // hid+eplaceId =>[hid+eplaceId+attrId]
|
|
||||||
equipAttrsByHidAndAttrId: Map<string, { hid: number, attrId: number, keys: string[]}> = new Map(); // hid+attrId =>[hid+eplaceId+attrId]
|
|
||||||
heroLv: Map<number, number> = new Map();
|
|
||||||
heroHistoryCe: Map<number, number> = new Map();
|
|
||||||
heroObjectId: Map<number, string> = new Map();
|
|
||||||
equipLv: Map<string, number> = new Map(); // hid+eplaceId => lv
|
|
||||||
originCes: Map<number, number> = new Map(); // hid => ce
|
originCes: Map<number, number> = new Map(); // hid => ce
|
||||||
resultCes: Map<number, number> = new Map(); // hid => ce
|
resultCes: Map<number, number> = new Map(); // hid => ce
|
||||||
schoolAttrs: Map<string, { hid: number, attrId: number, ce: number }> = new Map(); // hid + attr => ratio
|
data: CalCeData;
|
||||||
schoolAttrsByAttrId: Map<number, string[]> = new Map(); // attrId => hid + attr
|
|
||||||
schoolAttrsByHid: Map<number, string[]> = new Map(); // hid => hid + attr
|
|
||||||
scrollAttrs: Map<string, { hid: number, attrId: number, ce: number }> = new Map(); // hid + attr => ratio
|
|
||||||
scrollAttrsByAttrId: Map<number, string[]> = new Map(); // attrId => hid + attr
|
|
||||||
scrollAttrsByHid: Map<number, string[]> = new Map(); // hid => hid + attr
|
|
||||||
|
|
||||||
constructor(roleId: string) {
|
constructor(roleId: string) {
|
||||||
this.roleId = roleId;
|
this.roleId = roleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getGlobalAttrById(attrId: number) {
|
public setRoleCe(roleCe: RoleCeType) {
|
||||||
if(!this.globalAttrs.has(attrId)) {
|
this.data = new CalCeData(roleCe)
|
||||||
if(ABI_TYPE_MAIN.indexOf(attrId) != -1) {
|
this.originCes = this.calHeroCe();
|
||||||
let obj = new GlobalMainAttr(attrId);
|
|
||||||
this.globalAttrs.set(attrId, obj);
|
|
||||||
} else {
|
|
||||||
let obj = new GlobalSubAttr(attrId);
|
|
||||||
this.globalAttrs.set(attrId, obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.globalAttrs.get(attrId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getHeroAttrsByHid(hid: number) {
|
public getRoleCeTable() {
|
||||||
let keys = this.heroAttrsByHid.get(hid);
|
return this.data.getRoleCeTable(this.roleId);
|
||||||
return keys.map(key => this.heroAttrs.get(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
private getHeroAttrByHidAndId(hid: number, attrId: number) {
|
|
||||||
let key = `${hid}_${attrId}`;
|
|
||||||
if(!this.heroAttrs.has(key)) {
|
|
||||||
if(ABI_TYPE_MAIN.indexOf(attrId) != -1) {
|
|
||||||
let obj = new HeroMainAttr(hid, attrId);
|
|
||||||
this.heroAttrs.set(key, obj);
|
|
||||||
} else {
|
|
||||||
let obj = new HeroSubAttr(hid, attrId);
|
|
||||||
this.heroAttrs.set(key, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.heroAttrsByHid.has(hid)) {
|
|
||||||
this.heroAttrsByHid.set(hid, []);
|
|
||||||
}
|
|
||||||
this.heroAttrsByHid.get(hid).push(key);
|
|
||||||
}
|
|
||||||
return this.heroAttrs.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
private getEquipAttrByHidAndId(hid: number, eplaceId: number, attrId: number) {
|
|
||||||
let key = `${hid}_${eplaceId}_${attrId}`;
|
|
||||||
if(!this.equipAttrs.has(key)) {
|
|
||||||
if(ABI_TYPE_MAIN.indexOf(attrId) != -1) {
|
|
||||||
let obj = new EquipMainAttr(hid, attrId);
|
|
||||||
this.equipAttrs.set(key, obj);
|
|
||||||
} else {
|
|
||||||
let obj = new EquipSubAttr(hid, attrId);
|
|
||||||
this.equipAttrs.set(key, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.equipAttrsByHid.has(hid)) {
|
|
||||||
this.equipAttrsByHid.set(hid, []);
|
|
||||||
}
|
|
||||||
this.equipAttrsByHid.get(hid).push(key);
|
|
||||||
let key2 = `${hid}_${eplaceId}`;
|
|
||||||
if(!this.equipAttrsByHidAndEplace.has(key2)) {
|
|
||||||
this.equipAttrsByHidAndEplace.set(key2, { hid, eplaceId, keys: []});
|
|
||||||
}
|
|
||||||
this.equipAttrsByHidAndEplace.get(key2).keys.push(key);
|
|
||||||
}
|
|
||||||
return this.equipAttrs.get(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
private getEquipAttrsByHidAndEplace(hid: number, eplaceId: number) {
|
|
||||||
let key2 = `${hid}_${eplaceId}`;
|
|
||||||
if(!this.equipAttrsByHidAndEplace.has(key2)) return []
|
|
||||||
let { keys } = this.equipAttrsByHidAndEplace.get(key2);
|
|
||||||
return keys.map(key => this.equipAttrs.get(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
private setSchoolAttrs(hid: number, attrId: number, value: number) {
|
|
||||||
let key = `${hid}_${attrId}`;
|
|
||||||
if(!this.schoolAttrs.has(key)) {
|
|
||||||
this.schoolAttrs.set(key, { hid, attrId, ce: value });
|
|
||||||
if(!this.schoolAttrsByAttrId.has(attrId)) {
|
|
||||||
this.schoolAttrsByAttrId.set(attrId, []);
|
|
||||||
}
|
|
||||||
this.schoolAttrsByAttrId.get(attrId).push(key);
|
|
||||||
if(!this.schoolAttrsByHid.has(attrId)) {
|
|
||||||
this.schoolAttrsByHid.set(hid, []);
|
|
||||||
}
|
|
||||||
this.schoolAttrsByHid.get(hid).push(key);
|
|
||||||
} else {
|
|
||||||
this.schoolAttrs.get(key).ce = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private getSchoolAttrsByHid(hid: number) {
|
|
||||||
let keys = this.schoolAttrsByHid.get(hid)||[];
|
|
||||||
return keys.map(key => this.schoolAttrs.get(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
private calSchoolAttrsToGlobal(attrId: number) {
|
|
||||||
let keys = this.schoolAttrsByAttrId.get(attrId)||[];
|
|
||||||
let schoolResult = 0;
|
|
||||||
for(let key of keys) {
|
|
||||||
let { ce } = this.schoolAttrs.get(key);
|
|
||||||
schoolResult += ce;
|
|
||||||
}
|
|
||||||
let globalAttr = this.getGlobalAttrById(attrId);
|
|
||||||
globalAttr.school = schoolResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
private setScrollAttrs(hid: number, attrId: number, value: number) {
|
|
||||||
let key = `${hid}_${attrId}`;
|
|
||||||
if(!this.scrollAttrs.has(key)) {
|
|
||||||
this.scrollAttrs.set(key, { hid, attrId, ce: value });
|
|
||||||
if(!this.scrollAttrsByAttrId.has(attrId)) {
|
|
||||||
this.scrollAttrsByAttrId.set(attrId, []);
|
|
||||||
}
|
|
||||||
this.scrollAttrsByAttrId.get(attrId).push(key);
|
|
||||||
if(!this.scrollAttrsByHid.has(attrId)) {
|
|
||||||
this.scrollAttrsByHid.set(hid, []);
|
|
||||||
}
|
|
||||||
this.scrollAttrsByHid.get(hid).push(key);
|
|
||||||
} else {
|
|
||||||
this.scrollAttrs.get(key).ce = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private getScrollAttrsByHid(hid: number) {
|
|
||||||
let keys = this.scrollAttrsByHid.get(hid)||[];
|
|
||||||
return keys.map(key => this.scrollAttrs.get(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
private calScrollAttrsToGlobal(attrId: number) {
|
|
||||||
let keys = this.scrollAttrsByAttrId.get(attrId)||[];
|
|
||||||
let result = 0;
|
|
||||||
for(let key of keys) {
|
|
||||||
let { ce } = this.scrollAttrs.get(key);
|
|
||||||
result += ce;
|
|
||||||
}
|
|
||||||
let globalAttr = this.getGlobalAttrById(attrId);
|
|
||||||
globalAttr.scroll = result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public calHeroCe() {
|
public calHeroCe() {
|
||||||
let ces = new Map<number, { id: number, val: number }[]>(); // hid => [{attrId, val}]
|
let ces = new Map<number, { id: number, val: number }[]>(); // hid => [{attrId, val}]
|
||||||
for(let [hid, keys] of this.heroAttrsByHid) {
|
for(let [hid, keys] of this.data.heroAttrsByHid) {
|
||||||
let lv = this.heroLv.get(hid)||1;
|
let lv = this.data.heroLv.get(hid)||1;
|
||||||
for(let key of keys) {
|
for(let key of keys) {
|
||||||
let { attrId, mainBase = 0, subBase = 0, job = 0, starUp = 0, connect = 0, favour = 0, talent = 0, equipQuality = 0, equipStrength = 0, equipStar = 0, equipSuit = 0, jewel = 0, stone = 0 } = this.heroAttrs.get(key);
|
let { attrId, mainBase = 0, subBase = 0, job = 0, starUp = 0, connect = 0, favour = 0, talent = 0, equipQuality = 0, equipStrength = 0, equipStar = 0, equipSuit = 0, jewel = 0, stone = 0 } = this.data.heroAttrs.get(key);
|
||||||
let { school = 0, teraph = 0, title = 0, scroll = 0, skin = 0 } = this.getGlobalAttrById(attrId);
|
let { school = 0, teraph = 0, title = 0, scroll = 0, skin = 0 } = this.data.getGlobalAttrById(attrId);
|
||||||
let val = 0;
|
let val = 0;
|
||||||
if(ABI_TYPE_MAIN.indexOf(attrId)) {
|
if(ABI_TYPE_MAIN.indexOf(attrId)) {
|
||||||
// {[hp1 + lv * hp2 + hp3 * ( 1 + hp4 )] * (1 + hp5 ) + [( hp6 + hp7 ) * ( 1 + hp8 )] } * ( 1 + hp9 ) + hp10 + hp11
|
// {[hp1 + lv * hp2 + hp3 * ( 1 + hp4 )] * (1 + hp5 ) + [( hp6 + hp7 ) * ( 1 + hp8 )] } * ( 1 + hp9 ) + hp10 + hp11
|
||||||
@@ -210,93 +68,14 @@ export class CalCe {
|
|||||||
if(ce != originCe) {
|
if(ce != originCe) {
|
||||||
heroCe.set(hid, { inc: ce - originCe, origin: originCe, ce });
|
heroCe.set(hid, { inc: ce - originCe, origin: originCe, ce });
|
||||||
roleInc += ce - originCe;
|
roleInc += ce - originCe;
|
||||||
this.setHistoryCe(hid, ce);
|
this.data.setHistoryCe(hid, ce);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { heroCe, roleInc }
|
return { heroCe, roleInc }
|
||||||
}
|
}
|
||||||
|
|
||||||
private setHistoryCe(hid: number, ce: number) {
|
|
||||||
let historyCe = this.heroHistoryCe.get(hid)||0;
|
|
||||||
if(ce > historyCe) {
|
|
||||||
this.heroHistoryCe.set(hid, ce);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getRoleCeTable() {
|
|
||||||
let globalAttrs: AttrCell[] = [];
|
|
||||||
for(let [_, globalAttr] of this.globalAttrs) {
|
|
||||||
globalAttrs.push(globalAttr.getGlobalAttr());
|
|
||||||
}
|
|
||||||
let heroAttrs: HeroAttr[] = [];
|
|
||||||
for(let [hid, keys] of this.heroAttrsByHid) {
|
|
||||||
let lv = this.heroLv.get(hid);
|
|
||||||
let historyCe = this.heroHistoryCe.get(hid)||0;
|
|
||||||
let objectId = this.heroObjectId.get(hid);
|
|
||||||
let attrs: AttrCell[] = [];
|
|
||||||
for(let key of keys) {
|
|
||||||
let heroAttr = this.heroAttrs.get(key);
|
|
||||||
attrs.push(heroAttr.getHeroAttrCell());
|
|
||||||
}
|
|
||||||
heroAttrs.push({
|
|
||||||
hid, lv, attrs, historyCe, objectId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
let equipAttrs: EquipAttr[] = [];
|
|
||||||
for(let [key2, { hid, eplaceId, keys }] of this.equipAttrsByHidAndEplace) {
|
|
||||||
let lv = this.equipLv.get(key2);
|
|
||||||
let attrs: AttrCell[] = [];
|
|
||||||
for(let key of keys) {
|
|
||||||
let equipAttr = this.equipAttrs.get(key);
|
|
||||||
attrs.push(equipAttr.getEquipAttrCell());
|
|
||||||
}
|
|
||||||
equipAttrs.push({
|
|
||||||
hid, eplaceId, lv, attrs
|
|
||||||
});
|
|
||||||
}
|
|
||||||
let schoolAttrs: SchoolAttr[] = [];
|
|
||||||
for(let [_, { hid, attrId, ce }] of this.schoolAttrs) {
|
|
||||||
schoolAttrs.push({ hid, attrId, value: ce });
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
roleId: this.roleId, globalAttrs, heroAttrs, equipAttrs, schoolAttrs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public setRoleCe(roleCe: RoleCeType) {
|
|
||||||
if(roleCe) {
|
|
||||||
for(let globalAttr of roleCe.globalAttrs) {
|
|
||||||
let obj = this.getGlobalAttrById(globalAttr.attrId);
|
|
||||||
obj.setByRoleCe(globalAttr);
|
|
||||||
}
|
|
||||||
for(let {hid, lv, attrs, historyCe, objectId } of roleCe.heroAttrs) {
|
|
||||||
this.heroLv.set(hid, lv);
|
|
||||||
this.heroHistoryCe.set(hid, historyCe);
|
|
||||||
this.heroObjectId.set(hid, objectId);
|
|
||||||
for(let cell of attrs) {
|
|
||||||
let obj = this.getHeroAttrByHidAndId(hid, cell.attrId);
|
|
||||||
obj.setByRoleCe(cell);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(let { hid, eplaceId, lv, attrs } of roleCe.equipAttrs) {
|
|
||||||
this.equipLv.set(`${hid}_${eplaceId}`, lv);
|
|
||||||
for(let cell of attrs) {
|
|
||||||
let obj = this.getEquipAttrByHidAndId(hid, eplaceId, cell.attrId);
|
|
||||||
obj.setByRoleCe(cell);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(let { hid, attrId, value } of roleCe.schoolAttrs) {
|
|
||||||
this.setSchoolAttrs(hid, attrId, value);
|
|
||||||
}
|
|
||||||
for(let { hid, attrId, value } of roleCe.scrollAttrs) {
|
|
||||||
this.setScrollAttrs(hid, attrId, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.originCes = this.calHeroCe();
|
|
||||||
}
|
|
||||||
|
|
||||||
public setResultHero(hero: HeroType) {
|
public setResultHero(hero: HeroType) {
|
||||||
this.heroObjectId.set(hero.hid, hero._id);
|
this.data.setResultHero(hero);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getResultCeArr() {
|
public getResultCeArr() {
|
||||||
@@ -315,7 +94,7 @@ export class CalCe {
|
|||||||
if(arr[i]) {
|
if(arr[i]) {
|
||||||
let { hid, ce } = arr[i];
|
let { hid, ce } = arr[i];
|
||||||
topLineup.push({
|
topLineup.push({
|
||||||
hid, ce, hero: this.heroObjectId.get(hid)
|
hid, ce, hero: this.data.heroObjectId.get(hid)
|
||||||
});
|
});
|
||||||
topLineupCe += ce;
|
topLineupCe += ce;
|
||||||
}
|
}
|
||||||
@@ -323,66 +102,26 @@ export class CalCe {
|
|||||||
return { topLineup, topLineupCe };
|
return { topLineup, topLineupCe };
|
||||||
}
|
}
|
||||||
|
|
||||||
private clearRoleAttr(field: string) {
|
|
||||||
for(let globalAttr of this.globalAttrs) {
|
|
||||||
globalAttr[field] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private clearHeroAttrByHid(hid: number, field: string) {
|
|
||||||
let heroAttrs = this.getHeroAttrsByHid(hid);
|
|
||||||
for(let heroAttr of heroAttrs) {
|
|
||||||
heroAttr[field] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private clearEquipAttrByHidAndEplace(hid: number, eplaceId: number, field: string) {
|
|
||||||
let equipAttrs = this.getEquipAttrsByHidAndEplace(hid, eplaceId);
|
|
||||||
for(let equipAttr of equipAttrs) {
|
|
||||||
let originNum = equipAttr[field]||0;
|
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, equipAttr.attrId);
|
|
||||||
if(heroAttr && heroAttr[field]) {
|
|
||||||
heroAttr[field] -= originNum;
|
|
||||||
}
|
|
||||||
equipAttr[field] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private clearSchoolAttr(hid: number) {
|
|
||||||
let schoolAttrs = this.getSchoolAttrsByHid(hid);
|
|
||||||
for(let schoolAttr of schoolAttrs) {
|
|
||||||
schoolAttr.ce = 0;
|
|
||||||
this.calSchoolAttrsToGlobal(schoolAttr.attrId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private clearScrollAttr(hid: number) {
|
|
||||||
let scrollAttrs = this.getScrollAttrsByHid(hid);
|
|
||||||
for(let scrollAttr of scrollAttrs) {
|
|
||||||
scrollAttr.ce = 0;
|
|
||||||
this.calScrollAttrsToGlobal(scrollAttr.attrId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 武将基础&成长
|
// 武将基础&成长
|
||||||
public setHeroBase(hid: number, skinId: number) {
|
public setHeroBase(hid: number, skinId: number) {
|
||||||
this.clearHeroAttrByHid(hid, 'mainBase');
|
this.data.clearHeroAttrByHid(hid, 'mainBase');
|
||||||
let dicHero = gameData.hero.get(skinId);
|
let dicHero = gameData.hero.get(skinId);
|
||||||
|
|
||||||
for(let [attrId, value] of dicHero.baseAbilityArr) {
|
for(let [attrId, value] of dicHero.baseAbilityArr) {
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, attrId);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, attrId);
|
||||||
heroAttr.mainBase = value;
|
heroAttr.mainBase = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 武将等级
|
// 武将等级
|
||||||
public setHeroLv(hid: number, lv: number) {
|
public setHeroLv(hid: number, lv: number) {
|
||||||
this.heroLv.set(hid, lv);
|
this.data.heroLv.set(hid, lv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 星级相关
|
// 星级相关
|
||||||
public setHeroStar(hid: number, job: number, quality: number, star: number, starStage: number, colorStar: number, colorStarStage: number) {
|
public setHeroStar(hid: number, job: number, quality: number, star: number, starStage: number, colorStar: number, colorStarStage: number) {
|
||||||
this.clearHeroAttrByHid(hid, 'starUp');
|
this.data.clearHeroAttrByHid(hid, 'starUp');
|
||||||
let dicJob = gameData.job.get(job);
|
let dicJob = gameData.job.get(job);
|
||||||
let jobClass = dicJob.job_class;
|
let jobClass = dicJob.job_class;
|
||||||
const isWake = colorStar > 0; // 是否觉醒,只要激活了觉醒,彩星就会 > 1
|
const isWake = colorStar > 0; // 是否觉醒,只要激活了觉醒,彩星就会 > 1
|
||||||
@@ -398,47 +137,47 @@ export class CalCe {
|
|||||||
} else {
|
} else {
|
||||||
value = dicPreStar?.ceAttr.get(stage)||0;
|
value = dicPreStar?.ceAttr.get(stage)||0;
|
||||||
}
|
}
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, attrId);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, attrId);
|
||||||
heroAttr.starUp = value;
|
heroAttr.starUp = value;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 职业基础
|
// 职业基础
|
||||||
public setJob(hid: number, job: number, jobStage: number) {
|
public setJob(hid: number, job: number, jobStage: number) {
|
||||||
this.clearHeroAttrByHid(hid, 'job');
|
this.data.clearHeroAttrByHid(hid, 'job');
|
||||||
this.clearHeroAttrByHid(hid, 'subBase');
|
this.data.clearHeroAttrByHid(hid, 'subBase');
|
||||||
const dicJob = gameData.job.get(job);
|
const dicJob = gameData.job.get(job);
|
||||||
let lastJob = getJobByGradeAndClass(dicJob.job_class, dicJob.grade - 1);
|
let lastJob = getJobByGradeAndClass(dicJob.job_class, dicJob.grade - 1);
|
||||||
let dicLastJob = lastJob? gameData.job.get(lastJob.jobid): null;
|
let dicLastJob = lastJob? gameData.job.get(lastJob.jobid): null;
|
||||||
for(let i = 1; i <= dicJob.maxStage; i++) {
|
for(let i = 1; i <= dicJob.maxStage; i++) {
|
||||||
if(jobStage >= i) {
|
if(jobStage >= i) {
|
||||||
let { id, attr } = dicJob.ceAttr.get(i);
|
let { id, attr } = dicJob.ceAttr.get(i);
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||||
heroAttr.job = attr;
|
heroAttr.job = attr;
|
||||||
} else {
|
} else {
|
||||||
if(dicLastJob) {
|
if(dicLastJob) {
|
||||||
let { id, attr } = dicLastJob.ceAttr.get(i);
|
let { id, attr } = dicLastJob.ceAttr.get(i);
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||||
heroAttr.job = attr;
|
heroAttr.job = attr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(let { id, val } of dicJob.baseSubAttr) {
|
for(let { id, val } of dicJob.baseSubAttr) {
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||||
heroAttr.subBase = val;
|
heroAttr.subBase = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 好感度
|
// 好感度
|
||||||
public setFavour(hid: number, favourLv: number, connections: Connect[]) {
|
public setFavour(hid: number, favourLv: number, connections: Connect[]) {
|
||||||
this.clearHeroAttrByHid(hid, 'favour');
|
this.data.clearHeroAttrByHid(hid, 'favour');
|
||||||
let currentFiendShipLevel = gameData.friendShipLevelMap.get(favourLv);
|
let currentFiendShipLevel = gameData.friendShipLevelMap.get(favourLv);
|
||||||
let add = currentFiendShipLevel.add;
|
let add = currentFiendShipLevel.add;
|
||||||
|
|
||||||
for (let {shipId, level} of connections) {
|
for (let {shipId, level} of connections) {
|
||||||
let dicHeroFriendShip = getFriendShipById(shipId, level);
|
let dicHeroFriendShip = getFriendShipById(shipId, level);
|
||||||
for (let { id } of dicHeroFriendShip.attributes) {
|
for (let { id } of dicHeroFriendShip.attributes) {
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||||
heroAttr.favour = add;
|
heroAttr.favour = add;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -446,14 +185,14 @@ export class CalCe {
|
|||||||
|
|
||||||
// 羁绊
|
// 羁绊
|
||||||
public setConnection(hid: number, shipId: number, connections: Connect[]) {
|
public setConnection(hid: number, shipId: number, connections: Connect[]) {
|
||||||
this.clearHeroAttrByHid(hid, 'connect');
|
this.data.clearHeroAttrByHid(hid, 'connect');
|
||||||
let connect = connections.find(cur => cur.shipId == shipId);
|
let connect = connections.find(cur => cur.shipId == shipId);
|
||||||
let level = connect?.level||0;
|
let level = connect?.level||0;
|
||||||
|
|
||||||
let currentShip = getFriendShipById(shipId, level);
|
let currentShip = getFriendShipById(shipId, level);
|
||||||
if (currentShip) {
|
if (currentShip) {
|
||||||
for (let { id, number: val } of currentShip.attributes) {
|
for (let { id, number: val } of currentShip.attributes) {
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||||
heroAttr.connect = val;
|
heroAttr.connect = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -463,24 +202,24 @@ export class CalCe {
|
|||||||
public setAddSkin(skinId: number) {
|
public setAddSkin(skinId: number) {
|
||||||
let addSkin = gameData.fashion.get(skinId);
|
let addSkin = gameData.fashion.get(skinId);
|
||||||
for (let { id, number: val } of addSkin.globalAttr) {
|
for (let { id, number: val } of addSkin.globalAttr) {
|
||||||
let globalAttr = this.getGlobalAttrById(id);
|
let globalAttr = this.data.getGlobalAttrById(id);
|
||||||
globalAttr.skin += val;
|
globalAttr.skin += val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 天赋
|
// 天赋
|
||||||
public setTalent(hid: number, skins: HeroSkin[]) {
|
public setTalent(hid: number, skins: HeroSkin[]) {
|
||||||
this.clearHeroAttrByHid(hid, 'talent');
|
this.data.clearHeroAttrByHid(hid, 'talent');
|
||||||
let skin = skins.find(cur => cur.enable);
|
let skin = skins.find(cur => cur.enable);
|
||||||
let seids = this.getTalentSeid(skin.talent);
|
let seids = this.getTalentSeid(skin.talent);
|
||||||
let { ratioUp } = this.addSeidEffect(seids);
|
let { ratioUp } = this.addSeidEffect(seids);
|
||||||
for(let [attrId, val] of ratioUp) {
|
for(let [attrId, val] of ratioUp) {
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, attrId);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, attrId);
|
||||||
heroAttr.talent = val;
|
heroAttr.talent = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTalentSeid(talent: Talent[]) {
|
public getTalentSeid(talent: Talent[]) {
|
||||||
let seids = new Map<number, number[]>(); // id, seids
|
let seids = new Map<number, number[]>(); // id, seids
|
||||||
for(let { id, level } of talent) {
|
for(let { id, level } of talent) {
|
||||||
let dicHeroTalent = gameData.heroTalent.get(id);
|
let dicHeroTalent = gameData.heroTalent.get(id);
|
||||||
@@ -507,11 +246,11 @@ export class CalCe {
|
|||||||
|
|
||||||
// 装备升品
|
// 装备升品
|
||||||
public setEquipQuality(hid: number, eplaceId: number, equipId: number, quality: number, qualityStage: number) {
|
public setEquipQuality(hid: number, eplaceId: number, equipId: number, quality: number, qualityStage: number) {
|
||||||
this.clearEquipAttrByHidAndEplace(hid, eplaceId, 'equipQuality');
|
this.data.clearEquipAttrByHidAndEplace(hid, eplaceId, 'equipQuality');
|
||||||
let dicEquipQuality = getEquipQualityIdByEquipIdAndPoint(equipId, quality, qualityStage);
|
let dicEquipQuality = getEquipQualityIdByEquipIdAndPoint(equipId, quality, qualityStage);
|
||||||
for(let { id, num } of dicEquipQuality.attribute) {
|
for(let { id, num } of dicEquipQuality.attribute) {
|
||||||
let equipAttr = this.getEquipAttrByHidAndId(hid, eplaceId, id);
|
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, id);
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||||
heroAttr.equipQuality += num - equipAttr.equipQuality;
|
heroAttr.equipQuality += num - equipAttr.equipQuality;
|
||||||
equipAttr.equipQuality = num;
|
equipAttr.equipQuality = num;
|
||||||
}
|
}
|
||||||
@@ -519,11 +258,11 @@ export class CalCe {
|
|||||||
|
|
||||||
// 装备强化
|
// 装备强化
|
||||||
public setEquipStrength(hid: number, eplaceId: number, equipId: number, lv: number) {
|
public setEquipStrength(hid: number, eplaceId: number, equipId: number, lv: number) {
|
||||||
this.clearEquipAttrByHidAndEplace(hid, eplaceId, 'equipStrengthen');
|
this.data.clearEquipAttrByHidAndEplace(hid, eplaceId, 'equipStrengthen');
|
||||||
let dicEquipStrenth = getEquipStrenthenAttr(equipId, lv);
|
let dicEquipStrenth = getEquipStrenthenAttr(equipId, lv);
|
||||||
for(let { id, num } of dicEquipStrenth.attr) {
|
for(let { id, num } of dicEquipStrenth.attr) {
|
||||||
let equipAttr = this.getEquipAttrByHidAndId(hid, eplaceId, id);
|
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, id);
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||||
heroAttr.equipStrength = num - equipAttr.equipStrengthen;
|
heroAttr.equipStrength = num - equipAttr.equipStrengthen;
|
||||||
equipAttr.equipStrengthen = num;
|
equipAttr.equipStrengthen = num;
|
||||||
}
|
}
|
||||||
@@ -531,13 +270,13 @@ export class CalCe {
|
|||||||
|
|
||||||
// 装备精炼(升星)
|
// 装备精炼(升星)
|
||||||
public setEquipStar(hid: number, eplaceId: number, equipId: number, star: number, starStage: number) {
|
public setEquipStar(hid: number, eplaceId: number, equipId: number, star: number, starStage: number) {
|
||||||
this.clearEquipAttrByHidAndEplace(hid, eplaceId, 'equipStar');
|
this.data.clearEquipAttrByHidAndEplace(hid, eplaceId, 'equipStar');
|
||||||
let dicEquipStar = getEquipStarAttrByStage(equipId, star, starStage);
|
let dicEquipStar = getEquipStarAttrByStage(equipId, star, starStage);
|
||||||
if(dicEquipStar) {
|
if(dicEquipStar) {
|
||||||
let { mainAttr, subAttr } = dicEquipStar;
|
let { mainAttr, subAttr } = dicEquipStar;
|
||||||
for(let { id, num } of [...mainAttr, ...subAttr]) {
|
for(let { id, num } of [...mainAttr, ...subAttr]) {
|
||||||
let equipAttr = this.getEquipAttrByHidAndId(hid, eplaceId, id);
|
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, id);
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||||
heroAttr.equipStar = num - equipAttr.equipStar;
|
heroAttr.equipStar = num - equipAttr.equipStar;
|
||||||
equipAttr.equipStar = num;
|
equipAttr.equipStar = num;
|
||||||
}
|
}
|
||||||
@@ -546,7 +285,7 @@ export class CalCe {
|
|||||||
|
|
||||||
// 装备套装
|
// 装备套装
|
||||||
public setEquipSuit(hid: number, ePlace: EPlace[]) {
|
public setEquipSuit(hid: number, ePlace: EPlace[]) {
|
||||||
this.clearHeroAttrByHid(hid, 'equipSuit');
|
this.data.clearHeroAttrByHid(hid, 'equipSuit');
|
||||||
let dicEquipSuit = getEquipSuitByHero(hid);
|
let dicEquipSuit = getEquipSuitByHero(hid);
|
||||||
let suitStars: number[] = [];
|
let suitStars: number[] = [];
|
||||||
for(let equipId of dicEquipSuit.equips) {
|
for(let equipId of dicEquipSuit.equips) {
|
||||||
@@ -562,14 +301,14 @@ export class CalCe {
|
|||||||
|
|
||||||
let { ratioUp } = this.addSeidEffect(seids);
|
let { ratioUp } = this.addSeidEffect(seids);
|
||||||
for(let [attrId, val] of ratioUp) {
|
for(let [attrId, val] of ratioUp) {
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, attrId);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, attrId);
|
||||||
heroAttr.equipSuit = val;
|
heroAttr.equipSuit = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 天晶
|
// 天晶
|
||||||
public setJewel(hid: number, eplaceId: number, stones: Stone[], jewel: JewelType) {
|
public setJewel(hid: number, eplaceId: number, stones: Stone[], jewel: JewelType) {
|
||||||
this.clearEquipAttrByHidAndEplace(hid, eplaceId, 'jewel');
|
this.data.clearEquipAttrByHidAndEplace(hid, eplaceId, 'jewel');
|
||||||
let seids: number[] = [];
|
let seids: number[] = [];
|
||||||
if(jewel) {
|
if(jewel) {
|
||||||
for(let { id, seid, rand } of jewel.randSe) {
|
for(let { id, seid, rand } of jewel.randSe) {
|
||||||
@@ -580,14 +319,14 @@ export class CalCe {
|
|||||||
}
|
}
|
||||||
let { ratioUp } = this.addSeidEffect(seids);
|
let { ratioUp } = this.addSeidEffect(seids);
|
||||||
for(let [attrId, val] of ratioUp) {
|
for(let [attrId, val] of ratioUp) {
|
||||||
let equipAttr = this.getEquipAttrByHidAndId(hid, eplaceId, attrId);
|
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, attrId);
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, attrId);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, attrId);
|
||||||
heroAttr.jewel += val - equipAttr.jewel;
|
heroAttr.jewel += val - equipAttr.jewel;
|
||||||
equipAttr.jewel = val;
|
equipAttr.jewel = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private isRandSeUnLock(jewelId: number, randSeId: number, stones: Stone[]) {
|
public isRandSeUnLock(jewelId: number, randSeId: number, stones: Stone[]) {
|
||||||
let dicJewel = gameData.jewel.get(jewelId);
|
let dicJewel = gameData.jewel.get(jewelId);
|
||||||
let dicJewelCondition = getJewelConditionByLvAndSeId(dicJewel.lv, randSeId);
|
let dicJewelCondition = getJewelConditionByLvAndSeId(dicJewel.lv, randSeId);
|
||||||
let stoneCnt = 0, stoneLv = 0;
|
let stoneCnt = 0, stoneLv = 0;
|
||||||
@@ -603,13 +342,13 @@ export class CalCe {
|
|||||||
|
|
||||||
// 地玉
|
// 地玉
|
||||||
public setStone(hid: number, eplaceId: number, stones: Stone[]) {
|
public setStone(hid: number, eplaceId: number, stones: Stone[]) {
|
||||||
this.clearEquipAttrByHidAndEplace(hid, eplaceId, 'stone');
|
this.data.clearEquipAttrByHidAndEplace(hid, eplaceId, 'stone');
|
||||||
for(let { stone } of stones) {
|
for(let { stone } of stones) {
|
||||||
let dicStone = gameData.stone.get(stone);
|
let dicStone = gameData.stone.get(stone);
|
||||||
if(dicStone) {
|
if(dicStone) {
|
||||||
for(let { id, num } of dicStone.attribute) {
|
for(let { id, num } of dicStone.attribute) {
|
||||||
let equipAttr = this.getEquipAttrByHidAndId(hid, eplaceId, id);
|
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, id);
|
||||||
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
|
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||||
heroAttr.stone += num - equipAttr.stone;
|
heroAttr.stone += num - equipAttr.stone;
|
||||||
equipAttr.stone = num;
|
equipAttr.stone = num;
|
||||||
}
|
}
|
||||||
@@ -620,21 +359,21 @@ export class CalCe {
|
|||||||
|
|
||||||
// 爵位
|
// 爵位
|
||||||
public setTitle(title: number) {
|
public setTitle(title: number) {
|
||||||
this.clearRoleAttr('title');
|
this.data.clearRoleAttr('title');
|
||||||
let dicTitle = gameData.title.get(title)||{ mainAttrValue: new Map(), assiAttrValue: new Map() };
|
let dicTitle = gameData.title.get(title)||{ mainAttrValue: new Map(), assiAttrValue: new Map() };
|
||||||
for(let [attrId, value] of dicTitle.mainAttrValue) {
|
for(let [attrId, value] of dicTitle.mainAttrValue) {
|
||||||
let globalAttr = this.getGlobalAttrById(attrId);
|
let globalAttr = this.data.getGlobalAttrById(attrId);
|
||||||
globalAttr.title = value;
|
globalAttr.title = value;
|
||||||
}
|
}
|
||||||
for(let [attrId, value] of dicTitle.assiAttrValue) {
|
for(let [attrId, value] of dicTitle.assiAttrValue) {
|
||||||
let globalAttr = this.getGlobalAttrById(attrId);
|
let globalAttr = this.data.getGlobalAttrById(attrId);
|
||||||
globalAttr.title = value;
|
globalAttr.title = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 神像相关
|
// 神像相关
|
||||||
public setTeraph(teraphs: Teraph[]) {
|
public setTeraph(teraphs: Teraph[]) {
|
||||||
this.clearRoleAttr('teraph');
|
this.data.clearRoleAttr('teraph');
|
||||||
let teraphOfAttrId = new Map<number, number>();
|
let teraphOfAttrId = new Map<number, number>();
|
||||||
for(let teraph of teraphs) {
|
for(let teraph of teraphs) {
|
||||||
for(let [attrId, value] of teraph.attr) { // 主属性
|
for(let [attrId, value] of teraph.attr) { // 主属性
|
||||||
@@ -646,38 +385,38 @@ export class CalCe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(let [attrId, value] of teraphOfAttrId) {
|
for(let [attrId, value] of teraphOfAttrId) {
|
||||||
let globalAttr = this.getGlobalAttrById(attrId);
|
let globalAttr = this.data.getGlobalAttrById(attrId);
|
||||||
globalAttr.teraph = value;
|
globalAttr.teraph = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 名将谱
|
// 名将谱
|
||||||
public setScroll(hid: number, scrollStar: number, scrollQuality: number, scrollColorStar: number) {
|
public setScroll(hid: number, scrollStar: number, scrollQuality: number, scrollColorStar: number) {
|
||||||
this.clearScrollAttr(hid);
|
this.data.clearScrollAttr(hid);
|
||||||
let dicHero =gameData.hero.get(hid);
|
let dicHero =gameData.hero.get(hid);
|
||||||
let dicHeroScroll = getScollByStar(dicHero.quality, scrollStar, scrollQuality, scrollColorStar);
|
let dicHeroScroll = getScollByStar(dicHero.quality, scrollStar, scrollQuality, scrollColorStar);
|
||||||
|
|
||||||
if(dicHeroScroll) {
|
if(dicHeroScroll) {
|
||||||
for(let [attrId, value] of dicHeroScroll.ceAttr) {
|
for(let [attrId, value] of dicHeroScroll.ceAttr) {
|
||||||
this.setScrollAttrs(hid, attrId, value);
|
this.data.setScrollAttrs(hid, attrId, value);
|
||||||
this.calScrollAttrsToGlobal(attrId);
|
this.data.calScrollAttrsToGlobal(attrId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 百家学宫
|
// 百家学宫
|
||||||
public setSchool(isPutOn: boolean, hid: number, schoolId: number, star: number, colorStar: number, quality: number) {
|
public setSchool(isPutOn: boolean, hid: number, schoolId: number, star: number, colorStar: number, quality: number) {
|
||||||
this.clearSchoolAttr(hid);
|
this.data.clearSchoolAttr(hid);
|
||||||
let dicSchool = gameData.school.get(schoolId);
|
let dicSchool = gameData.school.get(schoolId);
|
||||||
let dicSchoolRate = getSchoolRateByStar(star, colorStar, quality);
|
let dicSchoolRate = getSchoolRateByStar(star, colorStar, quality);
|
||||||
|
|
||||||
for (let attrId of dicSchool.upAttribute) {
|
for (let attrId of dicSchool.upAttribute) {
|
||||||
if(ABI_TYPE_MAIN.includes(attrId)) { // 主属性
|
if(ABI_TYPE_MAIN.includes(attrId)) { // 主属性
|
||||||
this.setSchoolAttrs(hid, attrId, isPutOn?dicSchoolRate.mainAttrAPerent: 0);
|
this.data.setSchoolAttrs(hid, attrId, isPutOn?dicSchoolRate.mainAttrAPerent: 0);
|
||||||
} else {
|
} else {
|
||||||
this.setSchoolAttrs(hid, attrId, isPutOn?dicSchoolRate.assiAttrAddValue: 0);
|
this.data.setSchoolAttrs(hid, attrId, isPutOn?dicSchoolRate.assiAttrAddValue: 0);
|
||||||
}
|
}
|
||||||
this.calSchoolAttrsToGlobal(attrId);
|
this.data.calSchoolAttrsToGlobal(attrId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -735,6 +474,288 @@ export class CalCe {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CalCeData {
|
||||||
|
// 全局
|
||||||
|
globalAttrs: Map<number, GlobalMainAttr|GlobalSubAttr> = new Map(); // attrId => GlobalAttr
|
||||||
|
// 武将
|
||||||
|
heroAttrs: Map<string, HeroMainAttr|HeroSubAttr> = new Map(); // hid+attrId => HeroAttr
|
||||||
|
heroAttrsByHid: Map<number, string[]> = new Map(); // hid => [hid+attrId]
|
||||||
|
heroLv: Map<number, number> = new Map();
|
||||||
|
heroHistoryCe: Map<number, number> = new Map();
|
||||||
|
heroObjectId: Map<number, string> = new Map();
|
||||||
|
// 装备
|
||||||
|
equipAttrs: Map<string, EquipMainAttr|EquipSubAttr> = new Map(); // hid+eplaceId+attrId => EquipAttr
|
||||||
|
equipAttrsByHid: Map<number, string[]> = new Map(); // hid => [hid+eplaceId+attrId]
|
||||||
|
equipAttrsByHidAndEplace: Map<string, { hid: number, eplaceId: number, keys: string[]}> = new Map(); // hid+eplaceId =>[hid+eplaceId+attrId]
|
||||||
|
equipAttrsByHidAndAttrId: Map<string, { hid: number, attrId: number, keys: string[]}> = new Map(); // hid+attrId =>[hid+eplaceId+attrId]
|
||||||
|
equipLv: Map<string, number> = new Map(); // hid+eplaceId => lv
|
||||||
|
// 百家学宫
|
||||||
|
schoolAttrs: Map<string, { hid: number, attrId: number, ce: number }> = new Map(); // hid + attr => ratio
|
||||||
|
schoolAttrsByAttrId: Map<number, string[]> = new Map(); // attrId => hid + attr
|
||||||
|
schoolAttrsByHid: Map<number, string[]> = new Map(); // hid => hid + attr
|
||||||
|
// 名将谱
|
||||||
|
scrollAttrs: Map<string, { hid: number, attrId: number, ce: number }> = new Map(); // hid + attr => ratio
|
||||||
|
scrollAttrsByAttrId: Map<number, string[]> = new Map(); // attrId => hid + attr
|
||||||
|
scrollAttrsByHid: Map<number, string[]> = new Map(); // hid => hid + attr
|
||||||
|
|
||||||
|
constructor(roleCe: RoleCeType) {
|
||||||
|
if(roleCe) {
|
||||||
|
for(let globalAttr of roleCe.globalAttrs) {
|
||||||
|
let obj = this.getGlobalAttrById(globalAttr.attrId);
|
||||||
|
obj.setByRoleCe(globalAttr);
|
||||||
|
}
|
||||||
|
for(let {hid, lv, attrs, historyCe, objectId } of roleCe.heroAttrs) {
|
||||||
|
this.heroLv.set(hid, lv);
|
||||||
|
this.heroHistoryCe.set(hid, historyCe);
|
||||||
|
this.heroObjectId.set(hid, objectId);
|
||||||
|
for(let cell of attrs) {
|
||||||
|
let obj = this.getHeroAttrByHidAndId(hid, cell.attrId);
|
||||||
|
obj.setByRoleCe(cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(let { hid, eplaceId, lv, attrs } of roleCe.equipAttrs) {
|
||||||
|
this.equipLv.set(`${hid}_${eplaceId}`, lv);
|
||||||
|
for(let cell of attrs) {
|
||||||
|
let obj = this.getEquipAttrByHidAndId(hid, eplaceId, cell.attrId);
|
||||||
|
obj.setByRoleCe(cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(let { hid, attrId, value } of roleCe.schoolAttrs) {
|
||||||
|
this.setSchoolAttrs(hid, attrId, value);
|
||||||
|
}
|
||||||
|
for(let { hid, attrId, value } of roleCe.scrollAttrs) {
|
||||||
|
this.setScrollAttrs(hid, attrId, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getGlobalAttrById(attrId: number) {
|
||||||
|
if(!this.globalAttrs.has(attrId)) {
|
||||||
|
if(ABI_TYPE_MAIN.indexOf(attrId) != -1) {
|
||||||
|
let obj = new GlobalMainAttr(attrId);
|
||||||
|
this.globalAttrs.set(attrId, obj);
|
||||||
|
} else {
|
||||||
|
let obj = new GlobalSubAttr(attrId);
|
||||||
|
this.globalAttrs.set(attrId, obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.globalAttrs.get(attrId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public clearRoleAttr(field: string) {
|
||||||
|
for(let globalAttr of this.globalAttrs) {
|
||||||
|
globalAttr[field] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getHeroAttrsByHid(hid: number) {
|
||||||
|
let keys = this.heroAttrsByHid.get(hid);
|
||||||
|
return keys.map(key => this.heroAttrs.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
public getHeroAttrByHidAndId(hid: number, attrId: number) {
|
||||||
|
let key = `${hid}_${attrId}`;
|
||||||
|
if(!this.heroAttrs.has(key)) {
|
||||||
|
if(ABI_TYPE_MAIN.indexOf(attrId) != -1) {
|
||||||
|
let obj = new HeroMainAttr(hid, attrId);
|
||||||
|
this.heroAttrs.set(key, obj);
|
||||||
|
} else {
|
||||||
|
let obj = new HeroSubAttr(hid, attrId);
|
||||||
|
this.heroAttrs.set(key, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.heroAttrsByHid.has(hid)) {
|
||||||
|
this.heroAttrsByHid.set(hid, []);
|
||||||
|
}
|
||||||
|
this.heroAttrsByHid.get(hid).push(key);
|
||||||
|
}
|
||||||
|
return this.heroAttrs.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public clearHeroAttrByHid(hid: number, field: string) {
|
||||||
|
let heroAttrs = this.getHeroAttrsByHid(hid);
|
||||||
|
for(let heroAttr of heroAttrs) {
|
||||||
|
heroAttr[field] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getEquipAttrByHidAndId(hid: number, eplaceId: number, attrId: number) {
|
||||||
|
let key = `${hid}_${eplaceId}_${attrId}`;
|
||||||
|
if(!this.equipAttrs.has(key)) {
|
||||||
|
if(ABI_TYPE_MAIN.indexOf(attrId) != -1) {
|
||||||
|
let obj = new EquipMainAttr(hid, attrId);
|
||||||
|
this.equipAttrs.set(key, obj);
|
||||||
|
} else {
|
||||||
|
let obj = new EquipSubAttr(hid, attrId);
|
||||||
|
this.equipAttrs.set(key, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!this.equipAttrsByHid.has(hid)) {
|
||||||
|
this.equipAttrsByHid.set(hid, []);
|
||||||
|
}
|
||||||
|
this.equipAttrsByHid.get(hid).push(key);
|
||||||
|
let key2 = `${hid}_${eplaceId}`;
|
||||||
|
if(!this.equipAttrsByHidAndEplace.has(key2)) {
|
||||||
|
this.equipAttrsByHidAndEplace.set(key2, { hid, eplaceId, keys: []});
|
||||||
|
}
|
||||||
|
this.equipAttrsByHidAndEplace.get(key2).keys.push(key);
|
||||||
|
}
|
||||||
|
return this.equipAttrs.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getEquipAttrsByHidAndEplace(hid: number, eplaceId: number) {
|
||||||
|
let key2 = `${hid}_${eplaceId}`;
|
||||||
|
if(!this.equipAttrsByHidAndEplace.has(key2)) return []
|
||||||
|
let { keys } = this.equipAttrsByHidAndEplace.get(key2);
|
||||||
|
return keys.map(key => this.equipAttrs.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
public clearEquipAttrByHidAndEplace(hid: number, eplaceId: number, field: string) {
|
||||||
|
let equipAttrs = this.getEquipAttrsByHidAndEplace(hid, eplaceId);
|
||||||
|
for(let equipAttr of equipAttrs) {
|
||||||
|
let originNum = equipAttr[field]||0;
|
||||||
|
let heroAttr = this.getHeroAttrByHidAndId(hid, equipAttr.attrId);
|
||||||
|
if(heroAttr && heroAttr[field]) {
|
||||||
|
heroAttr[field] -= originNum;
|
||||||
|
}
|
||||||
|
equipAttr[field] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public setSchoolAttrs(hid: number, attrId: number, value: number) {
|
||||||
|
let key = `${hid}_${attrId}`;
|
||||||
|
if(!this.schoolAttrs.has(key)) {
|
||||||
|
this.schoolAttrs.set(key, { hid, attrId, ce: value });
|
||||||
|
if(!this.schoolAttrsByAttrId.has(attrId)) {
|
||||||
|
this.schoolAttrsByAttrId.set(attrId, []);
|
||||||
|
}
|
||||||
|
this.schoolAttrsByAttrId.get(attrId).push(key);
|
||||||
|
if(!this.schoolAttrsByHid.has(attrId)) {
|
||||||
|
this.schoolAttrsByHid.set(hid, []);
|
||||||
|
}
|
||||||
|
this.schoolAttrsByHid.get(hid).push(key);
|
||||||
|
} else {
|
||||||
|
this.schoolAttrs.get(key).ce = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getSchoolAttrsByHid(hid: number) {
|
||||||
|
let keys = this.schoolAttrsByHid.get(hid)||[];
|
||||||
|
return keys.map(key => this.schoolAttrs.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
public calSchoolAttrsToGlobal(attrId: number) {
|
||||||
|
let keys = this.schoolAttrsByAttrId.get(attrId)||[];
|
||||||
|
let schoolResult = 0;
|
||||||
|
for(let key of keys) {
|
||||||
|
let { ce } = this.schoolAttrs.get(key);
|
||||||
|
schoolResult += ce;
|
||||||
|
}
|
||||||
|
let globalAttr = this.getGlobalAttrById(attrId);
|
||||||
|
globalAttr.school = schoolResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public clearSchoolAttr(hid: number) {
|
||||||
|
let schoolAttrs = this.getSchoolAttrsByHid(hid);
|
||||||
|
for(let schoolAttr of schoolAttrs) {
|
||||||
|
schoolAttr.ce = 0;
|
||||||
|
this.calSchoolAttrsToGlobal(schoolAttr.attrId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public setScrollAttrs(hid: number, attrId: number, value: number) {
|
||||||
|
let key = `${hid}_${attrId}`;
|
||||||
|
if(!this.scrollAttrs.has(key)) {
|
||||||
|
this.scrollAttrs.set(key, { hid, attrId, ce: value });
|
||||||
|
if(!this.scrollAttrsByAttrId.has(attrId)) {
|
||||||
|
this.scrollAttrsByAttrId.set(attrId, []);
|
||||||
|
}
|
||||||
|
this.scrollAttrsByAttrId.get(attrId).push(key);
|
||||||
|
if(!this.scrollAttrsByHid.has(attrId)) {
|
||||||
|
this.scrollAttrsByHid.set(hid, []);
|
||||||
|
}
|
||||||
|
this.scrollAttrsByHid.get(hid).push(key);
|
||||||
|
} else {
|
||||||
|
this.scrollAttrs.get(key).ce = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public calScrollAttrsToGlobal(attrId: number) {
|
||||||
|
let keys = this.scrollAttrsByAttrId.get(attrId)||[];
|
||||||
|
let result = 0;
|
||||||
|
for(let key of keys) {
|
||||||
|
let { ce } = this.scrollAttrs.get(key);
|
||||||
|
result += ce;
|
||||||
|
}
|
||||||
|
let globalAttr = this.getGlobalAttrById(attrId);
|
||||||
|
globalAttr.scroll = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public clearScrollAttr(hid: number) {
|
||||||
|
let scrollAttrs = this.getScrollAttrsByHid(hid);
|
||||||
|
for(let scrollAttr of scrollAttrs) {
|
||||||
|
scrollAttr.ce = 0;
|
||||||
|
this.calScrollAttrsToGlobal(scrollAttr.attrId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getScrollAttrsByHid(hid: number) {
|
||||||
|
let keys = this.scrollAttrsByHid.get(hid)||[];
|
||||||
|
return keys.map(key => this.scrollAttrs.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
public setHistoryCe(hid: number, ce: number) {
|
||||||
|
let historyCe = this.heroHistoryCe.get(hid)||0;
|
||||||
|
if(ce > historyCe) {
|
||||||
|
this.heroHistoryCe.set(hid, ce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public setResultHero(hero: HeroType) {
|
||||||
|
this.heroObjectId.set(hero.hid, hero._id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getRoleCeTable(roleId: string) {
|
||||||
|
let globalAttrs: AttrCell[] = [];
|
||||||
|
for(let [_, globalAttr] of this.globalAttrs) {
|
||||||
|
globalAttrs.push(globalAttr.getGlobalAttr());
|
||||||
|
}
|
||||||
|
let heroAttrs: HeroAttr[] = [];
|
||||||
|
for(let [hid, keys] of this.heroAttrsByHid) {
|
||||||
|
let lv = this.heroLv.get(hid);
|
||||||
|
let historyCe = this.heroHistoryCe.get(hid)||0;
|
||||||
|
let objectId = this.heroObjectId.get(hid);
|
||||||
|
let attrs: AttrCell[] = [];
|
||||||
|
for(let key of keys) {
|
||||||
|
let heroAttr = this.heroAttrs.get(key);
|
||||||
|
attrs.push(heroAttr.getHeroAttrCell());
|
||||||
|
}
|
||||||
|
heroAttrs.push({
|
||||||
|
hid, lv, attrs, historyCe, objectId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let equipAttrs: EquipAttr[] = [];
|
||||||
|
for(let [key2, { hid, eplaceId, keys }] of this.equipAttrsByHidAndEplace) {
|
||||||
|
let lv = this.equipLv.get(key2);
|
||||||
|
let attrs: AttrCell[] = [];
|
||||||
|
for(let key of keys) {
|
||||||
|
let equipAttr = this.equipAttrs.get(key);
|
||||||
|
attrs.push(equipAttr.getEquipAttrCell());
|
||||||
|
}
|
||||||
|
equipAttrs.push({
|
||||||
|
hid, eplaceId, lv, attrs
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let schoolAttrs: SchoolAttr[] = [];
|
||||||
|
for(let [_, { hid, attrId, ce }] of this.schoolAttrs) {
|
||||||
|
schoolAttrs.push({ hid, attrId, value: ce });
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
roleId, globalAttrs, heroAttrs, equipAttrs, schoolAttrs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
abstract class GlobalAllAttr {
|
abstract class GlobalAllAttr {
|
||||||
attrId: number;
|
attrId: number;
|
||||||
school: number = 0;
|
school: number = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user