战力:修复创建武将bug

This commit is contained in:
luying
2022-03-28 17:44:14 +08:00
parent f35af70adc
commit 14b28921af
13 changed files with 379 additions and 393 deletions
+95 -50
View File
@@ -1,10 +1,10 @@
import { ABI_STAGE, ABI_STAGE_TO_TYPE, ABI_TYPE_MAIN, LINEUP_NUM, SEID_TYPE } from "../../consts";
import { HeroType, HeroUpdate } from "../../db/Hero";
import { RoleUpdate, Teraph } from "../../db/Role";
import { AttrCell, EquipAttr, HeroAttr, RoleCeType } from "../../db/RoleCe";
import { AttrCell, EquipAttr, HeroAttr, RoleCeType, SchoolAttr } from "../../db/RoleCe";
import { TopHero } from "../../domain/dbGeneral";
import { AttributeCal } from "../../domain/roleField/attribute";
import { gameData, getHeroStarByQuality, getHeroWakeByQuality, getTeraph } from "../../pubUtils/data";
import { gameData, getHeroStarByQuality, getHeroWakeByQuality, getSchoolRateByStar, getTeraph } from "../../pubUtils/data";
import { DicRandomEffectPool } from "../../pubUtils/dictionary/DicRandomEffectPool";
import { DicSe } from "../../pubUtils/dictionary/DicSe";
import { addToMap, deepCopy } from "../../pubUtils/util";
@@ -23,6 +23,8 @@ export class CalCe {
equipLv: Map<string, number> = new Map(); // hid+eplaceId => lv
originCes: 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
schoolAttrsByAttrId: Map<number, string[]> = new Map(); // attrId => hid + attr
private getGlobalAttrById(attrId: number) {
if(!this.globalAttrs.has(attrId)) {
@@ -39,6 +41,7 @@ export class CalCe {
private getHeroAttrByHidAndId(hid: number, attrId: number) {
let key = `${hid}_${attrId}`;
console.log('$$$$$$$$ getHeroAttrByHidAndId', hid, attrId)
if(!this.heroAttrs.has(key)) {
if(ABI_TYPE_MAIN.indexOf(attrId) != -1) {
let obj = new HeroMainAttr(hid, attrId);
@@ -53,6 +56,7 @@ export class CalCe {
}
this.heroAttrsByHid.get(hid).push(key);
}
console.log('$$$$$$$$ heroAttrsByHid', this.heroAttrsByHid)
return this.heroAttrs.get(key);
}
@@ -80,6 +84,30 @@ export class CalCe {
return this.equipAttrs.get(key);
}
private setSchoolRate(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);
} else {
this.schoolAttrs.get(key).ce = value;
}
}
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;
}
public calHeroCe() {
let ces = new Map<number, { id: number, val: number }[]>(); // hid => [{attrId, val}]
for(let [hid, keys] of this.heroAttrsByHid) {
@@ -98,17 +126,20 @@ export class CalCe {
ces.get(hid).push({ id: attrId, val });
}
}
let result = new Map<number, number>();
for(let [hid, arr] of ces) {
let obj = new AttributeCal();
obj.setByWarJson(arr);
let ce = obj.calCe();
this.resultCes.set(hid, ce);
result.set(hid, ce);
}
return this.resultCes;
return result;
}
public getCeInc() {
let ceResult = this.calHeroCe();
console.log('##### ceResult', ceResult, 'originCes', this.originCes)
let heroCe = new Map<number, { inc: number, origin: number, ce: number }>();
let roleInc = 0;
for(let [hid, ce] of ceResult) {
@@ -137,7 +168,7 @@ export class CalCe {
let heroAttrs: HeroAttr[] = [];
for(let [hid, keys] of this.heroAttrsByHid) {
let lv = this.heroLv.get(hid);
let historyCe = this.heroHistoryCe.get(hid);
let historyCe = this.heroHistoryCe.get(hid)||0;
let objectId = this.heroObjectId.get(hid);
let attrs: AttrCell[] = [];
for(let key of keys) {
@@ -160,12 +191,18 @@ export class CalCe {
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
roleId: this.roleId, globalAttrs, heroAttrs, equipAttrs, schoolAttrs
}
}
public setRoleCe(roleCe: RoleCeType) {
console.log('&&&&&&&& setRoleCe', roleCe)
this.roleId = roleCe.roleId;
if(roleCe) {
for(let globalAttr of roleCe.globalAttrs) {
@@ -188,23 +225,14 @@ export class CalCe {
obj.setByRoleCe(cell);
}
}
for(let { hid, attrId, value } of roleCe.schoolAttrs) {
this.setSchoolRate(hid, attrId, value);
}
}
this.originCes = this.calHeroCe();
console.log('############ setRoleCe', this.originCes)
}
public setInitHero(role: RoleUpdate, heroes: HeroUpdate[]) {
this.roleId = role.roleId;
for(let { hid, skinId, lv, quality, star, starStage, colorStar, colorStarStage, job, jobStage, } of heroes) {
this.setHeroBase(hid, skinId);
this.setHeroLv(hid, lv);
this.setHeroStar(hid, job, quality, star, starStage, colorStar, colorStarStage);
this.setJob(hid, job, jobStage);
}
this.setTitle(role.title);
this.setTeraph(role.teraphs);
}
public setResultHero(hero: HeroType) {
this.heroObjectId.set(hero.hid, hero._id);
}
@@ -267,7 +295,6 @@ export class CalCe {
let heroAttr = this.getHeroAttrByHidAndId(hid, attrId);
heroAttr.starUp = value;
};
}
// 职业基础
@@ -313,6 +340,23 @@ export class CalCe {
}
}
// 百家学宫
public setSchool(isPutOn: boolean, hid: number, schoolId: number, star: number, colorStar: number, quality: number) {
let dicSchool = gameData.school.get(schoolId);
let dicSchoolRate = getSchoolRateByStar(star, colorStar, quality);
console.log('#### setSchool', star, colorStar, quality, dicSchoolRate)
for (let attrId of dicSchool.upAttribute) {
if(ABI_TYPE_MAIN.includes(attrId)) { // 主属性
this.setSchoolRate(hid, attrId, isPutOn?dicSchoolRate.mainAttrAPerent: 0);
} else {
this.setSchoolRate(hid, attrId, isPutOn?dicSchoolRate.assiAttrAddValue: 0);
}
this.calSchoolAttrsToGlobal(attrId);
}
}
// 添加技能增加的被动属性
private addSeidEffect(seidList: number[]) {
let fixUp = new Map<number, number>(), ratioUp = new Map<number, number>();
@@ -383,9 +427,10 @@ abstract class GlobalAllAttr {
abstract getValues(): number[];
public getGlobalAttr() {
let values = this.getValues().map(cur => (cur||0));
return {
attrId: this.attrId,
values: this.getValues()
values
}
}
}
@@ -417,19 +462,19 @@ class GlobalMainAttr extends GlobalAllAttr {
for(let i = GLOBAL_MAIN_ATTR_INDEX.START; i < GLOBAL_MAIN_ATTR_INDEX.END; i++) {
switch(i) {
case GLOBAL_MAIN_ATTR_INDEX.SCHOOL:
if(this.school) values[i] = this.school;
values.push(this.school);
break;
case GLOBAL_MAIN_ATTR_INDEX.TERAPH:
if(this.teraph) values[i] = this.teraph;
values.push(this.teraph);
break;
case GLOBAL_MAIN_ATTR_INDEX.TITLE:
if(this.title) values[i] = this.title;
values.push(this.title);
break;
case GLOBAL_MAIN_ATTR_INDEX.SCROLL:
if(this.scroll) values[i] = this.scroll;
values.push(this.scroll);
break;
case GLOBAL_MAIN_ATTR_INDEX.SKIN:
if(this.skin) values[i] = this.skin;
values.push(this.skin);
break;
}
}
@@ -462,16 +507,16 @@ class GlobalSubAttr extends GlobalAllAttr {
for(let i = GLOBAL_MAIN_ATTR_INDEX.START; i < GLOBAL_MAIN_ATTR_INDEX.END; i++) {
switch(i) {
case GLOBAL_MAIN_ATTR_INDEX.SCHOOL:
if(this.school) values[i] = this.school;
values.push(this.school);
break;
case GLOBAL_MAIN_ATTR_INDEX.TERAPH:
if(this.teraph) values[i] = this.teraph;
values.push(this.teraph);
break;
case GLOBAL_MAIN_ATTR_INDEX.TITLE:
if(this.title) values[i] = this.title;
values.push(this.title);
break;
case GLOBAL_MAIN_ATTR_INDEX.SKIN:
if(this.skin) values[i] = this.skin;
values.push(this.skin);
break;
}
}
@@ -543,31 +588,31 @@ class HeroMainAttr extends HeroAllAttr {
for(let i = HERO_MAIN_ATTR_INDEX.START; i < HERO_MAIN_ATTR_INDEX.END; i++) {
switch(i) {
case HERO_MAIN_ATTR_INDEX.BASE:
if(this.base) values[i] = this.base;
values.push(this.base);
break;
case HERO_MAIN_ATTR_INDEX.JOB:
if(this.job) values[i] = this.job;
values.push(this.job);
break;
case HERO_MAIN_ATTR_INDEX.STAR_UP:
if(this.starUp) values[i] = this.starUp;
values.push(this.starUp);
break;
case HERO_MAIN_ATTR_INDEX.CONNECT:
if(this.connect) values[i] = this.connect;
values.push(this.connect);
break;
case HERO_MAIN_ATTR_INDEX.FAVOUR:
if(this.favour) values[i] = this.favour;
values.push(this.favour);
break;
case HERO_MAIN_ATTR_INDEX.TALENT:
if(this.talent) values[i] = this.talent;
values.push(this.talent);
break;
case HERO_MAIN_ATTR_INDEX.EQUIP:
if(this.equip) values[i] = this.equip;
values.push(this.equip);
break;
case HERO_MAIN_ATTR_INDEX.EQUIP_UP:
if(this.equipUp) values[i] = this.equipUp;
values.push(this.equipUp);
break;
case HERO_MAIN_ATTR_INDEX.EQUIP_STONE:
if(this.equipStone) values[i] = this.equipStone;
values.push(this.equipStone);
break;
}
}
@@ -599,16 +644,16 @@ class HeroSubAttr extends HeroAllAttr {
for(let i = HERO_SUB_ATTR_INDEX.START; i < HERO_SUB_ATTR_INDEX.END; i++) {
switch(i) {
case HERO_SUB_ATTR_INDEX.BASE:
if(this.base) values[i] = this.base;
values.push(this.base);
break;
case HERO_SUB_ATTR_INDEX.JOB:
if(this.job) values[i] = this.job;
values.push(this.job);
break;
case HERO_SUB_ATTR_INDEX.TALENT:
if(this.talent) values[i] = this.talent;
values.push(this.talent);
break;
case HERO_SUB_ATTR_INDEX.EQUIP:
if(this.equip) values[i] = this.equip;
values.push(this.equip);
break;
}
}
@@ -672,22 +717,22 @@ class EquipMainAttr extends EquipAllAttr {
for(let i = EQUIP_MAIN_ATTR_INDEX.START; i < EQUIP_MAIN_ATTR_INDEX.END; i++) {
switch(i) {
case EQUIP_MAIN_ATTR_INDEX.EQUIP_QUALITY:
if(this.equipQuality) values[i] = this.equipQuality;
values.push(this.equipQuality);
break;
case EQUIP_MAIN_ATTR_INDEX.EQUIP_STRENGTH:
if(this.equipStrengthen) values[i] = this.equipStrengthen;
values.push(this.equipStrengthen);
break;
case EQUIP_MAIN_ATTR_INDEX.EQUIP_STAR:
if(this.equipStar) values[i] = this.equipStar;
values.push(this.equipStar);
break;
case EQUIP_MAIN_ATTR_INDEX.EQUIP_SUIT:
if(this.equipSuit) values[i] = this.equipSuit;
values.push(this.equipSuit);
break;
case EQUIP_MAIN_ATTR_INDEX.JEWEL:
if(this.jewel) values[i] = this.jewel;
values.push(this.jewel);
break;
case EQUIP_MAIN_ATTR_INDEX.STONE:
if(this.stone) values[i] = this.stone;
values.push(this.stone);
break;
}
}
@@ -715,10 +760,10 @@ class EquipSubAttr extends EquipAllAttr {
for(let i = EQUIP_SUB_ATTR_INDEX.START; i < EQUIP_SUB_ATTR_INDEX.END; i++) {
switch(i) {
case EQUIP_SUB_ATTR_INDEX.EQUIP_STAR:
if(this.equipStar) values[i] = this.equipStar;
values.push(this.equipStar);
break;
case EQUIP_SUB_ATTR_INDEX.JEWEL:
if(this.jewel) values[i] = this.jewel;
values.push(this.jewel);
break;
}
}