战力:获取显示数据

This commit is contained in:
luying
2022-03-30 14:22:46 +08:00
parent ef731fc979
commit 9adbd08d3c
33 changed files with 205 additions and 1689 deletions
+29 -15
View File
@@ -2,7 +2,7 @@ import { ABI_STAGE, ABI_STAGE_TO_TYPE, ABI_TYPE_MAIN, LINEUP_NUM, SEID_TYPE, TAL
import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Stone, Talent } from "../../db/Hero";
import { JewelType } from "../../db/Jewel";
import { RoleUpdate, Teraph } from "../../db/Role";
import { AttrCell, EquipAttr, HeroAttr, RoleCeType, SchoolAttr } from "../../db/RoleCe";
import { AttrCell, Attribute, EquipAttr, HeroAttr, RoleCeType, SchoolAttr } from "../../db/RoleCe";
import { TopHero } from "../../domain/dbGeneral";
import { AttributeCal } from "../../domain/roleField/attribute";
import { gameData, getEquipQualityIdByEquipIdAndPoint, getEquipStarAttrByStage, getEquipStrenthenAttr, getEquipSuitByHero, getFriendShipById, getHeroStarByQuality, getHeroWakeByQuality, getJewelConditionByLvAndSeId, getJobByGradeAndClass, getSchoolRateByStar, getScollByStar, getTeraph } from "../../pubUtils/data";
@@ -14,6 +14,7 @@ export class CalCe {
originCes: Map<number, number> = new Map(); // hid => ce
resultCes: Map<number, number> = new Map(); // hid => ce
data: CalCeData;
attrsByHid: Map<number, { id: number, val: number, str: string }[]> = new Map();
constructor(roleId: string) {
this.roleId = roleId;
@@ -25,35 +26,43 @@ export class CalCe {
}
public getRoleCeTable() {
return this.data.getRoleCeTable(this.roleId);
let attributes: Attribute[] = [];
for(let [hid, attrs] of this.attrsByHid) {
attributes.push({ hid, attrs })
}
return this.data.getRoleCeTable(this.roleId, attributes);
}
public calHeroCe() {
let ces = new Map<number, { id: number, val: number }[]>(); // hid => [{attrId, val}]
let attrs = new Map<number, { id: number, val: number, str: string }[]>(); // hid => [{attrId, val}]
for(let [hid, keys] of this.data.heroAttrsByHid) {
let lv = this.data.heroLv.get(hid)||1;
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.data.heroAttrs.get(key);
let { school = 0, teraph = 0, title = 0, scroll = 0, skin = 0 } = this.data.getGlobalAttrById(attrId);
let val = 0;
if(ABI_TYPE_MAIN.indexOf(attrId)) {
// {[hp1 + lv * hp2 + hp3 * ( 1 + hp4 )] * (1 + hp5 ) + [( hp6 + hp7 ) * ( 1 + hp8 )] } * ( 1 + hp9 ) + hp10 + hp11
let val = 0, str = '';
if(ABI_TYPE_MAIN.indexOf(attrId) != -1) {
// {[hp1 + lv * hp2 + hp3 * ( 1 + hp4 )] * (1 + hp5 ) + [( hp6 + hp7 ) * ( 1 + hp8 )] } * ( 1 + hp9 ) + hp10 + hp11
val = ((mainBase + job + lv * starUp + connect * ( 1 + favour )) * ( 1 + school + talent ) + (( equipQuality + equipStrength ) * ( 1 + ( equipStar + equipSuit ))) ) * ( 1 + jewel ) + stone + teraph + title + scroll + skin;
str += `{[${mainBase}+${job}+${lv}*${starUp}+${connect}*(1+${favour})]*(1+${school}+${talent})+[(${equipQuality}+${equipStrength})*(1+${equipStar}+${equipSuit})]}*(1+${jewel})+${stone}+${teraph}+${title}+${scroll}+${skin}`;
} else {
// attr1 + attr2 + attr3 + attr4 + attr5 + attr6 + attr7 + attr8 + attr9
// attr1 + attr2 + attr3 + attr4 + attr5 + attr6 + attr7 + attr8 + attr9
val = subBase + job + talent + teraph + school + title + jewel + skin + equipStar;
str += `${subBase}+${job}+${talent}+${teraph}+${school}+${title}+${jewel}+${skin}+${equipStar}`;
}
if(!ces.has(hid)) ces.set(hid, []);
ces.get(hid).push({ id: attrId, val });
if(!attrs.has(hid)) attrs.set(hid, []);
attrs.get(hid).push({ id: attrId, val, str });
}
}
let result = new Map<number, number>();
for(let [hid, arr] of ces) {
for(let [hid, arr] of attrs) {
let obj = new AttributeCal();
obj.setLv(this.data.roleLv);
obj.setByWarJson(arr);
let ce = obj.calCe();
this.resultCes.set(hid, ce);
result.set(hid, ce);
this.attrsByHid.set(hid, arr);
}
return result;
}
@@ -102,6 +111,10 @@ export class CalCe {
return { topLineup, topLineupCe };
}
// 玩家等级
public setRoleLv(lv: number) {
this.data.roleLv = lv;
}
// 武将基础&成长
public setHeroBase(hid: number, skinId: number) {
@@ -475,6 +488,7 @@ export class CalCe {
}
class CalCeData {
roleLv: number = 1; // 玩家等级
// 全局
globalAttrs: Map<number, GlobalMainAttr|GlobalSubAttr> = new Map(); // attrId => GlobalAttr
// 武将
@@ -549,7 +563,7 @@ class CalCeData {
}
public getHeroAttrsByHid(hid: number) {
let keys = this.heroAttrsByHid.get(hid);
let keys = this.heroAttrsByHid.get(hid)||[];
return keys.map(key => this.heroAttrs.get(key));
}
@@ -573,7 +587,7 @@ class CalCeData {
}
public clearHeroAttrByHid(hid: number, field: string) {
let heroAttrs = this.getHeroAttrsByHid(hid);
let heroAttrs = this.getHeroAttrsByHid(hid)||[];
for(let heroAttr of heroAttrs) {
heroAttr[field] = 0;
}
@@ -656,7 +670,7 @@ class CalCeData {
}
public clearSchoolAttr(hid: number) {
let schoolAttrs = this.getSchoolAttrsByHid(hid);
let schoolAttrs = this.getSchoolAttrsByHid(hid)||[];
for(let schoolAttr of schoolAttrs) {
schoolAttr.ce = 0;
this.calSchoolAttrsToGlobal(schoolAttr.attrId);
@@ -715,7 +729,7 @@ class CalCeData {
this.heroObjectId.set(hero.hid, hero._id);
}
public getRoleCeTable(roleId: string) {
public getRoleCeTable(roleId: string, attributes: Attribute[]) {
let globalAttrs: AttrCell[] = [];
for(let [_, globalAttr] of this.globalAttrs) {
globalAttrs.push(globalAttr.getGlobalAttr());
@@ -751,7 +765,7 @@ class CalCeData {
schoolAttrs.push({ hid, attrId, value: ce });
}
return {
roleId, globalAttrs, heroAttrs, equipAttrs, schoolAttrs
roleLv: this.roleLv, roleId, globalAttrs, heroAttrs, equipAttrs, schoolAttrs, attributes
}
}
}