日志:增加日志详述,方便后台读取

This commit is contained in:
luying
2022-09-16 17:44:54 +08:00
parent e9bd4f51f1
commit 3294f5ada0
7 changed files with 59 additions and 17 deletions

View File

@@ -41,7 +41,9 @@ interface Param {
roleIncUpdate?: RoleUpdate;
heroes?: HeroType[],
schools?: SchoolType[];
skins?: SkinType[]
skins?: SkinType[],
stonesId?: number,
talentId?: number,
}
export async function calculateCeWithHero(type: HERO_SYSTEM_TYPE, roleId: string, serverId: number, sid: string, hid: number, heroUpdate: HeroUpdate, param: Param = {}) {
@@ -58,6 +60,7 @@ export async function calculateCeWithRole(type: HERO_SYSTEM_TYPE, roleId: string
}
export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serverId: number, sid: string, heroUpdates: Map<number, HeroUpdate>, roleUpdate: RoleUpdate, roleIncUpdate: RoleUpdate, param: Param = {}) {
const ceChangeTxt: string[] = [];
let calCe = new CalCe(roleId);
let roleCe = await RoleCeModel.findByRoleId(roleId);
calCe.setRoleCe(roleCe);
@@ -65,6 +68,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
case HERO_SYSTEM_TYPE.INIT:
{
for(let [hid, { skinId, lv, quality, star, starStage, colorStar, colorStarStage, job, jobStage, skins }] of heroUpdates) {
ceChangeTxt.push(`获得武将 ${hid}`);
calCe.setHeroBase(hid, skinId);
calCe.setHeroLv(hid, lv);
calCe.setHeroStar(hid, job, quality, star, starStage, colorStar, colorStarStage);
@@ -83,6 +87,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
case HERO_SYSTEM_TYPE.LVUP: // 1. 升级
{
for(let [hid, { lv }] of heroUpdates) {
ceChangeTxt.push(`武将 ${hid} 升级到 ${lv}`);
calCe.setHeroLv(hid, lv);
}
break;
@@ -90,6 +95,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
case HERO_SYSTEM_TYPE.STAR: // 2. 升星
{
for(let [hid, { star, starStage }] of heroUpdates) {
ceChangeTxt.push(`武将 ${hid} 升星到 ${star}${starStage}`);
let { hero: { quality, job, colorStar, colorStarStage }, isUpStar } = param;
await treatHeroStar(calCe, roleId, hid, star, starStage, quality, colorStar, colorStarStage, job, isUpStar);
}
@@ -98,6 +104,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
case HERO_SYSTEM_TYPE.QUALITY: // 3. 升品
{
for(let [hid, { quality }] of heroUpdates) {
ceChangeTxt.push(`武将 ${hid} 升品到 ${quality}`);
let { hero: { star, starStage, colorStar, colorStarStage, job } } = param;
await treatHeroStar(calCe, roleId, hid, star, starStage, quality, colorStar, colorStarStage, job, true);
}
@@ -106,6 +113,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
case HERO_SYSTEM_TYPE.COLORSTAR: // 4. 觉醒
{
for(let [hid, { quality, colorStar, colorStarStage }] of heroUpdates) {
ceChangeTxt.push(`武将 ${hid} 升彩星到 ${quality}`);
let { hero: { star, starStage, job }, isUpStar } = param;
await treatHeroStar(calCe, roleId, hid, star, starStage, quality, colorStar, colorStarStage, job, isUpStar);
}
@@ -115,6 +123,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
case HERO_SYSTEM_TYPE.STAGEUP: // 6. 职业进阶
{
for(let [hid, { job, jobStage }] of heroUpdates) {
ceChangeTxt.push(`武将 ${hid} 的职业升到 ${job} ${jobStage}`);
calCe.setJob(hid, job, jobStage);
}
break;
@@ -123,6 +132,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
{
let { hero: { quality, star, starStage, colorStar, colorStarStage, jobStage } } = param;
for(let [hid, { skinId, job, ePlace, skins }] of heroUpdates) {
ceChangeTxt.push(`武将 ${hid} 穿上了皮肤 ${skinId}`);
calCe.setHeroBase(hid, skinId);
calCe.setHeroStar(hid, job, quality, star, starStage, colorStar, colorStarStage);
calCe.setJob(hid, job, jobStage);
@@ -138,7 +148,10 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
}
case HERO_SYSTEM_TYPE.CONNECT: // 9. 羁绊
{
let { shipId } = param;
for(let [ hid, { connections } ] of heroUpdates) {
let curConnect = connections?.find(cur => cur.shipId);
ceChangeTxt.push(`武将 ${hid} 的羁绊 ${shipId} 升级到 ${curConnect?.level}`);
calCe.setConnection(hid, connections);
}
break;
@@ -147,6 +160,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
{
let { skinId } = param;
calCe.setAddSkin(skinId);
ceChangeTxt.push(`获得皮肤 ${skinId}`);
break;
}
case HERO_SYSTEM_TYPE.SCHOOL: // 16. 放百家学宫
@@ -154,10 +168,12 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
let { schoolId, schoolHid, preSchoolHid, hero } = param;
if(preSchoolHid) {
calCe.setSchool(false, preSchoolHid, schoolId, 0, 0, 0);
ceChangeTxt.push(`将武将 ${preSchoolHid} 从百家学宫移除`);
}
if(schoolHid) {
let { star, colorStar, quality } = hero;
calCe.setSchool(true, schoolHid, schoolId, star, colorStar, quality);
ceChangeTxt.push(`将武将 ${schoolHid} 放置到百家学宫`);
}
break;
}
@@ -165,6 +181,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
{
for(let [hid, { scrollStar, scrollQuality, scrollColorStar }] of heroUpdates) {
calCe.setScroll(hid, scrollStar, scrollQuality, scrollColorStar);
ceChangeTxt.push(`将武将 ${hid} 的名将谱激活至 ${scrollStar}${scrollQuality}${scrollColorStar}彩星`);
}
break;
}
@@ -172,13 +189,16 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
{
let { title } = roleUpdate;
calCe.setTitle(title);
ceChangeTxt.push(`爵位升级至 ${title}`);
break;
}
case HERO_SYSTEM_TYPE.TERAPH: // 19. 神像
case HERO_SYSTEM_TYPE.TERAPH_UP: // 20. 神像进阶
{
let { teraphId } = param;
let { teraphs } = roleUpdate;
calCe.setTeraph(teraphs);
ceChangeTxt.push(`神像 ${teraphId} 升级或进阶`);
break;
}
case HERO_SYSTEM_TYPE.COMPOSE_EQUIP: // 21. 合成装备
@@ -190,6 +210,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
calCe.setEquipQuality(hid, id, equipId, quality, qualityStage);
calCe.setEquipStrength(hid, id, equipId, lv);
calCe.setEquipStar(hid, id, equipId, star, starStage);
ceChangeTxt.push(`武将 ${hid}${equipId} 装备合成装备`);
}
}
calCe.setEquipSuit(hid, skinId, ePlace);
@@ -203,6 +224,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
for(let { id, equipId, lv } of ePlace) {
if(ePlaceIds.indexOf(id) != -1) {
calCe.setEquipStrength(hid, id, equipId, lv);
ceChangeTxt.push(`武将 ${hid}${equipId} 装备升级到 ${lv}`);
}
}
}
@@ -215,6 +237,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
for(let { id, equipId, quality, qualityStage } of ePlace) {
if(ePlaceId == id) {
calCe.setEquipQuality(hid, id, equipId, quality, qualityStage);
ceChangeTxt.push(`武将 ${hid}${equipId} 装备升级到 ${quality}${qualityStage}`);
}
}
}
@@ -227,6 +250,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
for(let { id, equipId, star, starStage } of ePlace) {
if(ePlaceId == id) {
calCe.setEquipStar(hid, id, equipId, star, starStage);
ceChangeTxt.push(`武将 ${hid}${equipId} 装备精炼到 ${star}${starStage}`);
}
}
calCe.setEquipSuit(hid, skinId, ePlace);
@@ -242,6 +266,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
for(let { id, stones } of ePlace) {
if(ePlaceId == id) {
calCe.setJewel(hid, id, stones, curJewel);
ceChangeTxt.push(`武将 ${hid}${ePlaceId} 装备栏的天晶 ${curJewel.id} 装备或洗练或淬炼`);
}
}
calCe.setEquipSuit(hid, skinId, ePlace);
@@ -250,12 +275,14 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
}
case HERO_SYSTEM_TYPE.EQUIP_STONE: // 26. 装备地玉
{
let { ePlaceId, jewel: curJewel, skinId } = param;
let { ePlaceId, jewel: curJewel, skinId, stonesId } = param;
for(let [hid, { ePlace = [] }] of heroUpdates) {
for(let { id, stones } of ePlace) {
if(ePlaceId == id) {
calCe.setStone(hid, ePlaceId, stones);
calCe.setJewel(hid, id, stones, curJewel);
ceChangeTxt.push(`武将 ${hid}${ePlaceId} 装备栏装备地玉 ${stonesId}`);
}
}
calCe.setEquipSuit(hid, skinId, ePlace);
@@ -274,17 +301,23 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
calCe.setTalent(hid, skins);
calCe.setScroll(hid, scrollStar, scrollQuality, scrollColorStar);
if(schoolId) calCe.setSchool(true, hid, schoolId, star, colorStar, quality);
ceChangeTxt.push(`武将 ${hid} 重生`);
}
break;
}
case HERO_SYSTEM_TYPE.TALENT: // 30. 天赋
case HERO_SYSTEM_TYPE.TALENT_UNLOCK: // 30. 天赋解锁
case HERO_SYSTEM_TYPE.TALENT_LV: // 32. 天赋升级
case HERO_SYSTEM_TYPE.TALENT_RESET: // 30. 天赋洗点
{
let { talentId } = param;
for(let [hid, { skins }] of heroUpdates) {
calCe.setTalent(hid, skins);
ceChangeTxt.push(`武将 ${hid} 天赋 ${talentId} 解锁、升级、洗点`);
}
break;
}
case HERO_SYSTEM_TYPE.RE_CAL: // 31. 玩家等级
case HERO_SYSTEM_TYPE.RE_CAL: // 31. 重新计算
{
let { role, schools, jewels, heroes, skins } = param;
calCe.clearRoleCe();
@@ -317,6 +350,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
for(let { id } of skins) {
calCe.setAddSkin(id);
}
ceChangeTxt.push(`后台重新计算`);
break;
}
}
@@ -335,7 +369,6 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
await PvpDefenseModel.updateCe(roleId, hid, ce); // 更新pvp防守阵战力
await LadderMatchModel.updateCe(roleId, hid, ce);
pushHeros.push({ hid, ce, incHeroCe: inc });
changeHids.push(hid);
} else {
let hero = await HeroModel.updateHeroInfo(roleId, hid, heroUpdate);
heroes.push(hero);
@@ -347,7 +380,6 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
await PvpDefenseModel.updateCe(roleId, hid, ce); // 更新pvp防守阵战力
await LadderMatchModel.updateCe(roleId, hid, ce);
pushHeros.push({ hid, ce: hero.ce, incHeroCe: inc });
changeHids.push(hid);
}
}
@@ -361,7 +393,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
let role = await RoleModel.incRoleInfo(roleId, { ...roleIncUpdate, ce: roleInc }, { ...roleUpdate, topLineup, topLineupCe });
let guild = await GuildModel.updateCe(roleId, roleInc); // 公会更新战力
saveCeChangeLog(role, roleInc, role.ce, type, changeHids);
saveCeChangeLog(role, roleInc, role.ce, type, ceChangeTxt);
updateRank(roleId, serverId, topLineupCe, role, pushHeros, guild);
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.PLAYER_CE_UPDATE, { ce: role.ce, heros: pushHeros, topLineupCe }, sid);
if(hasTopCeChange) await updateRoleOnlineInfo(roleId, { topLineupCe });