后台:重新计算玩家战力

This commit is contained in:
luying
2022-06-27 15:18:21 +08:00
parent 4dcf421ebf
commit e0d9681635
5 changed files with 67 additions and 7 deletions
@@ -19,11 +19,13 @@ import { HeroModel } from '../../../db/Hero';
import { SkinModel } from '../../../db/Skin'; import { SkinModel } from '../../../db/Skin';
import { PvpDefenseModel } from '../../../db/PvpDefense'; import { PvpDefenseModel } from '../../../db/PvpDefense';
import { createHeroes } from '../../../services/role/createHero'; import { createHeroes } from '../../../services/role/createHero';
import { calculateCeWithHero } from '../../../services/playerCeService'; import { calculateCeWithHero, calculateCeWithRole } from '../../../services/playerCeService';
import { pushChangeGuildLeader, pushGuildDismiss, pushGuildInfoUpdate } from '../../../services/guildService'; import { pushChangeGuildLeader, pushGuildDismiss, pushGuildInfoUpdate } from '../../../services/guildService';
import { sendMessageToUserWithSuc } from '../../../services/pushService'; import { sendMessageToUserWithSuc } from '../../../services/pushService';
import { RScriptRecordModel } from '../../../db/RScriptRecord'; import { RScriptRecordModel } from '../../../db/RScriptRecord';
import { DicWar } from '../../../pubUtils/dictionary/DicWar'; import { DicWar } from '../../../pubUtils/dictionary/DicWar';
import { SchoolModel } from '../../../db/School';
import { JewelModel } from '../../../db/Jewel';
let timer: NodeJS.Timer; let timer: NodeJS.Timer;
export default function (app: Application) { export default function (app: Application) {
@@ -283,4 +285,16 @@ export class GmRoleHandler {
return resResult(STATUS.SUCCESS); return resResult(STATUS.SUCCESS);
} }
async reCalCe(msg: { roleId: string }, session: BackendSession) {
const { roleId } = msg;
let role = await RoleModel.findByRoleId(roleId);
let schools = await SchoolModel.findByRoleId(roleId);
let jewels = await JewelModel.findbyRole(roleId);
let heroes = await HeroModel.findByRole(roleId);
let skins = await SkinModel.findbyRole(roleId);
await calculateCeWithRole(HERO_SYSTEM_TYPE.RE_CAL, roleId, role.serverId, null, {}, { role, schools, jewels, heroes, skins });
return resResult(STATUS.SUCCESS);
}
} }
+40 -5
View File
@@ -14,9 +14,10 @@ import { RoleCeModel } from '../db/RoleCe';
import { PvpDefenseModel } from '../db/PvpDefense'; import { PvpDefenseModel } from '../db/PvpDefense';
import { saveCeChangeLog } from '../pubUtils/logUtil'; import { saveCeChangeLog } from '../pubUtils/logUtil';
import { JewelType } from '../db/Jewel'; import { JewelType } from '../db/Jewel';
import { SchoolModel } from '../db/School'; import { SchoolModel, SchoolType } from '../db/School';
import { AttributeCal } from '../domain/roleField/attribute'; import { AttributeCal } from '../domain/roleField/attribute';
import { sendMessageToUserWithSuc } from './pushService'; import { sendMessageToUserWithSuc } from './pushService';
import { SkinType } from '../db/Skin';
interface Param { interface Param {
isInitRole?: boolean, isInitRole?: boolean,
@@ -35,7 +36,11 @@ interface Param {
preSchoolHid?: number, preSchoolHid?: number,
skinId?: number, skinId?: number,
roleUpdate?: RoleUpdate, roleUpdate?: RoleUpdate,
roleIncUpdate?: RoleUpdate role?: RoleType,
roleIncUpdate?: RoleUpdate;
heroes?: HeroType[],
schools?: SchoolType[];
skins?: SkinType[]
} }
export async function calculateCeWithHero(type: HERO_SYSTEM_TYPE, roleId: string, serverId: number, sid: string, hid: number, heroUpdate: HeroUpdate, param: Param = {}) { export async function calculateCeWithHero(type: HERO_SYSTEM_TYPE, roleId: string, serverId: number, sid: string, hid: number, heroUpdate: HeroUpdate, param: Param = {}) {
@@ -288,10 +293,40 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
} }
break; break;
} }
case HERO_SYSTEM_TYPE.ROLE_LV: // 31. 玩家等级 case HERO_SYSTEM_TYPE.RE_CAL: // 31. 玩家等级
{ {
let { lv } = roleUpdate; let { role, schools, jewels, heroes, skins } = param;
calCe.setRoleLv(lv); calCe.clearRoleCe();
for(let { hid, skinId, lv, quality, star, starStage, colorStar, colorStarStage, job, jobStage, connections, favourLv, skins, scrollStar, scrollQuality, scrollColorStar, ePlace } of heroes) {
calCe.setHeroBase(hid, skinId);
calCe.setHeroLv(hid, lv);
calCe.setHeroStar(hid, job, quality, star, starStage, colorStar, colorStarStage);
calCe.setJob(hid, job, jobStage);
calCe.setFavour(hid, favourLv, connections);
calCe.setConnection(hid, connections);
calCe.setTalent(hid, skins);
for(let { id, equipId, star, starStage, quality, qualityStage, lv: equipLv, stones, jewel } of ePlace) {
calCe.setEquipQuality(hid, id, equipId, quality, qualityStage);
calCe.setEquipStrength(hid, id, equipId, equipLv);
calCe.setEquipStar(hid, id, equipId, star, starStage);
let curJewel = jewels.find(cur => cur.seqId == jewel);
calCe.setJewel(hid, id, stones, curJewel);
calCe.setStone(hid, id, stones);
calCe.setTitle(role.title);
calCe.setTeraph(role.teraphs);
}
calCe.setEquipSuit(hid, skinId, ePlace);
calCe.setScroll(hid, scrollStar, scrollQuality, scrollColorStar);
}
for(let { schoolId, hid, } of schools) {
let curHero = heroes.find(cur => cur.hid == hid);
calCe.setSchool(true, hid, schoolId, curHero.star, curHero.colorStar, curHero.quality);
}
for(let { id } of skins) {
calCe.setAddSkin(id);
}
break; break;
} }
} }
+4
View File
@@ -25,6 +25,10 @@ export class CalCe {
this.originCes = this.calHeroCe(); this.originCes = this.calHeroCe();
} }
public clearRoleCe() {
this.data = new CalCeData(null);
}
public getRoleCeTable() { public getRoleCeTable() {
let attributes: Attribute[] = []; let attributes: Attribute[] = [];
for(let [hid, attrs] of this.attrsByHid) { for(let [hid, attrs] of this.attrsByHid) {
+1 -1
View File
@@ -31,7 +31,7 @@ export enum HERO_SYSTEM_TYPE {
JEWEL_QUENCH = 28, // 天晶石淬炼 JEWEL_QUENCH = 28, // 天晶石淬炼
REBIRTH = 29, // 武将重生 REBIRTH = 29, // 武将重生
TALENT = 30, // 天赋 TALENT = 30, // 天赋
ROLE_LV = 31, // 玩家等级 RE_CAL = 31, // 重新计算
}; };
// 武将上限 // 武将上限
+7
View File
@@ -824,5 +824,12 @@
"name": "跳过序章", "name": "跳过序章",
"module": "role", "module": "role",
"type": "update" "type": "update"
},
{
"id": 119,
"api": "gm.gmRoleHandler.reCalCe",
"name": "重新计算这个玩家的战力",
"module": "role",
"type": "update"
} }
] ]