diff --git a/game-server/app/servers/activity/handler/gachaHandler.ts b/game-server/app/servers/activity/handler/gachaHandler.ts index 8ec8b3ab2..69bb84e7d 100644 --- a/game-server/app/servers/activity/handler/gachaHandler.ts +++ b/game-server/app/servers/activity/handler/gachaHandler.ts @@ -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); diff --git a/game-server/app/services/comBattleService.ts b/game-server/app/services/comBattleService.ts index f14e37a16..f52c73850 100644 --- a/game-server/app/services/comBattleService.ts +++ b/game-server/app/services/comBattleService.ts @@ -260,7 +260,7 @@ export async function handleComBtlProgress(teamStatus, robotHurtTimer: Map {}), capId, quality); + await checkTaskInComBattleEnd(teamStatus.roleStatus, capId, quality); teamMap.delete(teamCode); } diff --git a/game-server/app/services/gachaService.ts b/game-server/app/services/gachaService.ts index 401d1cbdb..de8b56dc1 100644 --- a/game-server/app/services/gachaService.ts +++ b/game-server/app/services/gachaService.ts @@ -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(); - 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 diff --git a/game-server/app/services/taskService.ts b/game-server/app/services/taskService.ts index 251a51403..55931fc71 100644 --- a/game-server/app/services/taskService.ts +++ b/game-server/app/services/taskService.ts @@ -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 }); } } diff --git a/shared/domain/activityField/gachaField.ts b/shared/domain/activityField/gachaField.ts index 79f8d176a..b30feab21 100644 --- a/shared/domain/activityField/gachaField.ts +++ b/shared/domain/activityField/gachaField.ts @@ -4,9 +4,9 @@ import { prop } from '@typegoose/typegoose'; import { UserGachaType } from '../../db/UserGacha'; import { getAfterDateByDay } from '../../pubUtils/timeUtil'; import { DicGacha } from '../../pubUtils/dictionary/DicGacha'; -import { getFloorStatus } from '../../services/gachaService'; import { GACHA_OCCUPY_HID } from '../../consts'; import { gameData } from '../../pubUtils/data'; +import { getFloorStatus } from '../../pubUtils/util'; // 抽卡数据 diff --git a/shared/pubUtils/taskUtil.ts b/shared/pubUtils/taskUtil.ts index 86c4a04e7..39c519c18 100644 --- a/shared/pubUtils/taskUtil.ts +++ b/shared/pubUtils/taskUtil.ts @@ -310,7 +310,7 @@ export async function checkTask(roleId: string, taskType: number, count: number, let rec = await checkTaskRec(roleId, type, group, task0, count, isInc, param, funcs); if (rec) { for (let dicTask of tasks) { - if (checkRecResult(rec, dicTask.id, dicTask.condition)) { + if (checkRecResult(rec, dicTask.id)) { let received = rec.received || []; pushMessage.push({ type: dicTask.type, id: dicTask.id, count: rec.count, received: received.includes(dicTask.id) }); } @@ -458,7 +458,7 @@ function checkHero(taskParam: number[], index: number, heroes: number[]) { return heroes.indexOf(hid) != -1; } -function checkRecResult(rec: UserTaskRecType, id: number, condition: number) { +function checkRecResult(rec: UserTaskRecType, id: number) { if (!rec) return false; if (rec.received && rec.received.includes(id)) return false; // 已领取,不再推送 diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index f2203d1c4..69e35ce32 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -4,10 +4,11 @@ import { HeroModel, HeroType } from '../db/Hero'; import fs = require('fs'); import path = require('path'); -import { HERO_CE_RATIO, ABI_STAGE } from '../consts'; +import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR } from '../consts'; import { findIndex } from 'underscore'; import { getWeekDate } from './timeUtil'; +import { Floor } from '../domain/activityField/gachaField'; const randomName = require("chinese-random-name"); const moment = require('moment'); const crypto = require('crypto'); @@ -640,4 +641,24 @@ export function splitString(dataString: string, key: string) { numberArray.push(Number(num)); } return numberArray; +} + + +/** + * @description 获取抽卡保底状态 + * @param gachaId 招募类型 + * @param floor 玩家保底 + */ +export function getFloorStatus(gachaId: number, floor: Floor[]) { + let floorMap = new Map(); + 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 + } + }); } \ No newline at end of file