秘境:首通信息
This commit is contained in:
@@ -6,6 +6,8 @@ import { handleCost } from '../../../services/rewardService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
import { getDungeonData, getDungeonBuyCountCost } from '../../../services/dungeonService';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
import { DungeonFirstModel } from '../../../db/DungeonFirst';
|
||||
import { DungeonResultParam } from '../../../domain/battleField/dungeon';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new DungeonBattleHandler(app);
|
||||
@@ -64,4 +66,15 @@ export class DungeonBattleHandler {
|
||||
buyCount: dicParam.DUNGEON_CONST.DUNGEON_CONST_BUY - dungeonBuyCnt - count
|
||||
});
|
||||
}
|
||||
|
||||
// 购买每日次数
|
||||
async getFirstInfo(msg: { movePoint: number }, session: BackendSession) {
|
||||
const { movePoint } = msg;
|
||||
const serverId: number = session.get('serverId');
|
||||
const firstInfos = await DungeonFirstModel.findByMovePoint(serverId, movePoint);
|
||||
let result: DungeonResultParam[] = firstInfos.map(firstInfo => {
|
||||
return new DungeonResultParam(firstInfo);
|
||||
});
|
||||
return resResult(STATUS.SUCCESS, { infos: result });
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import { resResult } from '../../../pubUtils/util';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { RScriptRecordModel } from '../../../db/RScriptRecord';
|
||||
import { updateWarStar, checkBattleHeroes, roleLevelup, getBattleList } from '../../../services/normalBattleService';
|
||||
import { checkDungeonNum, checkDungeonAndIncrease } from '../../../services/dungeonService';
|
||||
import { checkDungeonNum, checkDungeonAndIncrease, saveDungeonFirst } from '../../../services/dungeonService';
|
||||
import { switchOnFunc } from '../../../services/funcSwitchService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import { pushMysteryFirstMsg, pushTowerMsg, pushVestigeFirstMsg } from '../../../services/chatService';
|
||||
@@ -58,7 +58,7 @@ export class NormalBattleHandler {
|
||||
if (preBattle == -1) return resResult(STATUS.BATTLE_NEED_PREVIOUS_GK);
|
||||
}
|
||||
|
||||
let { isOK, heroes } = await checkBattleHeroes(roleId, seqIds);
|
||||
let { isOK, heroes, lineup } = await checkBattleHeroes(roleId, seqIds);
|
||||
if (!isOK) return resResult(STATUS.BATTLE_HERO_NOT_FOUND);
|
||||
|
||||
const battleCode = genCode(8); // 关卡唯一值
|
||||
@@ -98,7 +98,7 @@ export class NormalBattleHandler {
|
||||
status: 0,
|
||||
warName: warInfo.gk_name,
|
||||
warType: warInfo.warType,
|
||||
record: { heroes, seqIds }
|
||||
record: { heroes, seqIds, lineup }
|
||||
}
|
||||
}, true);
|
||||
|
||||
@@ -192,8 +192,7 @@ export class NormalBattleHandler {
|
||||
let checkResult = await checkDungeonAndIncrease(roleId, 1, false);
|
||||
let role = await RoleModel.saveDungeonHero(roleId, battleId, heroes, isSuccess);
|
||||
if (role) {
|
||||
let r = new Rank(REDIS_KEY.DUNGEON_RANK, { serverId });
|
||||
await r.setRankWithRoleInfo(roleId, role.dungeonWarId, role.dungeonUpdatedAt, role);
|
||||
await saveDungeonFirst(role, battleId, BattleRecord);
|
||||
}
|
||||
|
||||
if (checkResult.status == -1) {
|
||||
|
||||
@@ -78,7 +78,7 @@ export class DonationHandler {
|
||||
//活动任务
|
||||
await checkActivityTask(serverId, sid, funcs, roleId, TASK_TYPE.GUILD_DONATE, 1);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { donateFund, reports, donateCnt, goods });
|
||||
return resResult(STATUS.SUCCESS, { donateFund, reports, donateCnt, simpleGoods: goods });
|
||||
}
|
||||
/**
|
||||
* 领取宝箱
|
||||
|
||||
@@ -6,6 +6,11 @@ import { resResult, shouldRefresh, } from '../pubUtils/util';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { RoleModel, RoleType } from '../db/Role';
|
||||
import * as dicParam from '../pubUtils/dicParam';
|
||||
import { RankParam } from '../domain/rank';
|
||||
import { BattleRecordType } from '../db/BattleRecord';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { DungeonFirstModel } from '../db/DungeonFirst';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
|
||||
/**
|
||||
* 获取秘境本数据
|
||||
@@ -85,4 +90,13 @@ export function getDungeonBuyCountCost(num:number) {
|
||||
cost = dicParam.DUNGEON_CONST.DUNGEON_CONST_TOP;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
export async function saveDungeonFirst(role: RoleType, warId: number, battleRecord: BattleRecordType) {
|
||||
let userInfo = new RankParam(role, true);
|
||||
let lineup = battleRecord.record.lineup;
|
||||
let dicWar = gameData.war.get(warId);
|
||||
await DungeonFirstModel.createDungeonFirst(role.serverId, dicWar.movePoint, warId, {
|
||||
time: nowSeconds(), roleId: role.roleId, userInfo, lineup
|
||||
})
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import { accomplishTask } from '../pubUtils/taskUtil';
|
||||
import { RScriptRecordModel } from '../db/RScriptRecord';
|
||||
import { setAp } from './actionPointService';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { LineupParam } from '../domain/rank';
|
||||
|
||||
export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kingExp: number = 0, session: BackendSession) {
|
||||
const serverId = session.get('serverId');
|
||||
@@ -82,7 +83,7 @@ export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kin
|
||||
|
||||
|
||||
export async function checkBattleHeroes(roleId: string, seqIds: Array<number> = []) {
|
||||
let heroes: number[] = [];
|
||||
let heroes: number[] = [], lineup: LineupParam[] = [];
|
||||
let flag = true;
|
||||
// if (seqIds.length <= 0) flag = false;
|
||||
|
||||
@@ -94,8 +95,9 @@ export async function checkBattleHeroes(roleId: string, seqIds: Array<number> =
|
||||
flag = false; break;
|
||||
}
|
||||
heroes.push(hero.hid);
|
||||
lineup.push(new LineupParam(hero));
|
||||
}
|
||||
return { isOK: flag, heroes };
|
||||
return { isOK: flag, heroes, seqIds, lineup };
|
||||
}
|
||||
|
||||
export async function checkBattleHeroesByHid(roleId: string, heroes: Array<number> = []) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { LineupParam } from '../domain/rank';
|
||||
|
||||
/**
|
||||
* 战斗记录接口
|
||||
@@ -12,6 +13,8 @@ class Record {
|
||||
heroes: Array<number>; // 武将id
|
||||
@prop({ required: true, type: Number })
|
||||
seqIds: Array<number>; // 武将seqid
|
||||
@prop({ required: true, type: () => LineupParam, _id: false })
|
||||
lineup: Array<LineupParam>; // 武将详细信息
|
||||
@prop({ required: false })
|
||||
oppRoleId?: string; // pvp对手
|
||||
@prop({ required: false })
|
||||
|
||||
45
shared/db/DungeonFirst.ts
Normal file
45
shared/db/DungeonFirst.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 秘境首通
|
||||
*/
|
||||
import BaseModel from './BaseModel';
|
||||
import { getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { RankParam, LineupParam } from '../domain/rank';
|
||||
|
||||
export default class DungeonFirst extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
serverId: number; // 服务器id
|
||||
|
||||
@prop({ required: true, default: 0})
|
||||
movePoint: number; // 秘境的类型
|
||||
|
||||
@prop({ required: true, default: 0})
|
||||
warId: number; // 关卡id
|
||||
|
||||
@prop({ required: true })
|
||||
time: number; // 首通时间
|
||||
|
||||
@prop({ required: true })
|
||||
roleId: string; // 玩家id
|
||||
|
||||
@prop({ required: true, type: () => RankParam, _id: false })
|
||||
userInfo: RankParam; // 玩家信息
|
||||
|
||||
@prop({ required: true, type: () => LineupParam, _id: false })
|
||||
lineup: LineupParam[]; // 玩家信息
|
||||
|
||||
public static async createDungeonFirst(serverId: number, movePoint: number, warId: number, update: DungeonFirstUpdateParam) {
|
||||
const rec: DungeonFirstType = await DungeonFirstModel.findOneAndUpdate({ serverId, movePoint, warId}, { $setOnInsert: update }, { new: true, upsert: true }).lean();
|
||||
return rec;
|
||||
}
|
||||
|
||||
public static async findByMovePoint(serverId: number, movePoint: number) {
|
||||
const rec: DungeonFirstType[] = await DungeonFirstModel.find({ serverId, movePoint}).lean();
|
||||
return rec;
|
||||
}
|
||||
}
|
||||
|
||||
export const DungeonFirstModel = getModelForClass(DungeonFirst);
|
||||
|
||||
export interface DungeonFirstType extends Pick<DocumentType<DungeonFirst>, keyof DungeonFirst>{}
|
||||
export type DungeonFirstUpdateParam = Partial<DungeonFirstType>; // 将所有字段变成可选项
|
||||
24
shared/domain/battleField/dungeon.ts
Normal file
24
shared/domain/battleField/dungeon.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { RankParam, LineupParam } from '../rank';
|
||||
import { DungeonFirstType } from '../../db/DungeonFirst';
|
||||
|
||||
class DungeonUserInfo extends RankParam {
|
||||
roleId: string;
|
||||
constructor(roleId: string, userInfo: RankParam) {
|
||||
super(userInfo, false);
|
||||
this.roleId = roleId;
|
||||
}
|
||||
}
|
||||
|
||||
export class DungeonResultParam {
|
||||
warId: number;
|
||||
time: number;
|
||||
userInfo: DungeonUserInfo;
|
||||
lineup: LineupParam[];
|
||||
|
||||
constructor(dungeon: DungeonFirstType) {
|
||||
this.warId = dungeon.warId;
|
||||
this.time = dungeon.time;
|
||||
this.userInfo = new DungeonUserInfo(dungeon.roleId, dungeon.userInfo);
|
||||
this.lineup = dungeon.lineup;
|
||||
}
|
||||
}
|
||||
@@ -5,21 +5,41 @@ import { reduceCe } from "../pubUtils/util";
|
||||
import { GuildUpdateParam } from "../db/Guild";
|
||||
import { HeroType, HeroUpdate } from "../db/Hero";
|
||||
import { getSeconds } from "../pubUtils/timeUtil";
|
||||
import { prop } from "@typegoose/typegoose";
|
||||
|
||||
// 排行榜返回玩家值
|
||||
export class RankParam {
|
||||
@prop({ required: true })
|
||||
roleName: string = "";
|
||||
|
||||
@prop({ required: true })
|
||||
lv: number = 0;
|
||||
|
||||
@prop({ required: true })
|
||||
vLv: number = 0;
|
||||
|
||||
@prop({ required: true })
|
||||
guildName: string = "";
|
||||
|
||||
@prop({ required: true })
|
||||
head: number = EXTERIOR.EXTERIOR_FACE;
|
||||
|
||||
@prop({ required: true })
|
||||
frame: number = EXTERIOR.EXTERIOR_FACECASE;
|
||||
|
||||
@prop({ required: true })
|
||||
spine: number = EXTERIOR.EXTERIOR_APPEARANCE;
|
||||
|
||||
@prop({ required: true })
|
||||
title: number = 1;
|
||||
|
||||
@prop({ required: true })
|
||||
ce: number = 0;
|
||||
|
||||
@prop({ required: true })
|
||||
updatedAt: number = 0;
|
||||
|
||||
constructor(role: RoleUpdate, fromDb: boolean) {
|
||||
constructor(role: RoleUpdate|RankParam, fromDb: boolean) {
|
||||
if(role.roleName) this.roleName = role.roleName;
|
||||
if(role.lv) this.lv = role.lv;
|
||||
if(role.vLv) this.vLv = role.vLv;
|
||||
@@ -29,7 +49,7 @@ export class RankParam {
|
||||
if(role.title) this.title = role.title;
|
||||
if(role.guildName) this.guildName = role.guildName||"";
|
||||
if(role.ce) {
|
||||
if(fromDb && !role.isReducedCe) {
|
||||
if(fromDb && !(<RoleUpdate>role).isReducedCe) {
|
||||
this.ce = reduceCe(role.ce);
|
||||
} else {
|
||||
this.ce = role.ce;
|
||||
@@ -141,11 +161,22 @@ export class GuildLeader {
|
||||
|
||||
// 排行榜返回玩家值
|
||||
export class LineupParam {
|
||||
@prop({ required: true })
|
||||
hid: number;
|
||||
|
||||
@prop({ required: true })
|
||||
star: number;
|
||||
|
||||
@prop({ required: true })
|
||||
colorStar: number;
|
||||
|
||||
@prop({ required: true })
|
||||
lv: number;
|
||||
|
||||
@prop({ required: true })
|
||||
quality: number;
|
||||
|
||||
@prop({ required: true })
|
||||
job: number;
|
||||
|
||||
constructor(hero: HeroType) {
|
||||
|
||||
@@ -38,6 +38,8 @@ export interface DicWar {
|
||||
readonly fobiddenCharactor: Array<{type: number, id: number}>;
|
||||
// 远征随机buff
|
||||
readonly mapseid: number[];
|
||||
// 秘境类型
|
||||
readonly movePoint: number;
|
||||
}
|
||||
|
||||
export const dicWar = new Map<number, DicWar>();
|
||||
|
||||
Reference in New Issue
Block a user