全局:加载json方法全部改为最新
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { DividendModel } from './../../../db/Dividend';
|
||||
import { Application, BackendSession, ChannelService } from "pinus";
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS, DIVIDEND_STATUS } from "../../../consts";
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS } from "../../../consts";
|
||||
import { LotModel } from "../../../db/Lot";
|
||||
import { ItemReward, LotRec } from "../../../domain/dbGeneral";
|
||||
import { ItemReward } from "../../../domain/dbGeneral";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus } from "../../../services/auctionService";
|
||||
import { addItems, handleCost } from '../../../services/rewardService';
|
||||
|
||||
@@ -7,14 +7,13 @@ import { difference } from 'underscore';
|
||||
* @Last Modified time: 2021-03-10 20:15:30
|
||||
*/
|
||||
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 } from './../../../consts';
|
||||
import { getGoodById, getBlueprtComposeByQuality, getBluePrtByQuality, getWarById, getWarIdByBlueprtId } from '../../../pubUtils/gamedata';
|
||||
import Role, { RoleModel } from '../../../db/Role';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult, getRandomByLen } from '../../../pubUtils/util';
|
||||
import { RoleStatus, ComBattleTeamModel, ComBattleTeamType } from '../../../db/ComBattleTeam';
|
||||
import { ItemModel } from '../../../db/Item';
|
||||
import { handleFixedReward, addItems, handleCost } from '../../../services/rewardService';
|
||||
import { resResult, getRandSingleEelm } from '../../../pubUtils/util';
|
||||
import { RoleStatus, ComBattleTeamModel, ComBattleTeamType, BossHp } from '../../../db/ComBattleTeam';
|
||||
import { ItemModel, ItemType } from '../../../db/Item';
|
||||
import { addItems, handleCost } from '../../../services/rewardService';
|
||||
import { checkRoleInQueue, rmRoleFromQueue, setTeamSearchReq } from '../../../services/redisService';
|
||||
import { getRandBlueprtId, clearComBtlTimer, getAssistTimesByQuality, getFrd, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam, incEquipPrintDrop, randEquipPrintId, handleComBtlProgress, getComBattleFriendAdd, teammateInBlackList, blueprtIdValid, createComTeamData, hasEnoughBlueprt, addRoleToTeam, addRoleStToTeam, addValidSearchingRoles, validToJoin, addRobotsToTeam, addRobotsLater, teamIsFullToStart, oneTeamNotInBlack } from '../../../services/comBattleService';
|
||||
import { setAp } from '../../../services/actionPointService';
|
||||
@@ -26,6 +25,7 @@ import { EXTERIOR } from '../../../pubUtils/dicParam';
|
||||
import { getTodayZeroDate } from '../../../pubUtils/timeUtil';
|
||||
import { FriendParams } from '../../../domain/roleField/friend';
|
||||
import { checkTask, checkTaskWithGoods } from '../../../services/taskService';
|
||||
import { gameData, getWarByBlueprtId } from '../../../pubUtils/data';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new ComBattleHandler(app);
|
||||
@@ -126,7 +126,7 @@ export class ComBattleHandler {
|
||||
let blueprtId = getRandBlueprtId(qualityArr).pop();
|
||||
let comTeam: MemComBtlTeam = createComTeamData(teamCode, false, blueprtId, 'robot', 0)
|
||||
|
||||
let { quality } = getGoodById(blueprtId);
|
||||
let { quality } = gameData.goods.get(blueprtId);
|
||||
let isFrd = await getFrd(roleId, quality);
|
||||
// 将玩家加入队伍
|
||||
addRoleToTeam(comTeam, roleInfo, false, isFrd);
|
||||
@@ -179,7 +179,7 @@ export class ComBattleHandler {
|
||||
if (teamStatus.roleIds.indexOf(roleId) !== -1) return resResult(STATUS.COM_BATTLE_DUP_ENTER);
|
||||
let { lv = 1, head = EXTERIOR.EXTERIOR_FACE, topLineupCe = 0, frame = EXTERIOR.EXTERIOR_FACECASE, spine = EXTERIOR.EXTERIOR_APPEARANCE } = await Role.findByRoleId(roleId, null, true);
|
||||
|
||||
let { quality } = getGoodById(teamStatus.blueprtId);
|
||||
let { quality } = gameData.goods.get(teamStatus.blueprtId);
|
||||
if (lv < COM_BTL_CONST.ENABLE_LV) {
|
||||
return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH);
|
||||
} else if (comBtlLvInvalid(lv, teamStatus.lvRange)) {
|
||||
@@ -346,7 +346,7 @@ export class ComBattleHandler {
|
||||
let channel = channelService.getChannel(teamCode, false);
|
||||
// 先推送离队消息,再将玩家从房间中移除
|
||||
channel.pushMessage('onLeaveTeam', resResult(STATUS.SUCCESS, {teamCode, roleId: roleIdToRm}));
|
||||
let users = channel.getMembers();
|
||||
let users: string[] = channel.getMembers();
|
||||
if (users.indexOf(roleIdToRm) !== -1) {
|
||||
channel.removeMember(roleIdToRm);
|
||||
}
|
||||
@@ -455,7 +455,7 @@ export class ComBattleHandler {
|
||||
}
|
||||
}
|
||||
// 重置总血量,计算真实伤害
|
||||
let actBossHurts = [];
|
||||
let actBossHurts: {dataId: number, hurtHp: number}[] = [];
|
||||
let totalHurtHp = 0;
|
||||
teamStatus.bossHpArr.forEach(boss => {
|
||||
for (let bh of bossHurts) {
|
||||
@@ -546,13 +546,9 @@ export class ComBattleHandler {
|
||||
}
|
||||
});
|
||||
if (roleSt.gotReward) return resResult(STATUS.COM_BATTLE_REWARDED);
|
||||
let warInfo = getWarById(getWarIdByBlueprtId(blueprtId));
|
||||
let warInfo = getWarByBlueprtId(blueprtId);
|
||||
if (!warInfo) return resResult(STATUS.BATTLE_MISS_INFO);
|
||||
|
||||
if(!warInfo.hasOwnProperty('cost')) {
|
||||
warInfo['cost'] = 0;
|
||||
}
|
||||
|
||||
const now = Date.now(); // 当前时间戳
|
||||
let apJson = await setAp(now, roleId, sid, funcs, -1 * warInfo.cost); // 扣除体力
|
||||
if(!apJson) {
|
||||
@@ -563,12 +559,12 @@ export class ComBattleHandler {
|
||||
if (dropResult) {
|
||||
const dropEquipId = randEquipPrintId(warInfo);
|
||||
if (dropEquipId) {
|
||||
roleSt.fixReward = `${roleSt.fixReward}|${dropEquipId}&${1}`;
|
||||
roleSt.fixReward.push({ id: dropEquipId, count: 1 });
|
||||
}
|
||||
}
|
||||
|
||||
await ComBattleTeamModel.updateRewardSt(teamCode, roleId, true);
|
||||
const goods = await handleFixedReward(roleId, roleName, sid, roleSt.fixReward, 1);
|
||||
const goods = await addItems(roleId, roleName, sid, roleSt.fixReward);
|
||||
let actordata = await roleLevelup(roleId, warInfo.kingExp, session);// 主公升级经验
|
||||
// 任务
|
||||
await checkTaskWithGoods(roleId, sid, funcs, TASK_TYPE.COM_BATTLE_DROP, goods);
|
||||
@@ -578,7 +574,7 @@ export class ComBattleHandler {
|
||||
|
||||
async getComBtlStatus(msg: {teamCode: string}, session: BackendSession) {
|
||||
let { teamCode } = msg;
|
||||
let roleStatus, status, bossHpArr, timeout;
|
||||
let roleStatus: RoleStatus[], status: number, bossHpArr: BossHp[], timeout: boolean;
|
||||
let memTeam = this.teamMap.get(teamCode);
|
||||
if (memTeam) {
|
||||
({ roleStatus, status, bossHpArr, timeout } = memTeam);
|
||||
@@ -615,7 +611,7 @@ export class ComBattleHandler {
|
||||
async getBlueprtCount(msg: {ids: number[]}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let { ids } = msg;
|
||||
let blueprts;
|
||||
let blueprts: ItemType[];
|
||||
if (ids && ids.length) {
|
||||
blueprts = await ItemModel.findbyRoleAndIds(roleId, ids);
|
||||
} else {
|
||||
@@ -650,7 +646,7 @@ export class ComBattleHandler {
|
||||
async getComBtlCnt(msg: {}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let cntMap = await getAssistTimesByQuality(roleId);
|
||||
let cnt = [];
|
||||
let cnt: number[] = [];
|
||||
for (let i = 0; i < COM_BTL_QUALITY.length; ++i) {
|
||||
cnt[i] = cntMap.get(i + 1) || 0;
|
||||
}
|
||||
@@ -749,7 +745,7 @@ export class ComBattleHandler {
|
||||
// 原材料检查
|
||||
let originalQuality: number, originalSum: number = 0;
|
||||
for(let {id, count} of original) {
|
||||
const goodInfo = getGoodById(id);
|
||||
const goodInfo = gameData.goods.get(id);
|
||||
if(!originalQuality) originalQuality = goodInfo.quality;
|
||||
if(originalQuality != goodInfo.quality) {
|
||||
return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
@@ -760,7 +756,7 @@ export class ComBattleHandler {
|
||||
}
|
||||
}
|
||||
|
||||
const dicCompose = getBlueprtComposeByQuality(originalQuality);
|
||||
const dicCompose = gameData.blurprtCompose.get(originalQuality);
|
||||
if(!dicCompose) {
|
||||
return resResult(STATUS.COM_BLUEPRT_QUALITY_CANNOT_COMPOSE);
|
||||
}
|
||||
@@ -777,12 +773,12 @@ export class ComBattleHandler {
|
||||
let costResult = await handleCost(roleId, sid, original);
|
||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
const targetList = getBluePrtByQuality(dicCompose.targetQuality);
|
||||
const target = getRandomByLen(targetList);
|
||||
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);
|
||||
if (dicCompose.targetQuality >= QUALITY_TYPE.ORANGE) {
|
||||
const { name } = getGoodById(target);
|
||||
const { name } = gameData.goods.get(target);
|
||||
pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.ORANGE_BLUEPRT_COMPOSE, target, name);
|
||||
}
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.COM_BATTLE_BLUEPRT, 1, true, { quality: dicCompose.targetQuality });
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { DailyRecordModel } from '../../../db/DailyRecord';
|
||||
import { getGamedata } from '../../../pubUtils/gamedata';
|
||||
import { GOLD_COST_RATIO } from '../../../consts';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult, calculateNum } from '../../../pubUtils/util';
|
||||
@@ -8,6 +7,7 @@ import { RoleModel } from '../../../db/Role';
|
||||
import { getDailyNum } from '../../../services/dailyBattleService';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new DailyBattleHandler(app);
|
||||
@@ -22,36 +22,34 @@ export class DailyBattleHandler {
|
||||
let roleId = session.get('roleId');
|
||||
|
||||
let {warStar} = await RoleModel.findByRoleId(roleId);
|
||||
let dicDaily = getGamedata('dic_zyz_daily');
|
||||
let dicDailyWar = getGamedata('dic_zyz_gk_daily');
|
||||
let dicDaily = gameData.daily;
|
||||
|
||||
let result = new Array();
|
||||
for(let {dailyType: type, name, timesPerDay, timesCanBuy } of dicDaily) {
|
||||
let refreshResult = await DailyRecordModel.refreshRecord(roleId, type);
|
||||
let wars = new Array();
|
||||
for(let {war_id, dailyType, cost, gk_name, previousGk } of dicDailyWar) {
|
||||
if(dailyType == type) {
|
||||
let status = 0, star = 0;
|
||||
let curBattle = warStar.find(cur => cur.id == war_id);
|
||||
if(curBattle) {
|
||||
status = 2;
|
||||
star = curBattle.star;
|
||||
} else {
|
||||
if (previousGk) {
|
||||
let preBattleRecord = warStar.find(cur => cur.id == previousGk);
|
||||
if(preBattleRecord) {
|
||||
status = 1;
|
||||
} else {
|
||||
status = 0;
|
||||
}
|
||||
} else {
|
||||
let wars: {battleId: number, cost: number, star: number, status: number, name: string}[] = new Array();
|
||||
let dicDailyWar = gameData.dailyWarByType.get(type);
|
||||
for(let {war_id, cost, gk_name, previousGk } of dicDailyWar) {
|
||||
let status = 0, star = 0;
|
||||
let curBattle = warStar.find(cur => cur.id == war_id);
|
||||
if(curBattle) {
|
||||
status = 2;
|
||||
star = curBattle.star;
|
||||
} else {
|
||||
if (previousGk) {
|
||||
let preBattleRecord = warStar.find(cur => cur.id == previousGk);
|
||||
if(preBattleRecord) {
|
||||
status = 1;
|
||||
} else {
|
||||
status = 0;
|
||||
}
|
||||
} else {
|
||||
status = 1;
|
||||
}
|
||||
wars.push({
|
||||
battleId: war_id, cost, star, status, name: gk_name
|
||||
});
|
||||
}
|
||||
wars.push({
|
||||
battleId: war_id, cost, star, status, name: gk_name
|
||||
});
|
||||
}
|
||||
let checkDailyResult = await getDailyNum(refreshResult, timesPerDay, timesCanBuy);
|
||||
result.push({
|
||||
@@ -70,8 +68,7 @@ export class DailyBattleHandler {
|
||||
const roleId = session.get('roleId');
|
||||
const sid = session.get('sid');
|
||||
|
||||
const dicDaily = getGamedata('dic_zyz_daily');
|
||||
const curDaily = dicDaily.find(cur => cur.dailyType == type);
|
||||
const curDaily = gameData.daily.find(cur => cur.dailyType == type);
|
||||
if(!curDaily) return resResult(STATUS.DAILY_TYPE_NOT_FOUND);
|
||||
let { timesPerDay, timesCanBuy } = curDaily;
|
||||
let { buyCount = 0 } = await DailyRecordModel.refreshRecord(roleId, type);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { EventRecordModel } from '../../../db/EventRecord';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { EVENT_STATUS, EVENT_RECORD_STATUS, EVENT_ANSWER_STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { checkEvent, checkEventStatus, getEventSuccessStatus, getEvent, checkQuiz } from '../../../services/eventSercive';
|
||||
import { handleFixedReward, addItems } from '../../../services/rewardService';
|
||||
import { addItems } from '../../../services/rewardService';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { checkTask } from '../../../services/taskService';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { getGamedata, getWarById, hasExpeditionById } from '../../../pubUtils/gamedata';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { ExpeditionRecordModel } from '../../../db/ExpeditionRecord';
|
||||
import { ExpeditionWarRecordModel } from '../../../db/ExpeditionWarRecord';
|
||||
@@ -9,12 +8,13 @@ import { calculateSumCE, genCode } from '../../../pubUtils/util';
|
||||
import { getPointRewardStatus, getResetRemainCnt, findOrCreateEnemies } from '../../../services/expeditionService';
|
||||
import { EXPEDITION_CONST, EXPEDITION_WAR_RECORD_STATUS, LINEUP_NUM, TASK_TYPE } from '../../../consts';
|
||||
import { WarReward } from '../../../services/warRewardService';
|
||||
import { handleFixedReward } from '../../../services/rewardService';
|
||||
import { addItems } from '../../../services/rewardService';
|
||||
import { getAp, setAp } from '../../../services/actionPointService';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
|
||||
import { checkTask, checkTaskInBattleEnd } from '../../../services/taskService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new ExpeditionBattleHandler(app);
|
||||
@@ -127,7 +127,7 @@ export class ExpeditionBattleHandler {
|
||||
let { battleId, enemyFrom, enemies, battleStatus, ce: curCe } = curExpeditionWarRecord;
|
||||
let nextCe = 0; // 下一关战力
|
||||
|
||||
if(hasExpeditionById(expeditionId + 1)) {
|
||||
if(gameData.expedition.has(expeditionId + 1)) {
|
||||
let nextExpeditionWarRecord = await findOrCreateEnemies(roleId, myCe, expeditionCode, expeditionId + 1, EXPEDITION_WAR_RECORD_STATUS.HIDE);
|
||||
if(nextExpeditionWarRecord) nextCe = nextExpeditionWarRecord.ce;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ export class ExpeditionBattleHandler {
|
||||
const { expeditionCode, expeditionId, battleId, heroes: seqIds = [] } = msg;
|
||||
let roleId = session.get('roleId');
|
||||
let roleName = session.get('roleName');
|
||||
let warInfo = getWarById(battleId);
|
||||
let warInfo = gameData.war.get(battleId);
|
||||
if(!warInfo) {
|
||||
return resResult(STATUS.BATTLE_MISS_INFO);
|
||||
}
|
||||
@@ -214,13 +214,10 @@ export class ExpeditionBattleHandler {
|
||||
let sid = session.get('sid');
|
||||
let funcs: number[] = session.get('funcs');
|
||||
|
||||
let warInfo = getWarById(battleId);
|
||||
let warInfo = gameData.war.get(battleId);
|
||||
if(!warInfo) {
|
||||
return resResult(STATUS.BATTLE_MISS_INFO);
|
||||
}
|
||||
if(!warInfo.hasOwnProperty('cost')) {
|
||||
warInfo['cost'] = 0;
|
||||
}
|
||||
|
||||
const BattleRecord = await BattleRecordModel.getBattleRecordByCode(battleCode);
|
||||
if(!BattleRecord || BattleRecord.status != 0) {
|
||||
@@ -297,8 +294,8 @@ export class ExpeditionBattleHandler {
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let {expeditionPoint} = role;
|
||||
let dicExpeditionPoint = getGamedata('dic_expedition_point');
|
||||
let curDicExpeditionPoint = dicExpeditionPoint.find(cur => cur.point == point);
|
||||
let dicExpeditionPoint = gameData.expeditionPoint;
|
||||
let curDicExpeditionPoint = dicExpeditionPoint.get(point);
|
||||
if(!curDicExpeditionPoint) {
|
||||
return resResult(STATUS.EXPEDITION_MISS_POINT_INFO);
|
||||
}
|
||||
@@ -318,12 +315,12 @@ export class ExpeditionBattleHandler {
|
||||
// 标记状态
|
||||
let {rewards: resultRewards} = await ExpeditionPointModel.updatePointStatus(roleId, point, curDicExpeditionPoint.reward);
|
||||
let hasReceivedAll = true, maxPoint = 0;
|
||||
for(let dic of dicExpeditionPoint) {
|
||||
let curReward = resultRewards.find(cur => cur.point == dic.point);
|
||||
for(let [ point ] of dicExpeditionPoint) {
|
||||
let curReward = resultRewards.find(cur => cur.point == point);
|
||||
if(!curReward || !curReward.received) {
|
||||
hasReceivedAll = false;
|
||||
}
|
||||
if(dic.point > maxPoint) maxPoint = dic.point;
|
||||
if(point > maxPoint) maxPoint = point;
|
||||
}
|
||||
if(hasReceivedAll) { // 全部领取了,刷新
|
||||
await ExpeditionPointModel.completeStatus(roleId);
|
||||
@@ -334,7 +331,7 @@ export class ExpeditionBattleHandler {
|
||||
// 任务
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.BATTLE_EXPEDITION_BOX, 1, true, { point });
|
||||
|
||||
let goods = await handleFixedReward(roleId, roleName, sid, curDicExpeditionPoint.reward, 1);
|
||||
let goods = await addItems(roleId, roleName, sid, curDicExpeditionPoint.reward);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
costPoint: hasReceivedAll?maxPoint: 0,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult, genCode, getRandomByLen } from '../../../pubUtils/util';
|
||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE, AUCTION_SOURCE } from '../../../consts';
|
||||
import { BossInstanceModel } from '../../../db/BossInstance';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
@@ -91,7 +91,7 @@ export class GuildHandler {
|
||||
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
|
||||
}
|
||||
let bossBase = getBossByLv(curStructure.lv);
|
||||
let { bossHp, warId } = getRandomByLen(bossBase.wars);
|
||||
let { bossHp, warId } = getRandSingleEelm(bossBase.wars);
|
||||
let resGuild = await GuildModel.costFund(code, bossBase.opencost);
|
||||
if (!resGuild) {
|
||||
res.releaseCallback();
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { resResult, genCode, getRandomByLen } from '../../../pubUtils/util';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { GuildTrainModel } from '../../../db/GuildTrain';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { nowSeconds, getHourPoint, getCurHourPoint } from '../../../pubUtils/timeUtil';
|
||||
import { getUserGuild, getGuildTrainInfo, unlockTrain, resetTrain, getGuildTrainRewards } from '../../../services/guildTrainService';
|
||||
import { findIndex, findWhere, indexBy } from 'underscore'
|
||||
import { getUserGuild, getGuildTrainInfo, unlockTrain, getGuildTrainRewards } from '../../../services/guildTrainService';
|
||||
import { findIndex, findWhere } from 'underscore'
|
||||
import { lockData } from '../../../services/redLockService';
|
||||
import { REFRESH_HOUR, GUILD_REPORT_NUM, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
|
||||
import { UserGuildModel } from '../../../db/UserGuild';
|
||||
@@ -319,7 +319,7 @@ export class GuildTrainHandler {
|
||||
res.releaseCallback();//解锁
|
||||
return resResult(STATUS.GUILD_TRAIN_BOX_IS_GOT);
|
||||
}
|
||||
let good = getRandomByLen(heroRewards);
|
||||
let good = getRandSingleEelm(heroRewards);
|
||||
good.count = Math.floor((100 + shilianRewardRatio) * good.count / 100);
|
||||
let goods = await addItems(roleId, roleName, sid, [good]);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { BattleSweepRecordModel } from '../../../db/BattleSweepRecord';
|
||||
import { getWarById, } from '../../../pubUtils/gamedata';
|
||||
import { genCode } from '../../../pubUtils/util';
|
||||
import { WAR_TYPE, EVENT_STATUS, FUNC_OPT_TYPE, MSG_SOURCE, REDIS_KEY, TASK_TYPE } from '../../../consts';
|
||||
import { checkDaily, checkDailyAndIncrease } from '../../../services/dailyBattleService';
|
||||
@@ -35,14 +34,10 @@ export class NormalBattleHandler {
|
||||
const { battleId, heroes: seqIds = [] } = msg;
|
||||
let roleId = session.get('roleId');
|
||||
let roleName = session.get('roleName');
|
||||
let warInfo = getWarById(battleId);
|
||||
let warInfo = gameData.war.get(battleId);
|
||||
if(!warInfo) {
|
||||
return resResult(STATUS.BATTLE_MISS_INFO);
|
||||
}
|
||||
if(!warInfo.hasOwnProperty('cost')) {
|
||||
warInfo['cost'] = 0;
|
||||
}
|
||||
|
||||
let apJson = await getAp(Date.now(), roleId);
|
||||
let {ap} = apJson;
|
||||
if(ap < warInfo.cost) {
|
||||
@@ -289,7 +284,7 @@ export class NormalBattleHandler {
|
||||
let roleName = session.get('roleName');
|
||||
let sid = session.get('sid');
|
||||
let funcs: number[] = session.get('funcs');
|
||||
let warInfo = getWarById(battleId);
|
||||
let warInfo = gameData.war.get(battleId);
|
||||
if(!warInfo) {
|
||||
return resResult(STATUS.BATTLE_MISS_INFO);
|
||||
}
|
||||
@@ -301,9 +296,6 @@ export class NormalBattleHandler {
|
||||
}
|
||||
|
||||
// 扣体力
|
||||
if(!warInfo.hasOwnProperty('cost')) {
|
||||
warInfo['cost'] = 0;
|
||||
}
|
||||
const now = Date.now(); // 当前时间戳
|
||||
let apJson = await setAp(now, roleId, sid, funcs, -1 * warInfo.cost * count); // 扣除体力
|
||||
if(!apJson) {
|
||||
@@ -359,7 +351,7 @@ export class NormalBattleHandler {
|
||||
|
||||
const { battleId, type, script } = msg;
|
||||
let roleId = session.get('roleId');
|
||||
let warInfo = getWarById(battleId);
|
||||
let warInfo = gameData.war.get(battleId);
|
||||
let result = await RScriptRecordModel.setScript(roleId, battleId, warInfo.warType, type, script);
|
||||
if(result) {
|
||||
if(!result.scriptBefore) result.scriptBefore = '';
|
||||
|
||||
@@ -6,13 +6,14 @@ import { HangUpRecordModel } from './../../../db/HangUpRecord';
|
||||
import { RoleModel } from './../../../db/Role';
|
||||
import { TowerRecordModel } from './../../../db/TowerRecord';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { getTaskById, getTowerDataByLv } from '../../../pubUtils/gamedata';
|
||||
import { decodeArrayStr, resResult, shouldRefresh, calculateNum, getRefTime, genCode } from '../../../pubUtils/util';
|
||||
import { calcuHangUpReward, checkTaskConditions, checkHangUpSpdUpCnt, createCurTasks, treatTask, getRemainTime, getTasksReward, getTaskStatus, getDoingOrWaitingTasks } from '../../../services/battleService';
|
||||
import { handleFixedReward, addItems, handleCost } from '../../../services/rewardService';
|
||||
import { resResult, shouldRefresh, calculateNum, genCode } from '../../../pubUtils/util';
|
||||
import { calcuHangUpReward, checkTaskConditions, checkHangUpSpdUpCnt, createCurTasks, treatTask, getRemainTime, getDoingOrWaitingTasks } from '../../../services/battleService';
|
||||
import { addItems, handleCost } from '../../../services/rewardService';
|
||||
import { checkBattleHeroes } from '../../../services/normalBattleService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import { ItemInter } from '../../../pubUtils/interface';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new TowerBattleHandler(app);
|
||||
@@ -39,10 +40,10 @@ export class TowerBattleHandler {
|
||||
}
|
||||
let towerRec = await TowerRecordModel.getRecordByLv(roleId, towerLv);
|
||||
if (!towerRec) {
|
||||
const towerInfo = getTowerDataByLv(towerLv);
|
||||
const towerInfo = gameData.tower.get(towerLv);
|
||||
const { warArray } = towerInfo;
|
||||
const sts = decodeArrayStr(warArray, '&').map(id => {
|
||||
return {warId: parseInt(id), status: false};
|
||||
const sts = warArray.map(id => {
|
||||
return {warId: id, status: false};
|
||||
});
|
||||
towerRec = await TowerRecordModel.createRecord({roleId, lv: towerLv, warStatus: sts});
|
||||
// return { code: 201, data: '天梯记录异常' };
|
||||
@@ -237,7 +238,7 @@ export class TowerBattleHandler {
|
||||
if(!curTask) {
|
||||
return resResult(STATUS.TOWER_TASK_MISSING)
|
||||
}
|
||||
let taskInfo = getTaskById(curTask.taskId);
|
||||
let taskInfo = gameData.towerTask.get(curTask.taskId);
|
||||
if (task.heroes.length !== taskInfo.actorNeeded) { // 武将数,从策划表中读取
|
||||
return resResult(STATUS.TOWER_TASK_MAX_HERO);
|
||||
}
|
||||
@@ -279,26 +280,27 @@ export class TowerBattleHandler {
|
||||
if (!curTasks || curTasks.length == 0) {
|
||||
return resResult(STATUS.TOWER_TASK_NOT_FOUND);
|
||||
}
|
||||
const compTasks = [];
|
||||
let goods = [];
|
||||
const compTasks: string[] = [];
|
||||
let rewards: ItemInter[] = [];
|
||||
for (let task of curTasks) {
|
||||
if (task.batchCode !== msg.batchCode) {
|
||||
return resResult(STATUS.TOWER_TASK_BATCH_NOT_FOUND);
|
||||
}
|
||||
if ((allFlag || task.taskCode === msg.taskCode) && task.status === 1) {
|
||||
let {completeTime, reward, termsForAdd, additionalReward} = getTaskById(task.taskId);
|
||||
let {completeTime, reward, termsForAdd, additionalReward} = gameData.towerTask.get(task.taskId);
|
||||
if (task.sendTime && task.sendTime.getTime() + completeTime * 1000 < curTime.getTime()) {
|
||||
compTasks.push(task.taskCode);
|
||||
const rewardGoods = await handleFixedReward(roleId, roleName, sid, reward, 1);
|
||||
goods = goods.concat(rewardGoods);
|
||||
rewards = rewards.concat(reward);
|
||||
if(termsForAdd) {
|
||||
const result = await checkTaskConditions(roleId, task.heroes, termsForAdd);
|
||||
const bonusGoods = await handleFixedReward(roleId, roleName, sid, result?additionalReward:'', 1);
|
||||
goods = goods.concat(bonusGoods);
|
||||
if(result) {
|
||||
rewards = rewards.concat(additionalReward)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let goods = addItems(roleId, roleName, sid, rewards);
|
||||
await TowerTaskRecModel.finishTask(msg.batchCode, compTasks);
|
||||
await TowerTaskRecModel.showTask(roleId, msg.batchCode, compTasks.length);
|
||||
let refRemainTime = getRemainTime(curTime);
|
||||
|
||||
Reference in New Issue
Block a user