战力:获取显示数据

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