战力:操作细节

This commit is contained in:
luying
2022-03-28 20:28:47 +08:00
parent 14b28921af
commit 1ccb66e3eb
7 changed files with 267 additions and 63 deletions
+138 -14
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 { ABI_STAGE, ABI_STAGE_TO_TYPE, ABI_TYPE_MAIN, LINEUP_NUM, SEID_TYPE, TALENT_RELATION_TYPE } from "../../consts";
import { Connect, HeroSkin, HeroType, HeroUpdate, Talent } from "../../db/Hero";
import { RoleUpdate, Teraph } from "../../db/Role";
import { AttrCell, EquipAttr, HeroAttr, RoleCeType, SchoolAttr } from "../../db/RoleCe";
import { TopHero } from "../../domain/dbGeneral";
import { AttributeCal } from "../../domain/roleField/attribute";
import { gameData, getHeroStarByQuality, getHeroWakeByQuality, getSchoolRateByStar, getTeraph } from "../../pubUtils/data";
import { gameData, getFriendShipById, getHeroStarByQuality, getHeroWakeByQuality, getJobByGradeAndClass, getSchoolRateByStar, getScollByStar, getTeraph } from "../../pubUtils/data";
import { DicRandomEffectPool } from "../../pubUtils/dictionary/DicRandomEffectPool";
import { DicSe } from "../../pubUtils/dictionary/DicSe";
import { addToMap, deepCopy } from "../../pubUtils/util";
@@ -25,6 +25,12 @@ export class CalCe {
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
scrollAttrs: Map<string, { hid: number, attrId: number, ce: number }> = new Map(); // hid + attr => ratio
scrollAttrsByAttrId: Map<number, string[]> = new Map(); // attrId => hid + attr
constructor(roleId: string) {
this.roleId = roleId;
}
private getGlobalAttrById(attrId: number) {
if(!this.globalAttrs.has(attrId)) {
@@ -41,7 +47,6 @@ 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);
@@ -56,7 +61,6 @@ export class CalCe {
}
this.heroAttrsByHid.get(hid).push(key);
}
console.log('$$$$$$$$ heroAttrsByHid', this.heroAttrsByHid)
return this.heroAttrs.get(key);
}
@@ -84,7 +88,7 @@ export class CalCe {
return this.equipAttrs.get(key);
}
private setSchoolRate(hid: number, attrId: number, value: number) {
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 });
@@ -108,6 +112,30 @@ export class CalCe {
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);
} else {
this.scrollAttrs.get(key).ce = value;
}
}
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() {
let ces = new Map<number, { id: number, val: number }[]>(); // hid => [{attrId, val}]
for(let [hid, keys] of this.heroAttrsByHid) {
@@ -201,9 +229,6 @@ export class CalCe {
}
public setRoleCe(roleCe: RoleCeType) {
console.log('&&&&&&&& setRoleCe', roleCe)
this.roleId = roleCe.roleId;
if(roleCe) {
for(let globalAttr of roleCe.globalAttrs) {
let obj = this.getGlobalAttrById(globalAttr.attrId);
@@ -226,11 +251,13 @@ export class CalCe {
}
}
for(let { hid, attrId, value } of roleCe.schoolAttrs) {
this.setSchoolRate(hid, attrId, value);
this.setSchoolAttrs(hid, attrId, value);
}
for(let { hid, attrId, value } of roleCe.scrollAttrs) {
this.setScrollAttrs(hid, attrId, value);
}
}
this.originCes = this.calHeroCe();
console.log('############ setRoleCe', this.originCes)
}
public setResultHero(hero: HeroType) {
@@ -300,13 +327,98 @@ export class CalCe {
// 职业基础
public setJob(hid: number, job: number, jobStage: number) {
const dicJob = gameData.job.get(job);
let lastJob = getJobByGradeAndClass(dicJob.job_class, dicJob.grade - 1);
let dicLastJob = lastJob? gameData.job.get(lastJob.jobid): null;
for(let i = 1; i <= dicJob.maxStage; i++) {
if(jobStage >= i) {
let { id, attr } = dicJob.ceAttr.get(i);
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
heroAttr.job = attr;
} else {
if(dicLastJob) {
let { id, attr } = dicLastJob.ceAttr.get(i);
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
heroAttr.job = attr;
}
}
}
for(let { id, val } of dicJob.baseSubAttr) {
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
heroAttr.base = val;
}
}
// 好感度
public setFavour(hid: number, favourLv: number, connections: Connect[]) {
let currentFiendShipLevel = gameData.friendShipLevelMap.get(favourLv);
let add = currentFiendShipLevel.add;
for (let {shipId, level} of connections) {
let dicHeroFriendShip = getFriendShipById(shipId, level);
for (let { id } of dicHeroFriendShip.attributes) {
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
heroAttr.favour = add;
}
}
}
// 羁绊
public setConnection(hid: number, shipId: number, connections: Connect[]) {
let connect = connections.find(cur => cur.shipId == shipId);
let level = connect?.level||0;
let currentShip = getFriendShipById(shipId, level);
if (currentShip) {
for (let { id, number: val } of currentShip.attributes) {
let heroAttr = this.getHeroAttrByHidAndId(hid, id);
heroAttr.connect = val;
}
}
}
// 第一次获得皮肤
public setAddSkin(skinId: number) {
let addSkin = gameData.fashion.get(skinId);
for (let { id, number: val } of addSkin.globalAttr) {
let globalAttr = this.getGlobalAttrById(id);
globalAttr.skin += val;
}
}
// 天赋
public setTalent(hid: number, skins: HeroSkin[]) {
let skin = skins.find(cur => cur.enable);
let seids = this.getTalentSeid(skin.talent);
let { ratioUp } = this.addSeidEffect(seids);
for(let [attrId, val] of ratioUp) {
let heroAttr = this.getHeroAttrByHidAndId(hid, attrId);
heroAttr.talent = val;
}
}
private getTalentSeid(talent: Talent[]) {
let seids = new Map<number, number[]>(); // id, seids
for(let { id, level } of talent) {
let dicHeroTalent = gameData.heroTalent.get(id);
for(let { type, ids} of dicHeroTalent.relation) {
if(type == TALENT_RELATION_TYPE.REPLACE) {
for(let id of ids) {
seids.delete(id);
}
}
}
for(let { lv, seid } of dicHeroTalent.level) {
if(level >= lv) {
if(!seids.has(id)) seids.set(id, []);
seids.get(id).push(seid);
}
}
}
let result: number[] = [];
for(let [_, ids] of seids) {
result.push(...ids);
}
return result;
}
// 爵位
@@ -340,18 +452,30 @@ export class CalCe {
}
}
// 名将谱
public setScroll(hid: number, scrollStar: number, scrollQuality: number, scrollColorStar: number) {
let dicHero =gameData.hero.get(hid);
let dicHeroScroll = getScollByStar(dicHero.quality, scrollStar, scrollQuality, scrollColorStar);
if(dicHeroScroll) {
for(let [attrId, value] of dicHeroScroll.ceAttr) {
this.setScrollAttrs(hid, attrId, value);
this.calScrollAttrsToGlobal(attrId);
}
}
}
// 百家学宫
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);
this.setSchoolAttrs(hid, attrId, isPutOn?dicSchoolRate.mainAttrAPerent: 0);
} else {
this.setSchoolRate(hid, attrId, isPutOn?dicSchoolRate.assiAttrAddValue: 0);
this.setSchoolAttrs(hid, attrId, isPutOn?dicSchoolRate.assiAttrAddValue: 0);
}
this.calSchoolAttrsToGlobal(attrId);
}
@@ -24,7 +24,7 @@ import { JewelModel, JewelType, jewelUpdate, RandSe } from '../../db/Jewel';
import { updateEplaces } from '../equipService';
import { combineItems, getCoinEventProperties, getGoldEventProperties, sortItems } from './util';
import { nowSeconds } from '../../pubUtils/timeUtil';
import { calculateCeWithHero } from '../playerCeService';
import { calculateCeWithHero, calculateWithRole } from '../playerCeService';
@@ -358,7 +358,7 @@ export async function addSkin(roleId: string, roleName: string, sid: string, ski
if(skin.hid && !hero) hero = await HeroModel.findByHidAndRole(skin.hid, roleId);
let condition = { type: FIGURE_UNLOCK_CONDITION.GET_SKIN, paramSkinId: skinId };
await unlockFigure(sid, roleId, [condition]); // 解锁头像
await calculateCeWithHero(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, hero.serverId, sid, skin.hid, {}, { skinId }); // 全局加成
await calculateWithRole(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, hero.serverId, sid, {}, { skinId }); // 全局加成
if (hero) { // 有武将的,将皮肤链接到武将上
let curSkin = hero.skins.find(cur => cur.id == skinId);