战力:操作细节

This commit is contained in:
luying
2022-03-28 20:28:47 +08:00
parent 14b28921af
commit 1ccb66e3eb
7 changed files with 267 additions and 63 deletions
+93 -7
View File
@@ -19,7 +19,6 @@ import { PvpDefenseModel } from '../db/PvpDefense';
import { saveCeChangeLog } from '../pubUtils/logUtil';
import { JewelType } from '../db/Jewel';
import { SchoolModel } from '../db/School';
import { HasJustId } from 'mongoose';
interface Param {
isInitRole?: boolean,
@@ -54,7 +53,7 @@ export async function calculateWithRole(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 = {}) {
let calCe = new CalCe();
let calCe = new CalCe(roleId);
let roleCe = await RoleCeModel.findByRoleId(roleId);
calCe.setRoleCe(roleCe);
switch (type) {
@@ -98,13 +97,62 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
}
case HERO_SYSTEM_TYPE.COLORSTAR: // 4. 觉醒
{
for(let [hid, { colorStar, colorStarStage }] of heroUpdates) {
let { hero: { star, starStage, quality, job }, isUpStar } = param;
for(let [hid, { quality, colorStar, colorStarStage }] of heroUpdates) {
let { hero: { star, starStage, job }, isUpStar } = param;
await treatHeroStar(calCe, roleId, hid, star, starStage, quality, colorStar, colorStarStage, job, isUpStar);
}
break;
}
case HERO_SYSTEM_TYPE.SCHOOL: // 放百家学宫
case HERO_SYSTEM_TYPE.TRAIN: // 5. 训练
case HERO_SYSTEM_TYPE.STAGEUP: // 6. 职业进阶
{
for(let [hid, { job, jobStage }] of heroUpdates) {
calCe.setJob(hid, job, jobStage);
}
break;
}
case HERO_SYSTEM_TYPE.SKIN: // 7. 穿皮肤
{
let { hero: { quality, star, starStage, colorStar, colorStarStage } } = param;
for(let [hid, { skinId, job, ePlace }] of heroUpdates) {
calCe.setHeroBase(hid, skinId);
calCe.setHeroStar(hid, job, quality, star, starStage, colorStar, colorStarStage);
// 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);
}
// TODO 装备
break;
}
case HERO_SYSTEM_TYPE.FAVOUR: // 8. 好感度
{
let { hero: { connections }, isFavourLvUp } = param;
if(isFavourLvUp) {
for(let [hid, { favourLv }] of heroUpdates) {
calCe.setFavour(hid, favourLv, connections);
}
}
break;
}
case HERO_SYSTEM_TYPE.CONNECT: // 9. 羁绊
{
for(let [ hid, { connections } ] of heroUpdates) {
let { shipId } = param;
calCe.setConnection(hid, shipId, connections);
}
break;
}
case HERO_SYSTEM_TYPE.ADD_SKIN: // 15. 第一次获得皮肤
{
let { skinId } = param;
calCe.setAddSkin(skinId);
break;
}
case HERO_SYSTEM_TYPE.SCHOOL: // 16. 放百家学宫
{
let { schoolId, schoolHid, preSchoolHid, hero } = param;
if(preSchoolHid) {
@@ -116,6 +164,44 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
}
break;
}
case HERO_SYSTEM_TYPE.SCROLL: // 17. 名将谱
{
for(let [hid, { scrollStar, scrollQuality, scrollColorStar }] of heroUpdates) {
calCe.setScroll(hid, scrollStar, scrollQuality, scrollColorStar);
}
break;
}
case HERO_SYSTEM_TYPE.TITLE: // 18. 爵位
{
let { title } = roleUpdate;
calCe.setTitle(title);
break;
}
case HERO_SYSTEM_TYPE.TERAPH: // 19. 神像
case HERO_SYSTEM_TYPE.TERAPH_UP: // 20. 神像进阶
{
let { teraphs } = roleUpdate;
calCe.setTeraph(teraphs);
break;
}
case HERO_SYSTEM_TYPE.REBIRTH: // 29. 重生
{
for(let [hid, { skinId, lv, quality, star, starStage, colorStar, colorStarStage, job, jobStage, }] of heroUpdates) {
calCe.setHeroBase(hid, skinId);
calCe.setHeroLv(hid, lv);
calCe.setHeroStar(hid, job, quality, star, starStage, colorStar, colorStarStage);
calCe.setJob(hid, job, jobStage);
// TODO 装备
}
break;
}
case HERO_SYSTEM_TYPE.TALENT: // 30. 天赋
{
for(let [hid, { skins }] of heroUpdates) {
calCe.setTalent(hid, skins);
}
break;
}
}
let { heroCe, roleInc } = calCe.getCeInc(); // 计算战力,获得有变化的武将战力
let changeHids: number[] = [];
@@ -133,7 +219,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
pushHeros.push({ hid, ce, incHeroCe: inc });
changeHids.push(hid);
} else {
let hero = await HeroModel.updateHeroInfo(roleId, param.hid, heroUpdate);
let hero = await HeroModel.updateHeroInfo(roleId, hid, heroUpdate);
heroes.push(hero);
}
}
@@ -202,7 +288,7 @@ async function updateRank(roleId: string, serverId: number, topLineupCe: number,
export async function getSumCe(roleId: string, num: number) {
let roleCe = await RoleCeModel.findByRoleId(roleId);
let calCe = new CalCe();
let calCe = new CalCe(roleId);
calCe.setRoleCe(roleCe);
let arr = calCe.getResultCeArr();
let ce = 0;