寻宝掉落
This commit is contained in:
@@ -303,6 +303,8 @@ export const COM_BATTLE_ROBOT_ROUND_LMT = 10;
|
||||
export const COM_BATTLE_ROBOT_HURT_RATIO = 0.2;
|
||||
// 机器人伤害上下浮动的比例
|
||||
export const COM_BATTLE_ROBOT_HURT_CH_RATIO = 0.1;
|
||||
// 队员奖励比例
|
||||
export const COM_BATTLE_ASSIST_REWARD_RATIO = 0.5;
|
||||
|
||||
// 机器人名字随机
|
||||
export const COM_BATTLE_ROBOT_ID_NAME = [
|
||||
|
||||
@@ -98,6 +98,7 @@ export const STATUS = {
|
||||
COM_BATTLE_NO_RECENT_REC: { code: 20624, simStr: '没有最近的寻宝记录' },
|
||||
COM_BATTLE_HURT_NUM_ERR: { code: 20625, simStr: '血量计算错误' },
|
||||
COM_BATTLE_START_ERR: { code: 20626, simStr: '开始战斗失败' },
|
||||
COM_BATTLE_REWARD_ERR: { code: 20627, simStr: '不能领取奖励' },
|
||||
|
||||
// 共斗藏宝图合成
|
||||
COM_BLUEPRT_QUALITY_CANNOT_COMPOSE: { code: 20630, simStr: '该品质藏宝图不可合成' },
|
||||
|
||||
@@ -40,6 +40,9 @@ export class RoleStatus {
|
||||
// 是否机器人
|
||||
@prop({ required: true, default: false })
|
||||
isRobot: boolean;
|
||||
// 是否领奖
|
||||
@prop({ required: true, default: false })
|
||||
gotReward: boolean;
|
||||
|
||||
constructor(roleId: string, roleName: string, isCap: boolean, isFrd: boolean, headHid: number, sHid: number, topFiveCe: number, lv: number, heroes = [], isRobot = false) {
|
||||
this.roleId = roleId;
|
||||
@@ -81,7 +84,7 @@ export default class ComBattleTeam extends BaseModel {
|
||||
@prop({ required: true })
|
||||
quality: number;
|
||||
|
||||
// 战斗状态 0:未开始,1:已开始,2:胜利,3:失败,4:已领奖
|
||||
// 战斗状态 0:未开始,1:已开始,2:胜利,3:失败
|
||||
@prop({ required: true, default: 0 })
|
||||
status: number;
|
||||
|
||||
@@ -125,6 +128,16 @@ export default class ComBattleTeam extends BaseModel {
|
||||
return team;
|
||||
}
|
||||
|
||||
public static async setupBattleInfo(teamCode: string, roleId: string, heroes: Array<number>, battleCode: string, lean = true) {
|
||||
const team = await ComBattleTeamModel.findOneAndUpdate({ teamCode, 'roleStatus.roleId': roleId}, {$set: {'roleStatus.$.heroes': heroes, 'roleStatus.$.battleCode': battleCode}}, {new: true}).lean(lean);
|
||||
return team;
|
||||
}
|
||||
|
||||
public static async updateRewardSt(roleId: string, battleCode: string, gotReward: boolean, lean = true) {
|
||||
const team = await ComBattleTeamModel.findOneAndUpdate({ roleIds: roleId, 'roleStatus.battleCode': battleCode}, {$set: {'roleStatus.$.gotReward': gotReward}}).lean(lean);
|
||||
return team;
|
||||
}
|
||||
|
||||
public static async syncTeamData(teamData: {teamCode: string, status: number, roleStatus: Array<RoleStatus>}, lean = true) {
|
||||
const team = await ComBattleTeamModel.findOneAndUpdate({ teamCode: teamData.teamCode }, {$set :{...teamData, roleCnt: teamData.roleStatus.length}}, {new: true}).lean(lean);
|
||||
return team;
|
||||
@@ -191,6 +204,26 @@ export default class ComBattleTeam extends BaseModel {
|
||||
const teams = await ComBattleTeamModel.find(query).limit(limitCnt).lean(lean);
|
||||
return teams;
|
||||
}
|
||||
|
||||
public static async getAssistTeamsByTime(roleId: string, qualityArr?: Array<number>, time?: Date, isAssist?: boolean, lean = true) {
|
||||
let query = {roleIds: roleId, status: {$in: [0, 1, 2]}}; // 失败不计入助战
|
||||
if (qualityArr) {
|
||||
query = Object.assign(query, {quality: {$in: qualityArr}});
|
||||
}
|
||||
if (time) {
|
||||
query = Object.assign(query, {createdAt: {$gte: time}});
|
||||
}
|
||||
if (isAssist) {
|
||||
query = Object.assign(query, {capId: {$ne: roleId}});
|
||||
}
|
||||
const teams = await ComBattleTeamModel.find(query).lean(lean);
|
||||
return teams;
|
||||
}
|
||||
|
||||
public static async getTeamByRoleAndBattleCode(roleId: string, battleCode: string, lean = true) {
|
||||
const team = await ComBattleTeamModel.findOne({roleIds: roleId, 'roleStatus.battleCode': battleCode}).lean(lean);
|
||||
return team;
|
||||
}
|
||||
}
|
||||
|
||||
export const ComBattleTeamModel = getModelForClass(ComBattleTeam);
|
||||
@@ -393,10 +393,18 @@ export function getWarIdByBlueprtId(blueprtId: number) {
|
||||
}
|
||||
|
||||
export function getBossHpByBlueprtId(blueprtId: number) {
|
||||
let bossHpInfo = getBossHpByWarId(getWarIdByBlueprtId(blueprtId));
|
||||
let warId = getWarIdByBlueprtId(blueprtId);
|
||||
let { dispatchJsonId } = getWarById(warId);
|
||||
let bossHpInfo = getBossHpByWarId(dispatchJsonId);
|
||||
return bossHpInfo;
|
||||
}
|
||||
|
||||
export function getRewardByBlueprtId(blueprtId: number) {
|
||||
let warId = getWarIdByBlueprtId(blueprtId);
|
||||
let { fixReward } = getWarById(warId);
|
||||
return fixReward;
|
||||
}
|
||||
|
||||
export function hasExpeditionById(id: number) {
|
||||
return expeditionInfo.has(id);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ export function decodeIdCntArrayStr(str: string, multi: number) {
|
||||
const strMap = new Map();
|
||||
strArr.forEach(item => {
|
||||
const kv = item.split('&');
|
||||
strMap.set(kv[0], multi? parseInt(kv[1]) * multi: kv[1]);
|
||||
strMap.set(kv[0], multi? Math.ceil(parseInt(kv[1]) * multi): kv[1]);
|
||||
});
|
||||
return strMap;
|
||||
}
|
||||
@@ -383,3 +383,12 @@ export async function updateCe(roleId: string, hero: any ) {
|
||||
await HeroModel.updateCe(roleId, hid, ce, oldCe, historyCe);
|
||||
}
|
||||
}
|
||||
|
||||
export function ratioReward(rewardStr: string, ratio: number): string {
|
||||
let rewards = decodeIdCntArrayStr(rewardStr, ratio);
|
||||
let res = '';
|
||||
for (let [k, v] of rewards) {
|
||||
res += `${k}&${v}|`;
|
||||
}
|
||||
return res.substring(0, res.length - 1);
|
||||
}
|
||||
Reference in New Issue
Block a user