添加获取对手阵容,开始战斗,结算

This commit is contained in:
luying
2021-01-07 17:37:06 +08:00
parent edc45932da
commit 5bfac1723c
12 changed files with 299 additions and 20 deletions

View File

@@ -105,6 +105,10 @@ export const STATUS = {
COM_BATTLE_REWARDED: { code: 20628, simStr: '奖励已领取' },
COM_BATTLE_HEROES_ERR: { code: 20629, simStr: '阵容异常' },
// PVP 20700-20799
PVP_ROLE_NOT_FOUND: { code: 20700, simStr: '未找到该对手' },
PVP_NOT_OPEN: { code: 20701, simStr: 'pvp尚未开启' },
// 共斗藏宝图合成
COM_BLUEPRT_QUALITY_CANNOT_COMPOSE: { code: 20630, simStr: '该品质藏宝图不可合成' },
COM_BLUEPRT_COUNT_ERROR: { code: 20631, simStr: '材料数量不足' },

View File

@@ -7,6 +7,15 @@ import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoos
@index({ roleId: 1, battleId: 1 })
@index({ battleCode: 1 })
class Record {
@prop({ required: true, type: Number })
heroes: Array <number>; // 武将id
@prop({ required: false })
oppRoleId?: string; // pvp对手
@prop({ required: false })
pos?: number; // pvp位置
}
export default class BattleRecord extends BaseModel {
@prop({ required: true })
roleId: string; // 角色 id
@@ -26,10 +35,8 @@ export default class BattleRecord extends BaseModel {
status: number; // 关卡状态 0-挑战中 1-挑战成功 2-挑战失败
@prop({ required: true, default: 0 })
star: number; // 关卡状态 0-挑战中 1-挑战成功 2-挑战失败
@prop({ required: true })
record: { // 使用的武将等记录
heroes: Array <number>; // 武将id
};
@prop({ required: true, _id: false })
record: Record; // 使用的武将等记录
public static async getBattleRecordByCode(battleCode: string, lean = true) {
const result: BattleRecordType = await BattleRecordModel.findOne({ battleCode }).lean(lean);

View File

@@ -153,6 +153,12 @@ export default class Hero extends BaseModel {
const hero: HeroType[] = await HeroModel.find({ seqId: {$in: seqIds}, roleId }).lean(lean);
return hero;
}
public static async findByHidRange(hids: Array<number>, roleId: string, lean = true) {
const hero: HeroType[] = await HeroModel.find({ hid: {$in: hids}, roleId }).lean(lean);
return hero;
}
public static async findBySeqIdAndRole(seqId: number, roleId: string, lean = true) {
const hero: HeroType = await HeroModel.findOne({ seqId, roleId }).lean(lean);
return hero;

View File

@@ -10,6 +10,8 @@ interface pvpUpdateInter {
oppPlayers?: OppPlayers[];
score?: number;
pLv?:number;
heroScores?: HeroScores[];
winStreakNum?: number;
}
export class Heroes {
@@ -74,6 +76,8 @@ export class Robot {
}
export class OppPlayers {
@prop({ required: true })
roleId: string;
@prop({ ref: 'PvpDefense', type: mongoose.Schema.Types.ObjectId })
oppDef: Ref<PvpDef>;
@prop({ required: true })
@@ -84,7 +88,7 @@ export class OppPlayers {
robot: Robot
}
class HeroScores {
export class HeroScores {
@prop({ required: true })
hid: number;
@prop({ required: true })
@@ -180,8 +184,8 @@ export default class PvpDefense extends BaseModel {
.populate({
path: 'oppPlayers.oppDef',
populate: {
path: 'role',
select: 'headHid sHid topFiveCe roleId roleName'
path: 'role heroes.hero',
select: 'headHid sHid topFiveCe roleId roleName hid ceAttr globalCeAttr'
}
}).lean();
return result;

View File

@@ -33,4 +33,5 @@ export const PVP = {
PVP_CHALLENGE_FINALTIMES: 60, // PVP赛季最后一天挑战次数刷新时间分钟
PVP_SEASON_DAYS: 30, // PVP一个赛季的时间
PVP_OPPONENT_FREEREFRESH: 3, // pvp挑战对手每日免费刷新次数
PVP_WINREWARD_UPLIMIT: 10, // 连胜奖励军功加成上限
};

View File

@@ -66,4 +66,33 @@ export interface oppPlayersInter {
defCe: number; // 防守阵容战力
addScore: number; // 战胜后可获军功
plusScore: number; // 连胜加成军功
rankLv: number;
}
export interface oppHeroesDefenseInter {
actorId: number; // 武将id
actorName: string; // 武将名
dataId: number; // 出兵表唯一id
relation: number; // 地方还是我方
direction: number; // 方向
outIndex: number; // 玩家设置的出场顺序即order字段
x: number; // 战场x坐标
y: number; // 战场y坐标
var: number; // 变量
lv: number; // 等级
hide: number; // 是否隐藏
initial_ai: number; // ai类型
attribute: Attributes;
star: number; // 星级
skill: string|number; // 技能
seid: string; // 技能
spine: string|number; // 动画
}
export interface pvpEndParamInter {
hid: number;
damage: number;
heal: number;
hurt: number;
}