boss等级
This commit is contained in:
@@ -65,13 +65,13 @@ export class GuildHandler {
|
|||||||
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
|
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
let bossBase = getBossByLv(curStructure.lv);
|
let bossBase = getBossByLv(curStructure.lv);
|
||||||
let {bossHp, warId } = getRandomByLen(bossBase.wars);
|
let {bossHp, warId, bossLevel } = getRandomByLen(bossBase.wars);
|
||||||
let resGuild = await GuildModel.costFund(code, bossBase.consume)
|
let resGuild = await GuildModel.costFund(code, bossBase.consume)
|
||||||
if (!resGuild)
|
if (!resGuild)
|
||||||
return resResult(STATUS.GUILD_FUND_NOT_ENOUGH);
|
return resResult(STATUS.GUILD_FUND_NOT_ENOUGH);
|
||||||
await BossInstanceModel.openBossInstance(code, bossHp, warId);
|
await BossInstanceModel.openBossInstance(code, bossHp, warId, bossLevel);
|
||||||
res.releaseCallback();
|
res.releaseCallback();
|
||||||
let result = {warId, ranks: [], myRank: {}, bossHp, status: 3, isBattled: false};
|
let result = {warId, ranks: [], myRank: {}, bossHp, status: 3, bossLv: bossLevel, isBattled: false};
|
||||||
return resResult(STATUS.SUCCESS, result);
|
return resResult(STATUS.SUCCESS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { getArmyBossRank } from '../pubUtils/data';
|
|||||||
* @param roleId
|
* @param roleId
|
||||||
*/
|
*/
|
||||||
export async function getBossInstanceInfo(bossInstance: BossInstanceType, roleId:string) {
|
export async function getBossInstanceInfo(bossInstance: BossInstanceType, roleId:string) {
|
||||||
let { warId, ranks, bossHp, winWarId, winTime, roleIdRecords, guildCode } = bossInstance;
|
let { warId, ranks, bossHp, bossLv, winWarId, winTime, roleIdRecords, guildCode } = bossInstance;
|
||||||
ranks.sort(function(a, b) {
|
ranks.sort(function(a, b) {
|
||||||
return b.score - a.score + a.time - b.time;
|
return b.score - a.score + a.time - b.time;
|
||||||
});
|
});
|
||||||
@@ -45,7 +45,7 @@ export async function getBossInstanceInfo(bossInstance: BossInstanceType, roleId
|
|||||||
}
|
}
|
||||||
return {roleId, score, rankLv: index + 1};
|
return {roleId, score, rankLv: index + 1};
|
||||||
});
|
});
|
||||||
return {warId, ranks: lastRanks, myRank, bossHp, status: 3, isBattled};
|
return {warId, ranks: lastRanks, myRank, bossHp, status: 3, isBattled, bossLv};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 战斗结束返回
|
* 战斗结束返回
|
||||||
@@ -54,16 +54,16 @@ export async function getBossInstanceInfo(bossInstance: BossInstanceType, roleId
|
|||||||
* @param battleNum
|
* @param battleNum
|
||||||
*/
|
*/
|
||||||
export async function getBossInstanceWhenEnd(bossInstance: BossInstanceType, roleId:string, battleNum:number) {
|
export async function getBossInstanceWhenEnd(bossInstance: BossInstanceType, roleId:string, battleNum:number) {
|
||||||
let { warId, ranks, bossHp, winWarId, guildCode, recordRanks, winNum } = bossInstance;
|
let { warId, ranks, bossHp, winWarId, guildCode, recordRanks, winNum, bossLv } = bossInstance;
|
||||||
let pushRanks;
|
let pushRanks;
|
||||||
let result:any = {};
|
let result:any = {};
|
||||||
if (battleNum == winNum) {
|
if (battleNum == winNum) {
|
||||||
pushRanks = deepCopy(recordRanks);
|
pushRanks = deepCopy(recordRanks);
|
||||||
result = {warId: winWarId, bossHp: 0, status: 3};
|
result = {warId: winWarId, bossHp: 0, bossLv, status: 3};
|
||||||
await BossInstanceModel.recordRoleIdWhenCheck(guildCode, roleId);
|
await BossInstanceModel.recordRoleIdWhenCheck(guildCode, roleId);
|
||||||
} else {
|
} else {
|
||||||
pushRanks = deepCopy(ranks);
|
pushRanks = deepCopy(ranks);
|
||||||
result = {warId, bossHp, status: 3};
|
result = {warId, bossHp, bossLv, status: 3};
|
||||||
}
|
}
|
||||||
pushRanks.sort(function(a, b) {
|
pushRanks.sort(function(a, b) {
|
||||||
return b.score - a.score + a.time - b.time;
|
return b.score - a.score + a.time - b.time;
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ export default class BossInstance extends BaseModel {
|
|||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
bossHp: number;
|
bossHp: number;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
bossLv: number;
|
||||||
|
|
||||||
@prop({ required: true, type: Rank, default:[]})
|
@prop({ required: true, type: Rank, default:[]})
|
||||||
ranks:Array<Rank>;
|
ranks:Array<Rank>;
|
||||||
|
|
||||||
@@ -48,13 +51,14 @@ export default class BossInstance extends BaseModel {
|
|||||||
|
|
||||||
@prop({ required: true, default: false })
|
@prop({ required: true, default: false })
|
||||||
winSettled: boolean; //胜利是否结算过
|
winSettled: boolean; //胜利是否结算过
|
||||||
|
|
||||||
public static async findBossInstance(guildCode: string, lean = true) {
|
public static async findBossInstance(guildCode: string, lean = true) {
|
||||||
const bossInstance: BossInstanceType = await BossInstanceModel.findOne({ guildCode }).lean(lean);
|
const bossInstance: BossInstanceType = await BossInstanceModel.findOne({ guildCode }).lean(lean);
|
||||||
return bossInstance;
|
return bossInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async openBossInstance(guildCode: string, bossHp: number, warId: number, lean = true) {
|
public static async openBossInstance(guildCode: string, bossHp: number, warId: number, bossLv: number, lean = true) {
|
||||||
const bossInstance: BossInstanceType = await BossInstanceModel.findOneAndUpdate({ guildCode },{ranks:[], time: nowSeconds(), bossHp, warId, $inc: { recordNum: 1 }}, {new: true, upsert: true}).lean(lean);
|
const bossInstance: BossInstanceType = await BossInstanceModel.findOneAndUpdate({ guildCode },{ranks:[], time: nowSeconds(), bossHp, bossLv, warId, $inc: { recordNum: 1 }}, {new: true, upsert: true}).lean(lean);
|
||||||
return bossInstance;
|
return bossInstance;
|
||||||
}
|
}
|
||||||
//记录玩家boss通关后首次查看boss关卡
|
//记录玩家boss通关后首次查看boss关卡
|
||||||
|
|||||||
Reference in New Issue
Block a user