寻宝:奖励
This commit is contained in:
@@ -174,7 +174,6 @@ export class ComBattleHandler {
|
||||
*/
|
||||
async joinTeam(msg: {teamCode: string, isFrd: boolean}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let roleName = session.get('roleName');
|
||||
let sid = session.get('sid');
|
||||
let { teamCode, isFrd } = msg;
|
||||
let teamStatus = this.teamMap.get(teamCode);
|
||||
@@ -184,15 +183,11 @@ export class ComBattleHandler {
|
||||
if (teamStatus.roleIds.indexOf(roleId) !== -1) return resResult(STATUS.COM_BATTLE_DUP_ENTER);
|
||||
if (teamStatus.blacklist.indexOf(roleId) != -1) return resResult(STATUS.COM_BATTLE_BE_KICKED);
|
||||
|
||||
let { lv = 1, head = EXTERIOR.EXTERIOR_FACE, topLineupCe = 0, frame = EXTERIOR.EXTERIOR_FACECASE, spine = EXTERIOR.EXTERIOR_APPEARANCE } = await Role.findByRoleId(roleId, null, true);
|
||||
let role = await Role.findByRoleId(roleId, null, true);
|
||||
|
||||
if (lv < COM_BTL_CONST.ENABLE_LV) {
|
||||
return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH);
|
||||
} else if (comBtlLvInvalid(lv, [teamStatus.lv])) {
|
||||
return resResult(STATUS.COM_BATTLE_ASSIST_LV_NOT_ENOUGH);
|
||||
} else if (topLineupCe < teamStatus.ceLimit) {
|
||||
return resResult(STATUS.COM_BATTLE_CE_LIMIT);
|
||||
}
|
||||
if (role.lv < COM_BTL_CONST.ENABLE_LV) return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH);
|
||||
if (comBtlLvInvalid(role.lv, [teamStatus.lv])) return resResult(STATUS.COM_BATTLE_ASSIST_LV_NOT_ENOUGH);
|
||||
if (role.topLineupCe < teamStatus.ceLimit) return resResult(STATUS.COM_BATTLE_CE_LIMIT);
|
||||
|
||||
if (!isFrd) {
|
||||
isFrd = await getFrd(roleId);
|
||||
@@ -200,7 +195,7 @@ export class ComBattleHandler {
|
||||
|
||||
// 加入队伍
|
||||
if (!validToJoin(teamStatus, roleId)) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
|
||||
let roleStatus = new RoleStatus(roleId, roleName, false, isFrd, head, frame, spine, topLineupCe, lv);
|
||||
let roleStatus = new RoleStatus(role, false, isFrd);
|
||||
const team = await ComBattleTeamModel.addRole(teamCode, roleStatus);
|
||||
if (!team) {
|
||||
return resResult(STATUS.COM_BATTLE_JOIN_ERR);
|
||||
@@ -243,51 +238,51 @@ export class ComBattleHandler {
|
||||
return resResult(STATUS.SUCCESS, { teamCode, isFrd });
|
||||
}
|
||||
|
||||
/**
|
||||
* ! 获取队伍列表-deprecated
|
||||
* @param msg
|
||||
* @param session
|
||||
*/
|
||||
async getTeams(msg: { blueprtIds: number[] }, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let { lv } = await Role.findByRoleId(roleId);
|
||||
if (lv < COM_BTL_CONST.ENABLE_LV) return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH);
|
||||
const teams = await ComBattleTeamModel.getTeamByBlueprt(msg.blueprtIds, COM_TEAM_STATUS.DEFAULT, true);
|
||||
if (!teams) return resResult(STATUS.COM_BATTLE_NO_VALID_TEAM);
|
||||
return resResult(STATUS.SUCCESS, { teamInfos: teams});
|
||||
}
|
||||
// /**
|
||||
// * ! 获取队伍列表-deprecated
|
||||
// * @param msg
|
||||
// * @param session
|
||||
// */
|
||||
// async getTeams(msg: { blueprtIds: number[] }, session: BackendSession) {
|
||||
// let roleId = session.get('roleId');
|
||||
// let { lv } = await Role.findByRoleId(roleId);
|
||||
// if (lv < COM_BTL_CONST.ENABLE_LV) return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH);
|
||||
// const teams = await ComBattleTeamModel.getTeamByBlueprt(msg.blueprtIds, COM_TEAM_STATUS.DEFAULT, true);
|
||||
// if (!teams) return resResult(STATUS.COM_BATTLE_NO_VALID_TEAM);
|
||||
// return resResult(STATUS.SUCCESS, { teamInfos: teams});
|
||||
// }
|
||||
|
||||
/**
|
||||
* ! deprecate
|
||||
* @description 队伍准备
|
||||
* @param {{teamCode: string, heroes: number[]}} msg
|
||||
* @param {BackendSession} session
|
||||
* @returns
|
||||
* @memberof ComBattleHandler
|
||||
*/
|
||||
async teammateReady(msg: {teamCode: string, heroes: number[]}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let { teamCode, heroes: hids } = msg;
|
||||
let teamStatus = this.teamMap.get(teamCode);
|
||||
if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
|
||||
// /**
|
||||
// * ! deprecate
|
||||
// * @description 队伍准备
|
||||
// * @param {{teamCode: string, heroes: number[]}} msg
|
||||
// * @param {BackendSession} session
|
||||
// * @returns
|
||||
// * @memberof ComBattleHandler
|
||||
// */
|
||||
// async teammateReady(msg: {teamCode: string, heroes: number[]}, session: BackendSession) {
|
||||
// let roleId = session.get('roleId');
|
||||
// let { teamCode, heroes: hids } = msg;
|
||||
// let teamStatus = this.teamMap.get(teamCode);
|
||||
// if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
|
||||
|
||||
const heroDBs = await HeroModel.findByHidRange(hids, roleId);
|
||||
const heroes = heroDBs.map(hero => {
|
||||
return new ComRoleStatusHero(hero);
|
||||
});
|
||||
// const heroDBs = await HeroModel.findByHidRange(hids, roleId);
|
||||
// const heroes = heroDBs.map(hero => {
|
||||
// return new ComRoleStatusHero(hero);
|
||||
// });
|
||||
|
||||
let team = await ComBattleTeamModel.updateHeroes(teamCode, roleId, heroes);
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_UPDATE_HEROES_ERR);
|
||||
// let team = await ComBattleTeamModel.updateHeroes(teamCode, roleId, heroes);
|
||||
// if (!team) return resResult(STATUS.COM_BATTLE_UPDATE_HEROES_ERR);
|
||||
|
||||
teamStatus.roleStatus.forEach(st => {
|
||||
if (st && st.roleId === roleId) {
|
||||
st.heroes = heroes;
|
||||
}
|
||||
});
|
||||
// teamStatus.roleStatus.forEach(st => {
|
||||
// if (st && st.roleId === roleId) {
|
||||
// st.heroes = heroes;
|
||||
// }
|
||||
// });
|
||||
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAMMATE_READY, {teamCode, roleId, heroes});
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
// sendMessageToTeam(teamCode, PUSH_ROUTE.TEAMMATE_READY, {teamCode, roleId, heroes});
|
||||
// return resResult(STATUS.SUCCESS);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @description 出兵时记录玩家阵容
|
||||
@@ -409,10 +404,8 @@ export class ComBattleHandler {
|
||||
if (teamStatus.capId !== roleId && teamStatus.capId !== 'robot') return resResult(STATUS.COM_BATTLE_CAP_ONLY);
|
||||
if (teamStatus.status !== COM_TEAM_STATUS.DEFAULT) return resResult(STATUS.COM_BATTLE_ALREADY_START);
|
||||
|
||||
teamStatus.status = COM_TEAM_STATUS.FIGHTING;
|
||||
teamStatus.endTime = nowSeconds() + COM_BTL_CONST.BTL_TIME_LMT/1000;
|
||||
|
||||
let team = await ComBattleTeamModel.updateStatusByCode(teamCode, COM_TEAM_STATUS.FIGHTING);
|
||||
teamStatus.startTeam();
|
||||
let team = await ComBattleTeamModel.updateStatusByCode(teamCode, teamStatus.status, teamStatus.startTime, teamStatus.endTime, teamStatus.hasTimeExtraReward);
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_START_ERR);
|
||||
|
||||
clearComBtlTimer(teamCode, this.teamDisTimer); // 战斗开始停止解散计时
|
||||
@@ -426,8 +419,6 @@ export class ComBattleHandler {
|
||||
clearRobotHurtTimer(teamStatus, this.robotHurtTimer);
|
||||
let team = await ComBattleTeamModel.syncTeamData({teamCode, status: COM_TEAM_STATUS.LOOSE, roleStatus: teamStatus.roleStatus, bossHpArr: teamStatus.bossHpArr}, true);
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||
// // 将藏宝图加回去
|
||||
// await addItems(roleId, roleName, sid, [{ id: team.blueprtId, count: 1 }])
|
||||
teamStatus.timeout = true;
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_COMPLETE, {teamCode, result: false, timeout: true});
|
||||
thiz.teamMap.delete(teamCode);
|
||||
@@ -507,32 +498,32 @@ export class ComBattleHandler {
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* ! 客户端给服务器的战斗结束通知-deprecated
|
||||
* @param msg
|
||||
* @param session
|
||||
*/
|
||||
async battleEnd(msg: {teamCode: string, isSuccess: boolean}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let { teamCode, isSuccess } = msg;
|
||||
let teamStatus = this.teamMap.get(teamCode);
|
||||
if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
|
||||
// /**
|
||||
// * ! 客户端给服务器的战斗结束通知-deprecated
|
||||
// * @param msg
|
||||
// * @param session
|
||||
// */
|
||||
// async battleEnd(msg: {teamCode: string, isSuccess: boolean}, session: BackendSession) {
|
||||
// let roleId = session.get('roleId');
|
||||
// let { teamCode, isSuccess } = msg;
|
||||
// let teamStatus = this.teamMap.get(teamCode);
|
||||
// if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) return resResult(STATUS.COM_BATTLE_TEAM_INVALID);
|
||||
|
||||
if (isSuccess && teamStatus.bossCurHp <= 0) {
|
||||
let team = await ComBattleTeamModel.updateResult(teamCode, roleId, isSuccess);
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_COMPLETE, {teamCode, result: isSuccess});
|
||||
} else if (!isSuccess) {
|
||||
let team = await ComBattleTeamModel.updateResult(teamCode, roleId, isSuccess);
|
||||
if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||
if (team.status === COM_TEAM_STATUS.LOOSE) {
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_COMPLETE, {teamCode, result: isSuccess});
|
||||
} else {
|
||||
sendMessageToTeam(teamCode, PUSH_ROUTE.TEAMMATE_ACT, {teamCode, bossCurHp: teamStatus.bossCurHp, roleStatus: {roleId, battleStatus: 2}});
|
||||
}
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { bossCurHp: teamStatus.bossCurHp });
|
||||
}
|
||||
// if (isSuccess && teamStatus.bossCurHp <= 0) {
|
||||
// let team = await ComBattleTeamModel.updateResult(teamCode, roleId, isSuccess);
|
||||
// if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||
// sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_COMPLETE, {teamCode, result: isSuccess});
|
||||
// } else if (!isSuccess) {
|
||||
// let team = await ComBattleTeamModel.updateResult(teamCode, roleId, isSuccess);
|
||||
// if (!team) return resResult(STATUS.COM_BATTLE_RESULT_ERR);
|
||||
// if (team.status === COM_TEAM_STATUS.LOOSE) {
|
||||
// sendMessageToTeam(teamCode, PUSH_ROUTE.TEAM_COMPLETE, {teamCode, result: isSuccess});
|
||||
// } else {
|
||||
// sendMessageToTeam(teamCode, PUSH_ROUTE.TEAMMATE_ACT, {teamCode, bossCurHp: teamStatus.bossCurHp, roleStatus: {roleId, battleStatus: 2}});
|
||||
// }
|
||||
// }
|
||||
// return resResult(STATUS.SUCCESS, { bossCurHp: teamStatus.bossCurHp });
|
||||
// }
|
||||
|
||||
/**
|
||||
* @description 寻宝结算
|
||||
@@ -563,25 +554,10 @@ export class ComBattleHandler {
|
||||
let warInfo = getWarByBlueprtId(blueprtId);
|
||||
if (!warInfo) return resResult(STATUS.BATTLE_MISS_INFO);
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let apJson = await setAp(serverId, roleId, ip, role.lv, -1 * warInfo.cost, sid, ITEM_CHANGE_REASON.COM_BATTLE_END); // 扣除体力
|
||||
if(!apJson) {
|
||||
return resResult(STATUS.BATTLE_ACTION_POINT_LACK);
|
||||
}
|
||||
|
||||
// const { dropResult } = await incEquipPrintDrop(roleSt);
|
||||
// if (dropResult) {
|
||||
// const dropEquipId = randEquipPrintId(warInfo);
|
||||
// if (dropEquipId) {
|
||||
// roleSt.fixReward.push({ id: dropEquipId, count: 1 });
|
||||
// }
|
||||
// }
|
||||
|
||||
await ComBattleTeamModel.updateRewardSt(teamCode, roleId, true);
|
||||
const goods = await addItems(roleId, roleName, sid, roleSt.fixReward, ITEM_CHANGE_REASON.COM_BATTLE_END);
|
||||
let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, warInfo.kingExp, session);// 主公升级经验
|
||||
const goods = await addItems(roleId, roleName, sid, roleSt.rewards, ITEM_CHANGE_REASON.COM_BATTLE_END);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { battleGoods: goods, ...actordata, teamInfo: {status, teamCode, roleStatus, bossHpArr} });
|
||||
return resResult(STATUS.SUCCESS, { teamInfo: {status, teamCode, roleStatus, bossHpArr} });
|
||||
}
|
||||
|
||||
async getComBtlStatus(msg: {teamCode: string}, session: BackendSession) {
|
||||
|
||||
@@ -155,7 +155,7 @@ export class NormalBattleHandler {
|
||||
return resResult(STATUS.BATTLE_MISS_INFO);
|
||||
}
|
||||
// 寻宝不使用通用战斗模块结算
|
||||
if (warInfo.warType == WAR_TYPE.WARLOARDS) {
|
||||
if (warInfo.warType == WAR_TYPE.COM_BATTLE) {
|
||||
return resResult(STATUS.BATTLE_END_WRONG_TYPE);
|
||||
}
|
||||
|
||||
|
||||
@@ -560,7 +560,7 @@ export function getRandRobot(cnt = 1, withAttr = false) {
|
||||
let setInfo = getRandExpedition(cnt);
|
||||
if (!setInfo || setInfo.length !== cnt) return null;
|
||||
|
||||
let robots = [];
|
||||
let robots: ComRoleStatusHero[][] = [];
|
||||
for (let info of setInfo) {
|
||||
if (!info || !info.warId) continue;
|
||||
const warInfo = gameData.warJson.get(info.warId);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { MemComBtlTeam } from './../domain/battleField/ComBattleTeamField';
|
||||
import { ItemModel } from './../db/Item';
|
||||
import { ITEM_CHANGE_REASON, IT_TYPE, PUSH_ROUTE } from './../consts';
|
||||
import { BATTLE_REWARD_TYPE, ITEM_CHANGE_REASON, IT_TYPE, PUSH_ROUTE } from './../consts';
|
||||
import { FriendRelationModel } from './../db/FriendRelation';
|
||||
import { RoleModel, RoleType } from './../db/Role';
|
||||
import { EquipPrintDropType, EquipPrintDropModel } from './../db/EquipPrintDrop';
|
||||
import { STATUS } from './../consts/statusCode';
|
||||
import { COM_TEAM_STATUS, FRIEND_DROP_TYPE, COM_BTL_CONST, FRIEND_DROP_MAX } from './../consts';
|
||||
import { RoleStatus, ComBattleTeamModel, ComBattleTeamType } from './../db/ComBattleTeam';
|
||||
import { RoleStatus, ComBattleTeamModel, ComBattleTeamType, ComBattleReward } from './../db/ComBattleTeam';
|
||||
import { getRandEelm, getRandValue, resResult, ratioReward, getRandValueByMinMax, getRandEelmWithWeight, getRobotInfo, getRandSingleEelm } from "../pubUtils/util";
|
||||
import { getRandRobot } from "./battleService";
|
||||
import { Channel, ChannelService, pinus } from 'pinus';
|
||||
@@ -16,9 +16,11 @@ import { getRoleIds } from '../pubUtils/friendUtil';
|
||||
import { getTeamSearchByLv, rmRoleFromQueue } from './redisService';
|
||||
import { getRewardByBlueprtId, gameData, getBossHpByBlueprtId, getDicBlueprtById } from '../pubUtils/data';
|
||||
import { getZeroPointD, nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { handleCost } from './role/rewardService';
|
||||
import { getFriendPointObject, handleCost } from './role/rewardService';
|
||||
import { addUserToTeamChannel, delTeamChannel, sendMessageToTeam, sendMessageToUsersWithSuc, sendMessageToUserWithSuc } from './pushService';
|
||||
import { checkTaskInComBattleEnd } from './task/taskService';
|
||||
import moment = require('moment');
|
||||
import { RewardInter } from '../pubUtils/interface';
|
||||
|
||||
/**
|
||||
* 在给定的品质列表中随机返回一定数量的藏宝图Id
|
||||
@@ -59,7 +61,12 @@ export function getRandComBtlRobots(topLineupCe: number, ceLimit: number, lv: nu
|
||||
if(robotLv > gameData.maxPlayerLv.max) robotLv = gameData.maxPlayerLv.max;
|
||||
// const imgHid = robot[Math.floor(Math.random() * robot.length)];
|
||||
const { robotRoleId, robotRoleName } = robotInfos[idx];
|
||||
let robotStatus = new RoleStatus(robotRoleId, robotRoleName, false, false, EXTERIOR.EXTERIOR_FACE, EXTERIOR.EXTERIOR_FACECASE, EXTERIOR.EXTERIOR_APPEARANCE, robotCe, robotLv, robot, true);
|
||||
let robotStatus = new RoleStatus({
|
||||
roleId: robotRoleId,
|
||||
roleName: robotRoleName,
|
||||
ce: robotCe,
|
||||
lv: robotLv
|
||||
}, false, false, robot, true);
|
||||
robotStArr.push(robotStatus);
|
||||
robotIdArr.push(robotRoleId);
|
||||
});
|
||||
@@ -104,35 +111,35 @@ export function checkComBattleResult(teamStatus) {
|
||||
return COM_TEAM_STATUS.FIGHTING;
|
||||
}
|
||||
|
||||
/**
|
||||
* ! deprecated
|
||||
* @description 计算寻宝结算
|
||||
* @export
|
||||
* @param {string} roleId
|
||||
* @param {string} battleCode
|
||||
* @returns
|
||||
*/
|
||||
export async function checkComBattleDrop(roleId: string, battleCode: string) {
|
||||
let team = await ComBattleTeamModel.getTeamByRoleAndBattleCode(roleId, battleCode);
|
||||
if (team.status !== COM_TEAM_STATUS.WIN) return { status: -1, resResult: resResult(STATUS.COM_BATTLE_REWARD_ERR) };
|
||||
let roleSt = null;
|
||||
team.roleStatus.forEach(st => {
|
||||
if (st.roleId === roleId) {
|
||||
roleSt = st;
|
||||
}
|
||||
});
|
||||
if (!roleSt || roleSt.gotReward) return { status: -1, resResult: resResult(STATUS.COM_BATTLE_REWARD_ERR) };
|
||||
let { fixReward, teammateReward } = getRewardByBlueprtId(team.blueprtId);
|
||||
if (!roleSt.isCap) {
|
||||
if (roleSt.isFrd) {
|
||||
fixReward = [];
|
||||
} else {
|
||||
fixReward = teammateReward;
|
||||
}
|
||||
}
|
||||
await ComBattleTeamModel.updateRewardSt(team.teamCode, roleId, true);
|
||||
return { status: 0, fixReward };
|
||||
}
|
||||
// /**
|
||||
// * ! deprecated
|
||||
// * @description 计算寻宝结算
|
||||
// * @export
|
||||
// * @param {string} roleId
|
||||
// * @param {string} battleCode
|
||||
// * @returns
|
||||
// */
|
||||
// export async function checkComBattleDrop(roleId: string, battleCode: string) {
|
||||
// let team = await ComBattleTeamModel.getTeamByRoleAndBattleCode(roleId, battleCode);
|
||||
// if (team.status !== COM_TEAM_STATUS.WIN) return { status: -1, resResult: resResult(STATUS.COM_BATTLE_REWARD_ERR) };
|
||||
// let roleSt = null;
|
||||
// team.roleStatus.forEach(st => {
|
||||
// if (st.roleId === roleId) {
|
||||
// roleSt = st;
|
||||
// }
|
||||
// });
|
||||
// if (!roleSt || roleSt.gotReward) return { status: -1, resResult: resResult(STATUS.COM_BATTLE_REWARD_ERR) };
|
||||
// let { fixReward, teammateReward } = getRewardByBlueprtId(team.blueprtId);
|
||||
// if (!roleSt.isCap) {
|
||||
// if (roleSt.isFrd) {
|
||||
// fixReward = [];
|
||||
// } else {
|
||||
// fixReward = teammateReward;
|
||||
// }
|
||||
// }
|
||||
// await ComBattleTeamModel.updateRewardSt(team.teamCode, roleId, true);
|
||||
// return { status: 0, fixReward };
|
||||
// }
|
||||
|
||||
export function clearComBtlTimer(teamCode: string, timerMap: Map<string, NodeJS.Timer>) {
|
||||
let timer = timerMap.get(teamCode);
|
||||
@@ -149,16 +156,35 @@ export function setComBtlTimer(teamCode: string, timer: NodeJS.Timer, timerMap:
|
||||
timerMap.set(teamCode, timer);
|
||||
}
|
||||
|
||||
export async function getRealReward(blueprtId: number, roleSt: RoleStatus) {
|
||||
let { fixReward, teammateReward } = getRewardByBlueprtId(blueprtId);
|
||||
if (!roleSt.isCap) {
|
||||
export async function getRealReward(blueprtId: number, roleSts: RoleStatus[], roleSt: RoleStatus, hasTimeExtraReward: boolean): Promise<ComBattleReward[]> {
|
||||
let dicReward = getRewardByBlueprtId(blueprtId);
|
||||
if(!dicReward) return [];
|
||||
|
||||
let fixRewards: RewardInter[], extraRewards: RewardInter[];
|
||||
if (roleSt.isCap) {
|
||||
fixRewards.push(...dicReward.captainReward);
|
||||
} else {
|
||||
if (roleSt.isFrd) {
|
||||
fixReward = []
|
||||
fixRewards.push(getFriendPointObject(TREASURE.REWARD_FRIENDPOINT));
|
||||
} else {
|
||||
fixReward = teammateReward;
|
||||
fixRewards.push(...dicReward.teammateReward)
|
||||
}
|
||||
}
|
||||
return fixReward;
|
||||
if(hasTimeExtraReward) {
|
||||
let sameGuildCnt = roleSts.filter(cur => cur.guildCode == roleSt.guildCode && cur.roleId != roleSt.roleId).length;
|
||||
if(sameGuildCnt > 0) {
|
||||
let dicGuildReward = roleSt.isCap? dicReward.captainTimeGuildReward: dicReward.teammateTimeGuildReward;
|
||||
let guildRewards = dicGuildReward.get(sameGuildCnt)||[]
|
||||
extraRewards.push(...guildRewards);
|
||||
} else {
|
||||
let guildRewards = roleSt.isCap? dicReward.captainTimeReward: dicReward.teammateTimeReward;
|
||||
extraRewards.push(...guildRewards);
|
||||
}
|
||||
}
|
||||
return [
|
||||
...fixRewards.map(reward => ({ type: BATTLE_REWARD_TYPE.FIX_REWARD, ...reward })),
|
||||
...extraRewards.map(reward => ({ type: BATTLE_REWARD_TYPE.EXTRA_REWARD, ...reward }))
|
||||
]
|
||||
}
|
||||
|
||||
export async function getAllAssistCnt(roleId: string) {
|
||||
@@ -225,7 +251,7 @@ export async function handleComBtlProgress(teamStatus: MemComBtlTeam, robotHurtT
|
||||
bs.curHp = 0;
|
||||
});
|
||||
for (let st of teamStatus.roleStatus) {
|
||||
st.fixReward = await getRealReward(teamStatus.blueprtId, st);
|
||||
st.rewards = await getRealReward(teamStatus.blueprtId, teamStatus.roleStatus, st, teamStatus.hasTimeExtraReward);
|
||||
};
|
||||
await checkTaskInComBattleEnd(teamStatus.roleStatus, teamStatus.capId);
|
||||
}
|
||||
@@ -427,13 +453,12 @@ async function teammateValid(roleInfo: Partial<RoleType>, roleId: string, roleId
|
||||
*/
|
||||
export async function getValidTeammateRoleSt(roleId: string, roleIds: string[], ceLimit: number) {
|
||||
let roleInfo = await RoleModel.findByRoleId(roleId, null, true);
|
||||
let { roleName, head = EXTERIOR.EXTERIOR_FACE, frame = EXTERIOR.EXTERIOR_FACECASE, spine = EXTERIOR.EXTERIOR_APPEARANCE, topLineupCe, lv: playerLv } = roleInfo;
|
||||
|
||||
const valid = await teammateValid(roleInfo, roleId, roleIds, ceLimit);
|
||||
if (!valid) return null;
|
||||
|
||||
let isFrd = await getFrd(roleId);
|
||||
const result = new RoleStatus(roleId, roleName, false, isFrd, head, frame, spine, topLineupCe, playerLv);
|
||||
const result = new RoleStatus(roleInfo, false, isFrd);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -485,9 +510,7 @@ export async function hasEnoughBlueprt(roleId: string, sid: string, blueprtId: n
|
||||
* @param {boolean} isFrd
|
||||
*/
|
||||
export function addRoleToTeam(comTeam: MemComBtlTeam, roleInfo: RoleType, isCap: boolean, isFrd: boolean) {
|
||||
const { roleId, roleName, head = EXTERIOR.EXTERIOR_FACE, frame = EXTERIOR.EXTERIOR_FACECASE, spine = EXTERIOR.EXTERIOR_APPEARANCE, lv } = roleInfo;
|
||||
let { topLineupCe = 1000 } = roleInfo;
|
||||
const roleSt = new RoleStatus(roleId, roleName, isCap, isFrd, head, frame, spine, topLineupCe, lv);
|
||||
const roleSt = new RoleStatus(roleInfo, isCap, isFrd);
|
||||
addRoleStToTeam(comTeam, roleSt);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user