diff --git a/game-server/app/servers/activity/handler/activityHandler.ts b/game-server/app/servers/activity/handler/activityHandler.ts index cfbb7344e..524ca6ec1 100644 --- a/game-server/app/servers/activity/handler/activityHandler.ts +++ b/game-server/app/servers/activity/handler/activityHandler.ts @@ -1,7 +1,6 @@ import { Application, BackendSession, HandlerService, pinus, } from 'pinus'; import { aesEncrypt, aesEncryptcfb, resResult } from '../../../pubUtils/util'; import { ENCRYPT_IV, ENCRYPT_KEY, STATUS, TASK_TYPE } from '../../../consts'; -import { checkActivityTask } from '../../../services/task/taskService'; import { ActivityGroupModel } from '../../../db/ActivityGroup'; import { ServerlistModel } from '../../../db/Serverlist'; import { getActivity, getActivityById } from '../../../services/activity/activityService'; @@ -58,50 +57,6 @@ export class ActivityHandler { return resResult(STATUS.SUCCESS, { playerActivityArray, playerGroupArray }); } - //测试活动任务数据 - async testActivityTask(msg: { hid: number, lv: number }, session: BackendSession) { - const { lv } = msg; - const roleId = session.get('roleId'); - const serverId = session.get('serverId'); - const sid: string = session.get('sid'); - - - let heroNum = 1; - // await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_QUALITY, heroNum, { heroes: [{ quality: 3 }] }) - // await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT, 1, { oldQuality: 1, quality: 2 }) - // await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_WAKE_UP_STAR_UP_COUNT, 1, { quality: 1, colorStar: 1 }) - // await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_MAIN_ELITE, 1, { mainEliteWarId: 9001 }) - // await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_DUNGEON_WAR, 1, { warId: 5001 }) - // await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_EXPEDITION_BOX, 1) - // await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_LV, 100) - // await checkActivityTask(serverId, sid, roleId, TASK_TYPE.PVP, 1) - - // await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_TOWER_LV, 1, { towerLv: lv }) - // await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GACHA, 1) - - // if (lv == 2) { - // await GTCreateListMessage('批量推送测试11', 259200000, '哈哈哈哈哈11', '噢噢噢噢噢噢噢噢11') - // } - // if (lv == 3) { - // await GTPushListCidMessage('RASL_0630_da707a0c484d4ee39f2d462d5f52984', ['ba64ee9a9d516bbd341267d685baceb4'], true); - // } - // if (lv == 1) { - // await GTPushSingleCidMessage('ba64ee9a9d516bbd341267d685baceb4', 259200000, '哈哈哈哈哈', '噢噢噢噢噢噢噢噢'); - // } - // let beginTime = 1624050000000; - // let interval = 86400; - // console.log('ddddddbbbbbbbbbbbbbb', moment(new Date).valueOf(), (moment(new Date).valueOf() - beginTime), ((moment(new Date).valueOf() - beginTime) % (interval * 1000)), 24 * 60 * 60 * 1000, ((moment(new Date).valueOf() - beginTime) % (interval * 1000)) / (24 * 60 * 60 * 1000)) - // let aaa = Math.ceil(((moment(new Date).valueOf() - beginTime) / (24 * 60 * 60 * 1000))); - // console.log('xxxxxxxxxxxxxxxxxxx', aaa); - //aesEncryptcfb - console.log('13121622738', await aesEncryptcfb("13121622738", ENCRYPT_KEY, ENCRYPT_IV)) - //18612532385:cc80b189dc03cff31fe75d - //13636354764:cc8bb18bd805c9f51be95c,Z6ArLdom2c - //13121622738:cc8bb68adf00cef31bec50 - return resResult(STATUS.SUCCESS,); - - } - async debugActivityMemory(msg: {}, session: BackendSession) { const { } = msg; const roleId = session.get('roleId'); diff --git a/game-server/app/servers/activity/handler/dailyCoinHandler.ts b/game-server/app/servers/activity/handler/dailyCoinHandler.ts index 64c2c0190..60d1c5a74 100644 --- a/game-server/app/servers/activity/handler/dailyCoinHandler.ts +++ b/game-server/app/servers/activity/handler/dailyCoinHandler.ts @@ -1,14 +1,13 @@ import { Application, BackendSession, HandlerService } from 'pinus'; import { resResult } from '../../../pubUtils/util'; import { ACTIVITY_RESOURCES_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, ITEM_CHANGE_REASON, STATUS } from '../../../consts'; -import { handleCost } from '../../../services/role/rewardService'; +import { getGoldObject, handleCost } from '../../../services/role/rewardService'; import { getPlayerDailyCoinData, mergeData } from '../../../services/activity/dailyCoinService'; import { ConsumeExchangeFormulaItem, CoinRewardFormulaItem } from '../../../domain/activityField/dailyCoinField'; import { ActivityDailyCoinModel } from '../../../db/ActivityDailyCoin'; import { addReward, stringToRewardParam } from '../../../services/activity/giftPackageService'; import { RewardParam } from '../../../domain/activityField/rewardField'; import { ItemInter } from '../../../pubUtils/interface'; -import { getGoldObject } from '../../../pubUtils/itemUtils'; import { RoleModel } from '../../../db/Role'; import moment = require('moment'); diff --git a/game-server/app/servers/activity/handler/gachaHandler.ts b/game-server/app/servers/activity/handler/gachaHandler.ts index d14e743c0..b16022965 100644 --- a/game-server/app/servers/activity/handler/gachaHandler.ts +++ b/game-server/app/servers/activity/handler/gachaHandler.ts @@ -7,12 +7,13 @@ import { UserGachaModel } from "../../../db/UserGacha"; import { refreshGacha, getGachaList, getVisitedHeroList, getAllHeroByQuality, GachaPull } from "../../../services/activity/gachaService"; import { RoleModel } from "../../../db/Role"; import { HeroModel } from "../../../db/Hero"; -import { handleCost, createHeroes, addItems } from "../../../services/role/rewardService"; +import { handleCost, addItems } from "../../../services/role/rewardService"; import { getZeroPointD, getTimeFun } from "../../../pubUtils/timeUtil"; import { UserGachaRecModel } from "../../../db/UserGachaRec"; import { RECRUIT } from "../../../pubUtils/dicParam"; import { getActivityById } from "../../../services/activity/activityService"; import { checkTaskInGacha } from "../../../services/task/taskService"; +import { createHeroes } from "../../../services/role/createHero"; export default function (app: Application) { new HandlerService(app, {}); diff --git a/game-server/app/servers/activity/handler/luckyTurntableHandler.ts b/game-server/app/servers/activity/handler/luckyTurntableHandler.ts index 68c3b4d62..b49a81329 100644 --- a/game-server/app/servers/activity/handler/luckyTurntableHandler.ts +++ b/game-server/app/servers/activity/handler/luckyTurntableHandler.ts @@ -2,7 +2,7 @@ import { Application, BackendSession, HandlerService, } from 'pinus'; import { resResult } from '../../../pubUtils/util'; import { ITEM_CHANGE_REASON, STATUS } from '../../../consts'; import { getPlayerLuckyTurntableDataShow, getPlayerLuckyTurntableData } from '../../../services/activity/luckyTurntableService'; -import { addItems, combineItems, handleCost } from '../../../services/role/rewardService'; +import { addItems, handleCost } from '../../../services/role/rewardService'; import { ActivityTurntableModel } from '../../../db/ActivityTurntableRec'; import { pick } from 'underscore'; import { addReward, stringToRewardInter, stringToRewardParam } from '../../../services/activity/giftPackageService'; diff --git a/game-server/app/servers/activity/handler/newHeroGachaHandler.ts b/game-server/app/servers/activity/handler/newHeroGachaHandler.ts index f6f85a2a5..fd80a7212 100644 --- a/game-server/app/servers/activity/handler/newHeroGachaHandler.ts +++ b/game-server/app/servers/activity/handler/newHeroGachaHandler.ts @@ -5,10 +5,11 @@ import { getPlayerNewHeroGachaData } from '../../../services/activity/newHeroGac import { RoleModel } from '../../../db/Role'; import { HeroModel } from '../../../db/Hero'; import { GachaPull } from '../../../services/activity/gachaService'; -import { addItems, createHeroes, handleCost } from '../../../services/role/rewardService'; +import { addItems, handleCost } from '../../../services/role/rewardService'; import { ActivityNewHeroGachaModel } from '../../../db/ActivityNewHeroGacha'; import { addReward, stringToRewardParam } from '../../../services/activity/giftPackageService'; import { RewardParam } from '../../../domain/activityField/rewardField'; +import { createHeroes } from '../../../services/role/createHero'; export default function (app: Application) { diff --git a/game-server/app/servers/activity/handler/timeLimitRankHandler.ts b/game-server/app/servers/activity/handler/timeLimitRankHandler.ts index 22576c73e..5b8b781fc 100644 --- a/game-server/app/servers/activity/handler/timeLimitRankHandler.ts +++ b/game-server/app/servers/activity/handler/timeLimitRankHandler.ts @@ -1,10 +1,7 @@ import { Application, BackendSession, HandlerService, } from 'pinus'; import { resResult } from '../../../pubUtils/util'; import { DEBUG_MAGIC_WORD, getRedisKeyByRankType, HERO_SELECT, ITEM_CHANGE_REASON, RANK_TYPE, ROLE_SELECT, STATUS } from '../../../consts'; -import { addItems, combineItems, handleCost } from '../../../services/role/rewardService'; -import { ActivityTurntableModel } from '../../../db/ActivityTurntableRec'; import { pick } from 'underscore'; -import { addReward, stringToRewardInter, stringToRewardParam } from '../../../services/activity/giftPackageService'; import { getTimeLimitRankData, getTimeLimitRankDataShow, sendRankMail, takeSnapshot } from '../../../services/activity/timeLimitRankService'; import { getRankInHandler, Rank } from '../../../services/rankService'; import { getActivityById } from '../../../services/activity/activityService'; diff --git a/game-server/app/servers/battle/handler/comBattleHandler.ts b/game-server/app/servers/battle/handler/comBattleHandler.ts index b113c472b..bd0c4ff6b 100644 --- a/game-server/app/servers/battle/handler/comBattleHandler.ts +++ b/game-server/app/servers/battle/handler/comBattleHandler.ts @@ -24,7 +24,7 @@ import { pushComBtlTeamMsg, pushFriendTeamInviteMsg, pushNormalItemMsg, pushTeam import { EXTERIOR } from '../../../pubUtils/dicParam'; import { getZeroPointD, getTimeFunD, getSeconds, nowSeconds } from '../../../pubUtils/timeUtil'; import { FriendParams } from '../../../domain/roleField/friend'; -import { checkActivityTask, checkTask, checkTaskInComBattleStart, checkTaskWithArgs, checkTaskWithGoods } from '../../../services/task/taskService'; +import { checkTask, checkTaskInComBattleStart } from '../../../services/task/taskService'; import { gameData, getWarByBlueprtId } from '../../../pubUtils/data'; import { HeroModel } from '../../../db/Hero'; @@ -461,7 +461,7 @@ export class ComBattleHandler { updateRobotHurtByTime(teamStatus, st, COM_BTL_CONST.ROBOT_BASE_TIME_INTERVAL + idx, channel, this.robotHurtTimer, this.teamMap); } }); - await checkTaskInComBattleStart(teamStatus.roleStatus, teamStatus.capId); + await checkTaskInComBattleStart(teamStatus.roleStatus, teamStatus.capId, teamStatus.blueprtId); return resResult(STATUS.SUCCESS); } @@ -565,6 +565,7 @@ export class ComBattleHandler { let roleName = session.get('roleName'); let sid = session.get('sid'); let ip = session.get('ip'); + let serverId = session.get('serverId'); let { teamCode } = msg; let team = await ComBattleTeamModel.getTeamByCode(teamCode); @@ -582,7 +583,7 @@ export class ComBattleHandler { if (!warInfo) return resResult(STATUS.BATTLE_MISS_INFO); let role = await RoleModel.findByRoleId(roleId, 'lv'); - let apJson = await setAp(roleId, ip, role.lv, -1 * warInfo.cost, sid, ITEM_CHANGE_REASON.COM_BATTLE_END); // 扣除体力 + 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); } @@ -598,8 +599,6 @@ export class ComBattleHandler { 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);// 主公升级经验 - // 任务 - await checkTaskWithGoods(roleId, sid, TASK_TYPE.COM_BATTLE_DROP, goods); return resResult(STATUS.SUCCESS, { battleGoods: goods, ...actordata, teamInfo: {status, teamCode, roleStatus, bossHpArr} }); } @@ -692,7 +691,7 @@ export class ComBattleHandler { } // 任务 - await checkTaskWithArgs(serverId, roleId, sid, TASK_TYPE.CHAT, { chatType: getChannelType(CHANNEL_PREFIX.TEAM) }); + await checkTask(serverId, roleId, sid, TASK_TYPE.CHAT, { chatType: getChannelType(CHANNEL_PREFIX.TEAM) }); return resResult(STATUS.SUCCESS); } diff --git a/game-server/app/servers/battle/handler/dailyBattleHandler.ts b/game-server/app/servers/battle/handler/dailyBattleHandler.ts index 616333602..0a93e82f2 100644 --- a/game-server/app/servers/battle/handler/dailyBattleHandler.ts +++ b/game-server/app/servers/battle/handler/dailyBattleHandler.ts @@ -4,8 +4,7 @@ import { STATUS } from '../../../consts/statusCode'; import { resResult } from '../../../pubUtils/util'; import { RoleModel } from '../../../db/Role'; import { getDailyNum, getDailyBattleList, getDailyBuyCountCost } from '../../../services/dailyBattleService'; -import { handleCost } from '../../../services/role/rewardService'; -import { getGoldObject } from '../../../pubUtils/itemUtils'; +import { getGoldObject, handleCost } from '../../../services/role/rewardService'; import { gameData } from '../../../pubUtils/data'; import { DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON } from '../../../consts'; diff --git a/game-server/app/servers/battle/handler/dungeonBattleHandler.ts b/game-server/app/servers/battle/handler/dungeonBattleHandler.ts index 437b91629..48fbc6f51 100644 --- a/game-server/app/servers/battle/handler/dungeonBattleHandler.ts +++ b/game-server/app/servers/battle/handler/dungeonBattleHandler.ts @@ -2,8 +2,7 @@ import { Application, BackendSession } from 'pinus'; import { STATUS } from '../../../consts/statusCode'; import { resResult, shouldRefresh } from '../../../pubUtils/util'; import { RoleModel } from '../../../db/Role'; -import { handleCost } from '../../../services/role/rewardService'; -import { getGoldObject } from '../../../pubUtils/itemUtils'; +import { getGoldObject, handleCost } from '../../../services/role/rewardService'; import { getDungeonData, getDungeonBuyCountCost } from '../../../services/dungeonService'; import * as dicParam from '../../../pubUtils/dicParam'; import { DungeonFirstModel } from '../../../db/DungeonFirst'; diff --git a/game-server/app/servers/battle/handler/eventBattleHandler.ts b/game-server/app/servers/battle/handler/eventBattleHandler.ts index 40fa3ae93..6c6289f25 100644 --- a/game-server/app/servers/battle/handler/eventBattleHandler.ts +++ b/game-server/app/servers/battle/handler/eventBattleHandler.ts @@ -6,7 +6,7 @@ import { checkEventStatus, getEventSuccessStatus, getEvent, checkQuiz, startEven import { addItems } from '../../../services/role/rewardService'; import { STATUS } from '../../../consts/statusCode'; import { resResult } from '../../../pubUtils/util'; -import { checkActivityTask, checkTask } from '../../../services/task/taskService'; +import { checkTask } from '../../../services/task/taskService'; import { gameData } from '../../../pubUtils/data'; export default function (app: Application) { @@ -123,9 +123,7 @@ export class EventBattleHandler { // 推送消息刷新 // await checkEvent(session, true); // 任务 - await checkTask(roleId, sid, TASK_TYPE.BATTLE_EVENT, 1, true, { eventType: dicEvent.eventType }) - // 活动任务 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_EVENT, 1, { eventType: dicEvent.eventType }) + await checkTask(serverId, roleId, sid, TASK_TYPE.BATTLE_EVENT, { eventType: dicEvent.eventType }); return resResult(STATUS.SUCCESS, { isSuccess, eventCode: result.eventCode, diff --git a/game-server/app/servers/battle/handler/expeditionBattleHandler.ts b/game-server/app/servers/battle/handler/expeditionBattleHandler.ts index 93e69d710..ae52159ee 100644 --- a/game-server/app/servers/battle/handler/expeditionBattleHandler.ts +++ b/game-server/app/servers/battle/handler/expeditionBattleHandler.ts @@ -13,7 +13,7 @@ import { getAp, setAp } from '../../../services/actionPointService'; import { STATUS } from '../../../consts/statusCode'; import { resResult } from '../../../pubUtils/util'; import { calculateWarStar, checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService'; -import { checkActivityTask, checkTask, checkTaskInBattleEnd } from '../../../services/task/taskService'; +import { checkTask, checkTaskInBattleEnd } from '../../../services/task/taskService'; import { gameData } from '../../../pubUtils/data'; import * as dicParam from '../../../pubUtils/dicParam'; import { getSeconds, nowSeconds } from '../../../pubUtils/timeUtil'; @@ -209,7 +209,7 @@ export class ExpeditionBattleHandler { } let role = await RoleModel.findByRoleId(roleId, 'lv'); - let apJson = await setAp(roleId, ip, role.lv, isSuccess?-1 * warInfo.cost: 0, sid, ITEM_CHANGE_REASON.EXPEDITION_BATTLE_END); // 扣除体力 + let apJson = await setAp(serverId, roleId, ip, role.lv, isSuccess?-1 * warInfo.cost: 0, sid, ITEM_CHANGE_REASON.EXPEDITION_BATTLE_END); // 扣除体力 if (!apJson) { return resResult(STATUS.BATTLE_ACTION_POINT_LACK); } @@ -315,8 +315,7 @@ export class ExpeditionBattleHandler { let pointRewards = await getPointRewardStatus(roleId); // 任务 - await checkTask(roleId, sid, TASK_TYPE.BATTLE_EXPEDITION_BOX, 1, true, { point }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_EXPEDITION_BOX, 1) + await checkTask(serverId, roleId, sid, TASK_TYPE.BATTLE_EXPEDITION_BOX, { point }); let goods = await addItems(roleId, roleName, sid, curDicExpeditionPoint.reward, ITEM_CHANGE_REASON.EXPEDITION_POINT_REWARD); diff --git a/game-server/app/servers/battle/handler/normalBattleHandler.ts b/game-server/app/servers/battle/handler/normalBattleHandler.ts index d4ca5c055..286de604b 100644 --- a/game-server/app/servers/battle/handler/normalBattleHandler.ts +++ b/game-server/app/servers/battle/handler/normalBattleHandler.ts @@ -19,7 +19,7 @@ import { gameData } from '../../../pubUtils/data'; import { pushMysteryFirstMsg, pushTowerMsg, pushVestigeFirstMsg } from '../../../services/chatService'; import { getSeconds, nowSeconds } from '../../../pubUtils/timeUtil'; import { Rank } from '../../../services/rankService'; -import { checkTaskWithWar, checkTaskInBattleEnd, checkActivityTask, checkTaskInBattleSweep } from '../../../services/task/taskService'; +import { checkTaskInBattleEnd, checkTaskInBattleSweep } from '../../../services/task/taskService'; import { ActivitySelfServiceModel } from '../../../db/ActivitySelfService'; import { getSelfServiceShopActivityData } from '../../../services/activity/selfServiceShopActivityService'; import { challengeDailyGK } from '../../../services/activity/dailyGKService'; @@ -164,7 +164,7 @@ export class NormalBattleHandler { } let role = await RoleModel.findByRoleId(roleId, 'lv'); - let apJson = await setAp(roleId, ip, role.lv, isSuccess? -1 * warInfo.cost: 0, sid, getReasonByWarType(warInfo.warType)); // 扣除体力 + let apJson = await setAp(serverId, roleId, ip, role.lv, isSuccess? -1 * warInfo.cost: 0, sid, getReasonByWarType(warInfo.warType)); // 扣除体力 if (!apJson) { return resResult(STATUS.BATTLE_ACTION_POINT_LACK); } @@ -218,7 +218,6 @@ export class NormalBattleHandler { if (role) { let r = new Rank(REDIS_KEY.MAIN_ELITE_RANK, { serverId }); await r.setRankWithRoleInfo(roleId, role.mainEliteWarId, role.mainEliteUpdatedAt, role); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_MAIN_ELITE, 1, { mainEliteWarId: battleId }) } } else if (warInfo.warType == WAR_TYPE.ACT_SELF_SHOP) { //糜家商队挑战成功后记录挑战次数 @@ -305,7 +304,7 @@ export class NormalBattleHandler { // 扣体力 let role = await RoleModel.findByRoleId(roleId, 'lv'); - let apJson = await setAp(roleId, ip, role.lv, -1 * warInfo.cost * count, sid, getReasonByWarType(warInfo.warType)); // 扣除体力 + let apJson = await setAp(serverId, roleId, ip, role.lv, -1 * warInfo.cost * count, sid, getReasonByWarType(warInfo.warType)); // 扣除体力 if (!apJson) { return resResult(STATUS.BATTLE_ACTION_POINT_LACK); } diff --git a/game-server/app/servers/battle/handler/pvpHandler.ts b/game-server/app/servers/battle/handler/pvpHandler.ts index 557dbf9a8..0a2ab0e9e 100644 --- a/game-server/app/servers/battle/handler/pvpHandler.ts +++ b/game-server/app/servers/battle/handler/pvpHandler.ts @@ -14,8 +14,7 @@ import { checkTask, checkTaskInPvpEnd } from '../../../services/task/taskService import { Attack, AttackHero, Defense, DefenseHero, PvpDataReturn } from '../../../domain/battleField/pvp'; import { DEBUG_MAGIC_WORD, FIGURE_UNLOCK_CONDITION, ITEM_CHANGE_REASON, LINEUP_NUM, REDIS_KEY, TASK_TYPE } from '../../../consts'; import { PVP } from '../../../pubUtils/dicParam'; -import { getGoldObject } from '../../../pubUtils/itemUtils'; -import { addItems, handleCost, unlockFigure } from '../../../services/role/rewardService'; +import { addItems, getGoldObject, handleCost, unlockFigure } from '../../../services/role/rewardService'; import { pick } from "underscore"; import { HeroModel } from '../../../db/Hero'; import PvpHistoryOpp, { PvpHistoryOppModel } from '../../../db/PvpHistoryOpp'; @@ -42,7 +41,7 @@ export class PvpHandler { let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId); if(!pvpDefense) { let role = await RoleModel.findByRoleId(roleId); - pvpDefense = await PvpDefenseModel.createPvpDefense({ roleId: role.roleId, roleName: role.roleName, role: role._id }); + pvpDefense = await PvpDefenseModel.createPvpDefense({ serverId: role.serverId, roleId: role.roleId, roleName: role.roleName, role: role._id }); } // 如果没有发过,将上赛季的奖励发下 pvpDefense = await sendLastSeasonRewardIfNotSent(pvpDefense); diff --git a/game-server/app/servers/battle/handler/towerBattleHandler.ts b/game-server/app/servers/battle/handler/towerBattleHandler.ts index 865659bc4..eb83a464f 100644 --- a/game-server/app/servers/battle/handler/towerBattleHandler.ts +++ b/game-server/app/servers/battle/handler/towerBattleHandler.ts @@ -8,9 +8,8 @@ import { TowerRecordModel } from './../../../db/TowerRecord'; import { Application, BackendSession } from 'pinus'; import { resResult, genCode, shouldRefresh } from '../../../pubUtils/util'; import { calcuHangUpReward, refreshTasks, treatTask, getRemainTime, getTowerStatus, getHungupRewards, getTasks, checkTaskRewards, getTowerTaskCostGold, getHangSpdUpCostGold, getManyHangSpdUpCostGold, getTaskStatus, checkForbiddenChar, checkAndStartHungUp, createNewTowerRecord, getTowerRecByLv } from '../../../services/battleService'; -import { addItems, handleCost } from '../../../services/role/rewardService'; +import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService'; import { checkBattleHeroes } from '../../../services/normalBattleService'; -import { getGoldObject } from '../../../pubUtils/itemUtils'; import { gameData } from '../../../pubUtils/data'; import * as dicParam from '../../../pubUtils/dicParam'; import { isNumber } from 'underscore'; diff --git a/game-server/app/servers/chat/handler/chatHandler.ts b/game-server/app/servers/chat/handler/chatHandler.ts index 2522ed651..8bf0df788 100644 --- a/game-server/app/servers/chat/handler/chatHandler.ts +++ b/game-server/app/servers/chat/handler/chatHandler.ts @@ -4,7 +4,7 @@ import { resResult } from '../../../pubUtils/util'; import { DEFAULT_MSG_PER_PAGE, STATUS, TASK_TYPE } from '../../../consts'; import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs, updatePrivateMsgIsTop, delPrivateMsg } from '../../../services/chatService'; import { getSimpleRoleInfo } from '../../../services/roleService'; -import { checkActivityTask, checkTaskWithArgs } from '../../../services/task/taskService'; +import { checkTask } from '../../../services/task/taskService'; import { RoleModel } from '../../../db/Role'; @@ -99,10 +99,7 @@ export class ChatHandler { await pushGroupMsgToRoom(msgData); // 任务 - await checkTaskWithArgs(roleId, sid, TASK_TYPE.CHAT, [getChannelType(channel)]); - - //活动任务 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.CHAT, 1, { chatType: getChannelType(channel) }) + await checkTask(serverId, roleId, sid, TASK_TYPE.CHAT, { chatType: getChannelType(channel) }); return resResult(STATUS.SUCCESS, msgData); } @@ -125,10 +122,7 @@ export class ChatHandler { if (!msgData) return resResult(STATUS.WRONG_PARMS); // 任务 - await checkTaskWithArgs(roleId, sid, TASK_TYPE.CHAT, [getChannelType('private')]); - //活动任务 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.CHAT, 1, { chatType: getChannelType('private') }) - + await checkTask(serverId, roleId, sid, TASK_TYPE.CHAT, { chatType: getChannelType('private') }); return resResult(STATUS.SUCCESS, msgData); } diff --git a/game-server/app/servers/gm/handler/gmRoleHandler.ts b/game-server/app/servers/gm/handler/gmRoleHandler.ts index 73367dbd3..f1d783bef 100644 --- a/game-server/app/servers/gm/handler/gmRoleHandler.ts +++ b/game-server/app/servers/gm/handler/gmRoleHandler.ts @@ -2,7 +2,7 @@ import { Application, BackendSession, pinus } from 'pinus'; import { resResult } from '../../../pubUtils/util'; import { STATUS } from '../../../consts/statusCode'; import { getRoleOnlineInfo, updateUserInfo } from '../../../services/redisService'; -import { addItems, createHeroes } from '../../../services/role/rewardService'; +import { addItems } from '../../../services/role/rewardService'; import { RewardInter } from '../../../pubUtils/interface'; import { gameData, getExpByLv, getHeroExpByLv, getHeroLvByExp, getLvByExp } from '../../../pubUtils/data'; import { RoleModel, RoleType } from '../../../db/Role'; @@ -22,6 +22,7 @@ import { calAllHeroCe, calPlayerCeAndSave } from '../../../services/playerCeServ import { SkinModel } from '../../../db/Skin'; import { PvpDefenseModel } from '../../../db/PvpDefense'; import { calculatetopLineup } from '../../../pubUtils/playerCe'; +import { createHeroes } from '../../../services/role/createHero'; let timer: NodeJS.Timer; export default function (app: Application) { diff --git a/game-server/app/servers/guild/handler/auctionHandler.ts b/game-server/app/servers/guild/handler/auctionHandler.ts index 2c62ca259..2acbe9c87 100644 --- a/game-server/app/servers/guild/handler/auctionHandler.ts +++ b/game-server/app/servers/guild/handler/auctionHandler.ts @@ -5,7 +5,7 @@ import { LotModel } from "../../../db/Lot"; import { ItemReward } from "../../../domain/dbGeneral"; import { genCode, resResult } from "../../../pubUtils/util"; import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction, pushAuctionOver, treatSingleLotTime, treatLotsTime } from "../../../services/auctionService"; -import { addItems, handleCost } from '../../../services/role/rewardService'; +import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService'; import { getSimpleRoleInfo } from '../../../services/roleService'; import { getRoleOnlineInfo } from '../../../services/redisService'; import { lockData } from '../../../services/redLockService'; @@ -20,7 +20,6 @@ import { gameData, getAuctionRewardByPoolId } from '../../../pubUtils/data'; import { addRoleToGuildAuctionChannel, addRoleToWorldAuctionChannel, channelServer, groupRoomId, leaveGuildAuctionChannel } from '../../../services/chatService'; import { RewardInter } from '../../../pubUtils/interface'; import { sendMailByContent } from '../../../services/mailService'; -import { getGoldObject } from '../../../pubUtils/itemUtils'; import { reportTAEvent } from '../../../services/sdkService'; export default function (app: Application) { diff --git a/game-server/app/servers/guild/handler/cityActivityHandler.ts b/game-server/app/servers/guild/handler/cityActivityHandler.ts index b325effcf..60d60c135 100644 --- a/game-server/app/servers/guild/handler/cityActivityHandler.ts +++ b/game-server/app/servers/guild/handler/cityActivityHandler.ts @@ -9,12 +9,11 @@ import { leaveCityChannel, addRoleToCityChannel, getCityChannelSid } from "../.. import { UserGuildModel } from "../../../db/UserGuild"; import { GuildActivityRecordModel } from "../../../db/GuildActivityRec"; import { nowSeconds, getTimeFun } from "../../../pubUtils/timeUtil"; -import { getGoldObject } from "../../../pubUtils/itemUtils"; import { GUILDACTIVITY, SERVER_DEBUG_MODE } from "../../../pubUtils/dicParam"; -import { handleCost } from "../../../services/role/rewardService"; +import { getGoldObject, handleCost } from "../../../services/role/rewardService"; import { addActive } from "../../../services/guildService"; import { Rank } from "../../../services/rankService"; -import { checkActivityTask, checkTask } from "../../../services/task/taskService"; +import { checkTask } from "../../../services/task/taskService"; import { guildInter } from "../../../pubUtils/interface"; import { dispatch } from "../../../pubUtils/dispatcher"; import { ServerRecordModel } from "../../../db/ServerRecords"; @@ -191,9 +190,7 @@ export class CityActivityHandler { await ServerRecordModel.addActiveGuild(serverId, guildCode); // 任务 - await checkTask(roleId, sid, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid }); - //成长任务 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_ACTIVITY, 1, { aid: this.aid }) + await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_ACTIVITY, { aid: this.aid }); // 前一天中位数战力 let medianCe = await getPreDayActiveData(serverId); diff --git a/game-server/app/servers/guild/handler/donateHandler.ts b/game-server/app/servers/guild/handler/donateHandler.ts index bfc6db323..48c8c67a8 100644 --- a/game-server/app/servers/guild/handler/donateHandler.ts +++ b/game-server/app/servers/guild/handler/donateHandler.ts @@ -12,7 +12,7 @@ import { addFund, getDonation } from '../../../services/donateService'; import { getUserGuildWithRefActive, refreshUserGuild } from '../../../services/guildService'; import { ARMY } from '../../../pubUtils/dicParam'; import { addActive } from '../../../services/guildService' -import { checkActivityTask, checkTask } from '../../../services/task/taskService'; +import { checkTask } from '../../../services/task/taskService'; import { guildInter } from '../../../pubUtils/interface'; import { lockData } from '../../../services/redLockService'; import { getVipDonateConsume } from '../../../services/activity/monthlyTicketService'; @@ -102,10 +102,7 @@ export class DonationHandler { await addActive(roleId, serverId, GUILD_POINT_WAYS.DONATE, id); // 任务 - await checkTask(roleId, sid, TASK_TYPE.GUILD_DONATE, 1, true, {}); - //活动任务 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_DONATE, 1); - + await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_DONATE); res.releaseCallback(); return resResult(STATUS.SUCCESS, { donateFund, reports, donateCnt, simpleGoods: goods }); } catch (e) { diff --git a/game-server/app/servers/guild/handler/gateActivityHandler.ts b/game-server/app/servers/guild/handler/gateActivityHandler.ts index 40f466667..7b32922fb 100644 --- a/game-server/app/servers/guild/handler/gateActivityHandler.ts +++ b/game-server/app/servers/guild/handler/gateActivityHandler.ts @@ -14,7 +14,7 @@ import { UserGuildModel } from "../../../db/UserGuild"; import { GuildActivityCityModel } from "../../../db/GuildActivityCity"; import { Rank } from "../../../services/rankService"; import { getTimeFun, getZeroPointD } from "../../../pubUtils/timeUtil"; -import { checkActivityTask, checkTask } from "../../../services/task/taskService"; +import { checkTask } from "../../../services/task/taskService"; import { guildInter } from "../../../pubUtils/interface"; import { ServerRecordModel } from "../../../db/ServerRecords"; @@ -97,10 +97,7 @@ export class GateActivityHandler { await ServerRecordModel.addActiveGuild(serverId, guildCode); // 任务 - await checkTask(roleId, sid, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid }); - //成长任务 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_ACTIVITY, 1, { aid: this.aid }) - + await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_ACTIVITY, { aid: this.aid }); return resResult(STATUS.SUCCESS, { code, ...statusResult, diff --git a/game-server/app/servers/guild/handler/guildBossHandler.ts b/game-server/app/servers/guild/handler/guildBossHandler.ts index 77b94bf5b..f01124b71 100644 --- a/game-server/app/servers/guild/handler/guildBossHandler.ts +++ b/game-server/app/servers/guild/handler/guildBossHandler.ts @@ -16,9 +16,8 @@ import { lockData } from '../../../services/redLockService'; import { pushGuildBossSucMsg, getGuildChannelSid } from '../../../services/chatService'; import { checkTask } from '../../../services/task/taskService'; import { guildInter } from '../../../pubUtils/interface'; -import { addItems, handleCost } from '../../../services/role/rewardService'; +import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService'; import * as dicParam from '../../../pubUtils/dicParam'; -import { getGoldObject } from '../../../pubUtils/itemUtils'; import { RoleModel } from '../../../db/Role'; import { sendMailToGuildByContent } from '../../../services/mailService'; import { genAuction } from '../../../services/auctionService'; @@ -128,7 +127,7 @@ export class GuildHandler { } let { myChallengeCnt: newMyChallengeCnt } = await refreshUserGuildOfBoss(userGuild, 0, 1); // 任务 - await checkTask(roleId, sid, TASK_TYPE.GUILD_BOSS, 1, true, {}); + await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_BOSS); return resResult(STATUS.SUCCESS, { battleCode, bossCode: bossInstance.code, myChallengeCnt: newMyChallengeCnt }); } diff --git a/game-server/app/servers/guild/handler/guildHandler.ts b/game-server/app/servers/guild/handler/guildHandler.ts index f998c9767..e4caa5da6 100644 --- a/game-server/app/servers/guild/handler/guildHandler.ts +++ b/game-server/app/servers/guild/handler/guildHandler.ts @@ -6,8 +6,7 @@ import { checkAuth, joinGuild, getGuildWithRefActive, getUserGuildWithRefActive, import { GuildModel, GuildType, GuildUpdateParam } from '../../../db/Guild'; import { RoleModel, RoleType } from '../../../db/Role'; import { ARMY } from '../../../pubUtils/dicParam'; -import { handleCost, addItems } from '../../../services/role/rewardService'; -import { getGoldObject } from '../../../pubUtils/itemUtils'; +import { handleCost, addItems, getGoldObject } from '../../../services/role/rewardService'; import { nowSeconds, getTimeFun, getSeconds } from '../../../pubUtils/timeUtil'; import { GuildListInfo, GuildMemberParam } from '../../../domain/battleField/guild'; import { GuildLeader } from '../../../domain/rank'; @@ -23,7 +22,7 @@ import { removeBossRank } from '../../../services/guildBossService'; import { removeTrainRank } from '../../../services/guildTrainService'; import { pushGuildNoticeUpdateMsg, pushGuildUpStructureMsg, addRoleToGuildChannel, getGuildChannelSid, createGroupMsg, pushGroupMsgToRoom } from '../../../services/chatService'; import { Rank } from '../../../services/rankService'; -import { checkActivityTask, checkTask } from '../../../services/task/taskService'; +import { checkTask } from '../../../services/task/taskService'; import { guildInter } from '../../../pubUtils/interface'; import * as dicParam from '../../../pubUtils/dicParam'; import { reportTAEvent } from '../../../services/sdkService'; @@ -99,8 +98,7 @@ export class GuildHandler { // 返回 const result = { ...guild, rank, myInfo: { ...userGuild, isOnline: true } }; - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_JOIN, 1); - await checkTask(roleId, sid, TASK_TYPE.GUILD_JOIN, 1, true, {}); + await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_JOIN); return resResult(STATUS.SUCCESS, result); } @@ -877,9 +875,7 @@ export class GuildHandler { userGuild = await UserGuildModel.updateInfo(roleId, { receivedActive: userGuild.receivedActive }, {}, 'receivedActive'); // 任务 - await checkTask(roleId, sid, TASK_TYPE.GUILD_RECEIVE_BOX, 1, true, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_RECEIVE_BOX, 1); - + await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_RECEIVE_BOX); return resResult(STATUS.SUCCESS, { goods, receivedActive: userGuild.receivedActive }); } diff --git a/game-server/app/servers/guild/handler/guildRefineHandler.ts b/game-server/app/servers/guild/handler/guildRefineHandler.ts index 826bc6de0..c08f9c16f 100644 --- a/game-server/app/servers/guild/handler/guildRefineHandler.ts +++ b/game-server/app/servers/guild/handler/guildRefineHandler.ts @@ -51,6 +51,7 @@ export class GuildRefineHandler { const roleId: string = session.get('roleId'); const sid: string = session.get('sid'); const roleName: string = session.get('roleName'); + const serverId: number = session.get('serverId'); let dicGoods = gameData.goods.get(id); if(!dicGoods) return resResult(STATUS.DIC_DATA_NOT_FOUND); @@ -92,7 +93,7 @@ export class GuildRefineHandler { let goods = await addItems(roleId, roleName, sid, [{ id, count }], ITEM_CHANGE_REASON.REFINE_EQUIP); // 任务 - await checkTask(roleId, sid, TASK_TYPE.GUILD_REFINE, 1, true, { quality: dicGoods.quality }); + await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_REFINE, { quality: dicGoods.quality, count }); return resResult(STATUS.SUCCESS, { goods, refineCnt }); } /** @@ -193,7 +194,7 @@ export class GuildRefineHandler { res.releaseCallback(); // 任务 - await checkTask(roleId, sid, TASK_TYPE.GUILD_ASSIST_REFINE, 1, true, {}); + await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_ASSIST_REFINE); return resResult(STATUS.SUCCESS, { scienceTrees }); } diff --git a/game-server/app/servers/guild/handler/guildTrainHandler.ts b/game-server/app/servers/guild/handler/guildTrainHandler.ts index 2427f2641..2e69fe19c 100644 --- a/game-server/app/servers/guild/handler/guildTrainHandler.ts +++ b/game-server/app/servers/guild/handler/guildTrainHandler.ts @@ -18,7 +18,7 @@ import { addActive } from '../../../services/guildService'; import { GuildTrainReportModel } from '../../../db/GuildTrainReport'; import { DATA_NAME } from '../../../consts/dataName'; import { pushGuildTrainSucMsg } from '../../../services/chatService'; -import { checkActivityTask, checkTask } from '../../../services/task/taskService'; +import { checkTaskInGuildTrain } from '../../../services/task/taskService'; import { sendPopUpActivityData } from '../../../services/guildActivity/guildActivityService'; import { guildInter, RewardInter } from '../../../pubUtils/interface'; import { getGuildTrainGkInfo } from '../../../pubUtils/data'; @@ -243,10 +243,6 @@ export class GuildTrainHandler { // guildTrain = await GuildTrainModel.updateGuildTrain(code, trainId, { ranks }); res.releaseCallback();//解锁 } - if (isComplete) {//解锁下一关,弹出礼包 // 1 true true 6Sjkgp(trainId, isComplete, needLockNext, code) - let pushMessage = await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_TRAIN_COUNT, 1, { trainId, code }) - await sendPopUpActivityData(code, serverId, pushMessage); - } await GuildTrainReportModel.pushGuildTrainReports(code, trainId, reports);//增加战报 let { trainCount, trainRewards } = userGuild; @@ -256,12 +252,7 @@ export class GuildTrainHandler { await addActive(roleId, serverId, GUILD_POINT_WAYS.TRAIN); // 任务 - if (isSuccess) { - await checkTask(roleId, sid, TASK_TYPE.GUILD_TRAIN_SUCESS, 1, true, {}); - } - await checkTask(roleId, sid, TASK_TYPE.GUILD_TRAIN, 1, true, {}); - //成长任务 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_TRAIN, 1) + await checkTaskInGuildTrain(serverId, roleId, sid, battleRecord.battleId, isSuccess, isComplete); return resResult(STATUS.SUCCESS, result); diff --git a/game-server/app/servers/guild/handler/raceActivityHandler.ts b/game-server/app/servers/guild/handler/raceActivityHandler.ts index 44414322c..0aa4f9983 100644 --- a/game-server/app/servers/guild/handler/raceActivityHandler.ts +++ b/game-server/app/servers/guild/handler/raceActivityHandler.ts @@ -7,7 +7,7 @@ import { GuildActivityRecordModel } from "../../../db/GuildActivityRec"; import { UserGuildActivityRecModel } from "../../../db/UserGuildActivityRec"; import { addActive } from "../../../services/guildService"; import { Rank } from "../../../services/rankService"; -import { checkActivityTask, checkTask } from "../../../services/task/taskService"; +import { checkTask } from "../../../services/task/taskService"; import { guildInter } from "../../../pubUtils/interface"; import { getGuildChannelSid } from "../../../services/chatService"; import { ServerRecordModel } from "../../../db/ServerRecords"; @@ -93,10 +93,7 @@ export class RaceActivityHandler { // 全服活跃统计 await ServerRecordModel.addActiveGuild(serverId, guildCode); // 任务 - await checkTask(roleId, sid, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid }); - //成长任务 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_ACTIVITY, 1, { aid: this.aid }) - + await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_ACTIVITY, { aid: this.aid }); return resResult(STATUS.SUCCESS, { code: myGuildActivityRec.code, diff --git a/game-server/app/servers/guild/handler/wishPoolHandler.ts b/game-server/app/servers/guild/handler/wishPoolHandler.ts index 165421b1d..08db311ef 100644 --- a/game-server/app/servers/guild/handler/wishPoolHandler.ts +++ b/game-server/app/servers/guild/handler/wishPoolHandler.ts @@ -5,7 +5,7 @@ import { WishPoolReportModel } from '../../../db/WishPoolReport'; import { resResult, genCode } from '../../../pubUtils/util'; import { ITEM_CHANGE_REASON, STATUS } from '../../../consts'; import { getArmyWishPoolBaseByLv, getGoodById, getWishPoolReward } from '../../../pubUtils/data'; -import { addItems, checkGoods, checkHeroEquips, checkHeroes } from '../../../services/role/rewardService'; +import { addItems, checkGoods, checkHeroEquips, checkHeroes, getHonourObject } from '../../../services/role/rewardService'; import { ITID, CONSUME_TYPE } from '../../../consts/constModules/itemConst'; import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst'; import { refreshUserGuild, getWishPool, getUserGuildWithRefActive } from '../../../services/guildService'; @@ -15,7 +15,6 @@ import { getRoleOnlineInfo } from '../../../services/redisService'; import { ARMY } from '../../../pubUtils/dicParam'; import { guildInter } from '../../../pubUtils/interface'; import { getSeconds, getZeroPoint, nowSeconds } from '../../../pubUtils/timeUtil'; -import { getHonourObject } from '../../../pubUtils/itemUtils'; export default function(app: Application) { return new WishPoolHandler(app); } diff --git a/game-server/app/servers/order/handler/orderHandler.ts b/game-server/app/servers/order/handler/orderHandler.ts index d00dcd2c7..ae817341e 100644 --- a/game-server/app/servers/order/handler/orderHandler.ts +++ b/game-server/app/servers/order/handler/orderHandler.ts @@ -10,7 +10,6 @@ import { applyOrder37 } from '../../../services/pay/37Pay'; import { settleOrder, settleOrderAli, settleOrderWx } from '../../../services/orderService'; import { addRechargeMoney } from '../../../services/activity/rechargeMoneyService'; import { addVipRechargeMoney } from '../../../services/activity/vipRechargeMoneyService'; -import { checkActivityTask } from '../../../services/task/taskService'; import { getActivityById } from '../../../services/activity/activityService'; import { reportTAEvent } from '../../../services/sdkService'; diff --git a/game-server/app/servers/role/handler/equipHandler.ts b/game-server/app/servers/role/handler/equipHandler.ts index 4bf608703..a9265758c 100644 --- a/game-server/app/servers/role/handler/equipHandler.ts +++ b/game-server/app/servers/role/handler/equipHandler.ts @@ -3,19 +3,20 @@ import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, TASK_TYPE } from "../../. import { ItemInter, RewardInter } from "../../../pubUtils/interface"; import { resResult, parseGoodStr } from "../../../pubUtils/util"; -import { addItems, handleCost, combineItems, CheckMeterial } from "../../../services/role/rewardService"; +import { addItems, getJewelRandSe, handleCost } from "../../../services/role/rewardService"; import { HeroModel, EPlace } from "../../../db/Hero"; import { calPlayerCeAndSave } from "../../../services/playerCeService"; import { gameData, getEquipByJobClassAndEPlace, getNextEquipQuality, getEquipStarIdByEquipId, getNextEquipStar } from "../../../pubUtils/data"; import { BAG, EQUIP } from "../../../pubUtils/dicParam"; -import { getRandSeResult, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip, checkTaskInComposeEquip, checkTaskInEquipLvUp, checkTaskInComposeStone, checkTaskInEquipReset, checkTaskInEquipQuench, isLocked } from "../../../services/equipService"; +import { getRandSeResult, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip, isLocked } from "../../../services/equipService"; import { isNumber, pick } from 'underscore'; import { JewelModel, RandSe } from "../../../db/Jewel"; -import { getJewelRandSe } from "../../../pubUtils/itemUtils"; -import { checkTaskInEquipQualityUp, checkTaskInEquipStarUp, checkTaskInPutJewel, checkTaskInPutStone } from '../../../services/equipService'; +import { checkTaskInComposeEquip, checkTaskInEquipLvUp, checkTaskInComposeStone, checkTaskInEquipReset, checkTaskInEquipQuench, checkTaskInEquipQualityUp, checkTaskInEquipStarUp, checkTaskInPutJewel, checkTaskInPutStone } from '../../../services/task/taskService'; import { pushEquipQualityMax, pushEquipStarMax } from "../../../services/sysChatService"; import { addConsumeToHero } from "../../../services/roleService"; +import { CheckMeterial } from "../../../services/role/checkMaterial"; +import { combineItems } from "../../../services/role/util"; export default function (app: Application) { new HandlerService(app, {}); @@ -57,7 +58,7 @@ export class EquipHandler { consumes: addConsumeToHero(hero.consumes, dicEquip.composeMaterial), } hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.COMPOSE_EQUIP, sid, roleId, hero, update, [ePlaceId]); - await checkTaskInComposeEquip(serverId, roleId, sid, oldEplace, newEplace, ePlaceId); + await checkTaskInComposeEquip(serverId, roleId, sid, oldEplace, newEplace); return resResult(STATUS.SUCCESS, { curHero: { diff --git a/game-server/app/servers/role/handler/friendHandler.ts b/game-server/app/servers/role/handler/friendHandler.ts index c3429f0a5..95428dcdb 100644 --- a/game-server/app/servers/role/handler/friendHandler.ts +++ b/game-server/app/servers/role/handler/friendHandler.ts @@ -11,8 +11,7 @@ import { isRoleOnline, getServerName, getRoleOnlineInfo } from "../../../service import { increaseFrdCnt, getRecommendType, sortByBeSentHeart, getApplyList, getFriendList, getMyApplyParam, getMyParamAsFriend } from "../../../services/friendService"; import { FriendPointModel } from "../../../db/FriendPoint"; import { gameData, getDicFriendByLv } from "../../../pubUtils/data"; -import { addItems, handleCost } from "../../../services/role/rewardService"; -import { getFriendPointObject } from "../../../pubUtils/itemUtils"; +import { addItems, getFriendPointObject, handleCost } from "../../../services/role/rewardService"; import { RewardInter } from "../../../pubUtils/interface"; import { FriendPresentLogModel } from '../../../db/FriendPresentLog'; import { HeroModel, EPlace } from "../../../db/Hero"; @@ -21,7 +20,7 @@ import { FRIEND } from "../../../pubUtils/dicParam"; import { PlayerDetail, PlayerDetailHero } from "../../../domain/battleField/guild"; import { createPrivateMsg, pushMsgToRole, pushPresent } from "../../../services/chatService"; import { Rank } from "../../../services/rankService"; -import { checkTaskWithRoles, checkTask, checkActivityTask } from "../../../services/task/taskService"; +import { checkTaskWithRoles, checkTask } from "../../../services/task/taskService"; import { ComBattleTeamModel } from "../../../db/ComBattleTeam"; import { JewelModel } from "../../../db/Jewel"; @@ -256,13 +255,6 @@ export class FriendHandler { roles.push(role); // 任务 await checkTaskWithRoles(serverId, roleId, sid, TASK_TYPE.FRIEND_NUM, roles); - for(let curRole of roles) { - if(curRole.roleId == role.roleId) { - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.FRIEND_NUM, curRole.friendCnt); - } else { - await checkActivityTask(serverId, null, curRole.roleId, TASK_TYPE.FRIEND_NUM, curRole.friendCnt); - } - } // 特殊处理:如果他点一键同意,有很多人,这个单独的人就不做这个额外的提示,直接把他好友申请删掉就好 if (str == getResStr(STATUS.FRIEND_HAS_ADD) && resultApplyCodeList.length > 1) str = ''; @@ -435,9 +427,6 @@ export class FriendHandler { // 任务 await checkTaskWithRoles(serverId, roleId, sid, TASK_TYPE.FRIEND_NUM, [role, friend]); - await checkActivityTask(serverId, sid, role.roleId, TASK_TYPE.FRIEND_NUM, role.friendCnt); - if(friend) await checkActivityTask(serverId, null, friend.roleId, TASK_TYPE.FRIEND_NUM, friend.friendCnt); - return resResult(STATUS.SUCCESS, { frdRoleIds, blackRoleIds, isSuccess: str == '', @@ -507,11 +496,9 @@ export class FriendHandler { // 更新情谊值 frdPointRec = await FriendPointModel.updateSendCntToday(roleId, roleName, todaySendInc, max, FRIEND_DROP_TYPE.SEND_GIFT); - // 任务 - await checkTask(roleId, sid, TASK_TYPE.FRIEND_SEND_HEART, todaySendInc, true, {}); // 活动任务 if (todaySendInc > 0) { - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.FRIEND_SEND_HEART, todaySendInc); + await checkTask(serverId, roleId, sid, TASK_TYPE.FRIEND_SEND_HEART, { count: todaySendInc }); } return resResult(STATUS.SUCCESS, { diff --git a/game-server/app/servers/role/handler/heroHandler.ts b/game-server/app/servers/role/handler/heroHandler.ts index 51665d3f3..a65894537 100644 --- a/game-server/app/servers/role/handler/heroHandler.ts +++ b/game-server/app/servers/role/handler/heroHandler.ts @@ -1,5 +1,5 @@ import { Application, BackendSession, ChannelService, HandlerService, } from 'pinus'; -import { handleCost, addItems, unlockFigure, createHeroes, createHero, CheckMeterial } from '../../../services/role/rewardService'; +import { handleCost, addItems, unlockFigure, getCoinObject, getGoldObject } from '../../../services/role/rewardService'; import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService'; import { resResult, deepCopy, reduceCe } from '../../../pubUtils/util'; import { STATUS } from '../../../consts/statusCode'; @@ -17,10 +17,11 @@ import { checkTask, checkTaskInHeroQUalityUp, checkTaskInHeroStarUp, checkTaskIn import { isNumber, pick } from 'underscore'; import { updateEplaces } from '../../../services/equipService'; import { addConsumeToHero } from '../../../services/roleService'; -import { getCoinObject, getGoldObject } from '../../../pubUtils/itemUtils'; import { JewelModel, jewelUpdate } from '../../../db/Jewel'; import { CalHeroCe } from '../../../domain/roleField/calCe'; import { REBORN } from '../../../pubUtils/dicParam'; +import { createHero, createHeroes } from '../../../services/role/createHero'; +import { CheckMeterial } from '../../../services/role/checkMaterial'; export default function (app: Application) { new HandlerService(app, {}); diff --git a/game-server/app/servers/role/handler/itemHandler.ts b/game-server/app/servers/role/handler/itemHandler.ts index 194c77e71..40fe316dd 100644 --- a/game-server/app/servers/role/handler/itemHandler.ts +++ b/game-server/app/servers/role/handler/itemHandler.ts @@ -67,6 +67,7 @@ export class ItemHandler { const roleId = session.get('roleId'); const sid = session.get('sid'); const ip = session.get('ip'); + const serverId = session.get('serverId'); if (count > 0) { let dicGoods = gameData.goods.get(id); @@ -90,7 +91,7 @@ export class ItemHandler { let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }], ITEM_CHANGE_REASON.USE_MEAT); if (!consumeResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH); - let apJson = await setAp(roleId, ip, role.lv, dicGoods.value * count, sid, ITEM_CHANGE_REASON.USE_MEAT); + let apJson = await setAp(serverId, roleId, ip, role.lv, dicGoods.value * count, sid, ITEM_CHANGE_REASON.USE_MEAT); return resResult(STATUS.SUCCESS, { apJson @@ -191,9 +192,10 @@ export class ItemHandler { const roleId = session.get('roleId'); const sid = session.get('sid'); const ip = session.get('ip'); + const serverId = session.get('serverId'); let role = await RoleModel.findByRoleId(roleId, 'lv'); - let apJson = await setAp(roleId, ip, role.lv, msg.ap, sid, ITEM_CHANGE_REASON.DEBUG); + let apJson = await setAp(serverId, roleId, ip, role.lv, msg.ap, sid, ITEM_CHANGE_REASON.DEBUG); if (!apJson) return resResult(STATUS.BATTLE_ACTION_POINT_LACK) return resResult(STATUS.SUCCESS, { apJson }); } diff --git a/game-server/app/servers/role/handler/roleHandler.ts b/game-server/app/servers/role/handler/roleHandler.ts index 55c6979f5..ba0d7e60d 100644 --- a/game-server/app/servers/role/handler/roleHandler.ts +++ b/game-server/app/servers/role/handler/roleHandler.ts @@ -3,7 +3,7 @@ import { RoleModel, RoleUpdate } from './../../../db/Role'; import { HeroModel, HeroUpdate } from '../../../db/Hero'; import { resResult, decodeIdCntArrayStr, parseGoodStr, genCode } from '../../../pubUtils/util'; import { Application, BackendSession, pinus, HandlerService, } from 'pinus'; -import { handleCost, addItems } from '../../../services/role/rewardService'; +import { handleCost, addItems, getGoldObject, getCoinObject } from '../../../services/role/rewardService'; import { getTitle, getTeraph, gameData, getScollByStar, getFriendLvByExp, getHeroExpByLv, getExpByLv } from '../../../pubUtils/data'; import { SCHOOL, SCROLL, EXTERIOR, SCRIPT } from '../../../pubUtils/dicParam'; import { getAtrrNameById } from '../../../consts/constModules/abilityConst' @@ -16,8 +16,7 @@ import { HERO_SYSTEM_TYPE, LINEUP_NUM, ROLE_SELECT, REDIS_KEY, TASK_TYPE, DEFAUL import { checkBattleHeroesByHid, roleLevelup } from '../../../services/normalBattleService'; import { Rank } from '../../../services/rankService'; import { updateUserInfo } from '../../../services/redisService'; -import { checkTask, checkTaskWithArgs, checkActivityTask } from '../../../services/task/taskService'; -import { getGoldObject, getCoinObject } from '../../../pubUtils/itemUtils'; +import { checkTask, checkTaskInActiveScroll } from '../../../services/task/taskService'; import { RScriptRecordModel } from '../../../db/RScriptRecord'; import { SkinModel, SkinUpdate } from '../../../db/Skin'; import { Figure } from '../../../domain/dbGeneral'; @@ -111,10 +110,7 @@ export class RoleHandler { let calResult = await calAllHeroCe(HERO_SYSTEM_TYPE.TITLE, sid, roleId, update); // 任务 - await checkTask(roleId, sid, TASK_TYPE.ROLE_TITLE, 1, false, { oldTitle: title, title: update.title }); - //成长任务 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_TITLE, update.title) - + await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TITLE, { oldTitle: title, title: update.title }); return resResult(STATUS.SUCCESS, { roleId: calResult.role, title: role.title }); } @@ -147,8 +143,7 @@ export class RoleHandler { let calResult = await calAllHeroCe(HERO_SYSTEM_TYPE.TERAPH, sid, roleId, { teraphs }, [id]); // 任务 - await checkTask(roleId, sid, TASK_TYPE.ROLE_TERAPH_STRENGTHEN, count, true, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_TERAPH_STRENGTHEN, count); + await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TERAPH_STRENGTHEN, { count }); return resResult(STATUS.SUCCESS, { roleId, teraphs: calResult.role.teraphs, criAttr }); } @@ -192,7 +187,7 @@ export class RoleHandler { let calResult = await calAllHeroCe(HERO_SYSTEM_TYPE.TERAPH_UP, sid, roleId, { teraphs }, [id]); // 神像进阶,进阶一次就触发一次礼包弹框 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_TERAPH_STAGE_UP, 1) + await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TERAPH_STAGE_UP); return resResult(STATUS.SUCCESS, { roleId, teraphs: calResult.role.teraphs }); } @@ -249,11 +244,7 @@ export class RoleHandler { await calAllHeroCe(HERO_SYSTEM_TYPE.SCHOOL, sid, roleId, {}, [schoolId, hid, preHid]); // 任务 - await checkTaskWithArgs(roleId, sid, TASK_TYPE.ROLE_SCHOOL_UNLOCK, [hid, preHid]); - if (hid > 0) { - //成长任务 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_SCHOOL_PUT_HERO, 1) - } + await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_SCHOOL_PUT_HERO, { hid, preHid }); return resResult(STATUS.SUCCESS, { schoolId, positionId, hid, preHid, isOpen @@ -291,8 +282,7 @@ export class RoleHandler { curSchool = await SchoolModel.updateBySclAndPos(roleId, schoolId, positionId, { isOpen: true }) // 任务 - await checkTask(roleId, sid, TASK_TYPE.ROLE_SCHOOL_UNLOCK, 1, true, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_SCHOOL_UNLOCK, 1) + await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_SCHOOL_UNLOCK); return resResult(STATUS.SUCCESS, { schoolId, positionId, hid: curSchool.hid, isOpen: curSchool.isOpen @@ -324,7 +314,6 @@ export class RoleHandler { update.scrollStar = dicHero.initialStars; update.scrollQuality = dicHero.quality; update.scrollColorStar = 0; - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_UNLOCK, 1, { dicHeroes: [dicHero] }) } else { if (star > scrollStar) { // 可以升星 update.scrollStar++; @@ -346,10 +335,7 @@ export class RoleHandler { await calAllHeroCe(HERO_SYSTEM_TYPE.SCROLL, sid, roleId, {}, [hid]); // 全局增加战力 // 任务 - if (!scrollActive) { - await checkTask(roleId, sid, TASK_TYPE.ROLE_SCROLL_ACTIVE, 1, true, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_SCROLL_ACTIVE, 1); - } + await checkTaskInActiveScroll(serverId, roleId, sid, scrollActive, hero); return resResult(STATUS.SUCCESS, { curHero: { diff --git a/game-server/app/servers/role/handler/shopHandler.ts b/game-server/app/servers/role/handler/shopHandler.ts index e06413960..29c31a687 100644 --- a/game-server/app/servers/role/handler/shopHandler.ts +++ b/game-server/app/servers/role/handler/shopHandler.ts @@ -7,7 +7,6 @@ import { UserShopModel } from "../../../db/UserShop"; import { handleCost, addItems } from "../../../services/role/rewardService"; import { GuildModel } from "../../../db/Guild"; import { SHOP } from "../../../pubUtils/dicParam"; -import { getHonourObject } from "../../../pubUtils/itemUtils"; import { HeroModel } from "../../../db/Hero"; import { getShopListById } from "../../../services/shopService"; import { RewardInter } from "../../../pubUtils/interface"; diff --git a/game-server/app/services/actionPointService.ts b/game-server/app/services/actionPointService.ts index 12cfba0ab..d59f40d19 100644 --- a/game-server/app/services/actionPointService.ts +++ b/game-server/app/services/actionPointService.ts @@ -4,7 +4,7 @@ import { ActionPointModel, ActionPointType } from '../db/ActionPoint'; import { TASK_TYPE, STATUS, TA_EVENT, ITEM_CHANGE_REASON } from '../consts'; -import { checkActivityTask, checkTask } from './task/taskService'; +import { checkTask } from './task/taskService'; import { getDicApByLv } from '../pubUtils/data'; import { pinus } from 'pinus'; import { resResult, shouldRefresh } from '../pubUtils/util'; @@ -68,7 +68,7 @@ function getApWithDataAp(roleId: string, ip: string, lv: number, dataAp: ActionP * @param changeAp 体力变化,正是加,负是减 * @param sid */ -export async function setAp(roleId: string, ip: string, lv: number, changeAp: number, sid: string, reason: ITEM_CHANGE_REASON) { +export async function setAp(serverId: number, roleId: string, ip: string, lv: number, changeAp: number, sid: string, reason: ITEM_CHANGE_REASON) { // console.log('***** setAp', roleId, ip, lv, changeAp) const now = Date.now(); const dicAp = getDicApByLv(lv); @@ -89,9 +89,7 @@ export async function setAp(roleId: string, ip: string, lv: number, changeAp: nu } if (changeAp < 0) { - await checkTask(roleId, sid, TASK_TYPE.BATTLE_COST_AP, -1 * changeAp, true, {}); - let { serverId } = await RoleModel.findByRoleId(roleId); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_COST_AP, -1 * changeAp,); + await checkTask(serverId, roleId, sid, TASK_TYPE.BATTLE_COST_AP, { count: -changeAp }); // reportTAEvent(roleId, TA_EVENT.AP_CONSUME, { change_count: -1 * changeAp, change_after: ap, change_reason: reason }, ip) } else { reportTAEvent(roleId, TA_EVENT.AP_GET, { change_count: changeAp, change_after: ap, change_reason: reason }, ip) diff --git a/game-server/app/services/activity/gachaService.ts b/game-server/app/services/activity/gachaService.ts index 5c1795df4..12982b75d 100644 --- a/game-server/app/services/activity/gachaService.ts +++ b/game-server/app/services/activity/gachaService.ts @@ -8,10 +8,10 @@ import { gameData, getDicGachaFloor } from "../../pubUtils/data"; import { RoleModel } from "../../db/Role"; import { RewardInter } from "../../pubUtils/interface"; import { CreateHeroParam } from "../../domain/roleField/hero"; -import { transPiece } from "../../pubUtils/itemUtils"; import { HeroType } from "../../db/Hero"; import { NewHeroGachaItem } from "../../domain/activityField/newHeroGachaField"; import { getActivityById } from "./activityService"; +import { transPiece } from "../role/util"; /** * 获取招募列表 diff --git a/game-server/app/services/activity/giftPackageService.ts b/game-server/app/services/activity/giftPackageService.ts index f69947c64..1231e47c9 100644 --- a/game-server/app/services/activity/giftPackageService.ts +++ b/game-server/app/services/activity/giftPackageService.ts @@ -1,11 +1,12 @@ import { GIFT_PACKAGE_TYPE, ACTIVITY_RESOURCES_TYPE, ITEM_CHANGE_REASON } from '../../consts'; import { gameData } from '../../pubUtils/data'; -import { addItems, createHeroes } from '../role/rewardService'; +import { addItems } from '../role/rewardService'; import { RewardParam } from '../../domain/activityField/rewardField'; import { CreateHeroParam } from '../../domain/roleField/hero'; import { DicGiftPackage } from '../../pubUtils/dictionary/DicGiftPackage'; import { ItemInter, RewardInter } from '../../pubUtils/interface'; import { decodeArrayListStr } from '../../pubUtils/util'; +import { createHeroes } from '../role/createHero'; diff --git a/game-server/app/services/activity/monthlyTicketService.ts b/game-server/app/services/activity/monthlyTicketService.ts index 2a15ab2d9..a4140ffb7 100644 --- a/game-server/app/services/activity/monthlyTicketService.ts +++ b/game-server/app/services/activity/monthlyTicketService.ts @@ -10,10 +10,10 @@ import { sendMailByContent } from './../mailService'; import { RoleModel, RoleType } from '../../db/Role'; import { getActivityById } from './activityService'; import { RewardInter } from '../../pubUtils/interface'; -import { getGoldId } from '../../pubUtils/itemUtils'; import { DUNGEON_CONST, PVP, VIP } from '../../pubUtils/dicParam'; import { cal } from '../../pubUtils/util'; import { pinus } from 'pinus'; +import { getGoldId } from '../role/rewardService'; /** * 获取活动数据 diff --git a/game-server/app/services/activity/popUpShopService.ts b/game-server/app/services/activity/popUpShopService.ts index efbf1684f..df28b3600 100644 --- a/game-server/app/services/activity/popUpShopService.ts +++ b/game-server/app/services/activity/popUpShopService.ts @@ -39,7 +39,7 @@ export async function getPopUpShopDataShow(activityId: number, serverId: number, return null } -export async function checkPopUpConditionInCreateHero(serverId, roleId, heroes: HeroType[]) { +export async function checkPopUpConditionInCreateHero(serverId: number, roleId: string, heroes: HeroType[]) { let conditions = heroes.map(hero => ({ conditionType: POP_UP_SHOP_CONDITION_TYPE.GET_HERO_BY_QUALITY, param: { quality: hero.quality } })); return await checkPopUpConditions(serverId, roleId, conditions); } diff --git a/game-server/app/services/battleService.ts b/game-server/app/services/battleService.ts index 28acc8da1..6ef094d18 100644 --- a/game-server/app/services/battleService.ts +++ b/game-server/app/services/battleService.ts @@ -9,7 +9,7 @@ import { STATUS } from '../consts/statusCode'; import { HangUpSpdUpRecModel } from '../db/HangUpSpdUpRec'; import { TaskHero, TowerTaskRecModel, TowerTaskRecType } from '../db/TowerTaskRec'; import { Rank } from './rankService'; -import { checkActivityTask, checkTask } from './task/taskService'; +import { checkTask } from './task/taskService'; import { getRandExpedition, gameData } from '../pubUtils/data'; import { ItemInter, RewardInter } from '../pubUtils/interface'; import { getTimeFunM } from '../pubUtils/timeUtil'; @@ -237,8 +237,7 @@ export async function towerBattleEnd(sid: string, roleId: string, serverId: numb if (reward) towerReward = reward; await checkAndStartHungUp(roleId, roleName, role.towerLv - 1); // 任务 - await checkTask(roleId, sid, TASK_TYPE.BATTLE_TOWER_LV, role.towerLv - 1, false, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_TOWER_LV, 1, { towerLv: role.towerLv - 1 }); + await checkTask(serverId, roleId, sid, TASK_TYPE.BATTLE_TOWER_LV, { towerLv: role.towerLv - 1 }); } return { status: 0, diff --git a/game-server/app/services/equipService.ts b/game-server/app/services/equipService.ts index 658891379..c094a1d9d 100644 --- a/game-server/app/services/equipService.ts +++ b/game-server/app/services/equipService.ts @@ -2,10 +2,8 @@ import { getRandEelm, } from '../pubUtils/util'; import { EPlace, Stone } from "../db/Hero"; import { gameData, getRandEffectByGroupAndLevel } from "../pubUtils/data"; import { JewelType, RandSe } from '../db/Jewel'; -import { getJewelRandSe } from '../pubUtils/itemUtils'; -import { checkActivityTask, checkTask, checkTaskWithEplaces, checkTaskWithEplace } from './task/taskService'; -import { TASK_TYPE } from '../consts'; import { DicRandomEffectPool } from '../pubUtils/dictionary/DicRandomEffectPool'; +import { getJewelRandSe } from './role/rewardService'; export function getRandSeResult(id: number, randSe: RandSe[], originSe: RandSe[] = [], originId?: number) { let { randomEffect, effectCount, lv } = gameData.jewel.get(id); @@ -129,98 +127,21 @@ export function checkStoneCanPutOnEquip(equip: EPlace, id: number, stone: number return true; } -export async function checkTaskInComposeEquip(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number) { - await checkTask(roleId, sid, TASK_TYPE.EQUIP_COMPOSE, newEplace.length - oldEplace.length, true, {}); - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_COMPOSE_CNT, oldEplace, newEplace, [ePlaceId]); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_COMPOSE, newEplace.length - oldEplace.length); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_COMPOSE_CNT, 1, { oldEplace, newEplace }); -} - -export async function checkTaskInEquipLvUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceIds: number[]) { - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_LV_TO, oldEplace, newEplace, ePlaceIds); - await checkTask(roleId, sid, TASK_TYPE.EQUIP_LV_UP, ePlaceIds.length, true, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_LV_TO, 1, { oldEplace, newEplace, ePlaceIds }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_LV_UP, ePlaceIds.length, true); -} - -export async function checkTaskInPutJewel(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, originJewel: JewelType, curJewel: JewelType) { - let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId); - await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL, oldEquip, newEquip, { jewels: [originJewel, curJewel ] }); - await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL_CNT, oldEquip, newEquip); - await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, oldEquip, newEquip, { jewels: [originJewel, curJewel ] }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_JEWEL, 1, { oldEquip, newEquip, jewels: [originJewel, curJewel ] }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_JEWEL_CNT, 1, { oldEquip, newEquip }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, 1, { oldEquip, newEquip, jewels: [originJewel, curJewel ] }); -} - -export async function checkTaskInPutStone(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, jewel: JewelType) { - let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId); - await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_STONE, oldEquip, newEquip); - await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_STONE_CNT, oldEquip, newEquip); - await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STONE_CNT, oldEquip, newEquip); - await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STONE_CNT_LV, oldEquip, newEquip); - await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, oldEquip, newEquip, { jewels: [ jewel ] }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_STONE, 1, { oldEquip, newEquip }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_STONE_CNT, 1, { oldEquip, newEquip }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STONE_CNT, 1, { oldEquip, newEquip }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STONE_CNT_LV, 1, { oldEquip, newEquip }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, 1, { oldEquip, newEquip, jewels: [ jewel ] }); -} - -export async function checkTaskInEquipStarUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpStar: boolean) { - if(isUpStar) { - let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId); - await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STAR_UP_TO, oldEquip, newEquip); - await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_SUIT_SEID_NUM, oldEplace, newEplace, [ePlaceId], { hid }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STAR_UP_TO, 1, { oldEquip, newEquip }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUIT_SEID_NUM, 1, { oldEplace, newEplace, ePlaceId, hid }); - } - await checkTask(roleId, sid, TASK_TYPE.EQUIP_STAR_UP_CNT, 1, true, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STAR_UP_CNT, 1, {}); -} - -export async function checkTaskInEquipQualityUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpQuality: boolean) { - if(isUpQuality) { - let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId); - await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP, oldEquip, newEquip, { hid }); - await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP_TO, oldEquip, newEquip); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP, 1, { ePlaceId, hid }); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP_TO, 1, { oldEquip, newEquip, hid }); - } - await checkTask(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP_CNT, 1, true, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP_CNT, 1); -} - -export async function checkTaskInEquipReset(serverId: number, roleId: string, sid: string) { - await checkTask(roleId, sid, TASK_TYPE.JEWEL_RESET, 1, true, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_RESET, 1); -} - -export async function checkTaskInEquipQuench(serverId: number, roleId: string, sid: string, isSuccess: boolean) { - await checkTask(roleId, sid, TASK_TYPE.JEWEL_QUENCH, 1, true, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_QUENCH, 1); - if(isSuccess) { - await checkTask(roleId, sid, TASK_TYPE.JEWEL_QUENCH_SUCCESS, 1, true, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_QUENCH_SUCCESS, 1); - } -} - -export async function checkTaskInComposeStone(serverId: number, roleId: string, sid: string, count: number) { - await checkTask(roleId, sid, TASK_TYPE.STONE_COMPOSE, count, true, {}); - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.STONE_COMPOSE, count); -} - - -function getEquipById(oldEplace: EPlace[], newEplace: EPlace[], eplaceId: number) { - let oldEquip = oldEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0); - let newEquip = newEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0); - return { oldEquip, newEquip } -} - - export function isLocked(randSe: RandSe[]) { for(let { locked } of randSe) { if(locked) return true; } return false; +} + +export function getEquipById(oldEplace: EPlace[], newEplace: EPlace[], eplaceId: number) { + let oldEquip = oldEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0); + let newEquip = newEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0); + return { oldEquip, newEquip } +} + +export function getJewelByEquip(oldEquip: EPlace, newEquip: EPlace, jewels: JewelType[]) { + let oldJewel = jewels.find(cur => cur && cur.seqId == oldEquip.jewel); + let newJewel = jewels.find(cur => cur && cur.seqId == newEquip.jewel); + return { oldJewel, newJewel } } \ No newline at end of file diff --git a/game-server/app/services/guildActivity/guildActivityService.ts b/game-server/app/services/guildActivity/guildActivityService.ts index 36b87df18..a183d9e97 100644 --- a/game-server/app/services/guildActivity/guildActivityService.ts +++ b/game-server/app/services/guildActivity/guildActivityService.ts @@ -15,7 +15,6 @@ import { pinus } from "pinus"; import { GuildActivityRecordModel } from "../../db/GuildActivityRec"; import { genAuction } from "../auctionService"; import { sendMailByContent } from "../mailService"; -import { getHonourObject } from '../../pubUtils/itemUtils'; import { GuildActivityCityType, GuildActivityCityModel } from "../../db/GuildActivityCity"; import { DicCityActivity } from "../../pubUtils/dictionary/DicCityActivity"; import { CityActivityObject } from "./cityActivityObj"; @@ -26,9 +25,9 @@ import { BossInstanceModel } from "../../db/BossInstance"; import { UserGuildModel } from "../../db/UserGuild"; import { raceActivityEnd } from "../timeTaskService"; import { addActive } from "../guildService"; -import { checkTask, checkActivityTask } from "../task/taskService"; import { ActivePlayer, GuildRecord, ServerRecordModel } from "../../db/ServerRecords"; import { Attack } from "../../domain/battleField/pvp"; +import { getHonourObject } from "../role/rewardService"; let gateActivityObj: GateActivityObject; let cityActivityObj: CityActivityObject; diff --git a/game-server/app/services/guildService.ts b/game-server/app/services/guildService.ts index e796bb05d..e4e5cfbd1 100644 --- a/game-server/app/services/guildService.ts +++ b/game-server/app/services/guildService.ts @@ -16,7 +16,7 @@ import { ErrLogModel } from '../db/ErrLog'; import { DATA_NAME } from '../consts/dataName'; import { addRoleToGuildChannel } from "./chatService"; import { Rank } from "./rankService"; -import { checkActivityTask, checkTask } from "./task/taskService"; +import { checkTask } from "./task/taskService"; import { CounterModel } from "../db/Counter"; import { getAuction } from "./auctionService"; import { changeGuildActivity } from "./activity/guildPayService"; @@ -126,8 +126,7 @@ export async function joinGuild(code: string, guildName: string, lv: number, rol } //成长任务-加入军团 - await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_JOIN, 1); - await checkTask(roleId, sid, TASK_TYPE.GUILD_JOIN, 1, true, {}); + await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_JOIN); return { status: 0, guild, userGuild, roleName: role.roleName, memberCnt: guild.memberCnt, guildCe: guild.guildCe } } @@ -316,7 +315,7 @@ export async function settleGuildWeekly() { }); await sendMailByContent(MAIL_TYPE.GUILD_ACTIVE_REWARD, roleId, { goods: reward }); // 任务 - await checkTask(roleId, null, TASK_TYPE.GUILD_JOB, 1, false, { job }); + await checkTask(serverId, roleId, null, TASK_TYPE.GUILD_JOB, { guildJob: job }); } await GuildModel.updateInfo(code, { activeWeekly: 0 }, {}); diff --git a/game-server/app/services/normalBattleService.ts b/game-server/app/services/normalBattleService.ts index 27ab6c8b3..e3936e72c 100644 --- a/game-server/app/services/normalBattleService.ts +++ b/game-server/app/services/normalBattleService.ts @@ -68,7 +68,7 @@ export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kin }); if(i != lv) { // 升级加体力 let dicAp = getDicApByLv(i); - await setAp(roleId, ip, i, dicAp.restoreAp, sid, ITEM_CHANGE_REASON.LV_UP); + await setAp(serverId, roleId, ip, i, dicAp.restoreAp, sid, ITEM_CHANGE_REASON.LV_UP); } } // 推送 diff --git a/game-server/app/services/orderService.ts b/game-server/app/services/orderService.ts index eadab397e..dcd058d77 100644 --- a/game-server/app/services/orderService.ts +++ b/game-server/app/services/orderService.ts @@ -22,7 +22,7 @@ import { resResult } from '../pubUtils/util'; import { checkOrderWX } from './pay/weixinPay'; import { addRechargeMoney } from './activity/rechargeMoneyService'; import { addVipRechargeMoney } from './activity/vipRechargeMoneyService'; -import { checkActivityTask } from './task/taskService'; +import { checkTask } from './task/taskService'; import { checkOrderALI } from './pay/aliPay'; import { getRoleOnlineInfo } from './redisService'; import { PayCallback37Data } from '../domain/sdk'; @@ -183,7 +183,7 @@ export async function settleOrder(order: UserOrderModelType, serverId: number, s addVipRechargeMoney(order.roleId, serverId, order.price); addGuildPay(result.roleInfo, order.price) //成长任务 - await checkActivityTask(serverId, sid, order.roleId, TASK_TYPE.ACTIVITY_RMB, order.price, { activityId: order.activityId }); + await checkTask(serverId, order.roleId, sid, TASK_TYPE.ACTIVITY_RMB, { count: order.price }); if(order.payType != PAY_TYPE.TEST) { reportTAEvent(order.roleId, TA_EVENT.RECHARGE_SUCCESS, { pay_id: order.localOrderID, charge_id: order.productID, pay_name: order.message, pay_amount: order.price, pay_channel: order.payType }) reportTAUserSet(TA_USERSET_TYPE.SET_ONCE, order.roleId, { first_pay_time: new Date() }); diff --git a/game-server/app/services/pvpService.ts b/game-server/app/services/pvpService.ts index 9af308e39..b86abcd26 100644 --- a/game-server/app/services/pvpService.ts +++ b/game-server/app/services/pvpService.ts @@ -630,8 +630,8 @@ export async function savePvpSeasonResult(pvpDefense: PvpDefenseType, seasonNum: } // 更新任务 - await checkTask(pvpDefense.roleId, null, TASK_TYPE.PVP_HERO_SCORE, 0, false, { heroScores: pvpDefense.heroScores }); - await checkTask(pvpDefense.roleId, null, TASK_TYPE.PVP_RANK, 1, false, { rankLv }); + await checkTask(pvpDefense.serverId, pvpDefense.roleId, null, TASK_TYPE.PVP_HERO_SCORE, { heroScores: pvpDefense.heroScores }); + await checkTask(pvpDefense.serverId, pvpDefense.roleId, null, TASK_TYPE.PVP_RANK, { pvpRank: rankLv }); return pvpSeasonResult; } diff --git a/game-server/app/services/role/checkMaterial.ts b/game-server/app/services/role/checkMaterial.ts new file mode 100644 index 000000000..006c9201f --- /dev/null +++ b/game-server/app/services/role/checkMaterial.ts @@ -0,0 +1,136 @@ +import { CURRENCY_TYPE, HANDLE_REWARD_TYPE, CURRENCY_BY_TYPE } from '../../consts'; +import { RoleModel, RoleType } from '../../db/Role'; +import { ItemModel, ItemType } from '../../db/Item'; +import { ItemInter, RewardInter, } from '../../pubUtils/interface'; +import { gameData } from '../../pubUtils/data'; +import { sortItems } from './util'; + +export class CheckMeterial { + private roleId: string; + private itemsIndb: Map = new Map(); // 玩家已有的东西 + private notEnoughItems: Map = new Map(); // 缺少的数量 + private consumes: ItemInter[] = []; // 消耗,正向数 + + private goldId = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD); + private coinId = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN); + + constructor(roleId: string, role?: RoleType, items?: ItemType[]) { + this.roleId = roleId; + if(role) { + this.itemsIndb.set(this.goldId, role.gold); + this.itemsIndb.set(this.coinId, role.coin); + } + if(items && items.length) { + for(let {id, count} of items) { + this.itemsIndb.set(id, count); + } + } + } + + private pushToNotEnoughItems(id: number, count: number) { + if(!this.notEnoughItems.has(id)) { + this.notEnoughItems.set(id, 0); + } + this.notEnoughItems.set(id, this.notEnoughItems.get(id) + count); + } + + private getNotEnoughItems() { + let map = new Map(); + for(let [ id, count ] of this.notEnoughItems) { + map.set(id, count); + } + return map; + } + + public async decrease(goods: {id: number, count: number}[]) { + this.notEnoughItems.clear(); + let { items, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST); + let isEnough = true; + for(let { id, count} of items) { + if(!this.itemsIndb.has(id)) { + let item = await ItemModel.findbyRoleAndGid(this.roleId, id); + if(!item) { + this.pushToNotEnoughItems(id, count); + isEnough = false; break; + } + this.itemsIndb.set(id, item.count); + } + if(this.itemsIndb.get(id) < count) { + this.pushToNotEnoughItems(id, count - this.itemsIndb.get(id)); + isEnough = false; break; + } + this.itemsIndb.set(id, this.itemsIndb.get(id) - count); + } + + if(gold.length > 0) { + if(!this.itemsIndb.has(this.goldId)) { + let role = await RoleModel.findByRoleId(this.roleId, 'gold coin'); + this.itemsIndb.set(this.goldId, role.gold); + this.itemsIndb.set(this.coinId, role.coin); + } + let goldCost = gold.reduce((pre, cur) => { return pre + cur.count }, 0); + if(this.itemsIndb.get(this.goldId) < goldCost) { + this.pushToNotEnoughItems(this.goldId, goldCost - this.itemsIndb.get(this.goldId)); + isEnough = false; + } + this.itemsIndb.set(this.goldId, this.itemsIndb.get(this.goldId) - goldCost); + } + if(isEnough && coin.length > 0) { + if(!this.itemsIndb.has(this.coinId)) { + let role = await RoleModel.findByRoleId(this.roleId, 'gold coin'); + this.itemsIndb.set(this.goldId, role.gold); + this.itemsIndb.set(this.coinId, role.coin); + } + let coinCost = coin.reduce((pre, cur) => pre + cur, 0); + if(this.itemsIndb.get(this.coinId) < coinCost) { + this.pushToNotEnoughItems(this.coinId, coinCost - this.itemsIndb.get(this.coinId)); + isEnough = false; + } + this.itemsIndb.set(this.coinId, this.itemsIndb.get(this.coinId) - coinCost); + } + + if(isEnough) this.consumes.push(...goods); + return isEnough; + } + + private getMaterialEnough(materials: RewardInter[], notEnoughItems: Map) { + let newMaterials: RewardInter[] = []; + for(let {id, count} of materials) { + if(notEnoughItems.has(id)) { + newMaterials.push({ id, count: count - notEnoughItems.get(id) }); + } else { + newMaterials.push({ id, count }); + } + } + return newMaterials; + } + + // 检查地玉石是否可以合成 + public async composeStone(id: number, count: number) { + let dicStone = gameData.stone.get(id); + if(!dicStone || dicStone.composeMaterial.length <= 0) return false; // 1阶石头不能再从下合成返回不行 + let materials = dicStone.composeMaterial.map(cur => ({...cur, count: cur.count * count })); + let isEnough = await this.decrease(materials); + if(!isEnough) { + let notEnoughItems = this.getNotEnoughItems(); + let newMaterials = this.getMaterialEnough(materials, notEnoughItems); + let isEnough = await this.decrease(newMaterials); // 消耗掉除了不足的部分以外的其他部分 + if(!isEnough) return false; + + let isAllOK = true; // 如果有石头不足,向下补充,isAllOK标识不足的都能补充上 + for(let [id, count] of notEnoughItems) { + let isEnough = await this.composeStone(id, count); + if(!isEnough) { + isAllOK = false; break; + } + } + return isAllOK; + } else { + return true; + } + } + + public getConsume() { + return this.consumes; + } +} \ No newline at end of file diff --git a/game-server/app/services/role/createHero.ts b/game-server/app/services/role/createHero.ts index 750866b68..ad52d5689 100644 --- a/game-server/app/services/role/createHero.ts +++ b/game-server/app/services/role/createHero.ts @@ -4,7 +4,6 @@ import { HeroModel, HeroSkin, HeroType, HeroUpdate } from "../../db/Hero"; import { RoleModel, RoleType, RoleUpdate } from "../../db/Role"; import { SkinUpdate } from "../../db/Skin"; import { Figure, TopHero } from "../../domain/dbGeneral"; -import { combineFigureInfo, unlockFigureWithoutSave } from '../../pubUtils/itemUtils'; import { TaskListReturn } from "../../domain/roleField/task"; import { GuildModel, GuildType } from "../../db/Guild"; import { PvpDefenseModel } from "../../db/PvpDefense"; @@ -12,12 +11,16 @@ import { pick } from "underscore"; import { calculatetopLineup } from "../../pubUtils/playerCe"; import { nowSeconds } from "../../pubUtils/timeUtil"; import { saveCeChangeLog } from "../../pubUtils/logUtil"; -import { reduceCe, resResult } from "../../pubUtils/util"; +import { getRandSingleEelm, reduceCe, resResult } from "../../pubUtils/util"; import { AttributeCal } from "../../domain/roleField/attribute"; -import { HeroShowParam } from "../../domain/roleField/hero"; +import { CreateHeroParam, HeroShowParam } from "../../domain/roleField/hero"; import { pinus } from "pinus"; import { Rank } from "../rankService"; import { checkTaskInCreateHero } from "../task/taskService"; +import { ItemInter, RewardInter } from "../../pubUtils/interface"; +import { transPiece } from "./util"; +import { getInitHeroById } from "../roleService"; +import { addItems, combineFigureInfo, unlockFigureWithoutSave } from "./rewardService"; export class UpdateHeroes { roleId: string; @@ -210,4 +213,65 @@ export class CreateHeroes extends UpdateHeroes { return { ...hero, ce: reduceCe(cur.ce)} }); } +} + + +/** + * 创建多个武将 + * @param roleId + * @param sid + * @param serverId + * @param heroInfo + */ + export async function createHeroes(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam[]) { + let hids = heroInfo.map(cur => cur.hid); + let userHeroesMap = await HeroModel.findMapByHidRange(hids, roleId); + + let infos: Map = new Map(), pieces: ItemInter[] = []; + for (let h of heroInfo) { + let heroCount = h.count || 1; + if (userHeroesMap.has(h.hid)) { + let { pieceId, count } = transPiece(h.hid); + pieces.push({ id: pieceId, count: count * heroCount }); + } else { + let initInfo: { heroInfo: HeroUpdate, skinInfo: SkinUpdate }; + if(pinus.app.getServerType() == 'role') { + initInfo = getInitHeroById(h.hid); + } else { + let roleServers = pinus.app.getServersByType('role'); + let server = getRandSingleEelm(roleServers); + initInfo = await pinus.app.rpc.role.roleRemote.getInitHeroById.toServer(server.id, h.hid); + } + + initInfo.heroInfo = { ...initInfo.heroInfo, ...h }; + + infos.set(h.hid, initInfo); + userHeroesMap.set(h.hid, null); + if (heroCount > 1) { + let { pieceId, count } = transPiece(h.hid); + pieces.push({ id: pieceId, count: count * (heroCount - 1) }); + } + } + } + + let resultHeroes: HeroType[] = [], resultItems: RewardInter[] = [], heroes: HeroShowParam[] = []; + if (infos.size > 0) { + let createHero = new CreateHeroes(roleId, roleName, serverId); + await createHero.createWithHeroInfo(infos); + await createHero.pushMessage(sid); + await createHero.updateRedisRank(); + heroes = createHero.getShowHeroes(); + resultHeroes = createHero.getResultHeroes(); + } + + if (pieces.length > 0) { + let goods = await addItems(roleId, roleName, sid, pieces, ITEM_CHANGE_REASON.HERO_TRANSFER_PIECE); + resultItems = goods; + } + return { heroes, resultHeroes, goods: resultItems } +} + +export async function createHero(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam) { + let result = await createHeroes(roleId, roleName, sid, serverId, [heroInfo]); + return result; } \ No newline at end of file diff --git a/game-server/app/services/role/initRoleService.ts b/game-server/app/services/role/initRoleService.ts index 39593c6f4..218990f28 100644 --- a/game-server/app/services/role/initRoleService.ts +++ b/game-server/app/services/role/initRoleService.ts @@ -5,7 +5,7 @@ import { SkinModel, SkinUpdate } from "../../db/Skin"; import { TopHero } from "../../domain/dbGeneral"; import { CalHeroCe, CalRoleCe } from "../../domain/roleField/calCe"; import { gameData, getHeroExpByLv } from "../../pubUtils/data"; -import { unlockFigureWithoutSave } from "../../pubUtils/itemUtils"; +import { unlockFigureWithoutSave } from "./rewardService"; // 储存在内存中的初始数据 export function getInitRoleInfo() { diff --git a/game-server/app/services/role/rewardService.ts b/game-server/app/services/role/rewardService.ts index 0c42bcee2..545df6c7a 100644 --- a/game-server/app/services/role/rewardService.ts +++ b/game-server/app/services/role/rewardService.ts @@ -1,163 +1,33 @@ -import { ITID, CONSUME_TYPE, ITEM_TABLE, CURRENCY, CURRENCY_TYPE, MAIL_TYPE, HANDLE_REWARD_TYPE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE, ITEM_CHANGE_REASON, TA_USERSET_TYPE, TA_EVENT, POP_UP_SHOP_CONDITION_TYPE } from '../../consts'; -import { getRandSingleEelm, resResult } from '../../pubUtils/util'; +import { ITID, CONSUME_TYPE, ITEM_TABLE, CURRENCY, CURRENCY_TYPE, MAIL_TYPE, HANDLE_REWARD_TYPE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE, ITEM_CHANGE_REASON, TA_USERSET_TYPE, TA_EVENT, POP_UP_SHOP_CONDITION_TYPE, ROLE_SELECT, FIGURE_UNLOCK_CONDITION } from '../../consts'; +import { getDecimalCnt, getRandEelm, getRandEelmWithWeight, getRandSingleEelm, getRandValueByMinMax, resResult } from '../../pubUtils/util'; import { RoleModel, RoleType } from '../../db/Role'; import { setAp } from '../actionPointService'; -import { pushCalAllHeroCe, calPlayerCeAndSave } from '../playerCeService'; +import { pushCalAllHeroCe, calPlayerCeAndSave, calAllHeroCe } from '../playerCeService'; import { ItemModel, ItemType } from '../../db/Item'; import { STATUS } from '../../consts/statusCode'; import { pinus } from 'pinus'; -import { addJewels, addBags, addSkin, addFigure, unlockFigure as pubUnlockFigure, transPiece, getGoldObject, getCoinObject, getApObject } from '../../pubUtils/itemUtils'; import { ItemInter, RewardInter, } from '../../pubUtils/interface'; import { gameData } from '../../pubUtils/data'; import { uniq } from 'underscore'; import { EPlace, HeroModel, HeroType, HeroUpdate } from '../../db/Hero'; import { Figure } from '../../domain/dbGeneral'; -import { Rank } from '../rankService'; -import { pushTaskUpdate } from '../task/taskService'; import { CreateHeroParam, HeroShowParam } from '../../domain/roleField/hero'; import { HeroSkin } from '../../db/Hero'; import { errlogger } from '../../util/logger'; import { BAG } from '../../pubUtils/dicParam'; import { sendMailByContent } from '../mailService'; -import { SkinUpdate } from '../../db/Skin'; +import { SkinModel, SkinUpdate } from '../../db/Skin'; import { getInitHeroById } from '../roleService'; import { getActivities } from '../activity/activityService'; import { reportTAEvent, reportTAUserSet } from '../sdkService'; import { saveCoinChangeLog, saveFigureInfoLog, saveGoldChangeLog, saveItemChangeLog } from '../../pubUtils/logUtil'; -import { JewelModel, JewelType } from '../../db/Jewel'; +import { JewelModel, JewelType, jewelUpdate, RandSe } from '../../db/Jewel'; import { updateEplaces } from '../equipService'; import { checkPopUpConditionInCreateHero } from '../activity/popUpShopService'; import { CreateHeroes } from './createHero'; +import { combineItems, getCoinEventProperties, getGoldEventProperties, sortItems } from './util'; +import { nowSeconds } from '../../pubUtils/timeUtil'; -export class CheckMeterial { - private roleId: string; - private itemsIndb: Map = new Map(); // 玩家已有的东西 - private notEnoughItems: Map = new Map(); // 缺少的数量 - private consumes: ItemInter[] = []; // 消耗,正向数 - - private goldId = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD); - private coinId = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN); - - constructor(roleId: string, role?: RoleType, items?: ItemType[]) { - this.roleId = roleId; - if(role) { - this.itemsIndb.set(this.goldId, role.gold); - this.itemsIndb.set(this.coinId, role.coin); - } - if(items && items.length) { - for(let {id, count} of items) { - this.itemsIndb.set(id, count); - } - } - } - - private pushToNotEnoughItems(id: number, count: number) { - if(!this.notEnoughItems.has(id)) { - this.notEnoughItems.set(id, 0); - } - this.notEnoughItems.set(id, this.notEnoughItems.get(id) + count); - } - - private getNotEnoughItems() { - let map = new Map(); - for(let [ id, count ] of this.notEnoughItems) { - map.set(id, count); - } - return map; - } - - public async decrease(goods: {id: number, count: number}[]) { - this.notEnoughItems.clear(); - let { items, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST); - let isEnough = true; - for(let { id, count} of items) { - if(!this.itemsIndb.has(id)) { - let item = await ItemModel.findbyRoleAndGid(this.roleId, id); - if(!item) { - this.pushToNotEnoughItems(id, count); - isEnough = false; break; - } - this.itemsIndb.set(id, item.count); - } - if(this.itemsIndb.get(id) < count) { - this.pushToNotEnoughItems(id, count - this.itemsIndb.get(id)); - isEnough = false; break; - } - this.itemsIndb.set(id, this.itemsIndb.get(id) - count); - } - - if(gold.length > 0) { - if(!this.itemsIndb.has(this.goldId)) { - let role = await RoleModel.findByRoleId(this.roleId, 'gold coin'); - this.itemsIndb.set(this.goldId, role.gold); - this.itemsIndb.set(this.coinId, role.coin); - } - let goldCost = gold.reduce((pre, cur) => { return pre + cur.count }, 0); - if(this.itemsIndb.get(this.goldId) < goldCost) { - this.pushToNotEnoughItems(this.goldId, goldCost - this.itemsIndb.get(this.goldId)); - isEnough = false; - } - this.itemsIndb.set(this.goldId, this.itemsIndb.get(this.goldId) - goldCost); - } - if(isEnough && coin.length > 0) { - if(!this.itemsIndb.has(this.coinId)) { - let role = await RoleModel.findByRoleId(this.roleId, 'gold coin'); - this.itemsIndb.set(this.goldId, role.gold); - this.itemsIndb.set(this.coinId, role.coin); - } - let coinCost = coin.reduce((pre, cur) => pre + cur, 0); - if(this.itemsIndb.get(this.coinId) < coinCost) { - this.pushToNotEnoughItems(this.coinId, coinCost - this.itemsIndb.get(this.coinId)); - isEnough = false; - } - this.itemsIndb.set(this.coinId, this.itemsIndb.get(this.coinId) - coinCost); - } - - if(isEnough) this.consumes.push(...goods); - return isEnough; - } - - private getMaterialEnough(materials: RewardInter[], notEnoughItems: Map) { - let newMaterials: RewardInter[] = []; - for(let {id, count} of materials) { - if(notEnoughItems.has(id)) { - newMaterials.push({ id, count: count - notEnoughItems.get(id) }); - } else { - newMaterials.push({ id, count }); - } - } - return newMaterials; - } - - // 检查地玉石是否可以合成 - public async composeStone(id: number, count: number) { - let dicStone = gameData.stone.get(id); - if(!dicStone || dicStone.composeMaterial.length <= 0) return false; // 1阶石头不能再从下合成返回不行 - let materials = dicStone.composeMaterial.map(cur => ({...cur, count: cur.count * count })); - let isEnough = await this.decrease(materials); - if(!isEnough) { - let notEnoughItems = this.getNotEnoughItems(); - let newMaterials = this.getMaterialEnough(materials, notEnoughItems); - let isEnough = await this.decrease(newMaterials); // 消耗掉除了不足的部分以外的其他部分 - if(!isEnough) return false; - - let isAllOK = true; // 如果有石头不足,向下补充,isAllOK标识不足的都能补充上 - for(let [id, count] of notEnoughItems) { - let isEnough = await this.composeStone(id, count); - if(!isEnough) { - isAllOK = false; break; - } - } - return isAllOK; - } else { - return true; - } - } - - public getConsume() { - return this.consumes; - } -} export async function handleCost(roleId: string, sid: string, goods: Array, reason: ITEM_CHANGE_REASON) { @@ -264,7 +134,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go } // 直接加的 - let { jewels: jewelInfos, pushMessages } = await addJewels(roleId, roleName, <{id: number, hid?: number}[]>incJewels, reason); + let { jewels: jewelInfos } = await addJewels(roleId, roleName, <{id: number, hid?: number}[]>incJewels, reason); for (let jewel of jewelInfos) { showItems.push({ seqId: jewel.seqId, id: jewel.id, count: 1, isBag: true }); } @@ -274,7 +144,6 @@ export async function addItems(roleId: string, roleName: string, sid: string, go //装备推送 if (!!jewelInfos.length) pinus.app.get('channelService').pushMessageByUids('onJewelAdd', resResult(STATUS.SUCCESS, { jewelInfos }), uids); - pushTaskUpdate(roleId, sid, pushMessages); //统计装备 if (jewelInfos.length > 0) { saveItemChangeLog(roleId, jewelInfos, reason); @@ -301,7 +170,7 @@ export async function addItems(roleId: string, roleName: string, sid: string, go // 3. 货币推送 if(gold.length > 0 || coin.length > 0 || ap > 0) { - await setAp(roleId, null, role.lv, ap, sid, reason); + await setAp(role.serverId, roleId, null, role.lv, ap, sid, reason); let incCoin = coin.reduce((pre, cur) => pre + cur, 0); let incGold = gold.reduce((pre, cur) => pre + cur.count, 0); role = await RoleModel.increaseGoldAndCoin(roleId, gold, incCoin); @@ -337,15 +206,10 @@ export async function addItems(roleId: string, roleName: string, sid: string, go let calAllHeroResult = undefined; // 全局战力变化推送 for (let skinId of skins) {//皮肤推送 - let result = await addSkin(roleId, roleName, skinId, false); - if (!!result) { + let hero = await addSkin(roleId, roleName, sid, skinId, false); + if (!!hero) { showItems.push({ id: skinId, count: 1 }); - figureInfos.push(result.figureInfo); - if(result.hero) { - heroskins.push({ skins: result.hero.skins, hid: result.hero.hid }); - if(result.calAllHeroResult) calAllHeroResult = result.calAllHeroResult; - } - skinInfos.push({ id: skinId, hid: result.hero?.hid||0, count: 1, inc: 1, reason }) + skinInfos.push({ id: skinId, hid: hero?.hid||0, count: 1, inc: 1, reason }) } } if (!!skinInfos.length) { @@ -376,127 +240,6 @@ export async function addItems(roleId: string, roleName: string, sid: string, go return showItems; } -function getGoldEventProperties(inc: number, count: number, reason: ITEM_CHANGE_REASON) { - let id = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD); - let dicGoods = gameData.goods.get(id); - return { item_id: id, item_name: dicGoods.name, item_itid: dicGoods.itid, change_count: inc, change_after: count, change_reason: reason } -} - -function getCoinEventProperties(inc: number, count: number, reason: ITEM_CHANGE_REASON) { - let id = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN); - let dicGoods = gameData.goods.get(id); - return { item_id: id, item_name: dicGoods.name, item_itid: dicGoods.itid, change_count: inc, change_after: count, change_reason: reason } -} - -export function combineItems(items: { id?: number, count?: number }[]) { - let result: { id: number, count: number }[] = []; - for(let { id, count = 1 } of items) { - let index = result.findIndex(cur => cur.id == id); - if(index == -1) { - result.push({ id, count }); - } else { - result[index].count += count; - } - } - return result; -} - -export function combineItemAndJewels(items: { id?: number, count?: number }[]) { - let result: { id: number, count: number }[] = []; - for(let { id, count = 1 } of items) { - let dicGoods = gameData.goods.get(id); - let dicItid = ITID.get(dicGoods.itid); - if(dicItid.table != 'jewel') { - let index = result.findIndex(cur => cur.id == id); - if(index == -1) { - result.push({ id, count }); - } else { - result[index].count += count; - } - } else { - result.push({ id, count }); - } - } - return result; -} - -function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) { - let items: { id: number, count: number }[] = []; // 可叠加道具 - let jewels: { seqId?: number, id?: number, hid?: number }[] = []; // 不可叠加装备 - let gold: { count: number, isPay: boolean }[] = []; // 金币 - let coin: number[] = []; - let ap: number = 0; - let skins: number[] = []; - let figures: number[] = []; - - for(let good of goods) { - if(good.count == 0) continue; - let dicGood = gameData.goods.get(good.id); - if(!dicGood) { - errlogger.error(`物品 ${good.id} 未配置`); - continue; - } - let dicItid = ITID.get(dicGood.itid); - if(!dicItid) { - errlogger.error(`itid ${dicGood.itid} 未配置`); - continue; - } - let { type, table, isCurrency } = dicItid; - if(table == ITEM_TABLE.JEWEL) { // 装备 - if(handleType == HANDLE_REWARD_TYPE.RECEIVE) { - for(let i = 0; i < good.count; i++) { - jewels.push({ id: good.id, hid: good.hid }) - } - } else { - if(!!good.seqId) { - jewels.push({ seqId: good.seqId }); - } - } - } else if (table == ITEM_TABLE.ITEM) { // 可叠加道具 - let index = items.findIndex(cur => cur.id == good.id); - if(index > 0) { - items[index].count += good.count; - } else { - items.push({ id: good.id, count: good.count }); - } - } else if (table == ITEM_TABLE.SKIN) { // 皮肤,不可重复获得,不可删 - if(handleType == HANDLE_REWARD_TYPE.RECEIVE) { - let index = skins.indexOf(good.id); - if (index == -1) { - skins.push(good.id); - } - } - } else if (table == ITEM_TABLE.ROLE) { - if(isCurrency) { // 3种货币 - let dicCurrency = CURRENCY.get(good.id); - if(dicCurrency) { - if(dicCurrency.type == CURRENCY_TYPE.GOLD) { // 金币,区分付费和免费,默认免费 - let index = gold.findIndex(cur => cur.isPay == !!good.isPay); - if(index > 0) { - gold[index].count += good.count; - } else { - gold.push({ count: good.count, isPay: !!good.isPay }); - } - } else if (dicCurrency.type == CURRENCY_TYPE.COIN) { // 铜钱 - coin.push(good.count); - } else if (dicCurrency.type == CURRENCY_TYPE.ACTION_POINT) { // 体力 - ap += good.count; - } - } - } else { - if (type == CONSUME_TYPE.HEAD || type == CONSUME_TYPE.FRAME || type == CONSUME_TYPE.SPINE) { // 头像等,不可重复获得,不可删 - let index = figures.indexOf(good.id); - if (index == -1) { - figures.push(good.id); - } - } - } - } - - } - - return { items, jewels, gold, coin, ap, skins, figures } -} export async function checkGoods(roleId: string, goodIds: Array) { let jewelSeqIds: Array = []; @@ -546,79 +289,24 @@ export async function checkHeroEquips(roleId: string, quality: number) { return await HeroModel.checkEquipByQuality(roleId, quality); } +/** + * 解锁头像/相框 + * @param roleId 玩家id + * @param conditions 解锁条件 + * @param role 如果已查询过role表就直接可以使用 + */ export async function unlockFigure(sid: string, roleId: string, conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number, paramWinStreakNum?: number }[], role?: RoleType) { - let figureInfo = await pubUnlockFigure(roleId, conditions, role); - await pushFigureUpdate(roleId, sid, figureInfo); -} - -export async function pushFigureUpdate(roleId: string, sid: string, figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }) { + if (!role || !role.heads || !role.frames) { + role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS); + } + let { figureInfo, heads, frames, spines } = unlockFigureWithoutSave(conditions, role); + role = await RoleModel.updateRoleInfo(roleId, { heads, frames, spines }); if (!!figureInfo && (figureInfo.heads.length > 0 || figureInfo.frames.length > 0 || figureInfo.spines.length > 0)) { let uids = [{ uid: roleId, sid }]; pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids); } } -/** - * 创建多个武将 - * @param roleId - * @param sid - * @param serverId - * @param heroInfo - */ -export async function createHeroes(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam[]) { - let hids = heroInfo.map(cur => cur.hid); - let userHeroesMap = await HeroModel.findMapByHidRange(hids, roleId); - - let infos: Map = new Map(), pieces: ItemInter[] = []; - for (let h of heroInfo) { - let heroCount = h.count || 1; - if (userHeroesMap.has(h.hid)) { - let { pieceId, count } = transPiece(h.hid); - pieces.push({ id: pieceId, count: count * heroCount }); - } else { - let initInfo: { heroInfo: HeroUpdate, skinInfo: SkinUpdate }; - if(pinus.app.getServerType() == 'role') { - initInfo = getInitHeroById(h.hid); - } else { - let roleServers = pinus.app.getServersByType('role'); - let server = getRandSingleEelm(roleServers); - initInfo = await pinus.app.rpc.role.roleRemote.getInitHeroById.toServer(server.id, h.hid); - } - - initInfo.heroInfo = { ...initInfo.heroInfo, ...h }; - - infos.set(h.hid, initInfo); - userHeroesMap.set(h.hid, null); - if (heroCount > 1) { - let { pieceId, count } = transPiece(h.hid); - pieces.push({ id: pieceId, count: count * (heroCount - 1) }); - } - } - } - - let resultHeroes: HeroType[] = [], resultItems: RewardInter[] = [], heroes: HeroShowParam[] = []; - if (infos.size > 0) { - let createHero = new CreateHeroes(roleId, roleName, serverId); - await createHero.createWithHeroInfo(infos); - await createHero.pushMessage(sid); - await createHero.updateRedisRank(); - heroes = createHero.getShowHeroes(); - resultHeroes = createHero.getResultHeroes(); - - await checkPopUpConditionInCreateHero(serverId, roleId, resultHeroes); - } - - if (pieces.length > 0) { - let goods = await addItems(roleId, roleName, sid, pieces, ITEM_CHANGE_REASON.HERO_TRANSFER_PIECE); - resultItems = goods; - } - return { heroes, resultHeroes, goods: resultItems } -} - -export async function createHero(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam) { - let result = await createHeroes(roleId, roleName, sid, serverId, [heroInfo]); - return result; -} /** * 皮肤数据变化去重、推送 @@ -640,4 +328,335 @@ function pushHeroSkinMsg(heroskins: {skins: HeroSkin[], hid: number}[], skinInf if(pushSkinInfos.length > 0 || skinInfos.length > 0) { pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, { heros: heroskins, skins: skinInfos }), uids); } -} \ No newline at end of file +} + + +/** + * 只插入皮肤,不管那么多的 + * @param roleId + * @param roleName + * @param skinId + * @returns + */ + export async function increaseSkin(roleId:string, roleName: string, skinId: number) { + let dicSkin = gameData.fashion.get(skinId); + if (!dicSkin) return false; + + let skin = await SkinModel.increaseSkin(roleId, skinId, { roleId, roleName, id: skinId, skinName: dicSkin.name, hid: dicSkin.actorId, skinId: dicSkin.heroId }); + if(!skin) return false; // 插入失败 + return skin +} + +/** + * 添加皮肤 + * @param roleId 玩家id + * @param roleName 玩家名 + * @param id 皮肤id + * @param hero 武将,如果已经查询过这个武将就不用再查询一次,主意要select skins字段 + * @returns {{ hero, figureInfo, calAllHeroResult }} hero:添加皮肤后的武将 figureInfo: 触发头像添加信息 calAllHeroResult:全局战力加成后结果 + */ +export async function addSkin(roleId: string, roleName: string, sid: string, skinId: number, enable: boolean, hero?: HeroType) { + let skin = await increaseSkin(roleId, roleName, skinId); + if(!skin) return false; + + if(skin.hid && !hero) hero = await HeroModel.findByHidAndRole(skin.hid, roleId); + let condition = { type: FIGURE_UNLOCK_CONDITION.GET_SKIN, paramSkinId: skinId }; + await unlockFigure(sid, roleId, [condition]); // 解锁头像 + await calAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, sid, roleId, {}, [skinId]); // 全局加成 + + if (hero) { // 有武将的,将皮肤链接到武将上 + let curSkin = hero.skins.find(cur => cur.id == skinId); + if (!curSkin) { + hero.skins.push({ id: skinId, skin: skin._id, enable, skinId: skin.skinId }); + await HeroModel.updateHeroInfo(roleId, hero.hid, hero); + } + return hero; + } else { + return null + } +} + +export async function addBags(roleId: string, roleName: string, datas: { id: number, count: number }[], reason: number) { + let items: { id: number, count: number, inc: number }[] = []; + for(let data of datas) { + let item = await addBag(roleId, roleName, data, reason); + items.push(item) + } + return { items } +} + +export async function addBag(roleId: string, roleName: string, data: { id: number, count: number }, reason: number) { + let { id, count } = data; + let { name: itemName, itid, hid } = gameData.goods.get(id); + let { type } = ITID.get(itid); + + let item = await ItemModel.increaseItem(roleId, id, count, { roleId, roleName, itemName, id, type, hid }); + return { id: item.id, count: item.count, inc: count, reason }; +} + + +export async function addJewels(roleId: string, roleName: string, jewels: { id: number, }[], reason: number) { + let jewelInfo: jewelUpdate[] = []; + for(let jewel of jewels) { + let info = await getAddJewelInfo(roleId, roleName, jewel); + jewelInfo.push(info); + } + + const jewelResult = await JewelModel.createJewels(roleId, jewelInfo); + return { jewels: jewelResult.map(jewel => { + return { ...jewel, count: 1, inc: 1, reason } + })} +} + +export async function getAddJewelInfo(roleId: string, roleName: string, jewel: { id: number, }) { + let { id, } = jewel; + let { name, randomEffect, effectCount } = gameData.jewel.get(id); + + // 随机属性 + let randomResult: number[] = getRandEelm(randomEffect, effectCount); + + let randSe: Array = randomResult.map((id: number, index: number) => { + return getJewelRandSe(index + 1, id); + }); + + return { roleId, roleName, id, name, randSe }; +} + +/** + * 天晶石已知词条随机值 + * @param id 词条位置,第几条 + * @param seid 词条id + * @returns + */ +export function getJewelRandSe(id: number, seid: number) { + let dicRandom = gameData.randomEffectPool.get(seid) + let rand = 0; + if (dicRandom.id > 0) { + let randRange = getRandEelmWithWeight(dicRandom.rate); + let randResult = getRandValueByMinMax(randRange.dic.min, randRange.dic.max, getDecimalCnt(dicRandom.gap)); + let n = Math.floor((randResult - dicRandom.Min)/dicRandom.gap); + rand = dicRandom.Min + n * dicRandom.gap; + } + return new RandSe(id, dicRandom.id, rand); +} + +export function getGoldId() { + return CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD); +} + +/** + * @description 获取元宝物品 { id, count } + * @param count 元宝数量 + */ +export function getGoldObject(count: number) { + return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count }; +} + +/** + * @description 获取金币物品 { id, count } + * @param count 元宝数量 + */ +export function getCoinObject(count: number) { + return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN), count }; +} + +/** + * @description 获取体力物品 { id, count } + * @param count 体力数量 + */ + export function getApObject(count: number) { + return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.ACTION_POINT), count }; +} +/** + * @description 获取友情点物品 { id, count } + * @param count 友情点数量 + */ +export function getFriendPointObject(count: number) { + return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.FRIEND_POINT), count }; +} + +/** + * @description 获取功勋物品 { id, count } + * @param count 功勋数量 + */ +export function getHonourObject(count: number) { + return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.HONOUR), count }; +} + +/** + * 返回 解锁头像/相框 + * @param conditions 解锁条件 + * @param role 如果已查询过role表就直接可以使用 + */ + export function unlockFigureWithoutSave(conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number, paramWinStreakNum?: number }[], role: RoleType) { + + let { heads, frames, spines } = role; + let figureInfo = { heads: new Array
(), frames: new Array
(), spines: new Array
() }; + for (let { type, paramHid, paramFavourLv, paramSkinId, paramWinStreakNum } of conditions) { + let canUnLockList = gameData.figureCondition.get(type); + if (canUnLockList) { + let reason = 0; + + for (let { id, params, gid } of canUnLockList) { + let flag = false; // 是否达成条件 + if (type == FIGURE_UNLOCK_CONDITION.GET_HERO) { + let [hid] = params; + if (paramHid == hid) flag = true; + reason = ITEM_CHANGE_REASON.GET_HERO_UNLOCK_FIGURE; + } else if (type == FIGURE_UNLOCK_CONDITION.HERO_FAVOR) { + let [hid, favourLv] = params; + if (paramHid == hid && paramFavourLv >= favourLv) flag = true; + reason = ITEM_CHANGE_REASON.HERO_FAVOR_UNLOCK_FIGURE; + } else if (type == FIGURE_UNLOCK_CONDITION.GET_SKIN) { + let [id] = params; + if (paramSkinId == id) flag = true; + reason = ITEM_CHANGE_REASON.ADD_SKIN_UNLOCK_FIGURE; + } else if (type == FIGURE_UNLOCK_CONDITION.PVP_WIN_SERIES) { + let [winStreakNum] = params; + if (paramWinStreakNum >= winStreakNum) flag = true; + reason = ITEM_CHANGE_REASON.PVP_SERIES_UNLOCK_FIGURE; + } + if (!flag) continue; + let dicGood = gameData.goods.get(gid); + if (!dicGood) continue; + let dicItid = ITID.get(dicGood.itid); + if (!dicItid) continue; + + if (dicItid.type == CONSUME_TYPE.HEAD) { + let figure = unlockSingleFigure(heads, gid, reason, false, id); + if (figure && figure.unlocked) figureInfo.heads.push(figure); + } else if (dicItid.type == CONSUME_TYPE.FRAME) { + let figure = unlockSingleFigure(frames, gid, reason, false, id); + if (figure && figure.unlocked) figureInfo.frames.push(figure); + } else if (dicItid.type == CONSUME_TYPE.SPINE) { + let figure = unlockSingleFigure(spines, gid, reason, false, id); + if (figure && figure.unlocked) figureInfo.spines.push(figure); + } else { + continue; + } + + } + + } + } + return { figureInfo, heads, frames, spines }; +} + + + +// 直接获得形象/相框 +export async function addFigure(roleId: string, ids: number[], reason: number) { + let role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS); + + if (!role) return false; + let { heads, frames, spines } = role; + + let figureInfo = { heads: [], frames: [], spines: [] }; + for (let gid of ids) { + let dicGoods = gameData.goods.get(gid); + if (!dicGoods) continue; + let dicItid = ITID.get(dicGoods.itid); + if (!dicItid) continue; + + if (dicItid.type == CONSUME_TYPE.HEAD) { + let figure = unlockSingleFigure(heads, gid, reason, true); + if (figure && figure.unlocked) figureInfo.heads.push(figure); + } else if (dicItid.type == CONSUME_TYPE.FRAME) { + let figure = unlockSingleFigure(frames, gid, reason, true); + if (figure && figure.unlocked) figureInfo.frames.push(figure); + } else if (dicItid.type == CONSUME_TYPE.SPINE) { + let figure = unlockSingleFigure(spines, gid, reason, true); + if (figure && figure.unlocked) figureInfo.spines.push(figure); + } else { + continue; + } + } + + role = await RoleModel.updateRoleInfo(roleId, { heads, frames, spines }); + return figureInfo; +} + +/** + * 根据物品id解锁/获得玩家数据 + * @param dbFigures 数据库内字段 + * @param id 物品id + * @param unlockDirect 是否不计算解锁条件直接解锁 + * @param conditionId 条件id + */ +function unlockSingleFigure(dbFigures: Figure[], id: number, reason: number, unlockDirect = false, conditionId?: number) { + let index = dbFigures.findIndex(cur => cur.id == id); + let figure = dbFigures[index]; + if (index == -1) { + figure = new Figure(id, false); + dbFigures.push(figure); + index = dbFigures.length - 1; + } + if (figure.unlocked) return; // 已解锁过 + if (!figure.unlockedId) figure.unlockedId = new Array(); + + let dicGoods = gameData.goods.get(id); + + let hasUnlockedAll = true; + if (!unlockDirect) { // 不能直接获得,需要通过type解锁 + if (figure.unlockedId.includes(conditionId)) return; + + figure.unlockedId.push(conditionId); + + for (let { id: cid } of dicGoods.condition) { + if (!figure.unlockedId.includes(cid)) { + hasUnlockedAll = false; break; + } + } + } + if (hasUnlockedAll) { + figure.unlocked = true; + delete figure.unlockedId; + + if (dicGoods.timeLimit) { + figure.time = nowSeconds() + dicGoods.timeLimit * 86400 + } + } + + figure.inc = 1; + figure.reason = reason; + dbFigures[index] = figure; + return figure +} + +// async function getSkinsOfThisHero(roleId: string, roleName: string, hid: number, initialSkin: number, allSkins?: SkinType[]) { +// if(!allSkins) allSkins = await SkinModel.findbyRoleAndHid(roleId, hid); +// let skin = await increaseSkin(roleId, roleName, initialSkin); +// if(skin) allSkins.push(skin); +// let skins: { id: number, skin: string, enable: boolean }[] = []; +// for(let skin of allSkins) { +// skins.push({ id: skin.id, skin: skin._id, enable: skin.id == initialSkin }); +// } + +// return skins +// } + +export function combineFigureInfo(figureInfos: { heads: Figure[], frames: Figure[], spines: Figure[] }[]) { + let figureInfo = { heads: new Array
(), frames: new Array
(), spines: new Array
() }; + for(let {heads, frames, spines} of figureInfos) { + for(let head of heads) { + figureInfo.heads.push(head); + } + for(let frame of frames) { + figureInfo.frames.push(frame); + } + for(let spine of spines) { + figureInfo.spines.push(spine); + } + } + return figureInfo; +} + +// export class CreateHero { +// roleId: string; +// roleName: string; +// serverId: number; + +// constructor(roleId: string, roleName: string, serverId: number) { + +// } +// } \ No newline at end of file diff --git a/game-server/app/services/role/util.ts b/game-server/app/services/role/util.ts new file mode 100644 index 000000000..c94fb6e3a --- /dev/null +++ b/game-server/app/services/role/util.ts @@ -0,0 +1,133 @@ +import { ITID, CONSUME_TYPE, ITEM_TABLE, CURRENCY, CURRENCY_TYPE, HANDLE_REWARD_TYPE, ITEM_CHANGE_REASON, CURRENCY_BY_TYPE } from '../../consts'; +import { ItemInter, RewardInter, } from '../../pubUtils/interface'; +import { gameData } from '../../pubUtils/data'; +import { errlogger } from '../../util/logger'; + +export function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) { + let items: { id: number, count: number }[] = []; // 可叠加道具 + let jewels: { seqId?: number, id?: number, hid?: number }[] = []; // 不可叠加装备 + let gold: { count: number, isPay: boolean }[] = []; // 金币 + let coin: number[] = []; + let ap: number = 0; + let skins: number[] = []; + let figures: number[] = []; + + for(let good of goods) { + if(good.count == 0) continue; + let dicGood = gameData.goods.get(good.id); + if(!dicGood) { + errlogger.error(`物品 ${good.id} 未配置`); + continue; + } + let dicItid = ITID.get(dicGood.itid); + if(!dicItid) { + errlogger.error(`itid ${dicGood.itid} 未配置`); + continue; + } + let { type, table, isCurrency } = dicItid; + if(table == ITEM_TABLE.JEWEL) { // 装备 + if(handleType == HANDLE_REWARD_TYPE.RECEIVE) { + for(let i = 0; i < good.count; i++) { + jewels.push({ id: good.id, hid: good.hid }) + } + } else { + if(!!good.seqId) { + jewels.push({ seqId: good.seqId }); + } + } + } else if (table == ITEM_TABLE.ITEM) { // 可叠加道具 + let index = items.findIndex(cur => cur.id == good.id); + if(index > 0) { + items[index].count += good.count; + } else { + items.push({ id: good.id, count: good.count }); + } + } else if (table == ITEM_TABLE.SKIN) { // 皮肤,不可重复获得,不可删 + if(handleType == HANDLE_REWARD_TYPE.RECEIVE) { + let index = skins.indexOf(good.id); + if (index == -1) { + skins.push(good.id); + } + } + } else if (table == ITEM_TABLE.ROLE) { + if(isCurrency) { // 3种货币 + let dicCurrency = CURRENCY.get(good.id); + if(dicCurrency) { + if(dicCurrency.type == CURRENCY_TYPE.GOLD) { // 金币,区分付费和免费,默认免费 + let index = gold.findIndex(cur => cur.isPay == !!good.isPay); + if(index > 0) { + gold[index].count += good.count; + } else { + gold.push({ count: good.count, isPay: !!good.isPay }); + } + } else if (dicCurrency.type == CURRENCY_TYPE.COIN) { // 铜钱 + coin.push(good.count); + } else if (dicCurrency.type == CURRENCY_TYPE.ACTION_POINT) { // 体力 + ap += good.count; + } + } + } else { + if (type == CONSUME_TYPE.HEAD || type == CONSUME_TYPE.FRAME || type == CONSUME_TYPE.SPINE) { // 头像等,不可重复获得,不可删 + let index = figures.indexOf(good.id); + if (index == -1) { + figures.push(good.id); + } + } + } + } + + } + + return { items, jewels, gold, coin, ap, skins, figures } +} + +export function getGoldEventProperties(inc: number, count: number, reason: ITEM_CHANGE_REASON) { + let id = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD); + let dicGoods = gameData.goods.get(id); + return { item_id: id, item_name: dicGoods.name, item_itid: dicGoods.itid, change_count: inc, change_after: count, change_reason: reason } +} + +export function getCoinEventProperties(inc: number, count: number, reason: ITEM_CHANGE_REASON) { + let id = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN); + let dicGoods = gameData.goods.get(id); + return { item_id: id, item_name: dicGoods.name, item_itid: dicGoods.itid, change_count: inc, change_after: count, change_reason: reason } +} + +export function combineItems(items: { id?: number, count?: number }[]) { + let result: { id: number, count: number }[] = []; + for(let { id, count = 1 } of items) { + let index = result.findIndex(cur => cur.id == id); + if(index == -1) { + result.push({ id, count }); + } else { + result[index].count += count; + } + } + return result; +} + +export function combineItemAndJewels(items: { id?: number, count?: number }[]) { + let result: { id: number, count: number }[] = []; + for(let { id, count = 1 } of items) { + let dicGoods = gameData.goods.get(id); + let dicItid = ITID.get(dicGoods.itid); + if(dicItid.table != 'jewel') { + let index = result.findIndex(cur => cur.id == id); + if(index == -1) { + result.push({ id, count }); + } else { + result[index].count += count; + } + } else { + result.push({ id, count }); + } + } + return result; +} + + +export function transPiece(hid: number) { + let dicHero = gameData.hero.get(hid); + let count = gameData.heroTransPiece.get(dicHero.quality); + return { pieceId: dicHero.pieceId, count } +} \ No newline at end of file diff --git a/game-server/app/services/roleService.ts b/game-server/app/services/roleService.ts index 7a4985a63..f4cf2c2cc 100644 --- a/game-server/app/services/roleService.ts +++ b/game-server/app/services/roleService.ts @@ -8,12 +8,12 @@ import { SCHOOL } from '../pubUtils/dicParam'; import { gameData } from '../pubUtils/data'; import { SchoolModel } from '../db/School'; import { SclResultInter, SclPosInter, RewardInter, ItemInter } from '../pubUtils/interface'; -import { CheckMeterial } from './role/rewardService'; import { HeroUpdate } from '../db/Hero'; import { SkinUpdate } from '../db/Skin'; import { Figure } from '../domain/dbGeneral'; import { pick } from 'underscore'; import { Reward } from '../domain/battleField/pvp'; +import { CheckMeterial } from './role/checkMaterial'; export async function getTeraphStrengthenResult(role: RoleType, count: number, dicTeraph: DicTeraph, teraph: Teraph) { let criAttr: number[] = [], times = 0; diff --git a/game-server/app/services/sdkService.ts b/game-server/app/services/sdkService.ts index dcd617c30..3716c4440 100644 --- a/game-server/app/services/sdkService.ts +++ b/game-server/app/services/sdkService.ts @@ -3,7 +3,6 @@ import { RoleModel, RoleType } from "../db/Role"; import { Chat37Params, CheckGuild37Params, CheckName37Params, GetWordParam } from "../domain/sdk"; import { sendMailByContent, sendMailToGuildByContent } from './mailService'; -import { getGoldObject } from '../pubUtils/itemUtils'; import { NAMEPLATE } from '../pubUtils/dicParam'; import { CHANNEL_PREFIX, FILENAME, getSdkChannelId, MAIL_TYPE, REDIS_KEY, SDK_37_ADDR, SDK_37_CONST, SDK_TA_CONST, STATUS, TA_USERSET_TYPE, THINKING_DATA_MODE, THINKING_DATA_MODE_LIST } from "../consts"; import { UserModel } from "../db/User"; @@ -16,6 +15,7 @@ import { getRandSingleEelm, readWordTxt, resResult, writeWordTxt } from "../pubU const ThinkingAnalytics = require("thinkingdata-node"); import Trie from '../pubUtils/trie'; import _ = require("underscore"); +import { getGoldObject } from "./role/rewardService"; // 检查私聊是否合法 diff --git a/game-server/app/services/task/taskObj.ts b/game-server/app/services/task/taskObj.ts index 3341c941e..1f3d3a64e 100644 --- a/game-server/app/services/task/taskObj.ts +++ b/game-server/app/services/task/taskObj.ts @@ -17,11 +17,13 @@ import { SevenDaysData } from "../../domain/activityField/sevenDaysField"; import { ThirtyDaysData } from "../../domain/activityField/thirtyDaysField"; import { TreasureHuntData } from "../../domain/activityField/treasureHuntField"; import { TaskListReturn, TaskParam, TaskParamInter, UpdateTaskParam } from "../../domain/roleField/task"; -import { gameData } from "../../pubUtils/data"; +import { gameData, getDicBlueprtById, getEquipSuitByHero } from "../../pubUtils/data"; import { getZeroPoint } from "../../pubUtils/timeUtil"; import { resResult } from "../../pubUtils/util"; import { getActivities, getActivitiesByType, getActivityByServerId } from "../activity/activityService"; import { getRoleCreateTime, getRoleOnlineInfo, getServerCreateTime } from "../redisService"; +import { getEquipById, getJewelByEquip } from "../equipService"; +import { isRandSeUnLock } from "../../pubUtils/playerCe"; export class CheckTask { serverId: number; // 区id @@ -167,18 +169,28 @@ export class CheckSingleTask { // 检查一般任务 let dicTasks = gameData.taskType.get(taskType); - for (let dicTask of dicTasks) { + let groups = new Map(); // 以group做区分 + for (let { id, type, group, taskParam } of dicTasks) { + if (!groups.has(`${type}_${group}`)) { + groups.set(`${type}_${group}`, { type, group, taskParam, taskIds: [] }); + } + groups.get(`${type}_${group}`).taskIds.push(id); + } + for (let [_typeAndGroup, { type, group, taskParam, taskIds }] of groups) { - let taskUpdateParam = await this.checkIsMatch(dicTask.taskParam, async () => { - let data = await UserTaskRecModel.findByRoleAndGroup(roleId, dicTask.type, taskType, dicTask.group); + let taskUpdateParam = await this.checkIsMatch(taskParam, async () => { + let data = await UserTaskRecModel.findByRoleAndGroup(roleId, type, taskType, group); return data? data.records: [] }); if (taskUpdateParam) { - let rec = await UserTaskRecModel.setOrIncTask(roleId, dicTask.type, taskType, dicTask.group, taskUpdateParam); + let rec = await UserTaskRecModel.setOrIncTask(roleId, type, taskType, group, taskUpdateParam); if (!rec) continue; - if (rec.received && rec.received.includes(dicTask.id)) continue; // 已领取,不再推送 - let received = rec.received || []; - this.addTaskPushMessage({ type: dicTask.type, id: dicTask.id, count: rec.count, received: received.includes(dicTask.id) }); + + for (let id of taskIds) { + if (rec.received && rec.received.includes(id)) continue; // 已领取,不再推送 + let received = rec.received || []; + this.addTaskPushMessage({ type, id: id, count: rec.count, received: received.includes(id) }); + } } } @@ -354,7 +366,7 @@ export class CheckSingleTask { case TASK_TYPE.ROLE_LV: // 3. 主公达x级 { let { lv, oldLv } = param; - if(oldLv < dicTaskParam[0] && lv >= dicTaskParam[0]) { + if(lv > oldLv) { result = { set: lv } } break; @@ -384,11 +396,14 @@ export class CheckSingleTask { break; } } - if(count + 1 >= dicTaskParam[1]) { + if(index == -1) { + records.push(`${hero.hid}_${count + 1}`); + } else { records[index] = `${hero.hid}_${count + 1}`; + } + if(count + 1 >= dicTaskParam[1]) { result = { inc: 1, records } } else { - records.push(`${hero.hid}_${count + 1}`); result = { records } } break; @@ -457,11 +472,14 @@ export class CheckSingleTask { break; } } - if( count < dicTaskParam[1] && count + trainCount >= dicTaskParam[1]) { + if(index == -1) { records[index] = `${hero.hid}_${count + trainCount}`; - result = { inc: 1, records } } else { records.push(`${hero.hid}_${count + trainCount}`); + } + if( count < dicTaskParam[1] && count + trainCount >= dicTaskParam[1]) { + result = { inc: 1, records } + } else { result = { records } } break; @@ -503,11 +521,14 @@ export class CheckSingleTask { break; } } - if( count < dicTaskParam[1] && count + stageUpCnt >= dicTaskParam[1]) { + if(index == -1) { records[index] = `${hero.hid}_${count + stageUpCnt}`; - result = { inc: 1, records } } else { records.push(`${hero.hid}_${count + stageUpCnt}`); + } + if( count < dicTaskParam[1] && count + stageUpCnt >= dicTaskParam[1]) { + result = { inc: 1, records } + } else { result = { records } } break; @@ -528,19 +549,73 @@ export class CheckSingleTask { } break; } - case TASK_TYPE.CHAT: + case TASK_TYPE.ROLE_SCHOOL_UNLOCK: // 17. 百家学宫解锁x个安置位 { - if (dicTaskParam[0] == 0 || dicTaskParam[0] == param.chatType) { - result = { inc: param.count }; + result = { inc: 1 }; + break; + } + case TASK_TYPE.ROLE_SCHOOL_PUT_HERO: // 18. 百家学宫放置x个武将 + { + let { hid, preHid } = param; + if (hid > 0 && preHid <= 0) { // 放置 + result = { inc: 1 }; + } else if (hid <= 0 && preHid > 0) { // 卸下 + result = { inc: -1 }; } break; } - case TASK_TYPE.FRIEND_NUM: + case TASK_TYPE.ROLE_TITLE: // 19. 爵位升至x + { + let { title, oldTitle } = param; + if(title > oldTitle) { + result = { set: title }; + } + break; + } + case TASK_TYPE.ROLE_TERAPH_STRENGTHEN: // 20. 神像强化x次 + { + let { count } = param; + result = { inc: count }; + break; + } + case TASK_TYPE.ROLE_SCROLL_ACTIVE: // 21. 名将谱激活x武将 + { + let { scrollActive } = param; + if(scrollActive) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.FRIEND_NUM: // 34. 拥有x名好友 { let role = this.getRole(); result = { set: role.friendCnt }; break; } + case TASK_TYPE.FRIEND_SEND_HEART: // 35. 赠送x次友情点 + { + let { count } = param; + if(count > 0) { + result = { inc: count }; + } + break; + } + case TASK_TYPE.CHAT: // 36. 聊天频道发言x次 + { + let { chatType, count = 1 } = param; + if (dicTaskParam[0] == 0 || dicTaskParam[0] == chatType) { + result = { inc: count }; + } + break; + } + case TASK_TYPE.BATTLE_COST_AP: // 37. 消耗体力 + { + let { count } = param; + if(count > 0) { + result = { inc: count }; + } + break; + } case TASK_TYPE.BATTLE_WITH_HERO: // 38. 使用hId武将挑战x关卡x次 { let { warId, battleHeroes } = param; @@ -553,7 +628,7 @@ export class CheckSingleTask { { let { warId, count } = param; let dicWar = gameData.war.get(warId); - if (dicWar.warType == WAR_TYPE.NORMAL) { + if (dicWar.warType == WAR_TYPE.NORMAL && this.checkIdList(dicTaskParam, 0, warId)) { result = { inc: count }; } break; @@ -567,6 +642,14 @@ export class CheckSingleTask { } break; } + case TASK_TYPE.BATTLE_EVENT: // 41. 奇遇(答题/解救百姓/劫匪) x 次 + { + let { eventType } = param; + if(dicTaskParam[0] == 0|| dicTaskParam[0] == eventType) { + result = { inc: 1 }; + } + break; + } case TASK_TYPE.BATTLE_DAILY_STAR: // 42. 每日x星通关 x 次 { let { warId, battleStar } = param; @@ -603,6 +686,12 @@ export class CheckSingleTask { } break; } + case TASK_TYPE.BATTLE_TOWER_LV: // 46. 通关镇念塔x层 + { + let { towerLv } = param; + result = { set: towerLv }; + break; + } case TASK_TYPE.BATTLE_TOWER: // 47. 通关镇念塔x次 { let { warId, count } = param; @@ -630,11 +719,20 @@ export class CheckSingleTask { } break; } + case TASK_TYPE.BATTLE_EXPEDITION_BOX: // 50. 领取x次远征 x宝箱 + { + let { point } = param; + if(dicTaskParam[0] == 0 || dicTaskParam[0] == point) { + result = { inc: 1 }; + } + break; + } case TASK_TYPE.COM_BATTLE_CREATE_TEAM: // 51. 寻宝招募队友x次 { result = { inc: 1 }; break; } + case TASK_TYPE.COM_BATTLE_ASSIST_TEAM: // 53. 协助寻宝x次 { result = { inc: 1 }; @@ -645,11 +743,6 @@ export class CheckSingleTask { result = { inc: 1 }; break; } - case TASK_TYPE.PVP_RECEIVE_BOX: // 59. 领取x次pvp巅峰之路宝箱 - { - result = { inc: 1 }; - break; - } case TASK_TYPE.PVP: // 57. pvp挑战 x 次 { result = { inc: 1 }; @@ -663,6 +756,11 @@ export class CheckSingleTask { } break; } + case TASK_TYPE.PVP_RECEIVE_BOX: // 59. 领取x次pvp巅峰之路宝箱 + { + result = { inc: 1 }; + break; + } case TASK_TYPE.PVP_WIN_SERIES: // 60. pvp连胜x次 { let { isSuccess } = param; @@ -688,6 +786,87 @@ export class CheckSingleTask { break; } + case TASK_TYPE.PVP_RANK: // 62. pvp赛季排名达到 x 名 + { + let { pvpRank } = param; + + let records = await getRecord(); + let oldPvpRank = parseInt(records[0]); + if(isNaN(oldPvpRank)) oldPvpRank = 0; + if(pvpRank > oldPvpRank) { + records[0] = `${pvpRank}`; + result = { set: pvpRank, records } + } + break; + } + case TASK_TYPE.GUILD_JOB: // 63. 军团官职晋升为x + { + let { guildJob } = param; + + let records = await getRecord(); + let oldGuildJob = parseInt(records[0]); + if(isNaN(oldGuildJob)) oldGuildJob = 0; + if(guildJob > oldGuildJob) { + records[0] = `${guildJob}`; + result = { set: guildJob, records } + } + break; + } + case TASK_TYPE.GUILD_DONATE: // 64. 军团捐献x次 + { + result = { inc: 1 }; + break; + } + case TASK_TYPE.GUILD_RECEIVE_BOX: //65. 领取x次军团活跃宝箱 + { + result = { inc: 1 }; + break; + } + case TASK_TYPE.GUILD_ASSIST_REFINE: // 67. 助力炼器堂研发加速x次 + { + result = { inc: 1 }; + break; + } + case TASK_TYPE.GUILD_TRAIN_SUCESS: // 68. 练兵场军团成功压制x次 + { + let { isSuccess } = param; + if(isSuccess) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.GUILD_BOSS: // 69. 演武台军团挑战x次boss + { + result = { inc: 1 }; + break; + } + case TASK_TYPE.GUILD_TRAIN: // 70. 挑战练兵场X次 + { + result = { inc: 1 }; + break; + } + case TASK_TYPE.GUILD_ACTIVITY: // 71. 参与 xxx 军团活动 x 次 + { + let { aid } = param; + if (dicTaskParam[0] == 0 || aid == dicTaskParam[0]) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.GUILD_JOIN: // 72. 加入军团 + { + result = { set: 1 }; + break; + } + case TASK_TYPE.BATTLE_MAIN_ELITE: // 73. 精英通关第x关 + { + let { warId, count } = param; + let dicWar = gameData.war.get(warId); + if (dicWar.warType == WAR_TYPE.MAIN_ELITE && this.checkIdList(dicTaskParam, 0, warId)) { + result = { inc: count }; + } + break; + } case TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT: // 74. x名初始x品质武将升至X品质 { let { hero } = param; @@ -714,6 +893,23 @@ export class CheckSingleTask { } break; } + case TASK_TYPE.GUILD_TRAIN_COUNT: // 79. 练兵场通关x关x次 + { + let { warId, isComplete } = param; + if(isComplete && this.checkIdList(dicTaskParam, 0, warId)) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.HERO_UNLOCK: // 80. 名将谱x阵营全部激活 + { + let { hero } = param; + let dicHero = gameData.hero.get(hero.hid); + if(dicHero && dicHero.camp == dicTaskParam[1]) { + result = { inc: 1 }; + } + break; + } case TASK_TYPE.GACHA_QUALITY_COUNT: // 81. 抽到*次品质*武将 { let { heroes } = param; @@ -727,6 +923,11 @@ export class CheckSingleTask { } break; } + case TASK_TYPE.ROLE_TERAPH_STAGE_UP: // 82. 神像进阶 + { + result = { inc: 1 }; + break; + } case TASK_TYPE.HERO_WAKE_UP_COUNT: // 84. x名武将觉醒 { let { hero, oldColorStar } = param; @@ -735,6 +936,271 @@ export class CheckSingleTask { } break; } + case TASK_TYPE.ACTIVITY_RMB: // 86. 某个活动充值*元 + { + let { count } = param; + result = { inc: count }; + break; + } + case TASK_TYPE.EQUIP_LV_TO: // 87. x件装备强化至x级 + { + let { oldEplace, newEplace, ePlaceIds } = param; + let addCount = 0; + for(let eplaceId of ePlaceIds) { + let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, eplaceId); + if(oldEquip.lv < param[1] && newEquip.lv >= param[1]) { + addCount += 1; + } else if (oldEquip.lv >= param[1] && newEquip.lv < param[1]) { + addCount -= 1; + } + } + if(addCount != 0) { + result = { inc: addCount }; + } + break; + } + case TASK_TYPE.EQUIP_PUT_JEWEL: // 88. x件装备镶嵌X阶天晶石 + { + let { oldEquip, newEquip, jewels } = param; + let { oldJewel, newJewel } = getJewelByEquip(oldEquip, newEquip, jewels); + let oldLv = gameData.jewel.get(oldJewel?.id)?.lv || 0; + let lv = gameData.jewel.get(newJewel?.id)?.lv || 0; + if(lv >= dicTaskParam[1] && oldLv < dicTaskParam[1]) { + result = { inc: 1 }; + } else if (lv < dicTaskParam[1] && oldLv >= dicTaskParam[1]) { + result = { inc: -1 }; + } + break; + } + case TASK_TYPE.EQUIP_PUT_STONE: // 89. x件装备镶嵌X个地玉石 + { + let { oldEquip, newEquip } = param; + let oldStoneCnt = oldEquip.stones.filter(cur => cur.stone != 0).length; + let newStoneCnt = newEquip.stones.filter(cur => cur.stone != 0).length; + + if(oldStoneCnt < param[1] && newStoneCnt >= param[1]) { + result = { inc: 1 }; + } else if (oldStoneCnt >= param[1] && newStoneCnt < param[1]) { + result = { inc: -1 }; + } + break; + } + case TASK_TYPE.EQUIP_STAR_UP_TO: // 90. x件装备升至X星 + { + let { oldEquip, newEquip } = param; + let oldStar = oldEquip?.star||0; + let star = newEquip?.star||0 + if(oldStar < param[1] && star >= param[1]) { + result = { inc: 1 }; + }; + break; + } + case TASK_TYPE.EQUIP_STAR_UP_CNT: // 91. x件装备升星X次 + { + let { hid, ePlaceId } = param; + let records = await getRecord(); + let count = 0, index = -1; + for(let i = 0; i < records.length; i++) { + let arr = records[i].split('|'); + if(parseInt(arr[0]) == hid && parseInt(arr[1]) == ePlaceId) { + count = parseInt(arr[2]); + index = i; + break; + } + } + + if(index == -1) { + records.push(`${hid}_${ePlaceId}_${count + 1}`); + } else { + records[index] = `${hid}_${ePlaceId}_${count + 1}`; + } + if(count + 1 >= dicTaskParam[1]) { + result = { inc: 1, records } + } else { + result = { records } + } + break; + } + case TASK_TYPE.EQUIP_SUIT_SEID_NUM: // 92. x名武将激活X条套装属性 + { + let { oldEplace, newEplace, hid } = param; + let dicEquipSuit = getEquipSuitByHero(hid); + let oldSuitStars: number[] = [], newSuitStars: number[] = []; + for(let equipId of dicEquipSuit.equips) { + let oldEquip = oldEplace.find(cur => cur.equipId == equipId); + oldSuitStars.push(oldEquip? oldEquip.star: 0); + let newEquip = newEplace.find(cur => cur.equipId == equipId); + newSuitStars.push(newEquip? newEquip.star: 0); + } + let oldStar = Math.min(...oldSuitStars); + let newStar = Math.min(...newSuitStars); + let oldCount = 0, count = 0; + for(let { star } of dicEquipSuit.effect) { + if(oldStar >= star) oldCount++; + if(newStar >= star) count++; + } + if(oldCount < param[1] && count >= param[1]) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.EQUIP_QUALITY_UP: // 93. x件装备进行升品 + { + let { hid, ePlaceId } = param; + let records = await getRecord(); + if(records.indexOf(`${hid}_${ePlaceId}`) == -1) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.EQUIP_QUALITY_UP_CNT: // 94. 装备升品X次 + { + result = { inc: 1 }; + break; + } + case TASK_TYPE.EQUIP_QUALITY_UP_TO: // 95. X件装备升品至Y品质 + { + let { oldEquip, newEquip } = param; + let oldQuality = oldEquip?.quality||0; + let quality = newEquip?.quality||0; + if(oldQuality < param[1] && quality >= param[1]) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.EQUIP_COMPOSE: // 96. 装备X件装备 + { + let { count } = param; + result = { inc: count }; + break; + } + case TASK_TYPE.EQUIP_COMPOSE_CNT: // 97. x名武将各装备x件装备 + { + let { oldEplace, newEplace } = param; + if(oldEplace.length < dicTaskParam[1] && newEplace.length >= dicTaskParam[1]) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.EQUIP_LV_UP: // 98. 装备强化X次 + { + let { count } = param; + result = { inc: count }; + break; + } + case TASK_TYPE.EQUIP_PUT_JEWEL_CNT: // 99. X件装备镶嵌天晶 + { + let { oldEquip, newEquip } = param; + if(oldEquip.jewel && !newEquip.jewel) { + result = { inc: -1 }; + } else if (!oldEquip.jewel && newEquip.jewel) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.EQUIP_PUT_STONE_CNT: // 100. X件装备镶嵌地玉 + { + let { oldEquip, newEquip } = param; + let oldStoneCnt = oldEquip.stones.filter(cur => cur.stone != 0).length; + let newStoneCnt = newEquip.stones.filter(cur => cur.stone != 0).length; + if(oldStoneCnt > 0 && newStoneCnt == 0) { + result = { inc: -1 }; + } else if (oldStoneCnt == 0 && newStoneCnt > 0) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.EQUIP_STONE_CNT: // 101. 镶嵌X个地玉 + { + let { oldEquip, newEquip } = param; + let oldStoneCnt = oldEquip.stones.filter(cur => cur.stone != 0).length; + let newStoneCnt = newEquip.stones.filter(cur => cur.stone != 0).length; + result = { inc: newStoneCnt - oldStoneCnt }; + break; + } + case TASK_TYPE.EQUIP_STONE_CNT_LV: // 102. X件装备镶嵌X个大于等于X阶地玉 + { + let { oldEquip, newEquip } = param; + let oldStoneLvs = oldEquip.stones.map(cur => { + let dicStone = gameData.stone.get(cur.stone); + return dicStone?dicStone.lv: 0; + }); + let newStoneLvs = newEquip.stones.map(cur => { + let dicStone = gameData.stone.get(cur.stone); + return dicStone?dicStone.lv: 0; + }); + let oldCount = oldStoneLvs.filter(lv => lv >= param[2]).length; + let newCount = newStoneLvs.filter(lv => lv >= param[2]).length; + if(oldCount < param[1] && newCount >= param[1]) { + result = { inc: 1 }; + } else if (oldCount >= param[1] && newCount < param[1]) { + result = { inc: -1 } + } + break; + } + case TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT: // 103.X个天晶的Y条特性词条被激活 + { + let { oldEquip, newEquip, jewels } = param; + let { oldJewel, newJewel } = getJewelByEquip(oldEquip, newEquip, jewels); + + let oldRandSe = oldJewel?.randSe||[]; + let oldUnlockSeCnt = oldRandSe.filter(se => { + return isRandSeUnLock(oldJewel.id, se.id, oldEquip.stones); + }).length; + + let newRandSe = newJewel?.randSe||[]; + let newUnlockSeCnt = newRandSe.filter(se => { + return isRandSeUnLock(newJewel.id, se.id, newEquip.stones); + }).length; + + if(oldUnlockSeCnt < param[1] && newUnlockSeCnt >= param[1]) { + result = { inc: -1 }; + } else if (oldUnlockSeCnt >= param[1] && newUnlockSeCnt < param[1]) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.STONE_COMPOSE: // 104. 地玉合成X次 + { + let { count } = param; + result = { inc: count }; + break; + } + case TASK_TYPE.JEWEL_RESET: // 105. 天晶洗炼X次 + { + result = { inc: 1 }; + break; + } + case TASK_TYPE.JEWEL_QUENCH: // 106. 天晶淬炼X次 + { + result = { inc: 1 }; + break; + } + case TASK_TYPE.JEWEL_QUENCH_SUCCESS: // 107. 天晶成功淬炼X次 + { + let { isSuccess } = param; + if(isSuccess) { + result = { inc: 1 }; + } + break; + } + case TASK_TYPE.COM_BATTLE_LV: // 108. 寻宝x品阶x次 + { + let { gid } = param; + let dicJewel = getDicBlueprtById(gid); + if(dicTaskParam[0] == dicJewel.lv) { + result = { inc: 1 }; + } + break + } + case TASK_TYPE.GUILD_REFINE: // 109. 炼器堂兑换X品阶天晶X次 + { + let { quality, count } = param; + if(dicTaskParam[0] == quality) { + result = { inc: count }; + } + break; + } } return result } diff --git a/game-server/app/services/task/taskService.ts b/game-server/app/services/task/taskService.ts index b4a71115b..f620fcf06 100644 --- a/game-server/app/services/task/taskService.ts +++ b/game-server/app/services/task/taskService.ts @@ -4,7 +4,6 @@ import { resResult, shouldRefresh } from '../../pubUtils/util'; import { STATUS, TASK_TYPE, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, WAR_TYPE } from '../../consts'; import { TaskParamInter, TaskListReturn } from '../../domain/roleField/task'; import { EPlace, HeroType } from '../../db/Hero'; -import { getRoleOnlineInfo } from '../redisService'; import { HeroScores } from '../../db/PvpHistoryOpp'; import { ItemInter } from '../../pubUtils/interface'; import { UserTaskModel, UserTaskType } from '../../db/UserTask'; @@ -15,6 +14,9 @@ import { getSeconds, getZeroPointD } from '../../pubUtils/timeUtil'; import { RoleStatus } from '../../db/ComBattleTeam'; import { getActivities } from '../activity/activityService'; import { CheckTask } from './taskObj'; +import { getEquipById } from '../equipService'; +import { JewelType } from '../../db/Jewel'; +import { checkPopUpConditionInCreateHero } from '../activity/popUpShopService'; export async function checkTaskWithRoles(serverId: number, roleId: string, sid: string, taskType: TASK_TYPE, roles: RoleType[]) { for (let role of roles) { @@ -52,6 +54,7 @@ export async function checkTaskInCreateHero(serverId: number, roleId: string, si task.setParam(TASK_TYPE.HERO_QUALITY_STAR_UP, { heroes }); task.setParam(TASK_TYPE.HERO_LV, { heroes }); await task.saveAndPush(sid); + await checkPopUpConditionInCreateHero(serverId, roleId, heroes); } export async function checkTaskInHeroStarUp(serverId: number, roleId: string, sid: string, hero: HeroType, oldStar: number) { @@ -72,11 +75,10 @@ export async function checkTaskInHeroWakeUp(serverId: number, roleId: string, si } export async function checkTaskInHeroQUalityUp(serverId: number, roleId: string, sid: string, hero: HeroType) { - // 任务 - await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_QUALITY_UP, { hero }); - // 任务 - await checkTask(serverId, sid, roleId, TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT, { hero }); - + let task = new CheckTask(serverId, roleId); + task.setParam(TASK_TYPE.HERO_QUALITY_UP, { hero }); + task.setParam(TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT, { hero }); + await task.saveAndPush(sid); } export async function checkTaskInHeroTrain(serverId: number, roleId: string, sid: string, hero: HeroType, trainCount: number) { @@ -86,6 +88,23 @@ export async function checkTaskInHeroTrain(serverId: number, roleId: string, sid await task.saveAndPush(sid); } +export async function checkTaskInActiveScroll(serverId: number, roleId: string, sid: string, scrollActive: boolean, hero: HeroType) { + if (!scrollActive) { + let task = new CheckTask(serverId, roleId); + task.setParam(TASK_TYPE.HERO_UNLOCK, { hero }); + task.setParam(TASK_TYPE.ROLE_SCROLL_ACTIVE, { scrollActive }); + await task.saveAndPush(sid); + } +} + +export async function checkTaskInGuildTrain(serverId: number, roleId: string, sid: string, warId: number, isSuccess: boolean, isComplete: boolean) { + let task = new CheckTask(serverId, roleId); + task.setParam(TASK_TYPE.GUILD_TRAIN_SUCESS, { isSuccess }); + task.setParam(TASK_TYPE.GUILD_TRAIN, {}); + task.setParam(TASK_TYPE.GUILD_TRAIN_COUNT, { isComplete, warId }); + await task.saveAndPush(sid); +} + /** * battle.normalBattleHandler.battleEnd 中会触发的任务,因为有点多提出来了 */ @@ -100,6 +119,7 @@ export async function checkTaskInHeroTrain(serverId: number, roleId: string, sid task.setParam(TASK_TYPE.BATTLE_TOWER, { warId, count: 1 }); task.setParam(TASK_TYPE.BATTLE_VESTIGE, { warId, count: 1 }); task.setParam(TASK_TYPE.BATTLE_EXPEDITION, { warId, count: 1 }); + task.setParam(TASK_TYPE.BATTLE_MAIN_ELITE, { warId, count: 1 }); await task.saveAndPush(sid); } @@ -118,33 +138,114 @@ export async function checkTaskInBattleSweep(serverId: number, roleId: string, s } -export async function checkTaskInComBattleStart(roleStatus: RoleStatus[], capId: string) { +export async function checkTaskInComBattleStart(roleStatus: RoleStatus[], capId: string, blueprtId: number) { // console.log('********', JSON.stringify(roleStatus), capId, quality) for (let { roleId, isRobot } of roleStatus) { if (!isRobot) { let role = await RoleModel.findByRoleId(roleId); - + let task = new CheckTask(role.serverId, roleId); + task.setRole(role); if (roleId == capId && roleStatus.length > 1) { // 招募队友 - await checkTaskWithRole(role.serverId, roleId, null, TASK_TYPE.COM_BATTLE_CREATE_TEAM, role); + task.setParam(TASK_TYPE.COM_BATTLE_CREATE_TEAM, {}); } else if (roleId !== capId) { // 协助寻宝 - await checkTaskWithRole(role.serverId, roleId, null, TASK_TYPE.COM_BATTLE_ASSIST_TEAM, role); + task.setParam(TASK_TYPE.COM_BATTLE_ASSIST_TEAM, {}); } - await checkTaskWithRole(role.serverId, roleId, null, TASK_TYPE.COM_BATTLE, role); + task.setParam(TASK_TYPE.COM_BATTLE, {}); + task.setParam(TASK_TYPE.COM_BATTLE_LV, { gid: blueprtId }); } } } export async function checkTaskInPvpEnd(serverId: number, roleId: string, sid: string, isSuccess: boolean, heroScores: HeroScores[]) { - await checkTask(serverId, roleId, sid, TASK_TYPE.PVP_WIN, { isSuccess }) - await checkTask(serverId, roleId, sid, TASK_TYPE.PVP_WIN_SERIES, { isSuccess }); - await checkTask(serverId, roleId, sid, TASK_TYPE.PVP_HERO_SCORE, { heroScores }); + let task = new CheckTask(serverId, roleId); + task.setParam(TASK_TYPE.PVP_WIN, { isSuccess }); + task.setParam(TASK_TYPE.PVP_WIN_SERIES, { isSuccess }); + task.setParam(TASK_TYPE.PVP_HERO_SCORE, { heroScores }); + await task.saveAndPush(sid); } export async function checkTaskInGacha(serverId: number, roleId: string, sid: string, count: number, heroes: HeroType[]) { - await checkTask(serverId, roleId, sid, TASK_TYPE.GACHA, { count }); - await checkTask(serverId, roleId, sid, TASK_TYPE.GACHA_QUALITY_COUNT, { heroes }); + let task = new CheckTask(serverId, roleId); + task.setParam(TASK_TYPE.GACHA, { count }); + task.setParam(TASK_TYPE.GACHA_QUALITY_COUNT, { heroes }); + await task.saveAndPush(sid); } + +export async function checkTaskInComposeEquip(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[]) { + let task = new CheckTask(serverId, roleId); + task.setParam(TASK_TYPE.EQUIP_COMPOSE, { count: newEplace.length - oldEplace.length }); + task.setParam(TASK_TYPE.EQUIP_COMPOSE_CNT, { oldEplace, newEplace }); + await task.saveAndPush(sid); +} + +export async function checkTaskInEquipLvUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceIds: number[]) { + let task = new CheckTask(serverId, roleId); + task.setParam(TASK_TYPE.EQUIP_LV_TO, { oldEplace, newEplace, ePlaceIds }); + task.setParam(TASK_TYPE.EQUIP_LV_UP, { count: ePlaceIds.length }); + await task.saveAndPush(sid); +} + +export async function checkTaskInPutJewel(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, originJewel: JewelType, curJewel: JewelType) { + let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId); + let task = new CheckTask(serverId, roleId); + task.setParam(TASK_TYPE.EQUIP_PUT_JEWEL, { oldEquip, newEplace, jewels: [originJewel, curJewel ] }); + task.setParam(TASK_TYPE.EQUIP_PUT_JEWEL_CNT, { oldEquip, newEquip }); + task.setParam(TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, { oldEquip, newEplace, jewels: [originJewel, curJewel ] }); + await task.saveAndPush(sid); +} + +export async function checkTaskInPutStone(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, jewel: JewelType) { + let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId); + let task = new CheckTask(serverId, roleId); + task.setParam(TASK_TYPE.EQUIP_PUT_STONE, { oldEquip, newEquip }); + task.setParam(TASK_TYPE.EQUIP_PUT_STONE_CNT, { oldEquip, newEquip }); + task.setParam(TASK_TYPE.EQUIP_STONE_CNT, { oldEquip, newEquip }); + task.setParam(TASK_TYPE.EQUIP_STONE_CNT_LV, { oldEquip, newEquip }); + task.setParam(TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, { oldEquip, newEplace, jewels: [jewel ] }); + await task.saveAndPush(sid); +} + +export async function checkTaskInEquipStarUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpStar: boolean) { + let task = new CheckTask(serverId, roleId); + if(isUpStar) { + let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId); + task.setParam(TASK_TYPE.EQUIP_STAR_UP_TO, { oldEquip, newEquip }); + task.setParam(TASK_TYPE.EQUIP_SUIT_SEID_NUM, { oldEplace, newEplace, ePlaceId, hid }); + } + task.setParam(TASK_TYPE.EQUIP_STAR_UP_CNT, { hid, ePlaceId }); + await task.saveAndPush(sid); +} + +export async function checkTaskInEquipQualityUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpQuality: boolean) { + let task = new CheckTask(serverId, roleId); + if(isUpQuality) { + let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId); + task.setParam(TASK_TYPE.EQUIP_QUALITY_UP, { hid, ePlaceId }); + task.setParam(TASK_TYPE.EQUIP_QUALITY_UP_TO, { oldEquip, newEquip }) + } + task.setParam(TASK_TYPE.EQUIP_QUALITY_UP_CNT, {}); + await task.saveAndPush(sid); +} + +export async function checkTaskInEquipReset(serverId: number, roleId: string, sid: string) { + await checkTask(serverId, roleId, sid, TASK_TYPE.JEWEL_RESET); +} + +export async function checkTaskInEquipQuench(serverId: number, roleId: string, sid: string, isSuccess: boolean) { + let task = new CheckTask(serverId, roleId); + task.setParam(TASK_TYPE.JEWEL_QUENCH, {}); + if(isSuccess) { + task.setParam(TASK_TYPE.JEWEL_QUENCH_SUCCESS, { isSuccess }); + } + await task.saveAndPush(sid); +} + +export async function checkTaskInComposeStone(serverId: number, roleId: string, sid: string, count: number) { + await checkTask(serverId, roleId, sid, TASK_TYPE.STONE_COMPOSE, { count }); +} + + // 获取task状态 export async function getCurTask(roleId: string, session: FrontendOrBackendSession) { let userTask = await UserTaskModel.findByRole(roleId); diff --git a/game-server/app/services/warRewardService.ts b/game-server/app/services/warRewardService.ts index a6677524e..a100038b0 100644 --- a/game-server/app/services/warRewardService.ts +++ b/game-server/app/services/warRewardService.ts @@ -6,12 +6,13 @@ import { BattleDropModel } from '../db/BattleDrop'; import { getRandEelmWithWeight, getRandSingleEelm, getReasonByWarType } from '../pubUtils/util'; import { BATTLE_REWARD_TYPE, BLUEPRT_CONST } from '../consts'; -import { addItems, combineItemAndJewels } from './role/rewardService'; +import { addItems } from './role/rewardService'; import { RoleModel } from '../db/Role'; import { gameData } from '../pubUtils/data'; import { DicWar } from '../pubUtils/dictionary/DicWar'; import { RewardInter } from '../pubUtils/interface'; import { getZeroPointD } from '../pubUtils/timeUtil'; +import { combineItemAndJewels } from './role/util'; export class WarReward { private roleId: string; diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 2d05d9f84..c698a7ac0 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -686,7 +686,7 @@ export enum TASK_TYPE { COM_BATTLE_ASSIST_TEAM = 53, // 队友协助寻宝 COM_BATTLE = 54, // 寻宝 // COM_BATTLE_QUALITY = 55, // 按品质寻宝 - COM_BATTLE_DROP = 56, // 寻宝掉落碎片 + // COM_BATTLE_DROP = 56, // 寻宝掉落碎片 PVP = 57, // PVP挑战 PVP_WIN = 58, // PVP胜利 PVP_RECEIVE_BOX = 59, // 领取宝箱 @@ -696,7 +696,7 @@ export enum TASK_TYPE { GUILD_JOB = 63, // 军团官职 GUILD_DONATE = 64, // 军团捐献 GUILD_RECEIVE_BOX = 65, // 领取活跃宝箱 - GUILD_REFINE = 66, // 军团炼器 + // GUILD_REFINE = 66, // 军团炼器 GUILD_ASSIST_REFINE = 67, // 军团助力加速 GUILD_TRAIN_SUCESS = 68, // 军团练兵场成功压制 GUILD_BOSS = 69, // 军团演武台挑战 @@ -715,7 +715,7 @@ export enum TASK_TYPE { ROLE_TERAPH_STAGE_UP = 82, // 神像进阶 // EQUIP_QUALITY_COUNT = 83, // 获得*件品质的*装备 HERO_WAKE_UP_COUNT = 84, // *名武将觉醒 - GUILD_JOIN_ACTIVITY_END = 85, // 参与*军团活动到结束 + // GUILD_JOIN_ACTIVITY_END = 85, // 参与*军团活动到结束 ACTIVITY_RMB = 86, // 累计充值*元 EQUIP_LV_TO = 87, // x件装备强化至x级 EQUIP_PUT_JEWEL = 88, // 多少件装备多少阶天晶石 @@ -738,6 +738,8 @@ export enum TASK_TYPE { JEWEL_RESET = 105, // 天晶洗练 JEWEL_QUENCH = 106, // 天晶淬炼 JEWEL_QUENCH_SUCCESS = 107, // 天晶淬炼成功 + COM_BATTLE_LV = 108, // 军团寻宝 + GUILD_REFINE = 109, // 军团兑换 } // 任务累积类型 diff --git a/shared/db/PvpDefense.ts b/shared/db/PvpDefense.ts index dea82034d..f76a85014 100644 --- a/shared/db/PvpDefense.ts +++ b/shared/db/PvpDefense.ts @@ -8,6 +8,8 @@ import { PVP } from '../pubUtils/dicParam'; @index({ roleId: 1 }) export default class PvpDefense extends BaseModel { + @prop({ required: true }) + serverId: number; // 区 id @prop({ required: true }) roleId: string; // 角色 id @prop({ required: true }) diff --git a/shared/domain/roleField/task.ts b/shared/domain/roleField/task.ts index 8b01c93de..1f32954a7 100644 --- a/shared/domain/roleField/task.ts +++ b/shared/domain/roleField/task.ts @@ -1,10 +1,11 @@ -import { HeroType } from "../../db/Hero"; +import { EPlace, HeroType } from "../../db/Hero"; +import { JewelType } from "../../db/Jewel"; import { HeroScore } from "../battleField/pvp"; export class TaskParamInter { hero?: HeroType; // 武将数据 heroes?: HeroType[]; // 很多武将数据 - count?: number; // 抽卡的次数 + count?: number; // 次数 warId?: number; // 当前关卡id towerLv?: number; // 镇念塔层数 @@ -18,6 +19,12 @@ export class TaskParamInter { connectLv?: number; // 羁绊等级 isSuccess?: boolean; // pvp是否胜利 heroScores?: HeroScore[]; // pvp各武将积分 + eventType?: number; // 奇遇类型 + + point?: number; // 远征宝箱点数 + pvpRank?: number; // pvp等级 + guildJob?: number; // 军团职位 + isComplete?: boolean; // 练兵场是否压制 oldLv?: number; // 原武将等级,原玩家等级 oldStar?: number; // 原武将星级 @@ -25,11 +32,30 @@ export class TaskParamInter { oldJob?: number; // 原武将职业 oldJobStage?: number; // 原武将职业阶 oldFavourLv?: number; // 原好感度等级 + + quality?: number; // 图纸品质 + aid?: number; // 军团活动id + + gid?: number; // 物品id + hid?: number; // 百家学宫当前武将 + preHid?: number; // 百家学宫前一个武将位置 + title?: number; // 当前爵位 + oldTitle?: number; // 之前的爵位 + scrollActive?: boolean; // 是否是激活 + + oldEplace?: EPlace[]; // 原装备栏 + newEplace?: EPlace[]; // 新装备栏 + ePlaceId?: number; // 装备栏上更新的装备(一个) + ePlaceIds?: number[]; // 装备栏上更新的装备 + oldEquip?: EPlace; // 原装备栏(一个) + newEquip?: EPlace; // 新装备栏(一个) + jewels?: JewelType[]; // 天晶石 + }; export class TaskParam extends TaskParamInter { - public setParam(params: TaskParamInter) { + public setParam(params: TaskParamInter = {}) { for(let key in params) { this[key] = params[key]; } diff --git a/shared/pubUtils/itemUtils.ts b/shared/pubUtils/itemUtils.ts deleted file mode 100644 index 41fcb5983..000000000 --- a/shared/pubUtils/itemUtils.ts +++ /dev/null @@ -1,377 +0,0 @@ - - -import { HeroModel, HeroType, } from '../db/Hero'; -import { ItemModel } from '../db/Item'; -import { gameData } from './data'; -import { ITID, CURRENCY_BY_TYPE, CURRENCY_TYPE, ROLE_SELECT, FIGURE_UNLOCK_CONDITION, CONSUME_TYPE, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON } from '../consts'; -import { getRandValueByMinMax, getRandEelm, getRandEelmWithWeight, getDecimalCnt } from './util'; - -import { findWhere } from 'underscore'; -import { RoleModel, RoleType, } from '../db/Role'; -import { Figure } from '../domain/dbGeneral'; -import { getTimeFun } from './timeUtil'; -import { reCalAllHeroCe } from './playerCe'; -// import { checkTask, checkTaskWithHeroes, checkTaskWithEquip, accomplishTask } from './taskUtil'; -import { SkinModel, } from '../db/Skin'; -import { TaskListReturn } from '../domain/roleField/task'; -import { JewelModel, jewelUpdate, RandSe, } from '../db/Jewel'; - -/** - * 只插入皮肤,不管那么多的 - * @param roleId - * @param roleName - * @param skinId - * @returns - */ -export async function increaseSkin(roleId:string, roleName: string, skinId: number) { - let dicSkin = gameData.fashion.get(skinId); - if (!dicSkin) return false; - - let skin = await SkinModel.increaseSkin(roleId, skinId, { roleId, roleName, id: skinId, skinName: dicSkin.name, hid: dicSkin.actorId, skinId: dicSkin.heroId }); - if(!skin) return false; // 插入失败 - return skin -} - -/** - * 添加皮肤 - * @param roleId 玩家id - * @param roleName 玩家名 - * @param id 皮肤id - * @param hero 武将,如果已经查询过这个武将就不用再查询一次,主意要select skins字段 - * @returns {{ hero, figureInfo, calAllHeroResult }} hero:添加皮肤后的武将 figureInfo: 触发头像添加信息 calAllHeroResult:全局战力加成后结果 - */ -export async function addSkin(roleId: string, roleName: string, skinId: number, enable: boolean, hero?: HeroType) { - let skin = await increaseSkin(roleId, roleName, skinId); - if(!skin) return false; - - if(skin.hid && !hero) hero = await HeroModel.findByHidAndRole(skin.hid, roleId); - let condition = { type: FIGURE_UNLOCK_CONDITION.GET_SKIN, paramSkinId: skinId }; - let figureInfo = await unlockFigure(roleId, [condition]); // 解锁头像 - let calAllHeroResult = await reCalAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, roleId, {}, [skinId]); // 全局加成 - - if (hero) { // 有武将的,将皮肤链接到武将上 - if (!findWhere(hero.skins, { id: skinId })) { - hero.skins.push({ id: skinId, skin: skin._id, enable, skinId: skin.skinId }); - await HeroModel.updateHeroInfo(roleId, hero.hid, hero); - } - return { hero, figureInfo, calAllHeroResult }; - } else { - return { hero: null, figureInfo, calAllHeroResult } - } -} - -export async function addBags(roleId: string, roleName: string, datas: { id: number, count: number }[], reason: number) { - let items: { id: number, count: number, inc: number }[] = []; - for(let data of datas) { - let item = await addBag(roleId, roleName, data, reason); - items.push(item) - } - return { items } -} - -export async function addBag(roleId: string, roleName: string, data: { id: number, count: number }, reason: number) { - let { id, count } = data; - let { name: itemName, itid, hid } = gameData.goods.get(id); - let { type } = ITID.get(itid); - - let item = await ItemModel.increaseItem(roleId, id, count, { roleId, roleName, itemName, id, type, hid }); - return { id: item.id, count: item.count, inc: count, reason }; -} - - -export async function addJewels(roleId: string, roleName: string, jewels: { id: number, }[], reason: number) { - let jewelInfo: jewelUpdate[] = []; - for(let jewel of jewels) { - let info = await getAddJewelInfo(roleId, roleName, jewel); - jewelInfo.push(info); - } - - const jewelResult = await JewelModel.createJewels(roleId, jewelInfo); - let pushMessages: TaskListReturn[] = []; - // TODO 修改任务 - // for(let equip of jewelResult) { - // let pushMessage = await checkTaskWithEquip(roleId, TASK_TYPE.EQUIP_SUIT, equip); - // if(reason == ITEM_CHANGE_REASON.EQUIP_COMPOSE) { - // let pm = await checkTaskWithEquip(roleId, TASK_TYPE.EQUIP_COMPOSE_SUIT, equip); - // pushMessages.push(...pm); - // } - // pushMessages.push(...pushMessage); - // } - - return { jewels: jewelResult.map(jewel => { - return { ...jewel, count: 1, inc: 1, reason } - }), pushMessages } -} - -export async function getAddJewelInfo(roleId: string, roleName: string, jewel: { id: number, }) { - let { id, } = jewel; - let { name, randomEffect, effectCount } = gameData.jewel.get(id); - - // 随机属性 - let randomResult: number[] = getRandEelm(randomEffect, effectCount); - - let randSe: Array = randomResult.map((id: number, index: number) => { - return getJewelRandSe(index + 1, id); - }); - - return { roleId, roleName, id, name, randSe }; -} - -/** - * 天晶石已知词条随机值 - * @param id 词条位置,第几条 - * @param seid 词条id - * @returns - */ -export function getJewelRandSe(id: number, seid: number) { - let dicRandom = gameData.randomEffectPool.get(seid) - let rand = 0; - if (dicRandom.id > 0) { - let randRange = getRandEelmWithWeight(dicRandom.rate); - let randResult = getRandValueByMinMax(randRange.dic.min, randRange.dic.max, getDecimalCnt(dicRandom.gap)); - let n = Math.floor((randResult - dicRandom.Min)/dicRandom.gap); - rand = dicRandom.Min + n * dicRandom.gap; - } - return new RandSe(id, dicRandom.id, rand); -} - -export function getGoldId() { - return CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD); -} - -/** - * @description 获取元宝物品 { id, count } - * @param count 元宝数量 - */ -export function getGoldObject(count: number) { - return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count }; -} - -/** - * @description 获取金币物品 { id, count } - * @param count 元宝数量 - */ -export function getCoinObject(count: number) { - return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN), count }; -} - -/** - * @description 获取体力物品 { id, count } - * @param count 体力数量 - */ - export function getApObject(count: number) { - return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.ACTION_POINT), count }; -} -/** - * @description 获取友情点物品 { id, count } - * @param count 友情点数量 - */ -export function getFriendPointObject(count: number) { - return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.FRIEND_POINT), count }; -} - -/** - * @description 获取功勋物品 { id, count } - * @param count 功勋数量 - */ -export function getHonourObject(count: number) { - return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.HONOUR), count }; -} - -/** - * 返回 解锁头像/相框 - * @param conditions 解锁条件 - * @param role 如果已查询过role表就直接可以使用 - */ - export function unlockFigureWithoutSave(conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number, paramWinStreakNum?: number }[], role: RoleType) { - - let { heads, frames, spines } = role; - let figureInfo = { heads: new Array
(), frames: new Array
(), spines: new Array
() }; - for (let { type, paramHid, paramFavourLv, paramSkinId, paramWinStreakNum } of conditions) { - let canUnLockList = gameData.figureCondition.get(type); - if (canUnLockList) { - let reason = 0; - - for (let { id, params, gid } of canUnLockList) { - let flag = false; // 是否达成条件 - if (type == FIGURE_UNLOCK_CONDITION.GET_HERO) { - let [hid] = params; - if (paramHid == hid) flag = true; - reason = ITEM_CHANGE_REASON.GET_HERO_UNLOCK_FIGURE; - } else if (type == FIGURE_UNLOCK_CONDITION.HERO_FAVOR) { - let [hid, favourLv] = params; - if (paramHid == hid && paramFavourLv >= favourLv) flag = true; - reason = ITEM_CHANGE_REASON.HERO_FAVOR_UNLOCK_FIGURE; - } else if (type == FIGURE_UNLOCK_CONDITION.GET_SKIN) { - let [id] = params; - if (paramSkinId == id) flag = true; - reason = ITEM_CHANGE_REASON.ADD_SKIN_UNLOCK_FIGURE; - } else if (type == FIGURE_UNLOCK_CONDITION.PVP_WIN_SERIES) { - let [winStreakNum] = params; - if (paramWinStreakNum >= winStreakNum) flag = true; - reason = ITEM_CHANGE_REASON.PVP_SERIES_UNLOCK_FIGURE; - } - if (!flag) continue; - let dicGood = gameData.goods.get(gid); - if (!dicGood) continue; - let dicItid = ITID.get(dicGood.itid); - if (!dicItid) continue; - - if (dicItid.type == CONSUME_TYPE.HEAD) { - let figure = unlockSingleFigure(heads, gid, reason, false, id); - if (figure && figure.unlocked) figureInfo.heads.push(figure); - } else if (dicItid.type == CONSUME_TYPE.FRAME) { - let figure = unlockSingleFigure(frames, gid, reason, false, id); - if (figure && figure.unlocked) figureInfo.frames.push(figure); - } else if (dicItid.type == CONSUME_TYPE.SPINE) { - let figure = unlockSingleFigure(spines, gid, reason, false, id); - if (figure && figure.unlocked) figureInfo.spines.push(figure); - } else { - continue; - } - - } - - } - } - return { figureInfo, heads, frames, spines }; -} - -/** - * 解锁头像/相框 - * @param roleId 玩家id - * @param conditions 解锁条件 - * @param role 如果已查询过role表就直接可以使用 - */ -export async function unlockFigure(roleId: string, conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number, paramWinStreakNum?: number }[], role?: RoleType) { - if (!role || !role.heads || !role.frames) { - role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS); - } - let { figureInfo, heads, frames, spines } = unlockFigureWithoutSave(conditions, role); - role = await RoleModel.updateRoleInfo(roleId, { heads, frames, spines }); - return figureInfo; -} - - -// 直接获得形象/相框 -export async function addFigure(roleId: string, ids: number[], reason: number) { - let role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS); - - if (!role) return false; - let { heads, frames, spines } = role; - - let figureInfo = { heads: [], frames: [], spines: [] }; - for (let gid of ids) { - let dicGoods = gameData.goods.get(gid); - if (!dicGoods) continue; - let dicItid = ITID.get(dicGoods.itid); - if (!dicItid) continue; - - if (dicItid.type == CONSUME_TYPE.HEAD) { - let figure = unlockSingleFigure(heads, gid, reason, true); - if (figure && figure.unlocked) figureInfo.heads.push(figure); - } else if (dicItid.type == CONSUME_TYPE.FRAME) { - let figure = unlockSingleFigure(frames, gid, reason, true); - if (figure && figure.unlocked) figureInfo.frames.push(figure); - } else if (dicItid.type == CONSUME_TYPE.SPINE) { - let figure = unlockSingleFigure(spines, gid, reason, true); - if (figure && figure.unlocked) figureInfo.spines.push(figure); - } else { - continue; - } - } - - role = await RoleModel.updateRoleInfo(roleId, { heads, frames, spines }); - return figureInfo; -} - -/** - * 根据物品id解锁/获得玩家数据 - * @param dbFigures 数据库内字段 - * @param id 物品id - * @param unlockDirect 是否不计算解锁条件直接解锁 - * @param conditionId 条件id - */ -function unlockSingleFigure(dbFigures: Figure[], id: number, reason: number, unlockDirect = false, conditionId?: number) { - let index = dbFigures.findIndex(cur => cur.id == id); - let figure = dbFigures[index]; - if (index == -1) { - figure = new Figure(id, false); - dbFigures.push(figure); - index = dbFigures.length - 1; - } - if (figure.unlocked) return; // 已解锁过 - if (!figure.unlockedId) figure.unlockedId = new Array(); - - let dicGoods = gameData.goods.get(id); - - let hasUnlockedAll = true; - if (!unlockDirect) { // 不能直接获得,需要通过type解锁 - if (figure.unlockedId.includes(conditionId)) return; - - figure.unlockedId.push(conditionId); - - for (let { id: cid } of dicGoods.condition) { - if (!figure.unlockedId.includes(cid)) { - hasUnlockedAll = false; break; - } - } - } - if (hasUnlockedAll) { - figure.unlocked = true; - delete figure.unlockedId; - - if (dicGoods.timeLimit) { - figure.time = getTimeFun().getAfterDay(dicGoods.timeLimit); // timeLimit天以后 - } - } - - figure.inc = 1; - figure.reason = reason; - dbFigures[index] = figure; - return figure -} - -// async function getSkinsOfThisHero(roleId: string, roleName: string, hid: number, initialSkin: number, allSkins?: SkinType[]) { -// if(!allSkins) allSkins = await SkinModel.findbyRoleAndHid(roleId, hid); -// let skin = await increaseSkin(roleId, roleName, initialSkin); -// if(skin) allSkins.push(skin); -// let skins: { id: number, skin: string, enable: boolean }[] = []; -// for(let skin of allSkins) { -// skins.push({ id: skin.id, skin: skin._id, enable: skin.id == initialSkin }); -// } - -// return skins -// } - -export function combineFigureInfo(figureInfos: { heads: Figure[], frames: Figure[], spines: Figure[] }[]) { - let figureInfo = { heads: new Array
(), frames: new Array
(), spines: new Array
() }; - for(let {heads, frames, spines} of figureInfos) { - for(let head of heads) { - figureInfo.heads.push(head); - } - for(let frame of frames) { - figureInfo.frames.push(frame); - } - for(let spine of spines) { - figureInfo.spines.push(spine); - } - } - return figureInfo; -} - -export function transPiece(hid: number) { - let dicHero = gameData.hero.get(hid); - let count = gameData.heroTransPiece.get(dicHero.quality); - return { pieceId: dicHero.pieceId, count } -} - -// export class CreateHero { -// roleId: string; -// roleName: string; -// serverId: number; - -// constructor(roleId: string, roleName: string, serverId: number) { - -// } -// } \ No newline at end of file diff --git a/web-server/app/service/Utils.ts b/web-server/app/service/Utils.ts index 49f131377..90af1d5c9 100644 --- a/web-server/app/service/Utils.ts +++ b/web-server/app/service/Utils.ts @@ -1,7 +1,5 @@ import { Service } from 'egg'; import { resResult as pubResult } from '../pubUtils/util'; -import { unlockFigure } from 'app/pubUtils/itemUtils'; -import { RoleType } from '@db/Role'; import { gameData } from 'app/pubUtils/data'; import { RedisClient } from 'redis'; import { REDIS_KEY } from '@consts'; @@ -45,10 +43,6 @@ export default class Utils extends Service { return pubResult(status, data, customMsg); } - public unlockFigure(roleId: string, conditions: {type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number}[], role?: RoleType) { - return unlockFigure(roleId, conditions, role); - } - public log(level: 'DEBUG'|'INFO'|'WARN'| 'ERROR', message: string) { const log = this.app.loggers.get('linkLogger');