数数:消耗来源
This commit is contained in:
@@ -6,7 +6,7 @@ import { difference } from 'underscore';
|
||||
* @Last Modified by: 梁桐川
|
||||
* @Last Modified time: 2021-08-27 17:47:56
|
||||
*/
|
||||
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, COM_BTL_QUALITY, MSG_SOURCE, QUALITY_TYPE, ROLE_SELECT, TASK_TYPE, KING_EXP_RATIO_TYPE } from './../../../consts';
|
||||
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, COM_BTL_QUALITY, MSG_SOURCE, QUALITY_TYPE, ROLE_SELECT, TASK_TYPE, KING_EXP_RATIO_TYPE, ITEM_CHANGE_REASON } from './../../../consts';
|
||||
import Role, { RoleModel } from '../../../db/Role';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
@@ -592,7 +592,7 @@ export class ComBattleHandler {
|
||||
// }
|
||||
|
||||
await ComBattleTeamModel.updateRewardSt(teamCode, roleId, true);
|
||||
const goods = await addItems(roleId, roleName, sid, roleSt.fixReward);
|
||||
const goods = await addItems(roleId, roleName, sid, roleSt.fixReward, ITEM_CHANGE_REASON.COM_BATTLE_REWARD);
|
||||
let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, warInfo.kingExp, session);// 主公升级经验
|
||||
// 任务
|
||||
await checkTaskWithGoods(roleId, sid, TASK_TYPE.COM_BATTLE_DROP, goods);
|
||||
@@ -799,13 +799,13 @@ export class ComBattleHandler {
|
||||
original.push(...dicCompose.coinNum);
|
||||
// 消耗藏宝图和寻宝币
|
||||
|
||||
let costResult = await handleCost(roleId, sid, original);
|
||||
let costResult = await handleCost(roleId, sid, original, ITEM_CHANGE_REASON.BLUEPRT_COMPOSE);
|
||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
const targetList = gameData.blueprt.get(dicCompose.targetQuality);
|
||||
const target = getRandSingleEelm(targetList);
|
||||
const reward = [{id: target, count: 1}];
|
||||
const goods = await addItems(roleId, roleName, sid, reward);
|
||||
const goods = await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.BLUEPRT_COMPOSE);
|
||||
if (dicCompose.targetQuality >= QUALITY_TYPE.ORANGE) {
|
||||
const { name } = gameData.goods.get(target);
|
||||
pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.ORANGE_BLUEPRT_COMPOSE, target, name);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { getDailyNum, getDailyBattleList, getDailyBuyCountCost } from '../../../
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import { DEBUG_MAGIC_WORD } from '../../../consts';
|
||||
import { DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON } from '../../../consts';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new DailyBattleHandler(app);
|
||||
@@ -55,7 +55,7 @@ export class DailyBattleHandler {
|
||||
return resResult(STATUS.DAILY_REFRESH_GOLD_LACK);
|
||||
}
|
||||
|
||||
await handleCost(roleId, sid, [getGoldObject(buyCost)]);
|
||||
await handleCost(roleId, sid, [getGoldObject(buyCost)], ITEM_CHANGE_REASON.DAILY_BATTLE_BUY_CNT);
|
||||
let newDailyRecord = await DailyRecordModel.increseBuyCount(roleId, type, count);
|
||||
|
||||
let checkDailyResult = await getDailyNum(newDailyRecord, timesPerDay, timesCanBuy);
|
||||
|
||||
@@ -8,7 +8,7 @@ import { getDungeonData, getDungeonBuyCountCost } from '../../../services/dungeo
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
import { DungeonFirstModel } from '../../../db/DungeonFirst';
|
||||
import { DungeonResultParam } from '../../../domain/battleField/dungeon';
|
||||
import { DEBUG_MAGIC_WORD } from '../../../consts';
|
||||
import { DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON } from '../../../consts';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new DungeonBattleHandler(app);
|
||||
@@ -56,7 +56,7 @@ export class DungeonBattleHandler {
|
||||
if(buyCost > gold) {
|
||||
return resResult(STATUS.DAILY_REFRESH_GOLD_LACK);
|
||||
}
|
||||
await handleCost(roleId, sid, [getGoldObject(buyCost)]);
|
||||
await handleCost(roleId, sid, [getGoldObject(buyCost)], ITEM_CHANGE_REASON.DUNGEON_BATTLE_BUY_CNT);
|
||||
await RoleModel.buyCnt(roleId, needRefresh, count, curTime);
|
||||
|
||||
let nextCostGold = getDungeonBuyCountCost(dungeonBuyCnt + count + 1);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { EventRecordModel } from '../../../db/EventRecord';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { EVENT_STATUS, EVENT_RECORD_STATUS, EVENT_ANSWER_STATUS, TASK_TYPE, DEBUG_MAGIC_WORD } from '../../../consts';
|
||||
import { EVENT_STATUS, EVENT_RECORD_STATUS, EVENT_ANSWER_STATUS, TASK_TYPE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON } from '../../../consts';
|
||||
import { checkEventStatus, getEventSuccessStatus, getEvent, checkQuiz, startEvent, refreshEvent, getEventTime } from '../../../services/eventSercive';
|
||||
import { addItems } from '../../../services/rewardService';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
@@ -116,7 +116,7 @@ export class EventBattleHandler {
|
||||
let result = await EventRecordModel.setStatusByCode(roleId, eventCode, isSuccess ? EVENT_RECORD_STATUS.SUCCESS_RECEIVED : EVENT_RECORD_STATUS.FAIL_RECEIVED);
|
||||
// 保存奖励
|
||||
let reward = isSuccess ? dicEvent.winReward : dicEvent.loseReward;
|
||||
let goods = await addItems(roleId, roleName, sid, reward);
|
||||
let goods = await addItems(roleId, roleName, sid, reward, ITEM_CHANGE_REASON.EVENT_REWARD);
|
||||
if (eventStatus == EVENT_STATUS.STARTING) { // 如果是第一次开启的挑战,保存成开启状态
|
||||
await RoleModel.setEventStatus(roleId, EVENT_STATUS.OPEN);
|
||||
// 第一场时间挑战完,开始正常刷新事件,所以刷新时间也重置起来
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ExpeditionPointModel } from '../../../db/ExpeditionPoint';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { calculateSumCE, genCode } from '../../../pubUtils/util';
|
||||
import { getPointRewardStatus, getResetRemainCnt, findOrCreateEnemies, getExpeditionStatus } from '../../../services/expeditionService';
|
||||
import { DEBUG_MAGIC_WORD, EXPEDITION_WAR_RECORD_STATUS, KING_EXP_RATIO_TYPE, LINEUP_NUM, TASK_TYPE } from '../../../consts';
|
||||
import { DEBUG_MAGIC_WORD, EXPEDITION_WAR_RECORD_STATUS, ITEM_CHANGE_REASON, KING_EXP_RATIO_TYPE, LINEUP_NUM, TASK_TYPE } from '../../../consts';
|
||||
import { WarReward } from '../../../services/warRewardService';
|
||||
import { addItems } from '../../../services/rewardService';
|
||||
import { getAp, setAp } from '../../../services/actionPointService';
|
||||
@@ -16,6 +16,7 @@ import { calculateWarStar, checkBattleHeroes, roleLevelup } from '../../../servi
|
||||
import { checkActivityTask, checkTask, checkTaskInBattleEnd } from '../../../services/taskService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import * as dicParam from '../../../pubUtils/dicParam';
|
||||
import { getSeconds } from '../../../pubUtils/timeUtil';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -197,7 +198,7 @@ export class ExpeditionBattleHandler {
|
||||
}
|
||||
|
||||
let flag = 1; // 对比hero信息
|
||||
let { record: { heroes: dbHeroes, seqIds: dbSeqIds } } = BattleRecord;
|
||||
let { record: { heroes: dbHeroes, seqIds: dbSeqIds }, createdAt } = BattleRecord;
|
||||
for (let { dataId } of heroes) {
|
||||
if (dbSeqIds.indexOf(dataId) == -1) flag = 0;
|
||||
}
|
||||
@@ -255,6 +256,7 @@ export class ExpeditionBattleHandler {
|
||||
battleStatus: expeditionWarRecord.battleStatus,
|
||||
battleGoods: reward,
|
||||
expeditionPoint,
|
||||
createdAt: getSeconds(createdAt),
|
||||
...actordata
|
||||
});
|
||||
}
|
||||
@@ -312,7 +314,7 @@ export class ExpeditionBattleHandler {
|
||||
await checkTask(roleId, sid, TASK_TYPE.BATTLE_EXPEDITION_BOX, 1, true, { point });
|
||||
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_EXPEDITION_BOX, 1)
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, curDicExpeditionPoint.reward);
|
||||
let goods = await addItems(roleId, roleName, sid, curDicExpeditionPoint.reward, ITEM_CHANGE_REASON.EXPEDITION_POINT_REWARD);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
costPoint: hasReceivedAll ? maxPoint : 0,
|
||||
|
||||
@@ -17,7 +17,7 @@ import { checkDungeonNum, checkDungeonAndIncrease, saveDungeonFirst } from '../.
|
||||
// import { switchOnFunc } from '../../../services/funcSwitchService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import { pushMysteryFirstMsg, pushTowerMsg, pushVestigeFirstMsg } from '../../../services/chatService';
|
||||
import { nowSeconds } from '../../../pubUtils/timeUtil';
|
||||
import { getSeconds, nowSeconds } from '../../../pubUtils/timeUtil';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { checkTaskWithWar, checkTaskInBattleEnd, checkActivityTask } from '../../../services/taskService';
|
||||
import { ActivitySelfServiceModel } from '../../../db/ActivitySelfService';
|
||||
@@ -147,7 +147,7 @@ export class NormalBattleHandler {
|
||||
}
|
||||
|
||||
let flag = 1; // 对比hero信息
|
||||
let { record: { heroes: dbHeroes, seqIds: dbSeqIds } } = BattleRecord;
|
||||
let { record: { heroes: dbHeroes, seqIds: dbSeqIds }, createdAt } = BattleRecord;
|
||||
for (let seqId of dbSeqIds) {
|
||||
if (dbSeqIds.indexOf(seqId) == -1) flag = 0;
|
||||
}
|
||||
@@ -269,6 +269,7 @@ export class NormalBattleHandler {
|
||||
battleCode, battleId, status,
|
||||
battleGoods: reward,
|
||||
towerStatus, dailyNum, dungeonNum,
|
||||
createdAt: getSeconds(createdAt),
|
||||
...actordata
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import { PVPConfigModel } from '../../../db/SystemConfig';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { checkActivityTask, checkTask, checkTaskInPvpEnd } from '../../../services/taskService';
|
||||
import { Attack, AttackHero, Defense, DefenseHero, PvpDataReturn } from '../../../domain/battleField/pvp';
|
||||
import { DEBUG_MAGIC_WORD, FIGURE_UNLOCK_CONDITION, LINEUP_NUM, REDIS_KEY, TASK_TYPE } from '../../../consts';
|
||||
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/rewardService';
|
||||
@@ -107,7 +107,7 @@ export class PvpHandler {
|
||||
return resResult(STATUS.PVP_REFRESH_CNT_REACH_MAX);
|
||||
}
|
||||
|
||||
let costResult = await handleCost(roleId, sid, refOppObj.consume);
|
||||
let costResult = await handleCost(roleId, sid, refOppObj.consume, ITEM_CHANGE_REASON.PVP_REFRESH_OPP);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
refOppObj.refOppCnt ++;
|
||||
|
||||
@@ -202,7 +202,7 @@ export class PvpHandler {
|
||||
return resResult(STATUS.BATTLE_STATUS_WRONG);
|
||||
}
|
||||
|
||||
let { record: { heroes: dbHeroes, oppRoleId, pos } } = BattleRecord;
|
||||
let { record: { heroes: dbHeroes, oppRoleId, pos }, createdAt } = BattleRecord;
|
||||
|
||||
let flag = 1; // 对比hero信息
|
||||
for (let { hid } of myHeroes) {
|
||||
@@ -276,6 +276,7 @@ export class PvpHandler {
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
battleCode, isSuccess,
|
||||
heroScores: showHeroScores,
|
||||
createdAt: getSeconds(createdAt),
|
||||
...pick(result, ['score', 'myRank', 'winStreakNum', 'attack', 'oppPlayers', 'challengeCnt', 'challengeRefTime'])
|
||||
});
|
||||
}
|
||||
@@ -297,7 +298,7 @@ export class PvpHandler {
|
||||
refOppObj.buyAttackCnt += count;
|
||||
|
||||
let gold = getGoldObject(PVP.PVP_SET_ATTACK_CNT_GOLD * count);
|
||||
let costResult = await handleCost(roleId, sid, [gold]);
|
||||
let costResult = await handleCost(roleId, sid, [gold], ITEM_CHANGE_REASON.PVP_BUY_ATTACK_CNT);
|
||||
if(!costResult) return resResult(STATUS.TOWER_GOLD_NOT_ENOUGH);
|
||||
|
||||
let update: pvpUpdateInter = { ...refOppObj };
|
||||
@@ -518,7 +519,7 @@ export class PvpHandler {
|
||||
receivedBox.push(id);
|
||||
let { challengeCnt, challengeRefTime } = refChallengeCnt(lastChallengeCnt, lastChallengeRefTime, seasonEndTime);
|
||||
await PvpDefenseModel.updateInfo(roleId, { receivedBox, challengeCnt, challengeRefTime });
|
||||
let result = await addItems(roleId, roleName, sid, pvpBox.reward);
|
||||
let result = await addItems(roleId, roleName, sid, pvpBox.reward, ITEM_CHANGE_REASON.PVP_BOX_REWARD);
|
||||
// 任务
|
||||
await checkTask(roleId, sid, TASK_TYPE.PVP_RECEIVE_BOX, 1, true, {});
|
||||
return resResult(STATUS.SUCCESS, { goods: result, receivedBox, challengeCnt, challengeRefTime });
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { STATUS } from './../../../consts/statusCode';
|
||||
import { HANG_UP_CONSTS, REDIS_KEY } from './../../../consts';
|
||||
import { HANG_UP_CONSTS, ITEM_CHANGE_REASON, REDIS_KEY } from './../../../consts';
|
||||
import { TaskHero, TowerTaskRecModel, TowerTaskRecType } from './../../../db/TowerTaskRec';
|
||||
import { HangUpSpdUpRecModel } from './../../../db/HangUpSpdUpRec';
|
||||
import { HangUpRecordModel } from './../../../db/HangUpRecord';
|
||||
@@ -72,7 +72,7 @@ export class TowerBattleHandler {
|
||||
}
|
||||
let { timeReward, endLv, endTime, deltaTime, needReceiveGoods } = result.data;
|
||||
|
||||
const goods = await addItems(roleId, roleName, sid, timeReward);
|
||||
const goods = await addItems(roleId, roleName, sid, timeReward, ITEM_CHANGE_REASON.TOWER_HUNG_UP_REWARD);
|
||||
await HangUpRecordModel.updateRec(roleId, roleName, endLv, endTime, needReceiveGoods);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { endTime, hangUpPassTime: Math.floor((deltaTime%HANG_UP_CONSTS.UNIT_TIME)/1000), goods });
|
||||
@@ -101,14 +101,14 @@ export class TowerBattleHandler {
|
||||
return resResult(STATUS.TOWER_GOLD_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
await handleCost(roleId, sid, [getGoldObject(costGold)])
|
||||
await handleCost(roleId, sid, [getGoldObject(costGold)], ITEM_CHANGE_REASON.TOWER_HUNG_UP_SDP_UP)
|
||||
|
||||
const spdUpResult = await RoleModel.hangUpSpdUp(roleId, msg.speedUpCnt, curTime);
|
||||
if (!spdUpResult) {
|
||||
return resResult(STATUS.TOWER_HANG_UP_FAILED);
|
||||
}
|
||||
const spdUpRec = await HangUpSpdUpRecModel.updateRec(roleId, roleName, msg.speedUpCnt, endLv, needReceiveGoods);
|
||||
const goods = await addItems(roleId, roleName, sid, timeReward);
|
||||
const goods = await addItems(roleId, roleName, sid, timeReward, ITEM_CHANGE_REASON.TOWER_HUNG_UP_REWARD);
|
||||
let nextCostGold = getManyHangSpdUpCostGold(spdUpResult.hangUpSpdUpCnt, 1);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { goods, hangUpSpdUpCnt: dicParam.TOWER_BOOST.TOWER_BOOSTTIME - spdUpResult.hangUpSpdUpCnt, nextCostGold, hangUpPassTime: Math.floor(deltaTime/1000), rewardLv: endLv, costGold });
|
||||
@@ -236,7 +236,7 @@ export class TowerBattleHandler {
|
||||
return resResult(STATUS.TOWER_TASK_BATCH_NOT_FOUND);
|
||||
}
|
||||
const { compTasks, rewards } = checkResult;
|
||||
let goods = await addItems(roleId, roleName, sid, rewards);
|
||||
let goods = await addItems(roleId, roleName, sid, rewards, ITEM_CHANGE_REASON.TOWER_TASK_REWARD);
|
||||
await TowerTaskRecModel.finishTask(msg.batchCode, compTasks);
|
||||
let refRemainTime = getRemainTime(curTime);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user