战力:装备上的战力算法更新
This commit is contained in:
@@ -267,39 +267,76 @@ export class CalCe {
|
||||
|
||||
// 装备升品
|
||||
public setEquipQuality(hid: number, eplaceId: number, equipId: number, quality: number, qualityStage: number) {
|
||||
this.data.clearHeroAttrByHid(hid, 'equipQuality');
|
||||
this.data.clearEquipAttrByHidAndEplace(hid, eplaceId, 'equipQuality');
|
||||
let dicEquipQuality = getEquipQualityIdByEquipIdAndPoint(equipId, quality, qualityStage);
|
||||
let map = new Map<number, number>(); // attrId => val
|
||||
for(let { id, num } of dicEquipQuality.attribute) {
|
||||
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, id);
|
||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||
heroAttr.equipQuality += num - equipAttr.equipQuality;
|
||||
equipAttr.equipQuality = num;
|
||||
if(!map.has(id)) {
|
||||
map.set(id, num);
|
||||
} else {
|
||||
map.set(id, map.get(id) + num);
|
||||
}
|
||||
}
|
||||
for(let [id, val] of map) {
|
||||
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, id);
|
||||
equipAttr.equipQuality = val;
|
||||
}
|
||||
let equips = this.data.getEquipAttrsByHid(hid);
|
||||
for(let { hid, attrId, equipQuality } of equips) {
|
||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, attrId);
|
||||
heroAttr.equipQuality = equipQuality;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 装备强化
|
||||
public setEquipStrength(hid: number, eplaceId: number, equipId: number, lv: number) {
|
||||
this.data.clearHeroAttrByHid(hid, 'equipStrengthen');
|
||||
this.data.clearEquipAttrByHidAndEplace(hid, eplaceId, 'equipStrengthen');
|
||||
let dicEquipStrenth = getEquipStrenthenAttr(equipId, lv);
|
||||
let map = new Map<number, number>(); // attrId => val
|
||||
for(let { id, num } of dicEquipStrenth.attr) {
|
||||
if(!map.has(id)) {
|
||||
map.set(id, num);
|
||||
} else {
|
||||
map.set(id, map.get(id) + num);
|
||||
}
|
||||
}
|
||||
for(let [id, val] of map) {
|
||||
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, id);
|
||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||
heroAttr.equipStrength = num - equipAttr.equipStrengthen;
|
||||
equipAttr.equipStrengthen = num;
|
||||
equipAttr.equipStrengthen = val;
|
||||
}
|
||||
let equips = this.data.getEquipAttrsByHid(hid);
|
||||
for(let { hid, attrId, equipStrengthen } of equips) {
|
||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, attrId);
|
||||
heroAttr.equipStrength = equipStrengthen;
|
||||
}
|
||||
}
|
||||
|
||||
// 装备精炼(升星)
|
||||
public setEquipStar(hid: number, eplaceId: number, equipId: number, star: number, starStage: number) {
|
||||
this.data.clearHeroAttrByHid(hid, 'equipStar');
|
||||
this.data.clearEquipAttrByHidAndEplace(hid, eplaceId, 'equipStar');
|
||||
let dicEquipStar = getEquipStarAttrByStage(equipId, star, starStage);
|
||||
if(dicEquipStar) {
|
||||
let { mainAttr, subAttr } = dicEquipStar;
|
||||
let map = new Map<number, number>(); // attrId => val
|
||||
for(let { id, num } of [...mainAttr, ...subAttr]) {
|
||||
if(!map.has(id)) {
|
||||
map.set(id, num);
|
||||
} else {
|
||||
map.set(id, map.get(id) + num);
|
||||
}
|
||||
}
|
||||
for(let [id, val] of map) {
|
||||
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, id);
|
||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||
heroAttr.equipStar = num - equipAttr.equipStar;
|
||||
equipAttr.equipStar = num;
|
||||
equipAttr.equipStar = val;
|
||||
}
|
||||
let equips = this.data.getEquipAttrsByHid(hid);
|
||||
for(let { hid, attrId, equipStar } of equips) {
|
||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, attrId);
|
||||
heroAttr.equipStar = equipStar;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,6 +362,7 @@ export class CalCe {
|
||||
|
||||
// 天晶
|
||||
public setJewel(hid: number, eplaceId: number, stones: Stone[], jewel: JewelType) {
|
||||
this.data.clearHeroAttrByHid(hid, 'jewel');
|
||||
this.data.clearEquipAttrByHidAndEplace(hid, eplaceId, 'jewel');
|
||||
let seids: number[] = [];
|
||||
if(jewel) {
|
||||
@@ -335,12 +373,23 @@ export class CalCe {
|
||||
}
|
||||
}
|
||||
let { ratioUp } = this.addSeidEffect(seids);
|
||||
for(let [attrId, val] of ratioUp) {
|
||||
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, attrId);
|
||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, attrId);
|
||||
heroAttr.jewel += val - equipAttr.jewel;
|
||||
let map = new Map<number, number>(); // attrId => val
|
||||
for(let [id, num] of ratioUp) {
|
||||
if(!map.has(id)) {
|
||||
map.set(id, num);
|
||||
} else {
|
||||
map.set(id, map.get(id) + num);
|
||||
}
|
||||
}
|
||||
for(let [id, val] of map) {
|
||||
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, id);
|
||||
equipAttr.jewel = val;
|
||||
}
|
||||
let equips = this.data.getEquipAttrsByHid(hid);
|
||||
for(let { hid, attrId, jewel } of equips) {
|
||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, attrId);
|
||||
heroAttr.jewel = jewel;
|
||||
}
|
||||
}
|
||||
|
||||
public isRandSeUnLock(jewelId: number, randSeId: number, stones: Stone[]) {
|
||||
@@ -359,18 +408,30 @@ export class CalCe {
|
||||
|
||||
// 地玉
|
||||
public setStone(hid: number, eplaceId: number, stones: Stone[]) {
|
||||
this.data.clearHeroAttrByHid(hid, 'stone');
|
||||
this.data.clearEquipAttrByHidAndEplace(hid, eplaceId, 'stone');
|
||||
let map = new Map<number, number>(); // attrId => val
|
||||
for(let { stone } of stones) {
|
||||
let dicStone = gameData.stone.get(stone);
|
||||
if(dicStone) {
|
||||
for(let { id, num } of dicStone.attribute) {
|
||||
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, id);
|
||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, id);
|
||||
heroAttr.stone += num - equipAttr.stone;
|
||||
equipAttr.stone = num;
|
||||
if(!map.has(id)) {
|
||||
map.set(id, num);
|
||||
} else {
|
||||
map.set(id, map.get(id) + num);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(let [id, val] of map) {
|
||||
let equipAttr = this.data.getEquipAttrByHidAndId(hid, eplaceId, id);
|
||||
equipAttr.stone = val;
|
||||
}
|
||||
let equips = this.data.getEquipAttrsByHid(hid);
|
||||
for(let { hid, attrId, stone } of equips) {
|
||||
let heroAttr = this.data.getHeroAttrByHidAndId(hid, attrId);
|
||||
heroAttr.stone = stone;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -625,6 +686,11 @@ class CalCeData {
|
||||
return this.equipAttrs.get(key);
|
||||
}
|
||||
|
||||
public getEquipAttrsByHid(hid: number) {
|
||||
let keys = this.equipAttrsByHid.get(hid);
|
||||
return keys.map(key => this.equipAttrs.get(key));
|
||||
}
|
||||
|
||||
public getEquipAttrsByHidAndEplace(hid: number, eplaceId: number) {
|
||||
let key2 = `${hid}_${eplaceId}`;
|
||||
if(!this.equipAttrsByHidAndEplace.has(key2)) return []
|
||||
|
||||
Reference in New Issue
Block a user