任务:修复共斗任务达成

This commit is contained in:
luying
2021-04-25 18:10:40 +08:00
parent 5e43bcfe83
commit cbc58f8a7a
7 changed files with 43 additions and 38 deletions

View File

@@ -74,8 +74,8 @@ export class GachaHandler {
if (!dicGacha.count.includes(count)) return resResult(STATUS.WRONG_PARMS);
let userGacha = await UserGachaModel.findByRole(roleId, gachaId, activityId);
let { floor, freeCount, hope, point, pickHero, refFreeTime } = await refreshGacha(dicGacha, userGacha);
if ((gachaId == GACHA_ID.ASSIGN || gachaId == GACHA_ID.TIMELIMIT) && !pickHero) return resResult(STATUS.GACHA_NOT_ASSIGN);
let { floor, freeCount, hope, point, pickHero, refFreeTime, count: historyCount } = await refreshGacha(dicGacha, userGacha);
if((gachaId == GACHA_ID.ASSIGN|| gachaId == GACHA_ID.TIMELIMIT) && !pickHero) return resResult(STATUS.GACHA_NOT_ASSIGN);
let userHeroes = await HeroModel.findByRole(roleId);
@@ -98,7 +98,7 @@ export class GachaHandler {
heroInfo.push({ hid: result.hid, count: 1 })//默认1个英雄
}
} else {
items.push({ id: result.id, count });
items.push({ id: result.id, count: result.count });
}
resultList.push(result);
}
@@ -123,9 +123,9 @@ export class GachaHandler {
let { heroes } = await createHeroes(roleId, roleName, sid, serverId, funcs, heroInfo);
await addItems(roleId, roleName, sid, items);
// 更新数据
point = Math.floor(count / RECRUIT.RECRUIT_BONUS);
point = Math.floor((historyCount + 1)/RECRUIT.RECRUIT_BONUS);
userGacha = await UserGachaModel.updateInfo(roleId, gachaId, activityId, {
freeCount, hope, floor, count, point
freeCount, hope, floor, count: historyCount + 1, point
});
await UserGachaRecModel.createRec(roleId, gachaId, activityId, count, resultList);

View File

@@ -260,7 +260,7 @@ export async function handleComBtlProgress(teamStatus, robotHurtTimer: Map<strin
channel.pushMessage('onTeamComplete', resResult(STATUS.SUCCESS, {teamCode, result}));
// 任务
await checkTaskInComBattleEnd(roleIds.filter(roleId => {}), capId, quality);
await checkTaskInComBattleEnd(teamStatus.roleStatus, capId, quality);
teamMap.delete(teamCode);
}

View File

@@ -49,25 +49,6 @@ export async function refreshGacha(dicGacha: DicGacha, userGacha: UserGachaType)
return userGacha
}
/**
* @description 获取保底状态
* @param gachaId 招募类型
* @param floor 玩家保底
*/
export function getFloorStatus(gachaId: number, floor: Floor[]) {
let floorMap = new Map<number, number>();
for(let { id, count } of floor) {
floorMap.set(id, count);
}
let dicFloorType = GACHA_TO_FLOOR.get(gachaId);
return dicFloorType.map(id => {
return {
id,
count: floorMap.get(id)||0
}
});
}
/**
* @description 获得保底结果
* @param gachaId 招募表id

View File

@@ -14,6 +14,7 @@ import { UserTaskRecModel } from '../db/UserTaskRec';
import { UserTaskHistoryModel } from '../db/UserTaskHistory';
import { gameData } from '../pubUtils/data';
import { getCurWeekDate, getSeconds } from '../pubUtils/timeUtil';
import { RoleStatus } from '../db/ComBattleTeam';
export async function checkTaskWithRoles(roleId: string, sid: string, funcs: number[], taskType: number, roles: RoleType[]) {
for (let role of roles) {
@@ -91,16 +92,18 @@ export async function checkTaskInBattleEnd(roleId: string, sid: string, funcs: n
}
export async function checkTaskInComBattleEnd(roleIds: string[], capId: string, quality: number) {
console.log('********', roleIds, capId, quality)
for (let roleId of roleIds) {
if (roleId == capId && roleIds.length > 1) { // 招募队友
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_CREATE_TEAM, 1, true, {});
} else if (roleId !== capId) { // 协助寻宝
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_ASSIST_TEAM, 1, true, {});
export async function checkTaskInComBattleEnd(roleStatus: RoleStatus[], capId: string, quality: number) {
console.log('********', JSON.stringify(roleStatus), capId, quality)
for (let { roleId, isRobot } of roleStatus) {
if(!isRobot) {
if (roleId == capId && roleStatus.length > 1) { // 招募队友
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_CREATE_TEAM, 1, true, {});
} else if (roleId !== capId) { // 协助寻宝
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_ASSIST_TEAM, 1, true, {});
}
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE, 1, true, {});
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_QUALITY, 1, true, { quality });
}
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE, 1, true, {});
await checkTask(roleId, null, null, TASK_TYPE.COM_BATTLE_QUALITY, 1, true, { quality });
}
}