红点:修改推送方式
This commit is contained in:
@@ -4,7 +4,7 @@ import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE,
|
||||
import { LotModel } from "../../../db/Lot";
|
||||
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 { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction } from "../../../services/auctionService";
|
||||
import { addItems, handleCost } from '../../../services/rewardService';
|
||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||
@@ -25,11 +25,9 @@ export class AuctionHandler {
|
||||
|
||||
const guildCode = session.get('guildCode');
|
||||
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
const begin = todayGuildBegin();
|
||||
let lots = magicWord === DEBUG_MAGIC_WORD ? await debugAuctionLots(session, begin) : await officialAuctionLots(session, begin);
|
||||
let result = await getAuction(guildCode, session, magicWord);
|
||||
|
||||
const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
|
||||
return resResult(STATUS.SUCCESS, { lots, dividends });
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
async offer(msg: { code: string, max: boolean }, session: BackendSession) {
|
||||
@@ -76,8 +74,11 @@ export class AuctionHandler {
|
||||
|
||||
if (curBuyer) {
|
||||
const { roleName: buyerName } = await getSimpleRoleInfo(curBuyer);
|
||||
const { sid: buyerSid } = await getRoleOnlineInfo(buyerName);
|
||||
const { isOnline, sid: buyerSid } = await getRoleOnlineInfo(curBuyer);
|
||||
await addItems(curBuyer, buyerName, buyerSid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count: curPrice }]);
|
||||
if(isOnline) {
|
||||
this.channelService.pushMessageByUids('onAuctionOver', resResult(STATUS.SUCCESS, { code }), [{ uid: curBuyer, sid: buyerSid }]);
|
||||
}
|
||||
}
|
||||
|
||||
if (maxFlag) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import { RoleStatus, ComBattleTeamModel, ComBattleTeamType, BossHp } from '../..
|
||||
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 { getRandBlueprtId, clearComBtlTimer, getFrd, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam, incEquipPrintDrop, randEquipPrintId, handleComBtlProgress, getComBattleFriendAdd, teammateInBlackList, blueprtIdValid, createComTeamData, hasEnoughBlueprt, addRoleToTeam, addRoleStToTeam, addValidSearchingRoles, validToJoin, addRobotsToTeam, addRobotsLater, teamIsFullToStart, oneTeamNotInBlack, getAllAssistCnt } from '../../../services/comBattleService';
|
||||
import { setAp } from '../../../services/actionPointService';
|
||||
import { roleLevelup } from '../../../services/normalBattleService';
|
||||
import { addUserToChannel, getSimpleRoleInfo } from '../../../services/roleService';
|
||||
@@ -630,11 +630,7 @@ export class ComBattleHandler {
|
||||
*/
|
||||
async getAssistCnt(msg: {}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let cntMap = await getAssistTimesByQuality(roleId);
|
||||
let cnt = [];
|
||||
for (let i = 0; i < COM_BTL_QUALITY.length; ++i) {
|
||||
cnt[i] = cntMap.get(i + 1) || 0;
|
||||
}
|
||||
let cnt = await getAllAssistCnt(roleId);
|
||||
return resResult(STATUS.SUCCESS, {cnt});
|
||||
}
|
||||
/**
|
||||
@@ -646,11 +642,7 @@ export class ComBattleHandler {
|
||||
*/
|
||||
async getComBtlCnt(msg: {}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let cntMap = await getAssistTimesByQuality(roleId);
|
||||
let cnt: number[] = [];
|
||||
for (let i = 0; i < COM_BTL_QUALITY.length; ++i) {
|
||||
cnt[i] = cntMap.get(i + 1) || 0;
|
||||
}
|
||||
let cnt = await getAllAssistCnt(roleId);
|
||||
const blueprts = await ItemModel.findByRoleAndType(roleId, CONSUME_TYPE.BLUEPRT);
|
||||
return resResult(STATUS.SUCCESS, { blueprts, assistCnt: cnt });
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { GOLD_COST_RATIO } from '../../../consts';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult, calculateNum } from '../../../pubUtils/util';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { getDailyNum } from '../../../services/dailyBattleService';
|
||||
import { getDailyNum, getDailyBattleList } from '../../../services/dailyBattleService';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
@@ -21,42 +21,8 @@ export class DailyBattleHandler {
|
||||
async getData(msg: { }, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
|
||||
let {warStar} = await RoleModel.findByRoleId(roleId);
|
||||
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: {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
|
||||
});
|
||||
}
|
||||
let checkDailyResult = await getDailyNum(refreshResult, timesPerDay, timesCanBuy);
|
||||
result.push({
|
||||
type, name, ...checkDailyResult,
|
||||
wars
|
||||
});
|
||||
}
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let result = await getDailyBattleList(role);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { list: result });
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { resResult, calculateNum, shouldRefresh } from '../../../pubUtils/util';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
import { getDungeonData } from '../../../services/dungeonService';
|
||||
|
||||
export default function(app: Application) {
|
||||
return new DungeonBattleHandler(app);
|
||||
@@ -17,19 +18,9 @@ export class DungeonBattleHandler {
|
||||
// 获取关卡列表
|
||||
async getData(msg: { }, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime, dungeonHeroes=[] } = await RoleModel.findByRoleId(roleId);
|
||||
let curTime = new Date();
|
||||
if(shouldRefresh(dungeonRefTime, curTime)) {
|
||||
dungeonCnt = 0; dungeonBuyCnt = 0;
|
||||
}
|
||||
|
||||
let nextCostGold = calculateNum(GOLD_COST_RATIO.DUNGRON_BUY_NUM, {num: dungeonBuyCnt + 1 }, 50);
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
nextCostGold,
|
||||
dungeonHeroes,
|
||||
battleCount: DUNGEON_CONST.MAX_CNT + dungeonBuyCnt - dungeonCnt,
|
||||
buyCount: DUNGEON_CONST.MAX_BUY_CNT - dungeonBuyCnt
|
||||
});
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let res = await getDungeonData(role);
|
||||
return resResult(STATUS.SUCCESS, res);
|
||||
}
|
||||
|
||||
// 购买每日次数
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ExpeditionWarRecordModel } from '../../../db/ExpeditionWarRecord';
|
||||
import { ExpeditionPointModel } from '../../../db/ExpeditionPoint';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { calculateSumCE, genCode } from '../../../pubUtils/util';
|
||||
import { getPointRewardStatus, getResetRemainCnt, findOrCreateEnemies } from '../../../services/expeditionService';
|
||||
import { getPointRewardStatus, getResetRemainCnt, findOrCreateEnemies, getExpeditionStatus } from '../../../services/expeditionService';
|
||||
import { EXPEDITION_CONST, EXPEDITION_WAR_RECORD_STATUS, LINEUP_NUM, TASK_TYPE } from '../../../consts';
|
||||
import { WarReward } from '../../../services/warRewardService';
|
||||
import { addItems } from '../../../services/rewardService';
|
||||
@@ -32,41 +32,9 @@ export class ExpeditionBattleHandler {
|
||||
let roleId = session.get('roleId');
|
||||
let roleName = session.get('roleName');
|
||||
|
||||
// 获取远征关卡状态
|
||||
let expeditionRecord = await ExpeditionRecordModel.getCurRecord(roleId);
|
||||
if (!expeditionRecord) { // 首次新建一条记录
|
||||
// 我方战力
|
||||
let myCe = await calculateSumCE(roleId, 1, { num: LINEUP_NUM });
|
||||
expeditionRecord = await ExpeditionRecordModel.createRecord({
|
||||
roleId, roleName, heroes: [], myCe
|
||||
});
|
||||
await findOrCreateEnemies(roleId, myCe, expeditionRecord.expeditionCode, 1, EXPEDITION_WAR_RECORD_STATUS.WAITING);
|
||||
}
|
||||
let res = await getExpeditionStatus(roleId, roleName);
|
||||
|
||||
// 每一关的挑战状态
|
||||
let { expeditionCode, heroes } = expeditionRecord;
|
||||
let expeditionWarRecord = await ExpeditionWarRecordModel.getRecordByCode(expeditionCode);
|
||||
let curLv = 0;
|
||||
if (expeditionWarRecord.length > 0) {
|
||||
curLv = expeditionWarRecord[expeditionWarRecord.length - 1].expeditionId;
|
||||
}
|
||||
|
||||
// 重置次数
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let curTime = new Date();
|
||||
let { resetCnt } = await getResetRemainCnt(curTime, roleId, role);
|
||||
|
||||
// 点数,和宝箱领取状态
|
||||
let pointRewards = await getPointRewardStatus(roleId, role);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
expeditionCode,
|
||||
curLv,
|
||||
expeditionWarRecord,
|
||||
pointRewards,
|
||||
heroes: heroes.map(cur => { return { "dataId": cur.seqId, "hp": cur.hp, "ap": cur.ap } }),
|
||||
resetCnt
|
||||
});
|
||||
return resResult(STATUS.SUCCESS, res);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { BossInstanceModel } from '../../../db/BossInstance';
|
||||
@@ -14,7 +14,7 @@ import { checkAuth, addActive } from '../../../services/guildService';
|
||||
import { GuildModel } from '../../../db/Guild';
|
||||
import { getBossByLv } from '../../../pubUtils/data';
|
||||
import { lockData } from '../../../services/redLockService';
|
||||
import { pushGuildBossSucMsg } from '../../../services/chatService';
|
||||
import { pushGuildBossSucMsg, getGuildChannelSid } from '../../../services/chatService';
|
||||
import { checkTask } from '../../../services/taskService';
|
||||
|
||||
export default function (app: Application) {
|
||||
@@ -99,6 +99,10 @@ export class GuildHandler {
|
||||
await BossInstanceModel.openBossInstance(code, bossHp, warId, bossBase.bossLevel);
|
||||
res.releaseCallback();
|
||||
let result = {warId, ranks: [], myRank: {}, bossHp, status: 3, bossLv: bossBase.bossLevel, isBattled: false};
|
||||
|
||||
let chatSid = await getGuildChannelSid(code);
|
||||
pinus.app.rpc.chat.guildRemote.pushBossOpen.toServer(chatSid, code, warId, bossHp, result.status);
|
||||
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Application, BackendSession, ChannelService } from 'pinus';
|
||||
import { resResult, getRandEelm, shouldRefresh, sortArrRandom } from '../../../pubUtils/util';
|
||||
import { STATUS, GUILD_OPERATE, GUILD_AUTH, GUILD_JOB, GUILD_APPLY_TYPE, GUILD_STRUCTURE, GUILD_REC_TYPE, GUILD_STRUCTURE_NAME, MAIL_TYPE, REDIS_KEY, GUILD_SELECT, USER_GUILD_SELECT, TASK_TYPE } from '../../../consts';
|
||||
import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { checkAuth, joinGuild, getGuildWithRefActive, getUserGuildWithRefActive, addActive, settleGuildWeekly } from '../../../services/guildService';
|
||||
import { checkAuth, joinGuild, getGuildWithRefActive, getUserGuildWithRefActive, addActive, settleGuildWeekly, getMyGuildInfo } from '../../../services/guildService';
|
||||
import { GuildModel, GuildType } from '../../../db/Guild';
|
||||
import { RoleModel, RoleType } from '../../../db/Role';
|
||||
import { ARMY } from '../../../pubUtils/dicParam';
|
||||
@@ -272,22 +272,7 @@ export class GuildHandler {
|
||||
return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
}
|
||||
|
||||
let leader = <RoleType>guild.leader;
|
||||
let leaderIsOnline = await isRoleOnline(leader.roleId);
|
||||
|
||||
// 打开公会页面,加入channel
|
||||
if(userGuild.guildCode) {
|
||||
addRoleToGuildChannel(roleId, sid, guild.code);
|
||||
session.set('guildCode', guild.code);
|
||||
session.push('guildCode', () => {});
|
||||
}
|
||||
|
||||
// 获取排行榜
|
||||
let r = new Rank(REDIS_KEY.GUILD_ACTIVE_RANK, { serverId });
|
||||
const rank = await r.getMyRank({ guildCode: guild.code });
|
||||
|
||||
// 返回
|
||||
const result = { hasGuild: true, ...guild, leader: { ...leader, isOnline: leaderIsOnline }, rank, myInfo: {...userGuild }};
|
||||
let result = await getMyGuildInfo(roleId, sid, userGuild, guild, serverId, session);
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { GuildTrainModel } from '../../../db/GuildTrain';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { nowSeconds, getTimeFun, getZeroPoint } from '../../../pubUtils/timeUtil';
|
||||
import { getUserGuild, getGuildTrainInfo, unlockTrain, getGuildTrainRewards } from '../../../services/guildTrainService';
|
||||
import { getUserGuild, getGuildTrainInfo, unlockTrain, getGuildTrainRewards, getGuildTrainInstance } from '../../../services/guildTrainService';
|
||||
import { findIndex, findWhere } from 'underscore'
|
||||
import { lockData } from '../../../services/redLockService';
|
||||
import { GUILD_REPORT_NUM, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
|
||||
@@ -37,15 +37,8 @@ export class GuildTrainHandler {
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let { trainId, trainLv } = await GuildModel.findGuild(code, serverId, 'trainId trainLv');
|
||||
let guildTrain = await GuildTrainModel.findTrainByTrainIdNotLock(code, trainId);
|
||||
if (!guildTrain) {
|
||||
guildTrain = await unlockTrain(code, trainId);
|
||||
}
|
||||
let { trainCount, trainRewards, buyTrainCount } = userGuild;
|
||||
let result: any = getGuildTrainInfo(guildTrain, roleId, trainCount, trainRewards);
|
||||
result.buyTrainCount = buyTrainCount || 0;
|
||||
result.trainLv = trainLv;
|
||||
let guild = await GuildModel.findGuild(code, serverId, 'trainId trainLv');
|
||||
let result = await getGuildTrainInstance(roleId, guild, userGuild);
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
//获得试炼战报
|
||||
|
||||
@@ -12,7 +12,7 @@ import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { RScriptRecordModel } from '../../../db/RScriptRecord';
|
||||
import { updateWarStar, checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
|
||||
import { updateWarStar, checkBattleHeroes, roleLevelup, getBattleList } from '../../../services/normalBattleService';
|
||||
import { checkDungeonNum, checkDungeonAndIncrease } from '../../../services/dungeonService';
|
||||
import { switchOnFunc } from '../../../services/funcSwitchService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
@@ -110,40 +110,7 @@ export class NormalBattleHandler {
|
||||
let roleId = session.get('roleId');
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let { warStar } = role;
|
||||
|
||||
let scripts = await RScriptRecordModel.findbyRole(roleId, type);
|
||||
|
||||
let result = []; // 去重
|
||||
for (let { battleId, scriptBefore = '', scriptAfter = '' } of scripts) {
|
||||
|
||||
result.push({
|
||||
battleId,
|
||||
status: 0,
|
||||
star: 0,
|
||||
scriptBefore,
|
||||
scriptAfter
|
||||
});
|
||||
}
|
||||
for (let { id, star, warType } of warStar) {
|
||||
if (warType == type) {
|
||||
let curResult = result.find(cur => cur.battleId == id);
|
||||
if (curResult) {
|
||||
curResult.status = 1;
|
||||
curResult.star = star;
|
||||
} else {
|
||||
result.push({
|
||||
battleId: id,
|
||||
status: 1,
|
||||
star,
|
||||
scriptBefore: '',
|
||||
scriptAfter: ''
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
result = result.sort((a, b) => { return a.battleId - b.battleId });
|
||||
|
||||
let result = await getBattleList(role, type);
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
list: result
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@ import { RoleModel } from './../../../db/Role';
|
||||
import { TowerRecordModel } from './../../../db/TowerRecord';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult, shouldRefresh, calculateNum, genCode } from '../../../pubUtils/util';
|
||||
import { calcuHangUpReward, checkTaskConditions, checkHangUpSpdUpCnt, createCurTasks, treatTask, getRemainTime, getDoingOrWaitingTasks } from '../../../services/battleService';
|
||||
import { calcuHangUpReward, checkTaskConditions, checkHangUpSpdUpCnt, createCurTasks, treatTask, getRemainTime, getDoingOrWaitingTasks, getTowerStatus, getHungupRewards, getTasks } from '../../../services/battleService';
|
||||
import { addItems, handleCost } from '../../../services/rewardService';
|
||||
import { checkBattleHeroes } from '../../../services/normalBattleService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
@@ -30,32 +30,9 @@ export class TowerBattleHandler {
|
||||
async getStatus(msg: {}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let serverId = session.get('serverId');
|
||||
let { towerLv } = await RoleModel.findByRoleId(roleId);
|
||||
if (!towerLv) {
|
||||
towerLv = 1;
|
||||
let role = await RoleModel.towerLvUp(roleId);
|
||||
// 更新redis
|
||||
let r = new Rank(REDIS_KEY.TOWER_RANK, { serverId });
|
||||
await r.setRankWithRoleInfo(roleId, towerLv, role.towerUpTime.getTime(), role);
|
||||
}
|
||||
let towerRec = await TowerRecordModel.getRecordByLv(roleId, towerLv);
|
||||
if (!towerRec) {
|
||||
const towerInfo = gameData.tower.get(towerLv);
|
||||
const { warArray } = towerInfo;
|
||||
const sts = warArray.map(id => {
|
||||
return {warId: id, status: false};
|
||||
});
|
||||
towerRec = await TowerRecordModel.createRecord({roleId, lv: towerLv, warStatus: sts});
|
||||
// return { code: 201, data: '天梯记录异常' };
|
||||
}
|
||||
const data = {
|
||||
canHungUp: towerLv >= HANG_UP_CONSTS.ENABLE_LV,
|
||||
hungUpEnableLv: HANG_UP_CONSTS.ENABLE_LV,
|
||||
canSendTask: true,
|
||||
curLv: towerLv,
|
||||
usedHeroes: towerRec.heroes,
|
||||
progress: towerRec.warStatus
|
||||
};
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let data = await getTowerStatus(role);
|
||||
|
||||
return resResult(STATUS.SUCCESS, data);
|
||||
}
|
||||
|
||||
@@ -79,20 +56,11 @@ export class TowerBattleHandler {
|
||||
|
||||
async checkHangUpRewards(msg: {}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
const result = await calcuHangUpReward(roleId);
|
||||
let result = await getHungupRewards(roleId);
|
||||
if(result.status == -1) {
|
||||
return result.resResult
|
||||
return result.resResult;
|
||||
}
|
||||
let {timeReward, startTime, deltaTime} = result.data;
|
||||
let {hangUpSpdUpCnt, lastSpdUpTime} = await RoleModel.findByRoleId(roleId);
|
||||
let curTime = new Date();
|
||||
if (!lastSpdUpTime || (shouldRefresh(lastSpdUpTime, curTime) && hangUpSpdUpCnt <= HANG_UP_CONSTS.MAX_SPD_UP_CNT)) {
|
||||
hangUpSpdUpCnt = HANG_UP_CONSTS.MAX_SPD_UP_CNT;
|
||||
}
|
||||
let num = HANG_UP_CONSTS.MAX_SPD_UP_CNT - hangUpSpdUpCnt + 1;
|
||||
let nextCostGold = calculateNum(GOLD_COST_RATIO.TOWER_HANG_SPDUP, {num}, 50);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {startTime, hangUpPassTime: Math.floor(deltaTime/1000), hangUpSpdUpCnt, nextCostGold, rewards: timeReward});
|
||||
return resResult(STATUS.SUCCESS, result.data);
|
||||
}
|
||||
|
||||
async recHangUpRewards(msg: {}, session: BackendSession) {
|
||||
@@ -162,30 +130,11 @@ export class TowerBattleHandler {
|
||||
async getTasks(msg: {}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let roleName = session.get('roleName');
|
||||
let curTime = new Date();
|
||||
|
||||
let { towerLv, towerTaskRefTime, towerTaskReCnt = 0 } = await RoleModel.findByRoleId(roleId);
|
||||
let curTasks = await TowerTaskRecModel.getCurTasks(roleId); // 当前显示中的任务
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let result = await getTasks(role);
|
||||
|
||||
const needRefresh = shouldRefresh(towerTaskRefTime, curTime);
|
||||
|
||||
if(needRefresh) {
|
||||
const batchCode = genCode(8);
|
||||
let {waitingTaskCode, doingTaskCode, doingIds} = getDoingOrWaitingTasks(curTasks, curTime);
|
||||
await TowerTaskRecModel.hideTask(roleId, waitingTaskCode); // 隐藏没有在做的任务
|
||||
await TowerTaskRecModel.updateBatchCode(roleId, doingTaskCode, batchCode); // 更新留下来的旧任务的batchCode
|
||||
await createCurTasks(towerLv, batchCode, roleId, roleName, doingTaskCode.length, TOWER_TASK_CONST.RAND_CNT-doingTaskCode.length, doingIds); // 新建任务
|
||||
curTasks = await TowerTaskRecModel.getCurTasks(roleId);
|
||||
|
||||
// 重置派遣次数
|
||||
const role = await RoleModel.resetTowerCnt(roleId, curTime);
|
||||
towerTaskReCnt = role.towerTaskReCnt;
|
||||
}
|
||||
|
||||
let refRemainTime = getRemainTime(curTime);
|
||||
let nextCostGold = calculateNum(GOLD_COST_RATIO.TOWER_TASK_REF, {num: towerTaskReCnt + 1}, 50);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { curTasks: treatTask(curTasks, curTime), refRemainTime, nextCostGold });
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
async refreshTasks(msg: {}, session: BackendSession) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import { getArmyWishPoolBaseByLv, getGoodById } from '../../../pubUtils/data';
|
||||
import { addItems, checkGoods } from '../../../services/rewardService';
|
||||
import { IT_TYPE } from '../../../consts/constModules/itemConst';
|
||||
import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst';
|
||||
import { getUserGuildWithRefActive } from '../../../services/guildService';
|
||||
import { getUserGuildWithRefActive, getWishPool } from '../../../services/guildService';
|
||||
import { findIndex, findWhere } from 'underscore';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||
@@ -27,15 +27,8 @@ export class WishPoolHandler {
|
||||
let userGuild = await getUserGuildWithRefActive(roleId, 'wishDntCnt wishGoods guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code, wishDntCnt, wishGoods } = userGuild;
|
||||
let userGuilds = await UserGuildModel.getWishPoolGoods(code, ' wishDntCnt wishGoods roleId');
|
||||
let list = [];
|
||||
userGuilds.map(({ wishGoods, roleId })=>{
|
||||
wishGoods.map(({ type, goodId, count, receiveCnt, drawCnt, id })=>{
|
||||
list.push({ type, goodId, count, receiveCnt, drawCnt, id, roleId })
|
||||
});
|
||||
});
|
||||
return resResult(STATUS.SUCCESS, { list, wishDntCnt:wishDntCnt||0, wishGoods });
|
||||
let res = await getWishPool(userGuild);
|
||||
return resResult(STATUS.SUCCESS, );
|
||||
}
|
||||
|
||||
// 许愿
|
||||
|
||||
Reference in New Issue
Block a user