diff --git a/game-server/app/servers/role/handler/friendHandler.ts b/game-server/app/servers/role/handler/friendHandler.ts index 95428dcdb..0a99bbaaa 100644 --- a/game-server/app/servers/role/handler/friendHandler.ts +++ b/game-server/app/servers/role/handler/friendHandler.ts @@ -15,7 +15,6 @@ import { addItems, getFriendPointObject, handleCost } from "../../../services/ro import { RewardInter } from "../../../pubUtils/interface"; import { FriendPresentLogModel } from '../../../db/FriendPresentLog'; import { HeroModel, EPlace } from "../../../db/Hero"; -import { getPlayerMainAttribute } from "../../../services/pvpService"; import { FRIEND } from "../../../pubUtils/dicParam"; import { PlayerDetail, PlayerDetailHero } from "../../../domain/battleField/guild"; import { createPrivateMsg, pushMsgToRole, pushPresent } from "../../../services/chatService"; @@ -23,6 +22,7 @@ import { Rank } from "../../../services/rankService"; import { checkTaskWithRoles, checkTask } from "../../../services/task/taskService"; import { ComBattleTeamModel } from "../../../db/ComBattleTeam"; import { JewelModel } from "../../../db/Jewel"; +import { getHeroesAttributes } from "../../../services/playerCeService"; export default function (app: Application) { @@ -719,9 +719,12 @@ export class FriendHandler { let jewels = await JewelModel.findMapbyRoleAndHids(hisRoleId, hids); + let attrByHid = await getHeroesAttributes(hisRoleId); let list: HeroDetailParam[] = []; for (let hero of heroList) { - let attributes = getPlayerMainAttribute(hero.attr, role.attr); + let attr = attrByHid.get(hero.hid); + if(!attr) continue; + let attributes = attr.getMainAttributes(); let heroParam = new HeroDetailParam(hero); heroParam.setAttributes(attributes); heroParam.setJewels(jewels); diff --git a/game-server/app/servers/role/handler/heroHandler.ts b/game-server/app/servers/role/handler/heroHandler.ts index adfe95257..b2daaddf6 100644 --- a/game-server/app/servers/role/handler/heroHandler.ts +++ b/game-server/app/servers/role/handler/heroHandler.ts @@ -16,7 +16,6 @@ import { isNumber, pick } from 'underscore'; import { updateEplaces } from '../../../services/equipService'; import { addConsumeToHero, checkUnlockTalentCondition, initSkinTalent, updateSkinTalent } from '../../../services/roleService'; import { JewelModel, jewelUpdate } from '../../../db/Jewel'; -import { CalHeroCe } from '../../../services/role/_calCe'; import { HERO, REBORN } from '../../../pubUtils/dicParam'; import { createHero, createHeroes } from '../../../services/role/createHero'; import { CheckMeterial } from '../../../services/role/checkMaterial'; diff --git a/game-server/app/servers/role/handler/roleHandler.ts b/game-server/app/servers/role/handler/roleHandler.ts index f4a38ced1..33a543ed6 100644 --- a/game-server/app/servers/role/handler/roleHandler.ts +++ b/game-server/app/servers/role/handler/roleHandler.ts @@ -25,7 +25,7 @@ import Counter from '../../../db/Counter'; import { UserModel } from '../../../db/User'; import { checkFilterWords, reportTAEvent, treatRoleName } from '../../../services/sdkService'; import { createHeroes } from '../../../services/role/createHero'; -import { calculateCeWithHero, calculateWithRole } from '../../../services/playerCeService'; +import { calculateCeWithHero, calculateCeWithRole } from '../../../services/playerCeService'; export default function (app: Application) { new HandlerService(app, {}); @@ -50,7 +50,7 @@ export class RoleHandler { let checkName = await RoleModel.checkName(roleName, serverId); if (checkName) return resResult(STATUS.NAME_HAS_USED); - let { resultHeroes: heroes } = await createHeroes(roleId, roleName, sid, serverId, DEFAULT_HEROES.map(hid => ({hid, count: 1})), { roleName, hasInit: true, title: role.title, teraphs: role.teraphs }); + let { resultHeroes: heroes } = await createHeroes(roleId, roleName, sid, serverId, DEFAULT_HEROES.map(hid => ({hid, count: 1})), { roleName, hasInit: true, title: role.title, teraphs: role.teraphs, lv: DEFAULT_LV }); // role = await RoleModel.updateRoleInfo(roleId, { roleName, hasInit: true }); // 在算战力的时候一起更新 session.set('roleName', roleName); session.push('roleName', () => { }); @@ -95,7 +95,7 @@ export class RoleHandler { return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH); let update = { title: title + 1 } - let { curRole } = await calculateWithRole(HERO_SYSTEM_TYPE.TITLE, roleId, serverId, sid, update); + let { curRole } = await calculateCeWithRole(HERO_SYSTEM_TYPE.TITLE, roleId, serverId, sid, update); // 任务 await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TITLE, { oldTitle: title, title: update.title }); @@ -128,7 +128,7 @@ export class RoleHandler { if (!result) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH); - let { curRole } = await calculateWithRole(HERO_SYSTEM_TYPE.TERAPH, roleId, serverId, sid, { teraphs }, { teraphId: id }); + let { curRole } = await calculateCeWithRole(HERO_SYSTEM_TYPE.TERAPH, roleId, serverId, sid, { teraphs }, { teraphId: id }); // 任务 await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TERAPH_STRENGTHEN, { count }); @@ -171,7 +171,7 @@ export class RoleHandler { let result = await handleCost(roleId, sid, consumes, ITEM_CHANGE_REASON.TERAPH_QUALITY_UP); if (!result) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH); - let { curRole } = await calculateWithRole(HERO_SYSTEM_TYPE.TERAPH_UP, roleId, serverId, sid, { teraphs }, { teraphId: id }); + let { curRole } = await calculateCeWithRole(HERO_SYSTEM_TYPE.TERAPH_UP, roleId, serverId, sid, { teraphs }, { teraphId: id }); // 神像进阶,进阶一次就触发一次礼包弹框 await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TERAPH_STAGE_UP); @@ -228,7 +228,7 @@ export class RoleHandler { } await SchoolModel.updateBySclAndPos(roleId, schoolId, positionId, { hid, isOpen }) - await calculateWithRole(HERO_SYSTEM_TYPE.SCHOOL, roleId, serverId, sid, {}, { schoolId, hero: curHero, schoolHid: hid, preSchoolHid: preHid }); + await calculateCeWithRole(HERO_SYSTEM_TYPE.SCHOOL, roleId, serverId, sid, {}, { schoolId, hero: curHero, schoolHid: hid, preSchoolHid: preHid }); // 任务 await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_SCHOOL_PUT_HERO, { hid, preHid }); diff --git a/game-server/app/services/dungeonService.ts b/game-server/app/services/dungeonService.ts index cb3db4088..1d3541bc5 100644 --- a/game-server/app/services/dungeonService.ts +++ b/game-server/app/services/dungeonService.ts @@ -97,7 +97,7 @@ export function getDungeonBuyCountCost(num:number) { } export async function saveDungeonFirst(role: RoleType, warId: number, battleRecord: BattleRecordType) { - let userInfo = new RankParam(role, true); + let userInfo = new RankParam(role); let lineup = battleRecord.record.lineup; let dicWar = gameData.war.get(warId); await DungeonFirstModel.createDungeonFirst(role.serverId, dicWar.movePoint, warId, { diff --git a/game-server/app/services/equipService.ts b/game-server/app/services/equipService.ts index c094a1d9d..c8fb0059f 100644 --- a/game-server/app/services/equipService.ts +++ b/game-server/app/services/equipService.ts @@ -1,6 +1,6 @@ import { getRandEelm, } from '../pubUtils/util'; import { EPlace, Stone } from "../db/Hero"; -import { gameData, getRandEffectByGroupAndLevel } from "../pubUtils/data"; +import { gameData, getJewelConditionByLvAndSeId, getRandEffectByGroupAndLevel } from "../pubUtils/data"; import { JewelType, RandSe } from '../db/Jewel'; import { DicRandomEffectPool } from '../pubUtils/dictionary/DicRandomEffectPool'; import { getJewelRandSe } from './role/rewardService'; @@ -144,4 +144,18 @@ export function getJewelByEquip(oldEquip: EPlace, newEquip: EPlace, jewels: Jewe let oldJewel = jewels.find(cur => cur && cur.seqId == oldEquip.jewel); let newJewel = jewels.find(cur => cur && cur.seqId == newEquip.jewel); return { oldJewel, newJewel } +} + +export function isRandSeUnLock(jewelId: number, randSeId: number, stones: Stone[]) { + let dicJewel = gameData.jewel.get(jewelId); + let dicJewelCondition = getJewelConditionByLvAndSeId(dicJewel.lv, randSeId); + let stoneCnt = 0, stoneLv = 0; + for(let { stone } of stones) { + let dicStone = gameData.stone.get(stone); + if(dicStone) { + stoneCnt++; + stoneLv += dicStone.lv; + } + } + return stoneCnt >= dicJewelCondition.stoneCnt && stoneLv >= dicJewelCondition.stoneLv; } \ No newline at end of file diff --git a/game-server/app/services/expeditionService.ts b/game-server/app/services/expeditionService.ts index 923dce455..d2ca098d3 100644 --- a/game-server/app/services/expeditionService.ts +++ b/game-server/app/services/expeditionService.ts @@ -1,16 +1,16 @@ import { ExpeditionPointModel } from '../db/ExpeditionPoint'; -import Role, { CeAttrDataRole, RoleModel } from '../db/Role'; +import Role, { RoleModel } from '../db/Role'; import { shouldRefresh, getRandSingleEelm } from '../pubUtils/util'; import { LINEUP_NUM, EXPEDITION_WAR_RECORD_STATUS } from '../consts'; import { ExpeditionWarRecordModel } from '../db/ExpeditionWarRecord'; -import { CeAttrData, HeroType } from '../db/Hero'; +import { HeroType } from '../db/Hero'; import { gameData } from '../pubUtils/data'; import { getTimeFunD } from '../pubUtils/timeUtil'; import { ExpeditionRecordModel } from '../db/ExpeditionRecord'; import { Attribute, AttributeCal } from '../domain/roleField/attribute'; import * as dicParam from '../pubUtils/dicParam'; -import { getSumCe } from './playerCeService'; +import { getHeroesAttributes, getSumCe } from './playerCeService'; /** * 获取远征关卡列表 @@ -137,7 +137,7 @@ export async function matchPlayers(roleId: string, scale: number, range: number, let index = Math.floor(Math.random() * resultRange.length); let role = resultRange[index]; let {roleId, topLineup, topLineupCe } = role; - let { attr: roleAttrs } = role; + let attrByHid = await getHeroesAttributes(roleId); enemyObj.enemyFrom = 1; enemyObj.enemyId = roleId; @@ -150,9 +150,10 @@ export async function matchPlayers(roleId: string, scale: number, range: number, if(hero) { let h = hero.hero; if(h) { - let { star, lv, attr: heroAttrs, ce } = h; + let { star, lv, ce } = h; let dicHero = gameData.hero.get(hero.hid); - let { attribute } = getPlayerAttribute(lv, heroAttrs, roleAttrs); + let attr = attrByHid.get(hero.hid); + let attribute = attr.getAttributesToString(); let heroInfo = { actorId: hero.hid, skinId: h.skinId, @@ -281,32 +282,18 @@ export async function getResetRemainCnt(curTime: Date, roleId: string, role?: Ro let newAttribute = new AttributeCal(); newAttribute.setLv(lv); newAttribute.setByWarJson(subAttrs); // 次级属性 - let subAttrCe = newAttribute.calSubAttrCeAndReduce() * enemyCount; + let subAttrCe = newAttribute.calSubAttrCe() * enemyCount; if(ce * ratio > subAttrCe) { let mainAttrCe = ce * ratio - subAttrCe; newAttribute.setByWarJson(mainAttrs, mainAttrCe / enemyCe); - let attrArr = newAttribute.getReduceAttributesToString(); - let newCe = newAttribute.calCelAndReduce(); + let attrArr = newAttribute.getAttributesToString(); + let newCe = newAttribute.calCe(); return { attribute: attrArr, ce: newCe }; } else { newAttribute = new AttributeCal(); newAttribute.setByWarJson(mainAttrs, ce * ratio / enemyCe); - let attrArr = newAttribute.getReduceAttributesToString(); - let newCe = newAttribute.calCelAndReduce(); + let attrArr = newAttribute.getAttributesToString(); + let newCe = newAttribute.calCe(); return { attribute: attrArr, ce: newCe }; } -} - -/** - * @description 根据玩家数据获取到他的属性 - * @param ceAttr hero表的ceAttr - * @param globalCeAttr role表中的globalCeAttr - */ -export function getPlayerAttribute(lv: number, heroAttrs: CeAttrData[] = [], roleAttrs: CeAttrDataRole[] = []) { - let newAttribute = new AttributeCal(); - newAttribute.setLv(lv); - newAttribute.setByDbData(roleAttrs, heroAttrs); - let attribute = newAttribute.getReduceAttributesToString(); - let ce = newAttribute.calCelAndReduce(); - return { attribute, ce }; } \ No newline at end of file diff --git a/game-server/app/services/guildActivity/guildActivityService.ts b/game-server/app/services/guildActivity/guildActivityService.ts index a183d9e97..7fa0ffe6d 100644 --- a/game-server/app/services/guildActivity/guildActivityService.ts +++ b/game-server/app/services/guildActivity/guildActivityService.ts @@ -1,6 +1,5 @@ import { ServerlistModel } from "../../db/Serverlist"; import { RoleModel } from "../../db/Role"; -import { reduceCe } from "../../pubUtils/util"; import { GUILDACTIVITY } from "../../pubUtils/dicParam"; import { gameData, getGuildAuctionRewards, getCityActivityRewards } from "../../pubUtils/data"; import { getCurDay, nowSeconds, getTimeFun } from "../../pubUtils/timeUtil"; @@ -82,7 +81,7 @@ export async function setPreDayActiveData() { } } - await ServerRecordModel.updateData(server.id, { activePlayerCnt, activePlayerCe: reduceCe(activePlayerCe), activePlayers, activeGuilds }); + await ServerRecordModel.updateData(server.id, { activePlayerCnt, activePlayerCe, activePlayers, activeGuilds }); } return servers; } diff --git a/game-server/app/services/guildBossService.ts b/game-server/app/services/guildBossService.ts index 01d6bcf15..28f76c774 100644 --- a/game-server/app/services/guildBossService.ts +++ b/game-server/app/services/guildBossService.ts @@ -4,7 +4,7 @@ import { findIndex } from 'underscore'; import { sismemberAsync, smembersAsync, saddAsync, delAsync, getRoleOnlineInfo } from '../services/redisService'; import { pinus } from 'pinus'; import { STATUS } from '../consts/statusCode'; -import { reduceCe, resResult, shouldRefresh } from '../pubUtils/util'; +import { resResult, shouldRefresh } from '../pubUtils/util'; import { BattleRecordModel } from '../db/BattleRecord'; import { getArmyBossRank, gameData, getAuctionRewardByPoolId } from '../pubUtils/data'; import { sendMailToGuildByContent } from '../services/mailService'; @@ -197,8 +197,6 @@ export async function getBossHp(serverId: number, guildCode: string, dicBossBase activeCe += activePlayers[i].topLineupCe; } } - activeCe = reduceCe(activeCe); - console.log(`getBossHp activeCe ${activeCe}`); let B = activeCe/6/GUILDACTIVITY.GATEACTIVITY_ENEMYCE; console.log(`getBossHp B ${B}`); diff --git a/game-server/app/services/normalBattleService.ts b/game-server/app/services/normalBattleService.ts index e3936e72c..05ea3947a 100644 --- a/game-server/app/services/normalBattleService.ts +++ b/game-server/app/services/normalBattleService.ts @@ -4,7 +4,7 @@ import Role, { RoleModel, RoleType } from '../db/Role' import { getLvByExp, getExpByLv, gameData, getDicApByLv } from '../pubUtils/data'; import { updateUserInfo } from './redisService'; // import { switchOnFunc } from './funcSwitchService'; -import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS, KING_EXP_RATIO_TYPE, ITEM_CHANGE_REASON, POP_UP_SHOP_CONDITION_TYPE } from '../consts'; +import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS, KING_EXP_RATIO_TYPE, ITEM_CHANGE_REASON, POP_UP_SHOP_CONDITION_TYPE, HERO_SYSTEM_TYPE } from '../consts'; import { BackendSession, pinus } from 'pinus'; import { REDIS_KEY } from '../consts'; import { Rank } from './rankService'; @@ -16,6 +16,7 @@ import { LineupParam } from '../domain/rank'; import { WarStar } from '../domain/dbGeneral'; import { uniq } from 'underscore'; import { checkPopUpCondition } from './activity/popUpShopService'; +import { calculateCeWithRole } from './playerCeService'; export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kingExp: number = 0, session: BackendSession) { const serverId = session.get('serverId'); @@ -47,6 +48,7 @@ export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kin await checkTask(serverId, roleId, session.get('sid'), TASK_TYPE.ROLE_LV, { oldLv: lv, lv: newLv }); // 弹出礼包 await checkPopUpCondition(serverId, roleId, POP_UP_SHOP_CONDITION_TYPE.LV_TO, { oldLv: lv, newLv }) + await calculateCeWithRole(HERO_SYSTEM_TYPE.ROLE_LV, roleId, serverId, sid, { lv: newLv }); } let actordata: { lv: number, exp: number, getExp: number, mostExp: number }[] = []; diff --git a/game-server/app/services/playerCeService.ts b/game-server/app/services/playerCeService.ts index b7393e36e..2c821b042 100644 --- a/game-server/app/services/playerCeService.ts +++ b/game-server/app/services/playerCeService.ts @@ -5,7 +5,7 @@ import { pinus } from 'pinus'; import { STATUS } from '../consts/statusCode'; -import { resResult, reduceCe } from '../pubUtils/util'; +import { resResult } from '../pubUtils/util'; import { HeroModel, HeroType, HeroUpdate } from '../db/Hero'; import { RoleUpdate, RoleType, RoleModel } from '../db/Role'; @@ -19,6 +19,7 @@ import { PvpDefenseModel } from '../db/PvpDefense'; import { saveCeChangeLog } from '../pubUtils/logUtil'; import { JewelType } from '../db/Jewel'; import { SchoolModel } from '../db/School'; +import { AttributeCal } from '../domain/roleField/attribute'; interface Param { isInitRole?: boolean, @@ -46,7 +47,7 @@ export async function calculateCeWithHero(type: HERO_SYSTEM_TYPE, roleId: string return { heroes, curHero, curRole } } -export async function calculateWithRole(type: HERO_SYSTEM_TYPE, roleId: string, serverId: number, sid: string, roleUpdate: RoleUpdate, param: Param = {}) { +export async function calculateCeWithRole(type: HERO_SYSTEM_TYPE, roleId: string, serverId: number, sid: string, roleUpdate: RoleUpdate, param: Param = {}) { let { heroes, curRole } = await calculateCes(type, roleId, serverId, sid, new Map(), roleUpdate, {}, param); return { heroes, curRole }; } @@ -64,8 +65,10 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve calCe.setHeroStar(hid, job, quality, star, starStage, colorStar, colorStarStage); calCe.setJob(hid, job, jobStage); } + console.log('####### roleUpdate', param.isInitRole, roleUpdate) if(param.isInitRole) { - let { title, teraphs } = roleUpdate; + let { title, teraphs, lv } = roleUpdate; + calCe.setRoleLv(lv) calCe.setTitle(title); calCe.setTeraph(teraphs); } @@ -286,6 +289,12 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve } break; } + case HERO_SYSTEM_TYPE.ROLE_LV: // 31. 玩家等级 + { + let { lv } = roleUpdate; + calCe.setRoleLv(lv); + break; + } } let { heroCe, roleInc } = calCe.getCeInc(); // 计算战力,获得有变化的武将战力 let changeHids: number[] = []; @@ -346,7 +355,7 @@ async function updateRank(roleId: string, serverId: number, topLineupCe: number, // 最强阵容 let r = new Rank(REDIS_KEY.TOP_LINEUP_RANK, { serverId }); - await r.setRankWithRoleInfo(roleId, reduceCe(topLineupCe), 0, role); + await r.setRankWithRoleInfo(roleId, topLineupCe, 0, role); // 最强武将 for(let { hid, ce } of pushHeros) { @@ -359,7 +368,7 @@ async function updateRank(roleId: string, serverId: number, topLineupCe: number, // 总战力 let r3 = new Rank(REDIS_KEY.SUM_CE_RANK, { serverId }); - await r3.setRankWithRoleInfo(roleId, reduceCe(role.ce), 0, role); + await r3.setRankWithRoleInfo(roleId, role.ce, 0, role); // 更新最强五人阵容信息 let r5 = new Rank(REDIS_KEY.TOP_LINEUP_INFO, { serverId }); @@ -382,4 +391,16 @@ export async function getSumCe(roleId: string, num: number) { } } return ce; +} + +export async function getHeroesAttributes(roleId: string) { + let roleCe = await RoleCeModel.findByRoleId(roleId); + let attrByHid = new Map(); + for(let { hid, attrs } of roleCe.attributes||[]) { + let cal = new AttributeCal(); + cal.setLv(roleCe.roleLv); + cal.setByWarJson(attrs); + attrByHid.set(hid, cal); + } + return attrByHid; } \ No newline at end of file diff --git a/game-server/app/services/pvpService.ts b/game-server/app/services/pvpService.ts index e94976c74..4ab840d32 100644 --- a/game-server/app/services/pvpService.ts +++ b/game-server/app/services/pvpService.ts @@ -1,7 +1,7 @@ import { PvpDefenseModel, PvpDefenseType, pvpUpdateInter } from '../db/PvpDefense'; import { Defense, Attack, LineupCe, OppPlayer, HeroScore, HeroReward, OppPlayerReturn, AttackHero, DefenseHero } from '../domain/battleField/pvp'; -import { RoleType, CeAttrDataRole } from '../db/Role'; +import { RoleType } from '../db/Role'; import { PVP_HERO_POS, REDIS_KEY, PVP_CONST, COUNTER, TASK_TYPE, MAIL_TYPE, TA_EVENT } from '../consts'; import { dicPvpOpponent, DicPvpOpponent } from "../pubUtils/dictionary/DicPvpOpponent"; import { getRandSingleIndex, genCode, shouldRefresh, getChineseName, makeRobotId, robotIdComBack, getRandSingleEelm } from '../pubUtils/util'; @@ -11,7 +11,7 @@ import { PVP } from '../pubUtils/dicParam'; import { PVPConfigModel, PVPConfigType } from '../db/SystemConfig' import { nowSeconds, getTimeFun } from '../pubUtils/timeUtil'; import { HeroesRecord, PvpRecordPlayerInfo } from '../db/PvpRecord'; -import { HeroModel, CeAttrData, HeroType } from '../db/Hero'; +import { HeroModel, HeroType } from '../db/Hero'; import { AttributeCal } from '../domain/roleField/attribute'; import { PvpEnemies, PvpHeroInfo, PvpOtherHeroes } from '../domain/dbGeneral'; import { DicWarJson } from '../pubUtils/dictionary/DicWarJson'; @@ -27,6 +27,7 @@ import { sendMailByContent } from './mailService'; import { RoleRankInfo } from '../domain/rank'; import { reportTAEvent } from './sdkService'; import { getVipPvpChallengeMaxCnt } from './activity/monthlyTicketService'; +import { getHeroesAttributes } from './playerCeService'; /** * 返回对手三人信息 @@ -203,6 +204,7 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, roleId: string, pos let heroes = new Array(); let otherHeroes = new Array(); // 阵容外的所有武将信息 let defCe = 0; + let attrByHid = await getHeroesAttributes(role.roleId); for (let dbHero of dbHeroes) { let h = defenseHeroes.find(cur => cur.actorId == dbHero.hid); // 阵容里是否有这个武将 let hs = heroScores.find(cur => cur.hid == dbHero.hid); // 这个武将是否有这个得分 @@ -213,7 +215,10 @@ async function generPlayerOppHis(pvpdefense: PvpDefenseType, roleId: string, pos let heroInfo = new PvpHeroInfo(); heroInfo.setHeroInfo(dbHero); // heroInfo.setOutIndex(h.order); - let { attribute, ce } = getPlayerAttribute(dbHero.lv, dbHero.attr, role.attr); + let attr = attrByHid.get(h.actorId); + if(!attr) continue; + let attribute = attr.getAttributesToString(); + let ce = attr.calCe(); heroInfo.setAttribute(attribute); let enemy = new PvpEnemies(warJson, heroInfo, hs ? hs.score : 0, ce); enemy.setOutIndex(h.order); @@ -372,37 +377,11 @@ export function getRobotAttribute(hid: number, posRatio: number, score: number) let newAttribute = new AttributeCal(); newAttribute.setLv(difficultRatio.enemyLv); newAttribute.setByMap(dicHero.baseAbilityArr, difficultRatio.value / 10000 * posRatio); - let attrArr = newAttribute.getReduceAttributesToString(); - let newCe = newAttribute.calCelAndReduce(); + let attrArr = newAttribute.getAttributesToString(); + let newCe = newAttribute.calCe(); return { attribute: attrArr, ce: newCe, lv: difficultRatio.enemyLv }; } -/** - * @description 根据玩家数据获取到他的属性 - * @param ceAttr hero表的ceAttr - * @param globalCeAttr role表中的globalCeAttr - */ -export function getPlayerAttribute(lv: number, heroAttrs: CeAttrData[] = [], roleAttrs: CeAttrDataRole[] = []) { - let newAttribute = new AttributeCal(); - newAttribute.setLv(lv); - newAttribute.setByDbData(roleAttrs, heroAttrs); - let attribute = newAttribute.getReduceAttributesToString(); - let ce = newAttribute.calCelAndReduce(); - return { attribute, ce }; -} - -/** - * @description 根据玩家数据获取到他的主属性 - * @param ceAttr - * @param globalCeAttr - */ -export function getPlayerMainAttribute(heroAttrs: CeAttrData[], roleAttrs: CeAttrDataRole[]) { - let newAttribute = new AttributeCal(); - newAttribute.setByDbData(roleAttrs, heroAttrs); - let mainAttributes = newAttribute.getReduceMainAttributes(); - return mainAttributes; -} - // 获取我方战报记录 export async function generMyRecInfo(pvpDefense: PvpDefenseType, role: RoleType, isSuccess: boolean, pos: number, myHeroes: pvpEndParamInter[]) { let { attack, defense, heroScores, winStreakNum, hisWinStreakNum = 0, score, hisScore } = pvpDefense; diff --git a/game-server/app/services/rankService.ts b/game-server/app/services/rankService.ts index ad52d186e..2dcf54bb9 100644 --- a/game-server/app/services/rankService.ts +++ b/game-server/app/services/rankService.ts @@ -243,13 +243,13 @@ export class Rank { if (!role) { role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.RANK, true); } - let param = new RankParam(role, true); + let param = new RankParam(role); await this.setUserInfo(infoKey, { roleId }, param); } else if (infoKey == REDIS_KEY.GUILD_INFO) { if (!guild) { guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK) } - let param = new GuildRankParam(guild, true); + let param = new GuildRankParam(guild); await this.setUserInfo(infoKey, { guildCode }, param); } else if (infoKey == REDIS_KEY.TOP_LINEUP_INFO) { if (!role) { @@ -436,13 +436,13 @@ export class Rank { if (!role) { role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.RANK, true); } - param = new RoleRankInfo(role, true); + param = new RoleRankInfo(role); param.setInfo(0, { roleId }, score, time); } else { const info = await redisClient().hgetAsync(this.infoKey, roleId); const userInfo = JSON.parse(info); - param = new RoleRankInfo(userInfo, false); + param = new RoleRankInfo(userInfo); param.setInfo(0, { roleId }, score, time); } @@ -462,12 +462,12 @@ export class Rank { if (!guild) { guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK); } - param = new GuildRankInfo(guild, true); + param = new GuildRankInfo(guild); param.setInfo(0, { guildCode }, score, time); } else { const info = await redisClient().hgetAsync(this.infoKey, guildCode); const guildInfo = JSON.parse(info); - param = new GuildRankInfo(guildInfo, false); + param = new GuildRankInfo(guildInfo); param.setInfo(0, { guildCode }, score, time); } @@ -487,12 +487,12 @@ export class Rank { if (!guild) { guild = await GuildModel.findByCode(guildCode, this.keyName.serverId, GUILD_SELECT.RANK); } - param = new GuildRankInfo(guild, true); + param = new GuildRankInfo(guild); param.setInfo2(0, { guildCode }, score, time, active); } else { const info = await redisClient().hgetAsync(this.infoKey, guildCode); const guildInfo = JSON.parse(info); - param = new GuildRankInfo(guildInfo, false); + param = new GuildRankInfo(guildInfo); param.setInfo2(0, { guildCode }, score, time, active); } @@ -512,13 +512,13 @@ export class Rank { if (!role) { role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.RANK, true); } - param = new RoleRankInfo(role, true); + param = new RoleRankInfo(role); param.setInfo(0, { roleId, hid }, score, time); } else { const info = await redisClient().hgetAsync(this.infoKey, roleId); const userInfo = JSON.parse(info); - param = new RoleRankInfo(userInfo, false); + param = new RoleRankInfo(userInfo); param.setInfo(0, { roleId, hid }, score, time); } @@ -710,14 +710,14 @@ export class Rank { if (nowSeconds() - userInfo.updatedAt > 2 * 30 * 24 * 60 * 60) { continue; } - param = new RoleRankInfo(userInfo, false); + param = new RoleRankInfo(userInfo); param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]); } else if (this.infoKey == REDIS_KEY.GUILD_INFO) { if(this.key == REDIS_KEY.GUILD_LV_RANK) { - param = new GuildRankInfo(userInfo, false); + param = new GuildRankInfo(userInfo); param.setInfo2(Math.floor(ii / 2) + 1, myId, scores[0], scores[1], scores[2]); } else { - param = new GuildRankInfo(userInfo, false); + param = new GuildRankInfo(userInfo); param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]); } } @@ -759,14 +759,14 @@ export class Rank { if (nowSeconds() - userInfo.updatedAt > 2 * 30 * 24 * 60 * 60) { continue; } - param = new RoleRankInfo(userInfo, false); + param = new RoleRankInfo(userInfo); param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]); } else if (this.infoKey == REDIS_KEY.GUILD_INFO) { if(this.key == REDIS_KEY.GUILD_LV_RANK) { - param = new GuildRankInfo(userInfo, false); + param = new GuildRankInfo(userInfo); param.setInfo2(Math.floor(ii / 2) + 1, myId, scores[0], scores[1], scores[2]); } else { - param = new GuildRankInfo(userInfo, false); + param = new GuildRankInfo(userInfo); param.setInfo(Math.floor(ii / 2) + 1, myId, scores[0], scores[1]); } } @@ -1083,7 +1083,7 @@ export async function getGeneralRank(role: RoleType & { rankReceived: number[] } let r = new Rank(redisKey, { serverId }, false, 1); let ranks = await r.getRankByRange(); // if (ranks.length > 0) { - let param = new GeneralRankParam(id, ranks[0] || new RoleRankInfo({}, false), general, received); + let param = new GeneralRankParam(id, ranks[0] || new RoleRankInfo({}), general, received); result.push({...param, general}); } } diff --git a/game-server/app/services/role/_calCe.ts b/game-server/app/services/role/_calCe.ts deleted file mode 100644 index 4c9c69ce1..000000000 --- a/game-server/app/services/role/_calCe.ts +++ /dev/null @@ -1,249 +0,0 @@ -import { ABI_STAGE, ABI_STAGE_TO_TYPE, ABI_TYPE, ABI_TYPE_MAIN, HERO_CE_RATIO, HERO_SYSTEM_TYPE, SEID_TYPE } from "../../consts"; -import { HeroModel, HeroUpdate, CeAttrData } from "../../db/Hero"; -import { CeAttrDataRole, RoleUpdate } from "../../db/Role"; -import { gameData, getHeroStarByQuality, getHeroWakeByQuality } from "../../pubUtils/data"; -import { DicRandomEffectPool } from "../../pubUtils/dictionary/DicRandomEffectPool"; -import { DicSe } from "../../pubUtils/dictionary/DicSe"; -import { deepCopy } from "../../pubUtils/util"; -import { AttributeCal } from "../../domain/roleField/attribute"; - -export class CalRoleCe { - private roleInfo: RoleUpdate; - private roleCeWithAttr: Map = new Map(); - - constructor(roleInfo?: RoleUpdate) { - this.roleInfo = roleInfo; - } - - public cal(type: HERO_SYSTEM_TYPE) { - switch (type) { - case HERO_SYSTEM_TYPE.INIT: - this.calTitleAbility(); - this.calTeraphMainAttr(); - break; - } - return this.getRoleAttr(); - } - - private calTitleAbility() { - let { title } = this.roleInfo; - - let dicTitle = gameData.title.get(title)||{ mainAttrValue: new Map(), assiAttrValue: new Map() }; - - for (let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) { - if (dicTitle.mainAttrValue.has(i)) { - let fixUp = dicTitle.mainAttrValue.get(i) || 0; - this.getSingleAttrObj(i).updateAttr({ inc: { fixUp } }); - } - if (dicTitle.assiAttrValue.has(i)) { - let fixUp = dicTitle.assiAttrValue.get(i) || 0; - this.getSingleAttrObj(i).updateAttr({ inc: { fixUp } }); - } - } - } - - private calTeraphMainAttr(id?: number) { - let { teraphs = [] } = this.roleInfo; - for(let teraph of teraphs) { - if(id == undefined || teraph.id == id) { - for(let [attrId, val] of teraph.attr) { - this.getSingleAttrObj(attrId).updateAttr({ inc: { fixUp: val } }); - } - } - } - } - - // 获取一个CeAttrData对象,没有就新建 - public getSingleAttrObj(attrId: ABI_TYPE) { - if(!this.roleCeWithAttr.has(attrId)) { - let calSingleAttr = new CeAttrDataRole(attrId); - this.roleCeWithAttr.set(attrId, calSingleAttr); - } - return this.roleCeWithAttr.get(attrId); - } - - private getRoleAttr() { - let attr: CeAttrDataRole[] = []; - this.roleCeWithAttr.forEach(value => { - if(value.ratioUp > 0 || value.fixUp > 0) { - attr.push(value); - } - }); - return attr; - } -} - -export class CalHeroCe { - private hid: number; - private heroInfo: HeroUpdate; - private heroCeWithAttr: Map = new Map(); - - constructor(hid: number, heroInfo?: HeroUpdate) { - this.hid = hid; - if(heroInfo) this.heroInfo = heroInfo; - } - - public async setHeroInfoByHid(roleId: string) { - let hero = await HeroModel.findByHidAndRole(this.hid, roleId); - this.heroInfo = hero; - } - - // 主要接口 - public cal(type: HERO_SYSTEM_TYPE) { - switch (type) { - case HERO_SYSTEM_TYPE.INIT: - case HERO_SYSTEM_TYPE.REBIRTH: - this.calBaseAbility(); - this.calSkinSeid(); - this.calJobAbility(); - break; - } - return this.getHeroAttr() - } - - // 计算基础属性 - private calBaseAbility() { - let { star, starStage, quality, colorStar, colorStarStage, lv, skinId } = this.heroInfo; - const dicHero = gameData.hero.get(skinId); - if(!dicHero) { - console.error(`not found hero: ${skinId}`); - return; - } - - for (let stage = ABI_STAGE.START + 1; stage <= ABI_STAGE.END; stage++) { - let attrId = ABI_STAGE_TO_TYPE.get(stage); - - const isWake = colorStar > 0; // 是否觉醒,只要激活了觉醒,彩星就会 > 1 - // console.log('*isUpstar', isUpStar, originStar, star, originColorStar, colorStar) - - const dicStar = isWake ? getHeroWakeByQuality(dicHero.jobClass, dicHero.quality, colorStarStage < stage? colorStar - 1: colorStar) : getHeroStarByQuality(dicHero.jobClass, quality, starStage < stage? star - 1: star); // 星级表 - - let heroAttr = dicHero.baseAbilityArr.get(attrId); // 武将表hp等 - let heroUpAttr = dicHero.baseAbilityUpArr.get(attrId); // 武将表hp_up等 - let starUp = 0; // 星级成长 - if (!!dicStar && !!dicStar.ceAttr) { - starUp = dicStar.ceAttr.get(stage); - } - let base = heroAttr + lv * (heroUpAttr + starUp); - this.getSingleAttrObj(attrId).updateAttr({ set: { base } }); - }; - } - - // 计算职业属性 - private calJobAbility() { - let { job, jobStage } = this.heroInfo; - - const dicJob = gameData.job.get(job); - for(let i = 1; i <= dicJob.maxStage; i++) { - if(jobStage >= i) { - let { id, attr } = dicJob.ceAttr.get(i); - this.getSingleAttrObj(id).updateAttr({ inc: { fixUp: attr } }); - } - } - } - - - // 计算皮肤属性 - private calSkinSeid() { - let { skinId, star: _star, colorStar: _colorStar } = this.heroInfo; - - let seidList = new Map(); // type => seid - let dicHero = gameData.hero.get(skinId); - let { starSeidArr, colorStarSeidArr } = gameData.heroSkill.get(dicHero.skill); - for (let { star, value, type } of starSeidArr) { - if (_star >= star) { - seidList.set(type, value); - } - } - for (let { star, value, type } of colorStarSeidArr) { - if (_colorStar >= star) { - seidList.set(type, value); - } - } - let list: number[] = []; - for(let [_type, value] of seidList) list.push(value); - addSeidEffect.bind(this, list); - } - - public getHeroAttr() { - let attr: CeAttrData[] = []; - this.heroCeWithAttr.forEach(value => { - if(value.base > 0 || value.equipUp > 0 || value.fixUp > 0 || value.ratioUp > 0) { - attr.push(value); - } - }); - return attr; - } - - // 获取一个CeAttrData对象,没有就新建 - public getSingleAttrObj(attrId: ABI_TYPE) { - if(!this.heroCeWithAttr.has(attrId)) { - let calSingleAttr = new CeAttrData(attrId); - this.heroCeWithAttr.set(attrId, calSingleAttr); - } - return this.heroCeWithAttr.get(attrId); - } - - public getCalculatedCe(roleAttr: CeAttrDataRole[]) { - let attrCal = new AttributeCal(); - attrCal.setLv(this.heroInfo.lv); - attrCal.setByDbData(roleAttr, this.getHeroAttr()); - return attrCal.calCe(); - } -} - -// 添加技能增加的被动属性 -function addSeidEffect(this: CalRoleCe|CalHeroCe, seidList: number[]) { - // console.log('******addSeidEffect',this, seidList) - - // console.log('addSeidList', addSeidList.join()) - // console.log('removeSeidList', removeSeidList.join()) - let effectList: DicSe[] = []; // any: dic_zyz_se表内容 - - for (let ii = 0; ii < seidList.length; ii += 2) { - let seid = seidList[ii]; - let rand = seidList[ii + 1] || 0; - let dicSeid: DicSe | DicRandomEffectPool = gameData.se.get(seid); - if (!dicSeid) dicSeid = gameData.randomEffectPool.get(seid); - if (dicSeid && dicSeid.id > 0) { - addSeid(effectList, dicSeid.id, rand, dicSeid.gainValueArr) - } - } - - // console.log('effectList', JSON.stringify(effectList)); - for (let { type, gainValueArr: [ability, value] } of effectList) { - if (type == SEID_TYPE.TYPE101) { // 加值 - this.getSingleAttrObj(ability).updateAttr({ inc: { fixUp: value } }); - } else if (type == SEID_TYPE.TYPE103) { // 主属性加百分比 - if(ABI_TYPE_MAIN.includes(ability)) { - this.getSingleAttrObj(ability).updateAttr({ inc: {ratioUp: value / 1000} }); - } - } else if (type == SEID_TYPE.TYPE104) { // 次级属性加百分比 - if(!ABI_TYPE_MAIN.includes(ability)) { - this.getSingleAttrObj(ability).updateAttr({ inc: { fixUp: value * 100 * HERO_CE_RATIO } }); - } - } - - } - -} - -// 获取dic_zyz_se内容 -function addSeid(effectList: (DicSe | DicRandomEffectPool)[], seidId: number, rand: number, seidValue: number[] = []) { - let curSeid: DicSe | DicRandomEffectPool = gameData.se.get(seidId); - if (!curSeid) curSeid = gameData.randomEffectPool.get(seidId); - if (!curSeid) { console.log("seidId not found:" + seidId); return; } - if (!seidValue) seidValue = curSeid.gainValueArr; - - if (curSeid.type === SEID_TYPE.TYPE999) { - for (let i = 0; i < seidValue.length; i++) { - addSeid(effectList, seidValue[i], rand); - } - return; - } - let seid: DicSe | DicRandomEffectPool = deepCopy(curSeid); - if (curSeid.index > 0) { - seid.gainValueArr[curSeid.index - 1] = rand; - } - effectList.push(seid); -} \ No newline at end of file diff --git a/game-server/app/services/role/calCe.ts b/game-server/app/services/role/calCe.ts index e6ffb73ab..66fc87053 100644 --- a/game-server/app/services/role/calCe.ts +++ b/game-server/app/services/role/calCe.ts @@ -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 = new Map(); // hid => ce resultCes: Map = new Map(); // hid => ce data: CalCeData; + attrsByHid: Map = 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(); // hid => [{attrId, val}] + let attrs = new Map(); // 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(); - 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 = 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 } } } diff --git a/game-server/app/services/role/createHero.ts b/game-server/app/services/role/createHero.ts index 83b651f04..2a655bf70 100644 --- a/game-server/app/services/role/createHero.ts +++ b/game-server/app/services/role/createHero.ts @@ -3,14 +3,12 @@ import { SkinModel } from "../../db/Skin"; import { HeroModel, HeroSkin, HeroType, HeroUpdate } from "../../db/Hero"; import { SkinUpdate } from "../../db/Skin"; import { nowSeconds } from "../../pubUtils/timeUtil"; -import { getRandSingleEelm, reduceCe, resResult } from "../../pubUtils/util"; -import { CreateHeroParam, HeroParam, HeroShowParam } from "../../domain/roleField/hero"; +import { resResult } from "../../pubUtils/util"; +import { CreateHeroParam, HeroShowParam } from "../../domain/roleField/hero"; import { pinus } from "pinus"; -import { Rank } from "../rankService"; -import { checkTaskInCreateHero } from "../task/taskService"; import { ItemInter, RewardInter } from "../../pubUtils/interface"; import { transPiece } from "./util"; -import { addItems, combineFigureInfo, unlockFigure, } from "./rewardService"; +import { addItems, unlockFigure, } from "./rewardService"; import { CounterModel } from "../../db/Counter"; import { calculateCes } from "../playerCeService"; import { RoleUpdate } from "../../db/Role"; @@ -63,7 +61,7 @@ import { RoleUpdate } from "../../db/Role"; if(initRoleInfos) { roleUpdata = { ...initRoleInfos, ...roleUpdata } } - let { heroes } = await calculateCes(HERO_SYSTEM_TYPE.INIT, roleId, serverId, sid, heroInfos, roleUpdata, { heroNum: incHeroNum }); + let { heroes } = await calculateCes(HERO_SYSTEM_TYPE.INIT, roleId, serverId, sid, heroInfos, roleUpdata, { heroNum: incHeroNum }, { isInitRole: !!initRoleInfos }); for(let hero of heroes) { showHeroes.push(new HeroShowParam(hero)); resultHeroes.push(hero); diff --git a/game-server/app/services/role/rewardService.ts b/game-server/app/services/role/rewardService.ts index eef4db82c..73f6761b1 100644 --- a/game-server/app/services/role/rewardService.ts +++ b/game-server/app/services/role/rewardService.ts @@ -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, calculateWithRole } from '../playerCeService'; +import { calculateCeWithHero, calculateCeWithRole } 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 calculateWithRole(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, hero.serverId, sid, {}, { skinId }); // 全局加成 + await calculateCeWithRole(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, hero.serverId, sid, {}, { skinId }); // 全局加成 if (hero) { // 有武将的,将皮肤链接到武将上 let curSkin = hero.skins.find(cur => cur.id == skinId); diff --git a/game-server/app/services/task/taskObj.ts b/game-server/app/services/task/taskObj.ts index 4790e89d9..ea4346ccd 100644 --- a/game-server/app/services/task/taskObj.ts +++ b/game-server/app/services/task/taskObj.ts @@ -22,8 +22,7 @@ import { getZeroPoint } from "../../pubUtils/timeUtil"; import { resResult } from "../../pubUtils/util"; import { getActivities, getActivitiesByType, getActivityByServerId } from "../activity/activityService"; import { getRoleCreateTime, getRoleOnlineInfo, getServerCreateTime } from "../redisService"; -import { getEquipById, getJewelByEquip } from "../equipService"; -import { isRandSeUnLock } from "../../pubUtils/playerCe"; +import { getEquipById, getJewelByEquip, isRandSeUnLock } from "../equipService"; export class CheckTask { serverId: number; // 区id diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index 92c8b6635..93cfb27d2 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -306,7 +306,7 @@ export default class GMUsers extends Service { let list = heroes.map(cur => { let cal = new AttributeCal(); cal.setByDbData(roleMap.get(cur.roleId), cur.attr); - return {...cur, calculatedAttr: cal.getReduceAttributesToArr(), env: ctx.app.config.realEnv} + return {...cur, calculatedAttr: cal.getAttributesToArr(), env: ctx.app.config.realEnv} }) return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total }) diff --git a/shared/consts/constModules/heroConst.ts b/shared/consts/constModules/heroConst.ts index c1ff1c2b7..8ba9a7b40 100644 --- a/shared/consts/constModules/heroConst.ts +++ b/shared/consts/constModules/heroConst.ts @@ -31,6 +31,7 @@ export enum HERO_SYSTEM_TYPE { JEWEL_QUENCH = 28, // 天晶石淬炼 REBIRTH = 29, // 武将重生 TALENT = 30, // 天赋 + ROLE_LV = 31, // 玩家等级 }; // 武将上限 @@ -47,10 +48,8 @@ export const JOB_TYPE = { MAGIC: 2 } -// 武将战力放大系数 -export const HERO_CE_RATIO = 100; // 次级属性放大系数 -export const HERO_SUB_ATTR_RATIO = 1000 * 100; +export const HERO_SUB_ATTR_RATIO = 1000; export const HERO_INITIAL_QUALITY = { BLUE: 1, diff --git a/shared/consts/constModules/selectConst.ts b/shared/consts/constModules/selectConst.ts index 888077c9d..00b11c993 100644 --- a/shared/consts/constModules/selectConst.ts +++ b/shared/consts/constModules/selectConst.ts @@ -14,14 +14,14 @@ export enum ROLE_SELECT { COM_BATTLE = 'lv head frame spine heads frames spines topLineupCe', GET_HEADS = 'heads head frames frame spines spine', // 排行榜基础数据 - RANK = 'roleId roleName lv vLv head frame spine heads frames spines title guildName ce isReducedCe topLineup towerLv towerUpTime topLineupCe heroNum updatedAt heroNumUpdatedAt dungeonWarId dungeonUpdatedAt dungeonHeroes mainWarId mainUpdatedAt mainEliteWarId mainEliteUpdatedAt showLineup hasGuild', + RANK = 'roleId roleName lv vLv head frame spine heads frames spines title guildName ce topLineup towerLv towerUpTime topLineupCe heroNum updatedAt heroNumUpdatedAt dungeonWarId dungeonUpdatedAt dungeonHeroes mainWarId mainUpdatedAt mainEliteWarId mainEliteUpdatedAt showLineup hasGuild', }; export enum HERO_SELECT { ENTRY = '-_id -attr', - HERO_DETAIL = 'roleId roleName hid hName ce isReducedCe lv star colorStar quality job skins attr ePlace skinId', + HERO_DETAIL = 'roleId roleName hid hName ce lv star colorStar quality job skins attr ePlace skinId', // 排行榜中lineup字段 - RANK_LINEUP = 'seqId roleId hid star colorStar lv quality job ce isReducedCe updatedAt skinId' + RANK_LINEUP = 'seqId roleId hid star colorStar lv quality job ce updatedAt skinId' } export enum EQUIP_SELECT { diff --git a/shared/db/Guild.ts b/shared/db/Guild.ts index 740eb259f..fd469e018 100644 --- a/shared/db/Guild.ts +++ b/shared/db/Guild.ts @@ -3,7 +3,6 @@ import { index, getModelForClass, prop, DocumentType, Ref, mongoose } from '@typ import Role, { RoleType } from './Role'; import { GUILD_STRUCTURE, GUILD_STATUS, GUILD_PER_PAGE, GUILD_SELECT, REDIS_KEY, SHOP_REFRESH_TYPE } from '../consts'; import { getZeroPoint, getZeroPointD, nowSeconds } from '../pubUtils/timeUtil'; -import { reduceCe } from '../pubUtils/util'; import { gameData } from '../pubUtils/data'; import { SearchGuildParam } from '../domain/backEndField/search'; @@ -77,12 +76,9 @@ export default class Guild extends BaseModel { @prop({ required: true, default: new Date(), select: false }) refTimeDaily: Date; - @prop({ required: true, default: 0, get: (val:number) => reduceCe(val), set: (val: number) => val }) + @prop({ required: true, default: 0 }) guildCe: number; // 总战力 - @prop({ required: false, set: (val: boolean) => val, get: () => true }) - isReducedCe: boolean; // 如果战力没有缩过就会返回false,缩过了就会返回true - @prop({ required: true, type: String, default: [], select: false }) members: string[]; // 军团成员的roleId,用于增加战力的时候加入总战力 diff --git a/shared/db/Hero.ts b/shared/db/Hero.ts index 825eb8687..a2c8aaef7 100644 --- a/shared/db/Hero.ts +++ b/shared/db/Hero.ts @@ -1,56 +1,12 @@ import BaseModel from './BaseModel'; import { index, getModelForClass, prop, Ref, mongoose, DocumentType } from '@typegoose/typegoose'; // import Equip, { } from './Equip'; -import { CounterModel } from './Counter'; -import { COUNTER, DEFAULT_HERO_LV, HERO_CE_RATIO } from '../consts'; -import { reduceCe } from '../pubUtils/util'; +import { DEFAULT_HERO_LV } from '../consts'; import Skin, { SkinUpdate } from './Skin'; import { SearchHeroParam } from '../domain/backEndField/search'; import { Reward } from '../domain/battleField/pvp'; import { gameData, getHeroExpByLv, getHeroInitTalent } from '../pubUtils/data'; -type CeAttrUpdate = Partial; -export class CeAttrData { - @prop({ required: true }) - id: number = 0; - @prop({ required: true }) - base: number = 0; - @prop({ required: true }) - ratioUp: number = 0; - @prop({ required: true }) - fixUp: number = 0; - @prop({ required: true }) - equipUp: number = 0; - - constructor(id: number) { - this.id = id; - } - - public copyFromHero(data: CeAttrData) { - this.base = data.base; - this.ratioUp = data.ratioUp; - this.fixUp = data.fixUp; - this.equipUp = data.equipUp; - } - - public updateAttr(update: { inc?: CeAttrUpdate, set?: CeAttrUpdate }) { - if(update.inc) { - let { base, equipUp, fixUp, ratioUp } = update.inc; - if(base != undefined) this.base += base * HERO_CE_RATIO; - if(equipUp != undefined) this.equipUp += equipUp * HERO_CE_RATIO; - if(fixUp != undefined) this.fixUp += fixUp * HERO_CE_RATIO; - if(ratioUp != undefined) this.ratioUp += ratioUp; - } - if(update.set) { - let { base, equipUp, fixUp, ratioUp } = update.set; - if(base != undefined) this.base = base * HERO_CE_RATIO; - if(equipUp != undefined) this.equipUp = equipUp * HERO_CE_RATIO; - if(fixUp != undefined) this.fixUp = fixUp * HERO_CE_RATIO; - if(ratioUp != undefined) this.ratioUp = ratioUp; - } - } -} - /** * 英雄表 */ @@ -162,12 +118,8 @@ export default class Hero extends BaseModel { exp: number; // 经验值 @prop({ required: true, default: 1 }) lv: number; // 武将等级 - @prop({ required: true, default: 0, set: (val: number) => val, get: (val: number) => reduceCe(val) }) + @prop({ required: true, default: 0 }) ce: number; // 武将战力 - @prop({ required: false, set: (val: boolean) => val, get: () => true }) - isReducedCe: boolean; // 如果战力没有缩过就会返回false,缩过了就会返回true - @prop({ required: true, type: CeAttrData, default: [], _id: false }) - attr: CeAttrData[]; // 影响战力的属性 @prop({ required: true, default: 1 }) star: number; // 星级 diff --git a/shared/db/Role.ts b/shared/db/Role.ts index 02b515dd5..01f12b89f 100644 --- a/shared/db/Role.ts +++ b/shared/db/Role.ts @@ -1,42 +1,14 @@ -import { ROLE_TERAPH, ROLE_SELECT, ABI_TYPE, HERO_CE_RATIO, BLOCK_TYPE } from './../consts'; +import { ROLE_TERAPH, ROLE_SELECT, ABI_TYPE, BLOCK_TYPE } from './../consts'; import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType, Ref, mongoose } from '@typegoose/typegoose'; import User from './User'; -import { shouldRefresh, reduceCe } from '../pubUtils/util'; +import { shouldRefresh } from '../pubUtils/util'; import { nowSeconds, getTimeFunD } from '../pubUtils/timeUtil'; import { Figure } from '../domain/dbGeneral'; import * as dicParam from '../pubUtils/dicParam'; import Hero from './Hero'; import { SearchRoleParam } from '../domain/backEndField/search'; -type CeAttrUpdate = Partial; -// role表属性格式 -export class CeAttrDataRole { - @prop({ required: true }) - id: number = 0; - @prop({ required: true }) - ratioUp: number = 0; - @prop({ required: true }) - fixUp: number = 0; - - constructor(id: number) { - this.id = id; - } - - public updateAttr(update: { inc?: CeAttrUpdate, set?: CeAttrUpdate }) { - if(update.inc) { - let { fixUp, ratioUp } = update.inc; - if(fixUp != undefined) this.fixUp += fixUp * HERO_CE_RATIO; - if(ratioUp != undefined) this.ratioUp += ratioUp; - } - if(update.set) { - let { fixUp, ratioUp } = update.set; - if(fixUp != undefined) this.fixUp = fixUp * HERO_CE_RATIO; - if(ratioUp != undefined) this.ratioUp = ratioUp; - } - } -} - export class TopHero { @prop({ required: true }) hid: number; // 武将id @@ -185,16 +157,12 @@ export default class Role extends BaseModel { exp: number; // 经验值 @prop({ required: true, default: 1 }) lv: number; // 主公等级 - @prop({ required: true, default: 0, set: (val: number) => val, get: (val: number) => reduceCe(val) }) + @prop({ required: true, default: 0 }) ce: number; // 总战力 - @prop({ required: true, type: CeAttrDataRole, default: [], _id: false }) - attr: CeAttrDataRole[]; // 总战力 - @prop({ required: true, default: 0, set: (val: number) => val, get: (val: number) => reduceCe(val) }) + @prop({ required: true, default: 0 }) topLineupCe: number; // 最强x人战力 @prop({ required: true, type: TopHero, default: [], _id: false }) topLineup: Array; // 总战力 - @prop({ required: false, set: (val: boolean) => val, get: () => true }) - isReducedCe: boolean; // 如果战力没有缩过就会返回false,缩过了就会返回true @prop({ required: true, default: 100 }) gold: number; // 总金币 diff --git a/shared/db/RoleCe.ts b/shared/db/RoleCe.ts index 59f1b627d..f604d8a9f 100644 --- a/shared/db/RoleCe.ts +++ b/shared/db/RoleCe.ts @@ -45,7 +45,7 @@ export class SchoolAttr { } // 名将谱加成 -class ScrollAttr { +export class ScrollAttr { @prop({ required: true }) hid: number; // 武将id @prop({ required: true }) @@ -54,6 +54,24 @@ class ScrollAttr { value: number; // 百家学宫有多个武将,单独拎出来方便计算,计算之后结果存到globaAttrs的global1 } + +// 属性结果 +export class SingleAttribute { + @prop({ required: true }) + id: number; // 属性id + @prop({ required: true }) + val: number; // 值 + @prop({ required: true }) + str: string; // 公式 +} + +export class Attribute { + @prop({ required: true }) + hid: number; + @prop({ required: true, type: SingleAttribute, _id: false }) + attrs: SingleAttribute[]; // 属性id +} + /** * 属性表 */ @@ -66,6 +84,9 @@ export default class RoleCe extends BaseModel { @prop({ required: true }) roleId: string; // 角色 id + @prop({ required: true }) + roleLv: number; // 玩家等级 + @prop({ required: true, type: AttrCell, _id: false }) globalAttrs: AttrCell[] @@ -81,6 +102,9 @@ export default class RoleCe extends BaseModel { @prop({ required: true, type: ScrollAttr, _id: false }) scrollAttrs: ScrollAttr[]; + @prop({ required: true, type: Attribute, _id: false }) + attributes: Attribute[]; + public static async findByRoleId(roleId: string) { let result: RoleCeType = await RoleCeModel.findOne({ roleId }).lean(); return result; diff --git a/shared/db/User.ts b/shared/db/User.ts index 2677646f2..33fd4d0d1 100644 --- a/shared/db/User.ts +++ b/shared/db/User.ts @@ -65,10 +65,15 @@ export default class User extends BaseModel { guestTime: number; // 游客体验时间 // 防沉迷相关 - @prop({ required: false, default: false }) + @prop({ required: false, default: true }) hasAuthenticated: boolean; // 是否是已认证 - @prop({ required: false }) + @prop({ required: false, default: '1990-01-01' }) birthday: string; // 生日年月 + // 暂时不使用内部防沉迷 + // @prop({ required: false, default: false }) + // hasAuthenticated: boolean; // 是否是已认证 + // @prop({ required: false }) + // birthday: string; // 生日年月 @prop({ required: false }) pi: string; // 已通过实名认证用户唯一标识 @prop({ required: false, default: 0 }) diff --git a/shared/domain/battleField/dungeon.ts b/shared/domain/battleField/dungeon.ts index f63f9c656..e18955dd7 100644 --- a/shared/domain/battleField/dungeon.ts +++ b/shared/domain/battleField/dungeon.ts @@ -4,7 +4,7 @@ import { DungeonFirstType } from '../../db/DungeonFirst'; class DungeonUserInfo extends RankParam { roleId: string; constructor(roleId: string, userInfo: RankParam) { - super(userInfo, false); + super(userInfo); this.roleId = roleId; } } diff --git a/shared/domain/rank.ts b/shared/domain/rank.ts index 852b0012f..4a95ce2af 100644 --- a/shared/domain/rank.ts +++ b/shared/domain/rank.ts @@ -1,7 +1,6 @@ import { EXTERIOR } from "../pubUtils/dicParam"; import { WoodenHorse } from "./battleField/guildActivity"; import { RoleUpdate, RoleType } from "../db/Role"; -import { reduceCe } from "../pubUtils/util"; import { GuildUpdateParam } from "../db/Guild"; import { HeroUpdate, } from "../db/Hero"; import { getSeconds } from "../pubUtils/timeUtil"; @@ -38,7 +37,7 @@ export class RankParam { @prop({ required: true }) updatedAt?: number = 0; - constructor(role: RoleUpdate|RankParam, fromDb: boolean) { + constructor(role: RoleUpdate|RankParam) { if(role.roleName) this.roleName = role.roleName; if(role.lv) this.lv = role.lv; if(role.head) this.head = role.head; @@ -46,13 +45,7 @@ export class RankParam { if(role.spine) this.spine = role.spine; if(role.title) this.title = role.title; if(role.guildName) this.guildName = role.guildName||""; - if(role.ce) { - if(fromDb && !(role).isReducedCe) { - this.ce = reduceCe(role.ce); - } else { - this.ce = role.ce; - } - } + if(role.ce) this.ce = role.ce; if(role.updatedAt) { if(typeof role.updatedAt == 'number') { this.updatedAt = role.updatedAt; @@ -178,27 +171,14 @@ export class GuildRankParam { @prop({ required: true }) guildCe: number; - constructor(guild: GuildUpdateParam, fromDb: boolean) { + constructor(guild: GuildUpdateParam) { this.icon = guild.icon; this.name = guild.name; this.lv = guild.lv; let leader = guild.leader; let _leader = new GuildLeader(leader); this.leader = _leader; - // console.log('*****', guild.isReducedCe, guild.guildCe, reduceCe(guild.guildCe)) - if(guild.isReducedCe) { - this.guildCe = guild.guildCe; - } else { - this.guildCe = reduceCe(guild.guildCe); - } - - if(fromDb && !(guild).isReducedCe) { - this.guildCe = reduceCe(guild.guildCe); - } else { - this.guildCe = guild.guildCe; - } - - + this.guildCe = guild.guildCe; this.memberCnt = guild.memberCnt; } } diff --git a/shared/domain/roleField/attribute.ts b/shared/domain/roleField/attribute.ts index f7aa55022..9f7dd91bb 100644 --- a/shared/domain/roleField/attribute.ts +++ b/shared/domain/roleField/attribute.ts @@ -1,8 +1,6 @@ -import { HERO_CE_RATIO, getAtrrNameById, ABI_TYPE_MAIN } from '../../consts'; -import { CeAttrDataRole } from '../../db/Role'; -import { CeAttrData } from '../../db/Hero'; +import { getAtrrNameById, ABI_TYPE_MAIN } from '../../consts'; import { gameData } from '../../pubUtils/data'; -import { decodeArrayListStr, reduceCe } from '../../pubUtils/util'; +import { decodeArrayListStr } from '../../pubUtils/util'; import { ATTRIBUTE } from '../../pubUtils/dicParam'; export class AttributeCal { @@ -14,34 +12,12 @@ export class AttributeCal { this.lv = lv; } - public setByDbData(roleAttrs: CeAttrDataRole[], heroAttrs: CeAttrData[]) { - for(let { id, fixUp: roleFix, ratioUp: roleRatio } of roleAttrs) { - let heroAttr = heroAttrs.find(heroAttr => heroAttr.id == id); - if(heroAttr) { - let { fixUp: heroFix, base: heroBase, ratioUp: heroRatio, equipUp: heroEquip } = heroAttr; - let value = this.calAttrValue(roleFix, roleRatio, heroBase, heroFix, heroRatio, heroEquip); - this.attrs.set(id, value); - } else { - let value = this.calAttrValue(roleFix, roleRatio, 0, 0, 0, 0); - this.attrs.set(id, value); - } - } - - for(let { id, base: heroBase, fixUp: heroFix, ratioUp: heroRatio, equipUp: heroEquip } of heroAttrs) { - let roleAttr = roleAttrs.find(roleAttr => roleAttr.id == id); - if(!roleAttr) { - let value = this.calAttrValue(0, 0, heroBase, heroFix, heroRatio, heroEquip); - this.attrs.set(id, value); - } - } - } - public setByWarJson(attributes: {id: number, val: number}[], ratio: number = 1) { for(let {id, val} of attributes) { if(ABI_TYPE_MAIN.includes(id)) { - this.attrs.set(id, Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO)); + this.attrs.set(id, Math.floor(val * ratio)); } else { - this.attrs.set(id, Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO)); + this.attrs.set(id, Math.floor(val)); } } } @@ -49,58 +25,42 @@ export class AttributeCal { public setByMap( attributes: Map, ratio: number = 1 ) { for(let [id, val] of attributes) { if(ABI_TYPE_MAIN.includes(id)) { - this.attrs.set(id, Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO)); + this.attrs.set(id, Math.floor(val * ratio)); } else { - this.attrs.set(id, Math.floor(val * HERO_CE_RATIO * HERO_CE_RATIO)); + this.attrs.set(id, Math.floor(val)); } } } - private calAttrValue(roleFix: number = 0, roleRatio: number = 0, heroBase: number = 0, heroFix: number = 0, heroRatio: number = 0, heroEquip: number = 0) { - return (heroFix + heroEquip + roleFix) * HERO_CE_RATIO + heroBase * ( HERO_CE_RATIO + heroRatio + roleRatio ); - } - - // private getRealAttrToMap() { - // let newMap = new Map(); - // for(let [id, val] of this.attrs) { - // if(ABI_TYPE_MAIN.includes(id)) { // 主属性 - // newMap.set(id, val / HERO_CE_RATIO / HERO_CE_RATIO); - // } else { - // newMap.set(id, val / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO); - // } - // } - // return newMap; - // } - - private getReduceAttrMap() { + private getAttrMap() { let newMap = new Map(); for(let [id, val] of this.attrs) { - newMap.set(id, reduceCe(val)); + newMap.set(id, val); } return newMap } - public getReduceAttributes() { + public getAttributes() { let attrs = new Attribute(); - attrs.setByMap(this.getReduceAttrMap()); + attrs.setByMap(this.getAttrMap()); return attrs; } - public getReduceAttributesToArr() { + public getAttributesToArr() { let arr: {id: number, val: number}[] = []; - for(let [id, val] of this.getReduceAttrMap()) { + for(let [id, val] of this.getAttrMap()) { arr.push({ id, val }); } return arr; } - public getReduceAttributesToString() { - let arr = this.getReduceAttributesToArr(); + public getAttributesToString() { + let arr = this.getAttributesToArr(); return arr.map(cur => `${cur.id}&${cur.val}`).join('|'); } - public getReduceMainAttributes() { - let attribute = this.getReduceAttributes(); + public getMainAttributes() { + let attribute = this.getAttributes(); return attribute.getMainAttr(); } @@ -126,12 +86,8 @@ export class AttributeCal { return Math.floor(ce); } - public calSubAttrCeAndReduce() { - return Math.floor(this.calCe(3) / HERO_CE_RATIO / HERO_CE_RATIO); - } - - public calCelAndReduce() { - return Math.floor(this.calCe() / HERO_CE_RATIO / HERO_CE_RATIO); + public calSubAttrCe() { + return Math.floor(this.calCe(3)); } } diff --git a/shared/domain/roleField/hero.ts b/shared/domain/roleField/hero.ts index c083e6640..7ca654a48 100644 --- a/shared/domain/roleField/hero.ts +++ b/shared/domain/roleField/hero.ts @@ -1,7 +1,6 @@ import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Talent } from '../../db/Hero'; import { gameData } from '../../pubUtils/data'; -import { reduceCe } from '../../pubUtils/util'; export interface CreateHeroParam extends HeroUpdate { hid: number; count: number; @@ -73,11 +72,7 @@ export class HeroParam { this.hName = hero.hName; this.exp = hero.exp; this.lv = hero.lv; - if(hero.isReducedCe) { - this.ce = hero.ce; - } else { - this.ce = reduceCe(hero.ce); - } + this.ce = hero.ce; this.star = hero.star; this.starStage = hero.starStage; this.colorStar = hero.colorStar; diff --git a/shared/pubUtils/data.ts b/shared/pubUtils/data.ts index 45198af9d..019956af7 100644 --- a/shared/pubUtils/data.ts +++ b/shared/pubUtils/data.ts @@ -335,7 +335,7 @@ export function getBossHpByWarId(warId: number) { if (relation === 2) { let newAttr = new AttributeCal(); newAttr.setByWarJson(attribute, 1); - let attrJson = newAttr.getReduceAttributes(); + let attrJson = newAttr.getAttributes(); const hp = attrJson.hp || 0; if (hp > 0) { diff --git a/shared/pubUtils/dictionary/DicEquipStrengthAttr.ts b/shared/pubUtils/dictionary/DicEquipStrengthAttr.ts index cca1f991a..2fca2c74d 100644 --- a/shared/pubUtils/dictionary/DicEquipStrengthAttr.ts +++ b/shared/pubUtils/dictionary/DicEquipStrengthAttr.ts @@ -1,5 +1,5 @@ // 装备强化表 -import { readFileAndParse, parseGoodStr, decodeArrayListStr } from '../util' +import { readFileAndParse, decodeArrayListStr } from '../util' import { FILENAME } from '../../consts' export interface DicEquipStrengthAttr { diff --git a/shared/pubUtils/playerCe.ts b/shared/pubUtils/playerCe.ts deleted file mode 100644 index 2e6109a4a..000000000 --- a/shared/pubUtils/playerCe.ts +++ /dev/null @@ -1,1108 +0,0 @@ -// /** -// * 体力系统 -// */ - -import { HERO_SYSTEM_TYPE, ABI_TYPE, HERO_CE_RATIO, LINEUP_NUM, TALENT_RELATION_TYPE } from '../consts'; - -import { HeroModel, HeroType, HeroUpdate, CeAttrData, EPlace, Stone, Talent } from '../db/Hero'; -import { RoleModel, RoleType, RoleUpdate, CeAttrDataRole } from '../db/Role'; -import { AttributeCal } from '../domain/roleField/attribute'; -import { ABI_STAGE, SEID_TYPE } from '../consts'; -import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById, getSchoolRateByStar, getScollByStar, getTeraph, getEquipQualityIdByEquipIdAndPoint, getEquipSuitByHero, getEquipStarAttrByStage, getJewelConditionByLvAndSeId } from './data'; -import { DicSe } from './dictionary/DicSe'; -import { DicRandomEffectPool } from './dictionary/DicRandomEffectPool'; -import { SchoolModel } from '../db/School'; -import { ABI_TYPE_MAIN, ABI_JOB_STAGE, ABI_STAGE_TO_TYPE } from '../consts/constModules/abilityConst' -import { PvpDefenseModel } from '../db/PvpDefense'; -import { findIndex } from 'underscore'; -import { GuildModel } from '../db/Guild'; -import { DicJob } from './dictionary/DicJob'; -import { saveCeChangeLog } from './logUtil'; -import { JewelType } from '../db/Jewel'; -// import { type } from 'os'; - -// // 修改并下发战力 -// export async function calPlayerCeAndSave(type: number, roleId: string, originHero: HeroType, update: HeroUpdate, args?: Array, params?: any) { -// let role = await RoleModel.findByRoleId(roleId); - -// let { attr: roleAttrs = [], serverId } = role; - -// let heroAttrs = await calPlayerCe(originHero, update, type, args, params); // 根据操作计算attr的增加 - -// let newAttr = new AttributeCal(); -// newAttr.setLv(update.lv||originHero.lv); -// newAttr.setByDbData(roleAttrs, heroAttrs); -// let heroCe = newAttr.calCe(); // 计算最终战力 -// let incCe = heroCe - originHero.ce; - -// // 更新到武将 -// update.attr = heroAttrs; -// update.ce = heroCe; -// if (originHero.historyCe < heroCe) update.historyCe = heroCe; -// let hero = await HeroModel.updateHeroInfo(roleId, originHero.hid, update, null, true); // 更新武将 返回是战力缩过的 - -// // 更新到角色 -// let { topLineup, topLineupCe } = await calculatetopLineup(role, originHero.hid, heroCe, originHero._id); // 计算更新最强五人战力 -// role = await RoleModel.updateRoleInfo(roleId, { ce: role.ce + incCe, topLineup, topLineupCe }); - -// await PvpDefenseModel.updateCe(roleId, originHero.hid, reduceCe(incCe)); // 更新pvp防守阵战力 -// let guild = await GuildModel.updateCe(roleId, incCe); // 公会更新战力 - -// let pushHeros = new Array<{ hid: number, ce: number, incHeroCe: number }>(); -// pushHeros.push({ -// hid: originHero.hid, -// ce: reduceCe(heroCe), -// incHeroCe: reduceCe(incCe), -// }); - -// saveCeChangeLog(role, incCe, role.ce, type, [originHero.hid]); - -// return { pushHeros, role, topLineupCe, hero, guild, serverId } -// } - -// //全局属性加成 -// export async function reCalAllHeroCe(type: number, roleId: string, update: RoleUpdate, args?: Array, params?: any) { -// let role = await RoleModel.findByRoleId(roleId); -// let heros = await HeroModel.findByRole(roleId); - -// let roleAttrs = await reCalRoleAttr(type, heros, role, update, args, params); -// if(!roleAttrs) return {role, pushHeros: [], ce: role.ce, topLineupCe: role.topLineupCe, serverId: role.serverId, heros }; // 无加成 - -// let pushHeros = new Array<{ hid: number, ce: number, incHeroCe: number }>(); - -// let allIncCe = 0; -// let resultHeroes = []; -// for (let hero of heros) { -// let { attr: heroAttrs, lv } = hero; -// let newAttr = new AttributeCal(); -// newAttr.setLv(lv); -// newAttr.setByDbData(roleAttrs, heroAttrs); -// let heroCe = newAttr.calCe(); // 计算最终战力 -// if(heroCe != hero.ce) { -// let incHeroCe = heroCe - hero.ce; -// allIncCe += incHeroCe; -// pushHeros.push({ hid: hero.hid, ce: reduceCe(heroCe), incHeroCe: reduceCe(incHeroCe) }); -// let resultHero = await HeroModel.updateHeroInfo(roleId, hero.hid, { ce: heroCe }); -// resultHeroes.push(resultHero); -// await PvpDefenseModel.updateCe(roleId, hero.hid, reduceCe(incHeroCe)); // 更新pvp防守阵战力 -// } else { -// resultHeroes.push(hero); -// } - -// } -// let { topLineup, topLineupCe } = await calculatetopLineup(role); // 计算更新最强五人战力 - -// if(allIncCe != 0) { -// update.attr = roleAttrs; -// update.topLineup = topLineup; -// update.topLineupCe = topLineupCe; -// } - -// // console.log('************ roleAttr', update.attr) -// role = await RoleModel.incRoleInfo(roleId, { ce: allIncCe },update); - -// let guild = await GuildModel.updateCe(roleId, allIncCe); // 公会更新战力 - -// saveCeChangeLog(role, allIncCe, role.ce, type, args); -// return { role, pushHeros, ce: role.ce, topLineupCe: role.topLineupCe, guild, serverId: role.serverId, heros: resultHeroes } - -// } - -// // 计算武将全局战力 -// async function reCalRoleAttr(type: number, heros: Array, role: RoleType, update: RoleUpdate, args: Array, params: any) { -// let { attr: roleAttrs } = role; -// switch (type) { -// case HERO_SYSTEM_TYPE.ADD_SKIN: -// roleAttrs = calHeroAddSkin(role, args); -// break; -// case HERO_SYSTEM_TYPE.SCHOOL: -// roleAttrs = calSchoolAddAttr(role, heros, args[0], args[1], args[2]); -// break; -// case HERO_SYSTEM_TYPE.SCROLL: -// roleAttrs = calScrollAddAttr(role, heros, args[0]); -// break; -// case HERO_SYSTEM_TYPE.STAR: -// case HERO_SYSTEM_TYPE.COLORSTAR: -// case HERO_SYSTEM_TYPE.QUALITY: -// roleAttrs = await calSchoolStarIncAttr(role, heros, type, args[0], args[1]); -// break; -// case HERO_SYSTEM_TYPE.TITLE: -// roleAttrs = calTitle(role, update); -// break; -// case HERO_SYSTEM_TYPE.TERAPH: -// roleAttrs = calTeraphMainAttr(role, update, args[0]); -// break; -// case HERO_SYSTEM_TYPE.TERAPH_UP: -// roleAttrs = calTeraphAssistAttr(role, update, args[0]); -// break; -// case HERO_SYSTEM_TYPE.REBIRTH: -// roleAttrs = await calHeroRebirth(role, params.originHero, params.heroUpdate); -// break; -// } - -// return roleAttrs; -// } - -// // 计算单个武将战力 -// export async function calPlayerCe(hero: HeroType, update: HeroUpdate, type: number, args: Array = [], params) { -// let heroAttrs: CeAttrData[] = []; // {"hp": {"base": number, "fixUp": number, "ratioUp": number}} - -// let addSeidList = new Array(); -// let removeSeidList = new Array(); - -// switch (type) { -// case HERO_SYSTEM_TYPE.STAR: -// case HERO_SYSTEM_TYPE.LVUP: -// case HERO_SYSTEM_TYPE.COLORSTAR: -// case HERO_SYSTEM_TYPE.QUALITY: -// heroAttrs = calHeroStarIncAttr(hero, update, type, addSeidList, removeSeidList); // args: 升的星盘 -// break; -// case HERO_SYSTEM_TYPE.TRAIN: -// heroAttrs = calHeroTrainIncAttr(hero, update); -// break; -// case HERO_SYSTEM_TYPE.STAGEUP: -// // heroAttrs = calHeroJobStageUpIncAttr(hero, update, addSeidList, removeSeidList); -// break; -// case HERO_SYSTEM_TYPE.SKIN: -// heroAttrs = calHeroWearSkinIncAttr(hero, update, addSeidList, removeSeidList); -// break; -// case HERO_SYSTEM_TYPE.FAVOUR: -// heroAttrs = calHeroFavourUpIncAttr(hero, update); -// break; -// case HERO_SYSTEM_TYPE.CONNECT: -// heroAttrs = calHeroConectIncAttr(hero, update, args[0]); -// break; -// case HERO_SYSTEM_TYPE.COMPOSE_EQUIP: -// heroAttrs = calComposeEquipIncAttr(hero, update, args[0]); -// break; -// case HERO_SYSTEM_TYPE.EQUIP_STRENGTH: -// heroAttrs = calEquipStrengthIncAttr(hero, update, args); -// break; -// case HERO_SYSTEM_TYPE.EQUIP_QUALITY: -// heroAttrs = calEquipQualityIncAttr(hero, update, args); -// break; -// case HERO_SYSTEM_TYPE.EQUIP_STAR: -// heroAttrs = calEquipStarIncAttr(hero, update, args, addSeidList, removeSeidList); -// break; -// case HERO_SYSTEM_TYPE.EQUIP_JEWEL: -// heroAttrs = calEquipPutOnOrOffJewelIncAttr(hero, update, args, params, addSeidList, removeSeidList); -// break; -// case HERO_SYSTEM_TYPE.EQUIP_STONE: -// heroAttrs = calEquipPutOnOrOffStoneIncAttr(hero, update, args, params, addSeidList, removeSeidList); -// break; -// case HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE: -// case HERO_SYSTEM_TYPE.JEWEL_QUENCH: -// heroAttrs = calJewelResetRandSeIncAttr(hero, args, params, addSeidList, removeSeidList); -// break; -// case HERO_SYSTEM_TYPE.SCROLL: -// heroAttrs = calHeroCeScrollIncAttr(hero, update); -// break; -// case HERO_SYSTEM_TYPE.TALENT: -// heroAttrs = calHeroTalent(hero, update, addSeidList, removeSeidList); -// break; -// default: -// break; -// } -// addSeidEffect(heroAttrs, addSeidList, removeSeidList); // 处理加值 - -// return heroAttrs; -// } - - -// /** -// * 添加皮肤全局加成 -// * @param args -// * @param ceAttr -// */ -// function calHeroAddSkin(role: RoleType, skinIds: Array) { -// let { attr: roleAttrs } = role; - -// for (let id of skinIds) { -// let addSkin = gameData.fashion.get(id); -// for (let attr of addSkin.globalAttr) { -// let fixUp = attr.number * HERO_CE_RATIO; -// updateRoleAttr(roleAttrs, attr.id, { inc: { fixUp } }); -// } -// } -// role.attr = roleAttrs; -// return roleAttrs; -// } - -// /** -// * 升星觉醒升品等 -// * @param {HeroType} hero 武将更新前的值 -// * @param {HeroUpdate} update 更新的值 -// * @param {number} type 养成类型 -// * @param {number[]} addSeidList 用于更新被动 -// * @param {number[]} removeSeidList 用于更新被动 -// */ -// export function calHeroStarIncAttr(originHero: HeroType, update: HeroUpdate, type: number, addSeidList: Array, removeSeidList: Array) { -// let { star: originStar, starStage: originStarStage, quality: originQuality, colorStar: originColorStar, colorStarStage: originColorStarStage, attr: heroAttrs, skinId: originSkinId, lv: oldLv } = originHero; -// let { star = originStar, starStage = originStarStage, quality = originQuality, colorStar = originColorStar, colorStarStage = originColorStarStage, skinId = originSkinId, lv = oldLv } = update; - -// const dicHero = gameData.hero.get(skinId); - -// const isWake = colorStar > 0; // 是否觉醒,只要激活了觉醒,彩星就会 > 1 -// const isFirstWake = colorStar > 0 && originColorStar <= 0; // 是否是初次觉醒 -// const isUpStar = originStar != star || originColorStar != colorStar; // 是否有升星 -// // console.log('*isUpstar', isUpStar, originStar, star, originColorStar, colorStar) -// if(starStage == ABI_STAGE.START) star--; -// if(colorStarStage == ABI_STAGE.START) colorStar--; - -// const dicStar = isWake ? getHeroWakeByQuality(dicHero.jobClass, dicHero.quality, colorStar) : getHeroStarByQuality(dicHero.jobClass, quality, star); // 星级表 - - -// let stages = new Array(); // 需要升级的阶 -// if (type == HERO_SYSTEM_TYPE.LVUP) { -// stages = getAllAttrStage(); -// } else if (type == HERO_SYSTEM_TYPE.STAR) { -// let end = isUpStar? ABI_STAGE.END: starStage; -// if(end < originStarStage) { -// stages = getAllAttrStage(); -// } else { -// for(let i = originStarStage; i < end; i++) { -// stages.push(i + 1); -// } -// } -// } else if (type == HERO_SYSTEM_TYPE.QUALITY) { -// stages = getAllAttrStage(); -// } else if (type = HERO_SYSTEM_TYPE.COLORSTAR) { -// if (isFirstWake) { // 首次觉醒 -// stages = getAllAttrStage(); -// } else { -// let end = isUpStar? ABI_STAGE.END: colorStarStage; -// if(end < originColorStarStage) { -// stages = getAllAttrStage(); -// } else { -// for(let i = originColorStarStage; i < end; i++) { -// stages.push(i + 1); -// } -// } -// } -// } else if (type == HERO_SYSTEM_TYPE.SKIN) { -// stages = getAllAttrStage(); -// } -// for (let stage of stages) { - -// let targetAttrId = ABI_STAGE_TO_TYPE.get(stage); // 转换为18维的属性id -// let heroAttr = dicHero.baseAbilityArr.get(targetAttrId); // 武将表hp等 -// let heroUpAttr = dicHero.baseAbilityUpArr.get(targetAttrId); // 武将表hp_up等 -// let starUp = 0; // 星级成长 -// if (!!dicStar && !!dicStar.ceAttr) { -// starUp = dicStar.ceAttr.get(stage); -// } -// let newBase = (heroAttr + lv * (heroUpAttr + starUp)) * HERO_CE_RATIO; -// updateHeroAttr(heroAttrs, targetAttrId, { set: { base: newBase } }); -// } - -// let curSeidList = getSeidListOfFashion(skinId, star, colorStar); -// let preSeidList = getSeidListOfFashion(originSkinId, originStar, originColorStar); - -// curSeidList.forEach((seid, type) => { -// if (!preSeidList.has(type)) { -// addSeidList.push(seid, 0); -// } -// }); -// preSeidList.forEach((seid, type) => { -// if (!curSeidList.has(type)) { -// removeSeidList.push(seid, 0); -// } -// }); - -// originHero.attr = heroAttrs; -// return heroAttrs;//属性增量可以是多个 -// } - -// type updateCeAttr = Partial; -// function updateHeroAttr(heroAttrs: CeAttrData[], id: number, update: { inc?: updateCeAttr, set?: updateCeAttr }) { -// let index = heroAttrs.findIndex(cur => cur.id == id); -// let curAttr = heroAttrs[index]; -// if(!curAttr) { -// curAttr = new CeAttrData(id); -// heroAttrs.push(curAttr); -// index = heroAttrs.length - 1; -// } -// if(update.inc) { -// let { base, equipUp, fixUp, ratioUp } = update.inc; -// if(base != undefined) curAttr.base += base; -// if(equipUp != undefined) curAttr.equipUp += equipUp; -// if(fixUp != undefined) curAttr.fixUp += fixUp; -// if(ratioUp != undefined) curAttr.ratioUp += ratioUp; -// } -// if(update.set) { -// let { base, equipUp, fixUp, ratioUp } = update.set; -// if(base != undefined) curAttr.base = base; -// if(equipUp != undefined) curAttr.equipUp = equipUp; -// if(fixUp != undefined) curAttr.fixUp = fixUp; -// if(ratioUp != undefined) curAttr.ratioUp = ratioUp; -// } -// if(curAttr.base <= 0 && curAttr.equipUp <=0 && curAttr.fixUp <=0 && curAttr.ratioUp <= 0) { -// heroAttrs.splice(index, 1); -// } -// } - -// type updateCeAttrRole = Partial; -// function updateRoleAttr(roleAttrs: CeAttrDataRole[], id: number, update: { inc?: updateCeAttrRole, set?: updateCeAttrRole }) { -// let curAttr = roleAttrs.find(cur => cur.id == id); -// if(!curAttr) { -// curAttr = new CeAttrDataRole(id); -// roleAttrs.push(curAttr); -// } -// if(update.inc) { -// let { fixUp, ratioUp } = update.inc; -// if(fixUp) curAttr.fixUp = cal.add(curAttr.fixUp, fixUp); -// if(ratioUp) curAttr.ratioUp = cal.add(curAttr.ratioUp, ratioUp); -// } -// if(update.set) { -// let { fixUp, ratioUp } = update.set; -// if(fixUp) curAttr.fixUp = fixUp; -// if(ratioUp) curAttr.ratioUp = ratioUp; -// } -// } -// /** -// * 获取皮肤上的seid -// * @param skinId -// * @param originStar -// * @param originColorStar -// */ -// function getSeidListOfFashion(skinId: number, originStar: number, originColorStar: number) { -// let seidList = new Map(); // type => seid -// let dicHero = gameData.hero.get(skinId); - -// let { starSeidArr, colorStarSeidArr } = gameData.heroSkill.get(dicHero.skill); -// for (let { star, value, type } of starSeidArr) { -// if (originStar >= star) { -// seidList.set(type, value); -// } -// } -// for (let { star, value, type } of colorStarSeidArr) { -// if (originColorStar >= star) { -// seidList.set(type, value); -// } -// } -// return seidList -// } - -// /** -// * 兵种训练 -// * @param {HeroType} originHero 原始武将 -// * @param {HeroUpdate} update 更新的数据 -// */ -// export function calHeroTrainIncAttr(originHero: HeroType, update: HeroUpdate) { -// let { attr: heroAttrs, job: oldJob, jobStage: oldJobStage } = originHero; -// let { job = oldJob, jobStage = oldJobStage } = update; - -// let 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(oldJobStage < i && jobStage >= i) { -// let lastAttr = dicLastJob? dicLastJob.ceAttr.get(i).attr: 0; -// let targetAttrId = dicJob.ceAttr.get(i).id; -// let targetAttrValue = dicJob.ceAttr.get(i).attr; -// let inc = (targetAttrValue - lastAttr) * HERO_CE_RATIO; -// // console.log('*******', targetAttrId, targetAttrValue, lastAttr, inc ) -// updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp: inc } }); -// } -// } -// return heroAttrs; -// } - -// /** -// * 兵种进阶 -// * @param {HeroType} originHero 原始武将 -// * @param {HeroUpdate} update 更新内容 -// * @param {number[]} addSeidList 用于更新被动 -// * @param {number[]} removeSeidList 用于更新被动 -// */ -// // export function calHeroJobStageUpIncAttr(originHero: HeroType, update: HeroUpdate, addSeidList: Array, removeSeidList: Array) { -// // let { job: oldJob, attr: heroAttrs } = originHero; -// // let { job = oldJob } = update; - -// // let lastJob = gameData.job.get(oldJob); -// // let currentJob = gameData.job.get(job); -// // let lastSeids = lastJob?.seid||new Array(); -// // let curSeids = currentJob?.seid||new Array(); - -// // for (let seid of curSeids) { -// // let index = findIndex(lastSeids, seid); -// // if (index < 0) { -// // addSeidList.push(seid, 0); -// // } -// // } -// // for (let seid of lastSeids) { -// // let index = findIndex(curSeids, seid); -// // if (index < 0) { -// // removeSeidList.push(seid, 0); -// // } -// // } -// // return heroAttrs; -// // } - -// /** -// * 初始计算兵种属性 -// * @param {HeroType} originHero 原始武将 -// * @param {HeroUpdate} hero 更新后的武将 -// * @param {number[]} addSeidList 用于更新被动 -// * @param {number[]} removeSeidList 用于更新被动 -// */ -// export function calHeroJobAttr(originHero: HeroType, hero: HeroUpdate, addSeidList: Array, removeSeidList: Array) { -// let { attr: heroAttrs } = originHero; -// let currentJob = gameData.job.get(hero.job); -// let jobGradeAndClass = getJobByGradeAndClass(currentJob.job_class, currentJob.grade - 1); -// let lastJob: DicJob; -// if (!!jobGradeAndClass) { -// lastJob = gameData.job.get(jobGradeAndClass.jobid); -// } - -// for (let stage = ABI_JOB_STAGE.START; stage <= ABI_JOB_STAGE.END; stage++) { -// if(hero.jobStage >= stage) { -// let targetAttrId = currentJob.ceAttr.get(stage).id; -// let fixUp = currentJob.ceAttr.get(stage).attr * HERO_CE_RATIO; -// updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp }}) -// } else { -// if(lastJob) { -// let targetAttrId = lastJob.ceAttr.get(stage).id; -// let fixUp = lastJob.ceAttr.get(stage).attr * HERO_CE_RATIO; -// updateHeroAttr(heroAttrs, targetAttrId, { inc: { fixUp } }); -// } -// } -// }; - -// originHero.attr = heroAttrs; -// // heroAttrs = calHeroJobStageUpIncAttr(originHero, hero, addSeidList, removeSeidList); -// return heroAttrs; -// } - -// /** -// * 穿戴时装的单武将加成 -// * @param {HeroType} originHero 原始武将 -// * @param {number} wearSkinId 穿戴的皮肤 -// * @param {number} pullSkinId 脱下的皮肤 -// * @param {number[]} addSeidList 用于更新被动 -// * @param {number[]} removeSeidList 用于更新被动 -// * @param {boolean} isInit 是否是计算初始战力 -// */ -// export function calHeroWearSkinIncAttr(originHero: HeroType, update: HeroUpdate, addSeidList: number[], removeSeidList: number[]) { -// let { attr: heroAttrs, skinId: originSkinId } = originHero; -// let { skinId = originSkinId, ePlace: newEplace } = update; -// calHeroStarIncAttr(originHero, update, HERO_SYSTEM_TYPE.SKIN, addSeidList, removeSeidList); - -// let addSkin = gameData.fashionBySkinId.get(skinId); -// let delSkin = gameData.fashionBySkinId.get(originSkinId); - -// if (delSkin) { -// for (let attr of delSkin.actorAttr) { -// let fixUp = -1 * attr.number * HERO_CE_RATIO; -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp } }); -// } -// } -// for (let attr of addSkin.actorAttr) { -// let fixUp = attr.number * HERO_CE_RATIO; -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp } }); -// } -// originHero.attr = heroAttrs; - -// let eplaceIds = newEplace.map(cur => cur.id); -// calEquipStrengthIncAttr(originHero, update, eplaceIds); -// calEquipQualityIncAttr(originHero, update, eplaceIds); -// calEquipStarIncAttr(originHero, update, eplaceIds, addSeidList, removeSeidList); -// // 天赋点 -// calHeroTalent(originHero, update, addSeidList, removeSeidList); - -// return heroAttrs; -// } - -// /** -// * 羁绊解锁 -// * @param {HeroType} originHero 原始武将 -// * @param {HeroUpdate} update 更新数据 -// * @param {number} shipId 解锁的那个id -// */ -// export function calHeroConectIncAttr(originHero: HeroType, update: HeroUpdate, shipId: number) { -// let { connections: oldConnections = [], favourLv, attr: heroAttrs } = originHero; -// let { connections = oldConnections } = update; - -// let oldConnect = oldConnections.find(cur => cur.shipId == shipId); -// let connect = connections.find(cur => cur.shipId == shipId); - -// let oldLevel = oldConnect?.level||0; -// let level = connect?.level||0; - -// let fiendShipLevel = gameData.friendShipLevelMap.get(favourLv); -// let currentShip = getFriendShipById(shipId, level); -// if (currentShip) { -// for (let attr of currentShip.attributes) { -// let fixUp = attr.number * (HERO_CE_RATIO + fiendShipLevel.add); -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp } }); -// } -// } -// if (level > 1) { -// let lastShip = getFriendShipById(shipId, oldLevel); -// if (lastShip) { -// for (let attr of lastShip.attributes) { -// let fixUp = -1 * attr.number * (HERO_CE_RATIO + fiendShipLevel.add); -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp } }) -// } -// } -// } -// originHero.attr = heroAttrs; -// return heroAttrs; -// } - -// /** -// * 好感度升级,影响羁绊加成 -// * -// * @param {HeroType} originHero 原始武将数据 -// * @param {HeroUpdate} update 更新的数据 -// */ -// export function calHeroFavourUpIncAttr(originHero: HeroType, update: HeroUpdate) { -// let { favourLv: oldFavourLv, attr: heroAttrs } = originHero; -// let { favourLv = oldFavourLv } = update; - - -// let currentFiendShipLevel = gameData.friendShipLevelMap.get(favourLv); -// let difAdd = currentFiendShipLevel.add; -// if (oldFavourLv && oldFavourLv > 0) { // 减上一级好感 -// let lastFiendShipLevel = gameData.friendShipLevelMap.get(oldFavourLv); -// difAdd -= lastFiendShipLevel.add; -// } - -// for (let {shipId, level} of originHero.connections) { -// let dicHeroFriendShip = getFriendShipById(shipId, level); -// for (let attr of dicHeroFriendShip.attributes) { -// let fixUp = (attr.number + difAdd ) * HERO_CE_RATIO; -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp } }); -// } -// } -// originHero.attr = heroAttrs; -// return heroAttrs; -// } - -// export function calComposeEquipIncAttr(hero: HeroType, update: HeroUpdate, eplaceId: number) { -// let { attr: heroAttrs } = hero; -// let newEquip = update.ePlace.find(cur => cur.id == eplaceId); -// if(newEquip) { -// let dicEquip = gameData.equipById.get(newEquip.equipId); -// for(let attr of dicEquip.attribute) { -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: attr.num * HERO_CE_RATIO } }); -// } -// } -// return heroAttrs; -// } - -// export function calEquipStrengthIncAttr(hero: HeroType, update: HeroUpdate, eplaceIds: number[]) { -// let { attr: heroAttrs, ePlace: oldEplace } = hero; -// let { ePlace: newEplace } = update; -// for(let eplaceId of eplaceIds) { -// let oldEquip = oldEplace.find(cur => cur.id == eplaceId); -// let newEquip = newEplace.find(cur => cur.id == eplaceId); -// if(newEquip && oldEquip) { -// let dicOldEquip = gameData.equipById.get(oldEquip.equipId); -// let dicNewEquip = gameData.equipById.get(newEquip.equipId); -// for(let attr of dicOldEquip.attributeUp) { -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: -1 * attr.num * oldEquip.lv * HERO_CE_RATIO } }); -// } -// for(let attr of dicNewEquip.attributeUp) { -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: attr.num * newEquip.lv * HERO_CE_RATIO } }); -// } -// } -// } -// hero.attr = heroAttrs; -// return heroAttrs -// } - -// export function calEquipQualityIncAttr(hero: HeroType, update: HeroUpdate, eplaceIds: number[]) { -// let { attr: heroAttrs, ePlace: oldEplace } = hero; -// let { ePlace: newEplace } = update; -// for(let eplaceId of eplaceIds) { -// let oldEquip = oldEplace.find(cur => cur.id == eplaceId); -// let newEquip = newEplace.find(cur => cur.id == eplaceId); -// if(newEquip && oldEquip) { -// let dicOldEquipQuality = getEquipQualityIdByEquipIdAndPoint(oldEquip.equipId, oldEquip.quality, oldEquip.qualityStage); -// let dicNewEquipQuality = getEquipQualityIdByEquipIdAndPoint(newEquip.equipId, newEquip.quality, newEquip.qualityStage); -// for(let attr of dicOldEquipQuality.attribute) { -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: -1 * attr.num * HERO_CE_RATIO } }); -// } -// for(let attr of dicNewEquipQuality.attribute) { -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: attr.num * HERO_CE_RATIO } }); -// } -// } -// } -// hero.attr = heroAttrs; -// return heroAttrs -// } - - -// export function calEquipStarIncAttr(hero: HeroType, update: HeroUpdate, eplaceIds: number[], addSeidList: number[], removeSeidList: number[]) { -// // 升星本身的属性加成 -// let { hid, attr: heroAttrs, ePlace: oldEplace } = hero; -// let { ePlace: newEplace } = update; -// for(let eplaceId of eplaceIds) { -// let oldEquip = oldEplace.find(cur => cur.id == eplaceId); -// let newEquip = newEplace.find(cur => cur.id == eplaceId); -// if(newEquip && oldEquip) { -// let { mainAttr: oldMainAttr, subAttr: oldSubAttr } = getEquipStarAttrByStage(oldEquip.equipId, oldEquip.star, oldEquip.starStage); -// let { mainAttr: newMainAttr, subAttr: newSubAttr } = getEquipStarAttrByStage(newEquip.equipId, newEquip.star, newEquip.starStage); -// // 主属性 -// for(let attr of oldMainAttr) { -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: -1 * attr.num * HERO_CE_RATIO } }); -// } -// for(let attr of newMainAttr) { -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: attr.num * HERO_CE_RATIO } }); -// } -// for(let attr of oldSubAttr) { -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: -1 * attr.num * HERO_CE_RATIO } }); -// } -// for(let attr of newSubAttr) { -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: attr.num * HERO_CE_RATIO } }); -// } -// } -// } - -// // 套装属性 -// calEquipSuitIncAttr(hid, oldEplace, newEplace, addSeidList, removeSeidList); -// hero.attr = heroAttrs; -// return heroAttrs; -// } - -// function calEquipSuitIncAttr(hid: number, oldEplace: EPlace[], newEplace: EPlace[], addSeidList: number[], removeSeidList: number[]) { -// let dicEquipSuit = getEquipSuitByHero(hid); -// let oldSuitStars: number[] = [], newSuitStars: number[] = []; -// for(let equipId of dicEquipSuit.equips) { -// let oldEquip = oldEplace.find(cur => cur.equipId == equipId); -// oldSuitStars.push(oldEquip? oldEquip.star: 0); -// let newEquip = newEplace.find(cur => cur.equipId == equipId); -// newSuitStars.push(newEquip? newEquip.star: 0); -// } -// let oldStar = Math.min(...oldSuitStars); -// let newStar = Math.min(...newSuitStars); - -// for(let { star, seid } of dicEquipSuit.effect) { -// if(oldStar >= star) removeSeidList.push(seid); -// if(newStar >= star) addSeidList.push(seid, 0); -// } -// } - -// export function calEquipPutOnOrOffJewelIncAttr(hero: HeroType, update: HeroUpdate, eplaceIds: number[], params: { oldJewel: JewelType, newJewel: JewelType }, addSeidList: number[], removeSeidList: number[]) { -// let { attr: heroAttrs, ePlace: oldEplace } = hero; -// let { ePlace: newEplace } = update; -// for(let eplaceId of eplaceIds) { -// let oldEquip = oldEplace.find(cur => cur.id == eplaceId); -// setRandSeToSeidList(params.oldJewel, oldEquip, removeSeidList); -// let newEquip = newEplace.find(cur => cur.id == eplaceId); -// setRandSeToSeidList(params.newJewel, newEquip, addSeidList); -// } - -// return heroAttrs; -// } - -// function setRandSeToSeidList(jewel: JewelType, equip: EPlace, list: number[]) { -// if(equip && jewel) { -// for(let { id, seid, rand } of jewel.randSe) { -// if(isRandSeUnLock(jewel.id, id, equip.stones)) { -// list.push(seid, rand); -// } -// } -// } -// } - -export function isRandSeUnLock(jewelId: number, randSeId: number, stones: Stone[]) { - let dicJewel = gameData.jewel.get(jewelId); - let dicJewelCondition = getJewelConditionByLvAndSeId(dicJewel.lv, randSeId); - let stoneCnt = 0, stoneLv = 0; - for(let { stone } of stones) { - let dicStone = gameData.stone.get(stone); - if(dicStone) { - stoneCnt++; - stoneLv += dicStone.lv; - } - } - return stoneCnt >= dicJewelCondition.stoneCnt && stoneLv >= dicJewelCondition.stoneLv; -} - -// export function calEquipPutOnOrOffStoneIncAttr(hero: HeroType, update: HeroUpdate, eplaceIds: number[], params: { jewel: JewelType }, addSeidList: number[], removeSeidList: number[]) { -// let { attr: heroAttrs, ePlace: oldEplace } = hero; -// let { ePlace: newEplace } = update; -// for(let eplaceId of eplaceIds) { -// let oldEquip = oldEplace.find(cur => cur.id == eplaceId); -// updateHeroAttrOfStone(heroAttrs, oldEquip, -1); -// setRandSeToSeidList(params.jewel, oldEquip, removeSeidList); -// let newEquip = newEplace.find(cur => cur.id == eplaceId); -// updateHeroAttrOfStone(heroAttrs, newEquip, 1); -// setRandSeToSeidList(params.jewel, newEquip, addSeidList); // 地玉石阶数变化可能导致属性词条解锁变化 -// } -// return heroAttrs; -// } - -// function updateHeroAttrOfStone(heroAttrs: CeAttrData[], equip: EPlace, ratio: number) { -// for(let { stone } of equip.stones) { -// let dicStone = gameData.stone.get(stone); -// if(dicStone) { -// for(let attr of dicStone.attribute) { -// updateHeroAttr(heroAttrs, attr.id, { inc: { fixUp: ratio * attr.num * HERO_CE_RATIO } }); -// } -// } -// } - -// } - -// export function calJewelResetRandSeIncAttr(hero: HeroType, eplaceIds: number[], params: { oldJewel: JewelType, newJewel: JewelType }, addSeidList: number[], removeSeidList: number[]) { -// let { attr: heroAttrs, ePlace } = hero; -// for(let eplaceId of eplaceIds) { -// let equip = ePlace.find(cur => cur.id == eplaceId); -// setRandSeToSeidList(params.oldJewel, equip, removeSeidList); -// setRandSeToSeidList(params.newJewel, equip, addSeidList); -// } -// return heroAttrs; -// } - -// // 添加技能增加的被动属性 -// function addSeidEffect(heroAttrs: CeAttrData[], addSeidList: Array, removeSeidList: Array) { - -// // console.log('addSeidList', addSeidList.join()) -// // console.log('removeSeidList', removeSeidList.join()) -// let otiginalSeidList = [ -// { list: addSeidList, multi: 1 }, -// { list: removeSeidList, multi: -1 } -// ]; -// for (let { list, multi } of otiginalSeidList) { -// let effectList = new Array(); // any: dic_zyz_se表内容 - -// for (let ii = 0; ii < list.length; ii += 2) { -// let seid = list[ii]; -// let rand = list[ii + 1] || 0; -// let dicSeid: DicSe | DicRandomEffectPool = gameData.se.get(seid); -// if (!dicSeid) dicSeid = gameData.randomEffectPool.get(seid); -// if (dicSeid && dicSeid.id > 0) { -// addSeid(effectList, dicSeid.id, rand, dicSeid.gainValueArr) -// } -// } - -// // console.log('effectList', JSON.stringify(effectList)); -// for (let { type, gainValueArr: [ability, value] } of effectList) { -// if (type == SEID_TYPE.TYPE101) { // 加值 -// updateHeroAttr(heroAttrs, ability, { inc: {fixUp: value * multi * HERO_CE_RATIO} }); -// } else if (type == SEID_TYPE.TYPE103) { // 主属性加百分比 -// if(ABI_TYPE_MAIN.includes(ability)) { -// updateHeroAttr(heroAttrs, ability, { inc: {ratioUp: value / 1000 * multi} }); -// } -// } else if (type == SEID_TYPE.TYPE104) { // 次级属性加百分比 -// if(!ABI_TYPE_MAIN.includes(ability)) { -// updateHeroAttr(heroAttrs, ability, { inc: {fixUp: value * 100 * multi * HERO_CE_RATIO } }); -// } -// } -// } -// } - -// } - -// // 获取dic_zyz_se内容 -// function addSeid(effectList: Array, seidId: number, rand: number, seidValue = new Array()) { -// let curSeid: DicSe | DicRandomEffectPool = gameData.se.get(seidId); -// if (!curSeid) curSeid = gameData.randomEffectPool.get(seidId); -// if (!curSeid) { console.log("seidId not found:" + seidId); return; } -// if (!seidValue) seidValue = curSeid.gainValueArr; - -// if (curSeid.type === SEID_TYPE.TYPE999) { -// for (let i = 0; i < seidValue.length; i++) { -// addSeid(effectList, seidValue[i], rand); -// } -// return; -// } -// let seid: DicSe | DicRandomEffectPool = deepCopy(curSeid); -// if (curSeid.index > 0) { -// seid.gainValueArr[curSeid.index - 1] = rand; -// } -// effectList.push(seid); -// } - -// /** -// * 全局加成,百家学宫 -// * @param role 角色 -// * @param heros 所有武将 -// * @param schoolId 学宫学派 -// * @param hid 换上的武将 -// * @param preHid 撤下的武将 -// */ -// function calSchoolAddAttr(role: RoleType, heros: HeroType[], schoolId: number, hid: number, preHid: number) { -// let { attr: roleAttrs } = role; -// let school = gameData.school.get(schoolId); -// if (!school) return null; - -// let preHero = heros.find(cur => cur.hid == preHid); -// let curHero = heros.find(cur => cur.hid == hid); - -// let defaultPercent = { mainAttrAPerent: 0, assiAttrAddValue: 0 }; -// let preRate = preHero ? getSchoolRateByStar(preHero.star, preHero.colorStar, preHero.quality) : defaultPercent; -// let curRate = curHero ? getSchoolRateByStar(curHero.star, curHero.colorStar, curHero.quality) : defaultPercent; - -// for (let attrId of school.upAttribute) { -// if(ABI_TYPE_MAIN.includes(attrId)) { // 主属性 -// let ratioUp = curRate.mainAttrAPerent - preRate.mainAttrAPerent; -// updateRoleAttr(roleAttrs, attrId, { inc: { ratioUp } }); -// } else { -// let fixUp = (curRate.assiAttrAddValue - preRate.assiAttrAddValue) * HERO_CE_RATIO; -// updateRoleAttr(roleAttrs, attrId, { inc: { fixUp } }); -// } -// } - -// return roleAttrs; -// } - -// /** -// * 升星,觉醒,升品时,百家学宫配置武将会相应修改全局战力 -// * @param {HeroType[]} heros 全部武将 -// * @param {number} type 类型 HERO_SYSTEM_TYPE -// * @param {number} hid 更新的那个武将 -// * @param {number} isStarUp 是否升星 -// */ -// async function calSchoolStarIncAttr(role: RoleType, heros: HeroType[], type: number, hid: number, isStarUp: number) { -// let { roleId, attr: roleAttrs } = role; - -// if ((type == HERO_SYSTEM_TYPE.STAR || type == HERO_SYSTEM_TYPE.COLORSTAR) && !isStarUp) { -// return null; -// } - -// let hero = heros.find(cur => cur.hid == hid); -// if(!hero) return null; - -// let curHeroInSchool = await SchoolModel.findByHid(roleId, hid); -// if (!curHeroInSchool) return null; - -// let preStar = hero.star, preColorStar = hero.colorStar, preQuality = hero.quality; -// if (type == HERO_SYSTEM_TYPE.STAR && isStarUp) { -// preStar--; -// } else if (type == HERO_SYSTEM_TYPE.QUALITY) { -// preQuality--; -// } else if (type == HERO_SYSTEM_TYPE.COLORSTAR) { -// preColorStar--; -// if(preColorStar <= 0) preQuality--; -// } else { -// return null; -// } -// let school = gameData.school.get(curHeroInSchool.schoolId); -// let preRate = getSchoolRateByStar(preStar, preColorStar, preQuality); -// let curRate = getSchoolRateByStar(hero.star, hero.colorStar, hero.quality); - -// for (let attrId of school.upAttribute) { -// if(ABI_TYPE_MAIN.includes(attrId)) { // 主属性 -// let ratioUp = curRate.mainAttrAPerent - preRate.mainAttrAPerent; -// updateRoleAttr(roleAttrs, attrId, { inc: { ratioUp } }); -// } else { -// let fixUp = (curRate.assiAttrAddValue - preRate.assiAttrAddValue) * HERO_CE_RATIO; -// updateRoleAttr(roleAttrs, attrId, { inc: { fixUp } }); -// } -// } - -// return roleAttrs; -// } - -// /** -// * 全局加成, 名将谱 -// * @param heros 所有武将 -// * @param hid 激活的武将 -// * @param ceAttr -// */ -// function calScrollAddAttr(role: RoleType,heros: HeroType[], hid: number) { -// let { attr: roleAttrs } = role; -// // console.log('********** calScrollAddAttr', hid) - -// let curHero = heros.find(cur => cur.hid == hid); -// let dicHero = gameData.hero.get(hid); -// if (!curHero || !dicHero) return roleAttrs; -// let { quality } = dicHero; -// let { star, quality: curQuality, colorStar } = curHero; -// // console.log('********** calScrollAddAttr curHero', star, curQuality, colorStar); -// let heroScroll = getScollByStar(quality, star, curQuality, colorStar); -// if (!heroScroll) return roleAttrs; -// // console.log('********** heroScroll', heroScroll); - -// let isInit = star == dicHero.initialStars && curQuality == dicHero.quality && colorStar == 0; -// let preScroll = isInit? null: gameData.preHeroScroll.get(heroScroll.id); -// // console.log('********** preScroll', preScroll); - - -// heroScroll.ceAttr.forEach((add, attrId) => { - -// let preAdd = preScroll ? preScroll.ceAttr.get(attrId) : 0; -// let fixUp = (add - preAdd) * HERO_CE_RATIO; -// // console.log('********** preAdd', attrId, preAdd, fixUp); -// updateRoleAttr(roleAttrs, attrId, { inc: { fixUp } }); -// }); -// return roleAttrs; -// } - -// /** -// * 名将谱激活增加单个武将好感 -// * @param originHero 原始武将 -// * @param update 更新数据 -// */ -// function calHeroCeScrollIncAttr(originHero: HeroType, update: HeroUpdate) { -// let { attr: heroAttrs, favourLv: oldFavourLv } = originHero; -// let { favourLv = oldFavourLv } = update; -// if (favourLv != oldFavourLv) { -// heroAttrs = calHeroFavourUpIncAttr(originHero, update); -// } -// return heroAttrs; -// } - -// function calHeroTalent(originHero: HeroType, update: HeroUpdate, addSeidList: number[], removeSeidList: number[]) { -// let { attr: heroAttrs, skins: oldSkins } = originHero; -// let { skins } = update; -// let oldSkin = oldSkins.find(cur => cur.enable); -// let newSkin = skins.find(cur => cur.enable); -// let oldSeids = getTalentSeid(oldSkin.talent); -// let newSeids = getTalentSeid(newSkin.talent); -// for(let seid of newSeids) addSeidList.push(seid); -// for(let seid of oldSeids) removeSeidList.push(seid); -// return heroAttrs -// } - -// function getTalentSeid(talent: Talent[]) { -// let seids = new Map(); // 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; -// } - -// /** -// * 升爵位 -// * @param role 角色数据 -// * @param titleId 升到哪个爵位 -// */ -// function calTitle(role: RoleType, update: RoleUpdate) { -// let { title: oldTitle, attr: roleAttrs } = role; -// let { title: newTitle = oldTitle } = update; - -// let dicOldTitle = gameData.title.get(oldTitle)||{ mainAttrValue: new Map(), assiAttrValue: new Map() }; -// let dicNewTitle = gameData.title.get(newTitle); - -// for (let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) { -// if (dicNewTitle.mainAttrValue.has(i) || dicOldTitle.mainAttrValue.has(i)) { -// let fixUp = ((dicNewTitle.mainAttrValue.get(i) || 0) - (dicOldTitle.mainAttrValue.get(i) || 0)) * HERO_CE_RATIO; -// updateRoleAttr(roleAttrs, i, { inc: { fixUp } }); -// } -// if (dicNewTitle.assiAttrValue.has(i) || dicOldTitle.mainAttrValue.has(i)) { -// let fixUp = ((dicNewTitle.assiAttrValue.get(i) || 0) - (dicOldTitle.assiAttrValue.get(i) || 0)) * HERO_CE_RATIO; -// updateRoleAttr(roleAttrs, i, { inc: { fixUp } }); -// } -// } -// return roleAttrs; -// } - - -// /** -// * 神像强化,更新主属性加成 -// * @param role 角色数据 -// * @param update 更新数据 -// * @param id 更新哪座神像 -// */ -// function calTeraphMainAttr(role: RoleType, update: RoleUpdate, id: number) { -// let { attr: roleAttrs, teraphs: oldTeraphs = [] } = role; -// let { teraphs = oldTeraphs } = update; - -// let oldTeraph = oldTeraphs.find(cur => cur.id == id); -// let teraph = teraphs.find(cur => cur.id == id); -// if(teraph && teraph.attr) { -// for(let [attrId, val] of teraph.attr) { -// let oldVal = 0; -// if(oldTeraph && oldTeraph.attr && oldTeraph.attr.has(attrId)) { -// oldVal = oldTeraph.attr.get(attrId); -// } - -// let fixUp = (val - oldVal) * HERO_CE_RATIO; -// updateRoleAttr(roleAttrs, attrId, { inc: {fixUp} }) -// } -// } -// return roleAttrs; -// } - - -// /** -// * 神像进阶,更新次级属性加成 -// * @param role 角色数据 -// * @param update 更新数据 -// * @param id 更新哪座神像 -// */ -// function calTeraphAssistAttr(role: RoleType, update: RoleUpdate, id: number) { -// let { attr: roleAttrs, teraphs: oldTeraphs = [] } = role; -// let { teraphs = oldTeraphs } = update; - -// let oldTeraph = oldTeraphs.find(cur => cur.id == id); -// let teraph = teraphs.find(cur => cur.id == id); - -// let dicOldTeraph = getTeraph(id, oldTeraph?.grade); -// let dicTeraph = getTeraph(id, teraph?.grade); -// if(!dicTeraph) return null; - -// dicTeraph.assiAttrValue.forEach((val, attrId) => { -// let oldVal = 0; -// if(dicOldTeraph && dicOldTeraph.assiAttrValue && dicOldTeraph.assiAttrValue.has(attrId)) { -// oldVal = dicOldTeraph.assiAttrValue.get(attrId); -// } - -// let fixUp = (val - oldVal) * HERO_CE_RATIO; -// updateRoleAttr(roleAttrs, attrId, { inc: { fixUp } }); -// }); -// return roleAttrs; -// } - -// async function calHeroRebirth(role: RoleType, originHero: HeroType, updateHero: HeroUpdate) { -// let { roleId, attr: roleAttrs } = role; -// // 1. 名将谱 -// let dicHero = gameData.hero.get(originHero.hid); -// let dicHeroScroll = getScollByStar(dicHero.quality, updateHero.star, updateHero.quality, updateHero.colorStar); -// let dicPreScroll = getScollByStar(dicHero.quality, originHero.star, originHero.quality, originHero.colorStar); - -// if(dicHeroScroll) { -// for(let [attrId, value] of dicHeroScroll.ceAttr) { -// updateRoleAttr(roleAttrs, attrId, { inc: { fixUp: value * HERO_CE_RATIO } }); -// } -// } -// if(dicPreScroll) { -// for(let [attrId, value] of dicPreScroll.ceAttr) { -// updateRoleAttr(roleAttrs, attrId, { inc: { fixUp: -value * HERO_CE_RATIO } }); -// } -// } - -// // 2. 百家学宫 -// let school = await SchoolModel.findByHid(roleId, originHero.hid); -// if(school) { -// let dicSchool = gameData.school.get(school.schoolId); -// let preRate = getSchoolRateByStar(originHero.star, originHero.colorStar, originHero.quality); -// let curRate = getSchoolRateByStar(updateHero.star, updateHero.colorStar, updateHero.quality); -// console.log('####', updateHero.star, updateHero.colorStar, updateHero.quality) - -// for (let attrId of dicSchool.upAttribute) { -// if(ABI_TYPE_MAIN.includes(attrId)) { // 主属性 -// let ratioUp = (curRate?.mainAttrAPerent||0) - (preRate?.mainAttrAPerent||0); -// updateRoleAttr(roleAttrs, attrId, { inc: { ratioUp } }); -// } else { -// let fixUp = ((curRate?.assiAttrAddValue||0) - (preRate?.assiAttrAddValue||0)) * HERO_CE_RATIO; -// updateRoleAttr(roleAttrs, attrId, { inc: { fixUp } }); -// } -// } -// } - -// return roleAttrs; -// } \ No newline at end of file diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index 1b1d77ecf..9869fc3a3 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -1,21 +1,17 @@ import { STATUS } from './../consts/statusCode'; -import { HeroModel, HeroType } from '../db/Hero'; import { isNumber } from 'underscore'; const csprng = require('csprng'); import fs = require('fs'); import path = require('path'); -import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON, WAR_TYPE, LINEUP_NUM } from '../consts'; +import { ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON, WAR_TYPE } from '../consts'; import { findIndex } from 'underscore'; import { getTimeFunM } from './timeUtil'; import { Floor } from '../domain/activityField/gachaField'; import { WhiteListModel } from '../db/RegionWhiteList'; import { RewardInter } from './interface'; -import { RoleType } from '../db/Role'; -import { RoleCeModel } from '../db/RoleCe'; -import { CalCe } from '../services/role/calCe'; const randomName = require("chinese-random-name"); const moment = require('moment'); const crypto = require('crypto'); @@ -564,17 +560,6 @@ export function mergeSameGoods(goods: Array<{ id: number, count: number }>) { return resGoods; } -export function returnHeroCeRatio(hero: HeroType) { - let ce = reduceCe(hero.ce); - return Object.assign(hero, { ce }); -} - -// 缩小战力 -export function reduceCe(ce: number = 0) { - return Math.floor(ce / HERO_CE_RATIO / HERO_CE_RATIO) -} - - // 获取全部属性 export function getAllAttrStage() { let attrs = new Array(); // 有升级的属性 1-hp 2-atk 3-def 4-mdef 5-agi 6-luk