feat(共鸣系统): 添加最强6人推送,不可养成拦截

This commit is contained in:
zhangxk
2023-10-09 20:49:24 +08:00
parent ffcdb7c0bc
commit dac8ac07a6
10 changed files with 109 additions and 42 deletions

View File

@@ -1,5 +1,5 @@
import { Application, BackendSession, HandlerService, } from "pinus";
import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, TASK_TYPE, CONSUME_TYPE } from "../../../consts";
import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, TASK_TYPE, CONSUME_TYPE, RESONANCE } from "../../../consts";
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
import { resResult, parseGoodStr } from "../../../pubUtils/util";
@@ -20,6 +20,7 @@ import { calculateCeWithHero } from "../../../services/playerCeService";
import { ItemModel } from "../../../db/Item";
import { index } from "typegoose";
import { all } from "bluebird";
import { getResonanceDataMap } from "../../../services/role/resonanceService";
export default function (app: Application) {
new HandlerService(app, {});
@@ -80,6 +81,10 @@ export class EquipHandler {
let { hid, ePlaceId, isOneClick } = msg;
let { dbResonanceMap } = await getResonanceDataMap(roleId);
if(dbResonanceMap.has(hid)) return resResult(STATUS.RESONANCE__HID_NOT_CAN);
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let oldEplace = hero.ePlace || [];
@@ -126,6 +131,10 @@ export class EquipHandler {
let sid: string = session.get('sid');
let { hid, lv } = msg; // lv: 升到哪一级
let { dbResonanceMap } = await getResonanceDataMap(roleId);
if(dbResonanceMap.has(hid)) return resResult(STATUS.RESONANCE__HID_NOT_CAN);
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
@@ -179,6 +188,10 @@ export class EquipHandler {
let sid: string = session.get('sid');
let { hid, ePlaceId, isOneClick } = msg;
let { dbResonanceMap } = await getResonanceDataMap(roleId);
if(dbResonanceMap.has(hid)) return resResult(STATUS.RESONANCE__HID_NOT_CAN);
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
@@ -250,6 +263,10 @@ export class EquipHandler {
let sid: string = session.get('sid');
let { hid, ePlaceId, isOneClick } = msg;
let { dbResonanceMap } = await getResonanceDataMap(roleId);
if(dbResonanceMap.has(hid)) return resResult(STATUS.RESONANCE__HID_NOT_CAN);
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
@@ -332,6 +349,10 @@ export class EquipHandler {
let sid: string = session.get('sid');
let serverId: number = session.get('serverId');
let { dbResonanceMap } = await getResonanceDataMap(roleId);
if(dbResonanceMap.has(hid) && RESONANCE.JEWEL) return resResult(STATUS.RESONANCE__HID_NOT_CAN);
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
@@ -387,6 +408,9 @@ export class EquipHandler {
let sid: string = session.get('sid');
let serverId: number = session.get('serverId');
let { dbResonanceMap } = await getResonanceDataMap(roleId);
if(dbResonanceMap.has(hid) && RESONANCE.JEWEL) return resResult(STATUS.RESONANCE__HID_NOT_CAN);
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
@@ -416,6 +440,9 @@ export class EquipHandler {
let sid: string = session.get('sid');
let serverId: number = session.get('serverId');
let { dbResonanceMap } = await getResonanceDataMap(roleId);
if(dbResonanceMap.has(hid) && RESONANCE.STONE) return resResult(STATUS.RESONANCE__HID_NOT_CAN);
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);

View File

@@ -31,6 +31,7 @@ import { PvpSaveDataModel } from '../../../db/PvpSaveData';
import { ArtifactModel } from '../../../db/Artifact';
import { GVGVestigeRankModel } from '../../../db/GVGVestigeRank';
import { GVGTeamModel } from '../../../db/GVGTeam';
import { getResonanceDataMap } from '../../../services/role/resonanceService';
export default function (app: Application) {
new HandlerService(app, {});
@@ -78,6 +79,9 @@ export class HeroHandler {
let { hid, type } = msg;
if(isHeroHidden(hid)) return resResult(STATUS.HERO_IS_HIDDEN);
let { dbResonanceMap } = await getResonanceDataMap(roleId);
if(dbResonanceMap.has(hid)) return resResult(STATUS.RESONANCE__HID_NOT_CAN);
let addLv = 0;
if (type == 1) {
addLv = 1;
@@ -440,6 +444,9 @@ export class HeroHandler {
let { hid, shipId, type } = msg;
if(isHeroHidden(hid)) return resResult(STATUS.HERO_IS_HIDDEN);
let { dbResonanceMap } = await getResonanceDataMap(roleId);
if(dbResonanceMap.has(hid)) return resResult(STATUS.RESONANCE__HID_NOT_CAN);
let dicFriendShip = getFriendShipByIdAndLv(hid, shipId, 1);
if(!dicFriendShip) return resResult(STATUS.DIC_DATA_NOT_FOUND);

View File

@@ -1,7 +1,7 @@
import { Application, BackendSession, HandlerService, } from 'pinus';
import { getJewelDataMap, getResonanceDataMap, getStartLimt, refreshResonanceData } from '../../../services/role/resonanceService';
import { getInitEplace, getJewelDataMap, getResonanceDataMap, refreshResonanceData } from '../../../services/role/resonanceService';
import { resResult } from '../../../pubUtils/util'
import { HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, STATUS } from '../../../consts';
import { HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, LINEUP_NUM, RESONANCE, STATUS } from '../../../consts';
import { ResonanceModel } from '../../../db/Resonance';
import { gameData } from '../../../pubUtils/data';
import { RoleModel } from '../../../db/Role';
@@ -12,8 +12,6 @@ import { calculateCeWithHero } from '../../../services/playerCeService';
import { HeroParam } from '../../../domain/roleField/hero';
import { pick } from 'underscore';
import { ResonanceHistoryModel } from '../../../db/ResonanceHistory';
import { RESONANCE } from '../../../pubUtils/dicParam';
;
export default function (app: Application) {
new HandlerService(app, {});
@@ -29,7 +27,7 @@ export class HeroHandler {
const sid: string = session.get('sid');
const serverId: number = session.get('serverId');
if (!await getStartLimt(roleId)) return resResult(STATUS.RESONANCE_NO_START);
// if (!await getStartLimt(roleId)) return resResult(STATUS.RESONANCE_NO_START);
const resonances = await refreshResonanceData(roleId, serverId, sid);
return resResult(STATUS.SUCCESS, { resonanceDatas: resonances })
@@ -40,7 +38,7 @@ export class HeroHandler {
const roleId: string = session.get('roleId');
const sid: string = session.get('sid');
if (!await getStartLimt(roleId)) return resResult(STATUS.RESONANCE_NO_START);
// if (!await getStartLimt(roleId)) return resResult(STATUS.RESONANCE_NO_START);
let dbResonance = await ResonanceModel.findByPosition(roleId, position);
if (dbResonance) return resResult(STATUS.RESONANCE_POSITION_LOCK);
@@ -67,10 +65,10 @@ export class HeroHandler {
const sid: string = session.get('sid');
const serverId: number = session.get('serverId');
if (!await getStartLimt(roleId)) return resResult(STATUS.RESONANCE_NO_START);
// if (!await getStartLimt(roleId)) return resResult(STATUS.RESONANCE_NO_START);
let { dbResonanceMap } = await getResonanceDataMap(roleId);
let heroCount = await HeroModel.getHidCountByRoleId(roleId);
if (dbResonanceMap.size + RESONANCE.HOSTER >= heroCount) return resResult(STATUS.RESONANCE_PUT_NOT_POSITION)
let dbRole = await RoleModel.findByRoleId(roleId);
if (dbResonanceMap.size + LINEUP_NUM >= (dbRole?.heroNum || 0)) return resResult(STATUS.RESONANCE_PUT_NOT_POSITION)
let dbResonance = await ResonanceModel.findByPosition(roleId, position);
if (!dbResonance) return resResult(STATUS.RESONANCE_POSITION_UNLOCK);
@@ -86,7 +84,7 @@ export class HeroHandler {
if (jobStage) return resResult(STATUS.RESONANCE_PUT_POSITION_EXIST_JOBSTAGE);
if (skins.find(cur => (cur?.usedTalentPoint || 0) > 0)) return resResult(STATUS.RESONANCE_PUT_POSITION_EXIST_TALENT);
if (connections.length > 0) return resResult(STATUS.RESONANCE_PUT_POSITION_EXIST_CONNECT);
if (ePlace.length > 0) return resResult(STATUS.RESONANCE_PUT_POSITION_EXIST_EQUIP);
if (ePlace.length > 0) return resResult(STATUS.RESONANCE_PUT_POSITION_EXIST_EQUIP); //TODO
let result = await ResonanceModel.updateByPosition(roleId, position, { hid, seqId, lv, exp, jobStage, skinId, skins, connections, ePlace, ce });
if (!result) return resResult(STATUS.RESONANCE_PUT_POSITION_FAIL);
@@ -118,6 +116,19 @@ export class HeroHandler {
obj.usedTalentPoint = newSkin.usedTalentPoint;
}
}
for (let obj of dbHero.ePlace) {
let tempEPlace = ePlace.find(cur => cur.id == obj.id);
if (!tempEPlace && (!RESONANCE.JEWEL || !RESONANCE.STONE) && (obj.jewel || obj.stones.find(cur => cur.stone != 0))) {
ePlace.push({ ...await getInitEplace(obj.id, skinId) });
tempEPlace = ePlace.find(cur => cur.id == obj.id);
}
if (!RESONANCE.JEWEL && obj.jewel) {
tempEPlace.jewel = obj.jewel;
}
if (!RESONANCE.STONE && obj.stones.find(cur => cur.stone != 0)) {
tempEPlace.stones = obj.stones;
}
}
let heroResult = await HeroModel.updateHeroInfo(roleId, hid, { lv, exp, jobStage, skinId, skins: dbHero.skins, connections, ePlace });
if (!heroResult) return resResult(STATUS.RESONANCE_OFF_POSITION_FAIL);
@@ -134,7 +145,7 @@ export class HeroHandler {
await ResonanceModel.deletePosition(roleId, position);
let result = await ResonanceModel.updateByPosition(roleId, position, {});
if (!result || result.hid) return resResult(STATUS.RESONANCE_OFF_POSITION_FAIL);
await ResonanceHistoryModel.updateByPosition(roleId, position, { ...dbResonance, time: new Date() });
await ResonanceHistoryModel.updateByPosition(roleId, position, { ...dbResonance });
const resonances = await refreshResonanceData(roleId, serverId, sid);

View File

@@ -22,6 +22,7 @@ import { LadderMatchModel } from '../db/LadderMatch';
import { ArtifactModelType } from '../db/Artifact';
import { GVGVestigeRankModel } from '../db/GVGVestigeRank';
import { AuthorBookType } from '../db/AuthorBook';
import { getResonanceDataMap } from './role/resonanceService';
interface Param {
isInitRole?: boolean,
@@ -546,7 +547,8 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
}
}
let { topLineup, topLineupCe, hasTopCeChange } = calCe.getTopLineup();
const { dbResonanceMap } = await getResonanceDataMap(roleId);
let { topLineup, topLineupCe, hasTopCeChange } = calCe.getTopLineupNew(dbResonanceMap);
let roleCeUpdate: RoleCeUpdate = calCe.getRoleCeTable();
if(topLineupCe > (roleCe?.historyLineupCe||0)) {
roleCeUpdate = { ...roleCeUpdate, historyLineupCe: topLineupCe };
@@ -558,7 +560,7 @@ export async function calculateCes(type: HERO_SYSTEM_TYPE, roleId: string, serve
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);
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.PLAYER_CE_UPDATE, { ce: role.ce, heros: pushHeros, topLineupCe, topLineup }, sid);
if(hasTopCeChange) await updateRoleOnlineInfo(roleId, { topLineupCe });
if(guild) {
await updateUserInfo(REDIS_KEY.GUILD_INFO, guild.code, [{ field: 'guildCe', value: guild.guildCe }]);

View File

@@ -3,6 +3,7 @@ import { ArtifactModelType } from "../../db/Artifact";
import { AuthorBookType } from "../../db/AuthorBook";
import { Connect, EPlace, HeroSkin, HeroType, HeroUpdate, Stone, Talent } from "../../db/Hero";
import { JewelType } from "../../db/Jewel";
import { ResonanceType } from "../../db/Resonance";
import { RoleUpdate, Teraph } from "../../db/Role";
import { AttrCell, Attribute, EquipAttr, HeroAttr, RoleCeType, SchoolAttr, ScrollAttr } from "../../db/RoleCe";
import { TopHero } from "../../domain/dbGeneral";
@@ -137,6 +138,23 @@ export class CalCe {
return { topLineup, topLineupCe, hasTopCeChange: topLineupCe == this.originTopHeroCe };
}
public getTopLineupNew(dbResonanceMap: Map<number, ResonanceType>) {
let topLineup: TopHero[] = [], topLineupCe = 0;
let arr = this.getResultCeArr();
for (let obj of arr) {
if (topLineup.length >= LINEUP_NUM) break;
let { hid, ce } = obj;
if (dbResonanceMap.has(hid)) continue;
topLineup.push({
hid, ce, hero: this.data.heroObjectId.get(hid)
});
topLineupCe += ce;
}
return { topLineup, topLineupCe, hasTopCeChange: topLineupCe == this.originTopHeroCe };
}
// 玩家等级
public setRoleLv(lv: number) {
this.data.roleLv = lv;

View File

@@ -1,4 +1,4 @@
import { EQUIP_EPLACEID, EQUIP_STONE, FRIENDSHIP_INDEX, HERO_SYSTEM_TYPE, RESONANCE_SORT_TYPE } from "../../consts";
import { EQUIP_EPLACEID, EQUIP_STONE, FRIENDSHIP_INDEX, HERO_SYSTEM_TYPE, LINEUP_NUM, RESONANCE, RESONANCE_SORT_TYPE } from "../../consts";
import { ArtifactModel } from "../../db/Artifact";
import { EPlace, HeroModel, HeroType, HeroUpdate } from "../../db/Hero";
import { JewelModel, JewelType } from "../../db/Jewel";
@@ -6,24 +6,23 @@ import { ResonanceModel, ResonanceType } from "../../db/Resonance";
import { RoleModel } from "../../db/Role";
import { HeroParam } from "../../domain/roleField/hero";
import { gameData, getEquipByJobClassAndEPlace } from "../../pubUtils/data";
import { RESONANCE } from "../../pubUtils/dicParam";
import { ReturnResonanceParam } from "../../pubUtils/interface";
import { calculateCeWithHeroes } from "../playerCeService";
import { initSkinTalent } from "../roleService";
import { pick } from 'underscore';
import * as util from 'util';
export async function getStartLimt(roleId: string) {
const role = await RoleModel.findByRoleId(roleId);
if (!role || !role.mainWarId || role.mainWarId < RESONANCE.START_MAIN_WARId) return false;
return true;
}
// export async function getStartLimt(roleId: string) {
// const role = await RoleModel.findByRoleId(roleId);
// if (!role || !role.mainWarId || role.mainWarId < RESONANCE.START_MAIN_WARId) return false;
// return true;
// }
export async function refreshResonanceData(roleId: string, serverId: number, sid: string) {
let resonances: ReturnResonanceParam[] = [];
let dbHeroes: HeroType[] = await HeroModel.findByRole(roleId, [{ field: 'ce', sortBy: -1 }]);
if (dbHeroes.length < RESONANCE.HOSTER) return resonances;
if (dbHeroes.length < LINEUP_NUM) return resonances;
let { dbResonanceMap, newPositionArr } = await getResonanceDataMap(roleId);
@@ -86,8 +85,8 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
ePlaceData = await getInitEplace(id, hero.skinId);
hero.ePlace.push({ ...ePlaceData });
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
ePlaceData = hero.ePlace.find(cur => cur.id == id);
}
ePlaceData.lv = topLineHeroEplace.lv;
}
@@ -101,8 +100,8 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
ePlaceData = await getInitEplace(id, hero.skinId);
hero.ePlace.push({ ...ePlaceData });
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
ePlaceData = hero.ePlace.find(cur => cur.id == id);
};
ePlaceData.quality = topLineHeroEplace.quality;
ePlaceData.qualityStage = topLineHeroEplace.qualityStage;
@@ -117,8 +116,8 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
ePlaceData = await getInitEplace(id, hero.skinId);
hero.ePlace.push({ ...ePlaceData });
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
ePlaceData = hero.ePlace.find(cur => cur.id == id);
};
ePlaceData.star = topLineHeroEplace.star;
ePlaceData.starStage = topLineHeroEplace.starStage;
@@ -135,8 +134,8 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
ePlaceData = await getInitEplace(id, hero.skinId);
hero.ePlace.push({ ...ePlaceData });
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
ePlaceData = hero.ePlace.find(cur => cur.id == id);
};
ePlaceData.jewel = topLineHeroEplace.jewel;
}
@@ -156,8 +155,8 @@ export async function refreshResonanceData(roleId: string, serverId: number, sid
let ePlaceData = hero.ePlace.find(cur => cur.id == id);
if (!ePlaceData) {
ePlaceData = await getInitEplace(id, hero.skinId);
hero.ePlace.push({ ...ePlaceData });
hero.ePlace.push({ ...await getInitEplace(id, hero.skinId) });
ePlaceData = hero.ePlace.find(cur => cur.id == id);
};
ePlaceData.stones.find(cur => cur.id == index).stone = topLineHeroStone.stone;
}
@@ -251,12 +250,12 @@ export function sortData(dbResonanceMap: Map<number, ResonanceType>, heroes: Her
let topLineHeroes: HeroType[] = [];
for (let hero of heroes) {
const { hid } = hero;
if (!dbResonanceMap.has(hid) && topLineHeroes.length < RESONANCE.HOSTER) {
if (!dbResonanceMap.has(hid) && topLineHeroes.length < LINEUP_NUM) {
topLineHeroes.push(hero);
}
}
return topLineHeroes[RESONANCE.HOSTER - 1];
return topLineHeroes[1 - 1];
}
export function sortByConnect(heroes: HeroType[], index: number) {

View File

@@ -1435,6 +1435,11 @@ export enum BOSS_HP_RATIO_TYPE {
CITY_PLAYER_RATIO = 3, // 最低玩家人数
}
export enum RESONANCE {
JEWEL = 1,// 共灵阵是否包括共灵天晶镶嵌(1:包括 0不包括)
STONE = 1, // 共灵阵是否包括共灵地玉镶嵌(1:包括 0不包括)
}
export enum RESONANCE_SORT_TYPE {
LV = 1, //先等级后后战力
JOBSTAGE = 2, //职阶

View File

@@ -842,9 +842,11 @@ export const STATUS = {
RESONANCE_PUT_POSITION_EXIST_CONNECT: { code: 81009, simStr: '武将存在羁绊养成维度,请先重生' },
RESONANCE_PUT_POSITION_EXIST_EQUIP: { code: 81010, simStr: '武将存在装备养成维度,请先重生' },
RESONANCE_PUT_POSITION_FAIL: { code: 81011, simStr: '武将上阵失败' },
RESONANCE_PUT_NOT_POSITION: { code: 81011, simStr: '武将数量不足,不可上阵' },
RESONANCE_NOT_PUT_POSITION: { code: 81011, simStr: '该武将未在阵中' },
RESONANCE_OFF_POSITION_FAIL: { code: 81011, simStr: '该武将下阵失败' },
RESONANCE_PUT_NOT_POSITION: { code: 81012, simStr: '武将数量不足,不可上阵' },
RESONANCE_NOT_PUT_POSITION: { code: 81013, simStr: '该武将未在阵中' },
RESONANCE_OFF_POSITION_FAIL: { code: 81014, simStr: '该武将下阵失败' },
RESONANCE__HID_NOT_CAN: { code: 81015, simStr: '共鸣武将不可养成' },

View File

@@ -98,7 +98,7 @@ export default class ResonanceHistory extends BaseModel {
public static async updateByPosition(roleId: string, position: number, param: ResonanceHistoryPara, lean = true) {
delete param._id;
let result: ResonanceHistoryType = await ResonanceHistoryModel.findOneAndUpdate({ roleId, position }, { $set: param }, { new: true, upsert: true }).lean(lean);
let result: ResonanceHistoryType = await ResonanceHistoryModel.findOneAndUpdate({ roleId, position, time: new Date() }, { $set: param }, { new: true, upsert: true }).lean(lean);
return result;
}

View File

@@ -482,7 +482,3 @@ export const ROUGELIKE = {
SELECT_HOLLYCARD_WEIGHT: 30, // 选择的圣物卡后该特性卡权重减少比例(%
RANDOM_HOLLYCARD_WEIGHT: 10, // 随机出的圣物卡后该特性卡权重减少比例(%
};
export const RESONANCE = {
RESONANCE_JEWEL: 1, // 共灵阵是否包括共灵天晶的镶嵌(1:包括 0不包括)
RESONANCE_STONE: 1, // 共灵阵是否包括共灵地玉的镶嵌(1:包括 0不包括)
};