寻宝:奖励
This commit is contained in:
@@ -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