红点:修改推送方式
This commit is contained in:
@@ -4,7 +4,7 @@ import { STATUS, GACHA_ID, HERO_QUALITY_TYPE, TASK_TYPE, REFRESH_TIME, TIME_OUTP
|
|||||||
import { gameData } from "../../../pubUtils/data";
|
import { gameData } from "../../../pubUtils/data";
|
||||||
import { GachaListReturn, GachaResult, GachaData } from "../../../domain/activityField/gachaField";
|
import { GachaListReturn, GachaResult, GachaData } from "../../../domain/activityField/gachaField";
|
||||||
import { UserGachaModel } from "../../../db/UserGacha";
|
import { UserGachaModel } from "../../../db/UserGacha";
|
||||||
import { refreshGacha, getFloorResult, getResultFromContentId } from "../../../services/gachaService";
|
import { refreshGacha, getFloorResult, getResultFromContentId, getGachaList } from "../../../services/gachaService";
|
||||||
import { RoleModel } from "../../../db/Role";
|
import { RoleModel } from "../../../db/Role";
|
||||||
import { HeroModel } from "../../../db/Hero";
|
import { HeroModel } from "../../../db/Hero";
|
||||||
import { RewardInter } from "../../../pubUtils/interface";
|
import { RewardInter } from "../../../pubUtils/interface";
|
||||||
@@ -35,18 +35,7 @@ export class GachaHandler {
|
|||||||
async getGachaList(msg: {}, session: BackendSession) {
|
async getGachaList(msg: {}, session: BackendSession) {
|
||||||
const { } = msg;
|
const { } = msg;
|
||||||
const roleId: string = session.get('roleId');
|
const roleId: string = session.get('roleId');
|
||||||
|
const list = await getGachaList(roleId);
|
||||||
let userGachaList = await UserGachaModel.findAllByRole(roleId);
|
|
||||||
let list: GachaListReturn[] = [];
|
|
||||||
for (let [id, dicGacha] of gameData.gacha) {
|
|
||||||
if (id == GACHA_ID.TIMELIMIT) continue; // 不包括限时
|
|
||||||
|
|
||||||
let userGacha = userGachaList.find(cur => cur.gachaId == id);
|
|
||||||
if (userGacha)
|
|
||||||
userGacha = await refreshGacha(dicGacha, userGacha);
|
|
||||||
let param = new GachaListReturn(dicGacha, userGacha);
|
|
||||||
list.push(param);
|
|
||||||
}
|
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { list });
|
return resResult(STATUS.SUCCESS, { list });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE,
|
|||||||
import { LotModel } from "../../../db/Lot";
|
import { LotModel } from "../../../db/Lot";
|
||||||
import { ItemReward } from "../../../domain/dbGeneral";
|
import { ItemReward } from "../../../domain/dbGeneral";
|
||||||
import { resResult } from "../../../pubUtils/util";
|
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 { addItems, handleCost } from '../../../services/rewardService';
|
||||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||||
@@ -25,11 +25,9 @@ export class AuctionHandler {
|
|||||||
|
|
||||||
const guildCode = session.get('guildCode');
|
const guildCode = session.get('guildCode');
|
||||||
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND);
|
if (!guildCode) return resResult(STATUS.GUILD_NOT_FOUND);
|
||||||
const begin = todayGuildBegin();
|
let result = await getAuction(guildCode, session, magicWord);
|
||||||
let lots = magicWord === DEBUG_MAGIC_WORD ? await debugAuctionLots(session, begin) : await officialAuctionLots(session, begin);
|
|
||||||
|
|
||||||
const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
|
return resResult(STATUS.SUCCESS, result);
|
||||||
return resResult(STATUS.SUCCESS, { lots, dividends });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async offer(msg: { code: string, max: boolean }, session: BackendSession) {
|
async offer(msg: { code: string, max: boolean }, session: BackendSession) {
|
||||||
@@ -76,8 +74,11 @@ export class AuctionHandler {
|
|||||||
|
|
||||||
if (curBuyer) {
|
if (curBuyer) {
|
||||||
const { roleName: buyerName } = await getSimpleRoleInfo(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 }]);
|
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) {
|
if (maxFlag) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { RoleStatus, ComBattleTeamModel, ComBattleTeamType, BossHp } from '../..
|
|||||||
import { ItemModel, ItemType } from '../../../db/Item';
|
import { ItemModel, ItemType } from '../../../db/Item';
|
||||||
import { addItems, handleCost } from '../../../services/rewardService';
|
import { addItems, handleCost } from '../../../services/rewardService';
|
||||||
import { checkRoleInQueue, rmRoleFromQueue, setTeamSearchReq } from '../../../services/redisService';
|
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 { setAp } from '../../../services/actionPointService';
|
||||||
import { roleLevelup } from '../../../services/normalBattleService';
|
import { roleLevelup } from '../../../services/normalBattleService';
|
||||||
import { addUserToChannel, getSimpleRoleInfo } from '../../../services/roleService';
|
import { addUserToChannel, getSimpleRoleInfo } from '../../../services/roleService';
|
||||||
@@ -630,11 +630,7 @@ export class ComBattleHandler {
|
|||||||
*/
|
*/
|
||||||
async getAssistCnt(msg: {}, session: BackendSession) {
|
async getAssistCnt(msg: {}, session: BackendSession) {
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let cntMap = await getAssistTimesByQuality(roleId);
|
let cnt = await getAllAssistCnt(roleId);
|
||||||
let cnt = [];
|
|
||||||
for (let i = 0; i < COM_BTL_QUALITY.length; ++i) {
|
|
||||||
cnt[i] = cntMap.get(i + 1) || 0;
|
|
||||||
}
|
|
||||||
return resResult(STATUS.SUCCESS, {cnt});
|
return resResult(STATUS.SUCCESS, {cnt});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -646,11 +642,7 @@ export class ComBattleHandler {
|
|||||||
*/
|
*/
|
||||||
async getComBtlCnt(msg: {}, session: BackendSession) {
|
async getComBtlCnt(msg: {}, session: BackendSession) {
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let cntMap = await getAssistTimesByQuality(roleId);
|
let cnt = await getAllAssistCnt(roleId);
|
||||||
let cnt: number[] = [];
|
|
||||||
for (let i = 0; i < COM_BTL_QUALITY.length; ++i) {
|
|
||||||
cnt[i] = cntMap.get(i + 1) || 0;
|
|
||||||
}
|
|
||||||
const blueprts = await ItemModel.findByRoleAndType(roleId, CONSUME_TYPE.BLUEPRT);
|
const blueprts = await ItemModel.findByRoleAndType(roleId, CONSUME_TYPE.BLUEPRT);
|
||||||
return resResult(STATUS.SUCCESS, { blueprts, assistCnt: cnt });
|
return resResult(STATUS.SUCCESS, { blueprts, assistCnt: cnt });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { GOLD_COST_RATIO } from '../../../consts';
|
|||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
import { resResult, calculateNum } from '../../../pubUtils/util';
|
import { resResult, calculateNum } from '../../../pubUtils/util';
|
||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
import { getDailyNum } from '../../../services/dailyBattleService';
|
import { getDailyNum, getDailyBattleList } from '../../../services/dailyBattleService';
|
||||||
import { handleCost } from '../../../services/rewardService';
|
import { handleCost } from '../../../services/rewardService';
|
||||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||||
import { gameData } from '../../../pubUtils/data';
|
import { gameData } from '../../../pubUtils/data';
|
||||||
@@ -21,42 +21,8 @@ export class DailyBattleHandler {
|
|||||||
async getData(msg: { }, session: BackendSession) {
|
async getData(msg: { }, session: BackendSession) {
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
|
|
||||||
let {warStar} = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
let dicDaily = gameData.daily;
|
let result = await getDailyBattleList(role);
|
||||||
|
|
||||||
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
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { list: result });
|
return resResult(STATUS.SUCCESS, { list: result });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { resResult, calculateNum, shouldRefresh } from '../../../pubUtils/util';
|
|||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
import { handleCost } from '../../../services/rewardService';
|
import { handleCost } from '../../../services/rewardService';
|
||||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||||
|
import { getDungeonData } from '../../../services/dungeonService';
|
||||||
|
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
return new DungeonBattleHandler(app);
|
return new DungeonBattleHandler(app);
|
||||||
@@ -17,19 +18,9 @@ export class DungeonBattleHandler {
|
|||||||
// 获取关卡列表
|
// 获取关卡列表
|
||||||
async getData(msg: { }, session: BackendSession) {
|
async getData(msg: { }, session: BackendSession) {
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime, dungeonHeroes=[] } = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
let curTime = new Date();
|
let res = await getDungeonData(role);
|
||||||
if(shouldRefresh(dungeonRefTime, curTime)) {
|
return resResult(STATUS.SUCCESS, res);
|
||||||
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
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 购买每日次数
|
// 购买每日次数
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { ExpeditionWarRecordModel } from '../../../db/ExpeditionWarRecord';
|
|||||||
import { ExpeditionPointModel } from '../../../db/ExpeditionPoint';
|
import { ExpeditionPointModel } from '../../../db/ExpeditionPoint';
|
||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
import { calculateSumCE, genCode } from '../../../pubUtils/util';
|
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 { EXPEDITION_CONST, EXPEDITION_WAR_RECORD_STATUS, LINEUP_NUM, TASK_TYPE } from '../../../consts';
|
||||||
import { WarReward } from '../../../services/warRewardService';
|
import { WarReward } from '../../../services/warRewardService';
|
||||||
import { addItems } from '../../../services/rewardService';
|
import { addItems } from '../../../services/rewardService';
|
||||||
@@ -32,41 +32,9 @@ export class ExpeditionBattleHandler {
|
|||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let roleName = session.get('roleName');
|
let roleName = session.get('roleName');
|
||||||
|
|
||||||
// 获取远征关卡状态
|
let res = await getExpeditionStatus(roleId, 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 每一关的挑战状态
|
return resResult(STATUS.SUCCESS, res);
|
||||||
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
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Application, BackendSession } from 'pinus';
|
import { Application, BackendSession, pinus } from 'pinus';
|
||||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||||
import { STATUS, TASK_TYPE } from '../../../consts';
|
import { STATUS, TASK_TYPE } from '../../../consts';
|
||||||
import { BossInstanceModel } from '../../../db/BossInstance';
|
import { BossInstanceModel } from '../../../db/BossInstance';
|
||||||
@@ -14,7 +14,7 @@ import { checkAuth, addActive } from '../../../services/guildService';
|
|||||||
import { GuildModel } from '../../../db/Guild';
|
import { GuildModel } from '../../../db/Guild';
|
||||||
import { getBossByLv } from '../../../pubUtils/data';
|
import { getBossByLv } from '../../../pubUtils/data';
|
||||||
import { lockData } from '../../../services/redLockService';
|
import { lockData } from '../../../services/redLockService';
|
||||||
import { pushGuildBossSucMsg } from '../../../services/chatService';
|
import { pushGuildBossSucMsg, getGuildChannelSid } from '../../../services/chatService';
|
||||||
import { checkTask } from '../../../services/taskService';
|
import { checkTask } from '../../../services/taskService';
|
||||||
|
|
||||||
export default function (app: Application) {
|
export default function (app: Application) {
|
||||||
@@ -99,6 +99,10 @@ export class GuildHandler {
|
|||||||
await BossInstanceModel.openBossInstance(code, bossHp, warId, bossBase.bossLevel);
|
await BossInstanceModel.openBossInstance(code, bossHp, warId, bossBase.bossLevel);
|
||||||
res.releaseCallback();
|
res.releaseCallback();
|
||||||
let result = {warId, ranks: [], myRank: {}, bossHp, status: 3, bossLv: bossBase.bossLevel, isBattled: false};
|
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);
|
return resResult(STATUS.SUCCESS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Application, BackendSession, ChannelService } from 'pinus';
|
|||||||
import { resResult, getRandEelm, shouldRefresh, sortArrRandom } from '../../../pubUtils/util';
|
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 { 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 { 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 { GuildModel, GuildType } from '../../../db/Guild';
|
||||||
import { RoleModel, RoleType } from '../../../db/Role';
|
import { RoleModel, RoleType } from '../../../db/Role';
|
||||||
import { ARMY } from '../../../pubUtils/dicParam';
|
import { ARMY } from '../../../pubUtils/dicParam';
|
||||||
@@ -272,22 +272,7 @@ export class GuildHandler {
|
|||||||
return resResult(STATUS.GUILD_NOT_FOUND);
|
return resResult(STATUS.GUILD_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
let leader = <RoleType>guild.leader;
|
let result = await getMyGuildInfo(roleId, sid, userGuild, guild, serverId, session);
|
||||||
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 }};
|
|
||||||
return resResult(STATUS.SUCCESS, result);
|
return resResult(STATUS.SUCCESS, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { STATUS, TASK_TYPE } from '../../../consts';
|
|||||||
import { GuildTrainModel } from '../../../db/GuildTrain';
|
import { GuildTrainModel } from '../../../db/GuildTrain';
|
||||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||||
import { nowSeconds, getTimeFun, getZeroPoint } from '../../../pubUtils/timeUtil';
|
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 { findIndex, findWhere } from 'underscore'
|
||||||
import { lockData } from '../../../services/redLockService';
|
import { lockData } from '../../../services/redLockService';
|
||||||
import { GUILD_REPORT_NUM, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
|
import { GUILD_REPORT_NUM, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
|
||||||
@@ -37,15 +37,8 @@ export class GuildTrainHandler {
|
|||||||
if (!userGuild)
|
if (!userGuild)
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
const { guildCode: code } = userGuild;
|
const { guildCode: code } = userGuild;
|
||||||
let { trainId, trainLv } = await GuildModel.findGuild(code, serverId, 'trainId trainLv');
|
let guild = await GuildModel.findGuild(code, serverId, 'trainId trainLv');
|
||||||
let guildTrain = await GuildTrainModel.findTrainByTrainIdNotLock(code, trainId);
|
let result = await getGuildTrainInstance(roleId, guild, userGuild);
|
||||||
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;
|
|
||||||
return resResult(STATUS.SUCCESS, result);
|
return resResult(STATUS.SUCCESS, result);
|
||||||
}
|
}
|
||||||
//获得试炼战报
|
//获得试炼战报
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { STATUS } from '../../../consts/statusCode';
|
|||||||
import { resResult } from '../../../pubUtils/util';
|
import { resResult } from '../../../pubUtils/util';
|
||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
import { RScriptRecordModel } from '../../../db/RScriptRecord';
|
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 { checkDungeonNum, checkDungeonAndIncrease } from '../../../services/dungeonService';
|
||||||
import { switchOnFunc } from '../../../services/funcSwitchService';
|
import { switchOnFunc } from '../../../services/funcSwitchService';
|
||||||
import { gameData } from '../../../pubUtils/data';
|
import { gameData } from '../../../pubUtils/data';
|
||||||
@@ -110,40 +110,7 @@ export class NormalBattleHandler {
|
|||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
|
|
||||||
let role = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
let { warStar } = role;
|
let result = await getBattleList(role, type);
|
||||||
|
|
||||||
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 });
|
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, {
|
return resResult(STATUS.SUCCESS, {
|
||||||
list: result
|
list: result
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { RoleModel } from './../../../db/Role';
|
|||||||
import { TowerRecordModel } from './../../../db/TowerRecord';
|
import { TowerRecordModel } from './../../../db/TowerRecord';
|
||||||
import { Application, BackendSession } from 'pinus';
|
import { Application, BackendSession } from 'pinus';
|
||||||
import { resResult, shouldRefresh, calculateNum, genCode } from '../../../pubUtils/util';
|
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 { addItems, handleCost } from '../../../services/rewardService';
|
||||||
import { checkBattleHeroes } from '../../../services/normalBattleService';
|
import { checkBattleHeroes } from '../../../services/normalBattleService';
|
||||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||||
@@ -30,32 +30,9 @@ export class TowerBattleHandler {
|
|||||||
async getStatus(msg: {}, session: BackendSession) {
|
async getStatus(msg: {}, session: BackendSession) {
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let serverId = session.get('serverId');
|
let serverId = session.get('serverId');
|
||||||
let { towerLv } = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
if (!towerLv) {
|
let data = await getTowerStatus(role);
|
||||||
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
|
|
||||||
};
|
|
||||||
return resResult(STATUS.SUCCESS, data);
|
return resResult(STATUS.SUCCESS, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,20 +56,11 @@ export class TowerBattleHandler {
|
|||||||
|
|
||||||
async checkHangUpRewards(msg: {}, session: BackendSession) {
|
async checkHangUpRewards(msg: {}, session: BackendSession) {
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
const result = await calcuHangUpReward(roleId);
|
let result = await getHungupRewards(roleId);
|
||||||
if(result.status == -1) {
|
if(result.status == -1) {
|
||||||
return result.resResult
|
return result.resResult;
|
||||||
}
|
}
|
||||||
let {timeReward, startTime, deltaTime} = result.data;
|
return resResult(STATUS.SUCCESS, 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});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async recHangUpRewards(msg: {}, session: BackendSession) {
|
async recHangUpRewards(msg: {}, session: BackendSession) {
|
||||||
@@ -162,30 +130,11 @@ export class TowerBattleHandler {
|
|||||||
async getTasks(msg: {}, session: BackendSession) {
|
async getTasks(msg: {}, session: BackendSession) {
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
let roleName = session.get('roleName');
|
let roleName = session.get('roleName');
|
||||||
let curTime = new Date();
|
|
||||||
|
|
||||||
let { towerLv, towerTaskRefTime, towerTaskReCnt = 0 } = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
let curTasks = await TowerTaskRecModel.getCurTasks(roleId); // 当前显示中的任务
|
let result = await getTasks(role);
|
||||||
|
|
||||||
const needRefresh = shouldRefresh(towerTaskRefTime, curTime);
|
return resResult(STATUS.SUCCESS, result);
|
||||||
|
|
||||||
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 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async refreshTasks(msg: {}, session: BackendSession) {
|
async refreshTasks(msg: {}, session: BackendSession) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { getArmyWishPoolBaseByLv, getGoodById } from '../../../pubUtils/data';
|
|||||||
import { addItems, checkGoods } from '../../../services/rewardService';
|
import { addItems, checkGoods } from '../../../services/rewardService';
|
||||||
import { IT_TYPE } from '../../../consts/constModules/itemConst';
|
import { IT_TYPE } from '../../../consts/constModules/itemConst';
|
||||||
import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst';
|
import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst';
|
||||||
import { getUserGuildWithRefActive } from '../../../services/guildService';
|
import { getUserGuildWithRefActive, getWishPool } from '../../../services/guildService';
|
||||||
import { findIndex, findWhere } from 'underscore';
|
import { findIndex, findWhere } from 'underscore';
|
||||||
import { RoleModel } from '../../../db/Role';
|
import { RoleModel } from '../../../db/Role';
|
||||||
import { getRoleOnlineInfo } from '../../../services/redisService';
|
import { getRoleOnlineInfo } from '../../../services/redisService';
|
||||||
@@ -27,15 +27,8 @@ export class WishPoolHandler {
|
|||||||
let userGuild = await getUserGuildWithRefActive(roleId, 'wishDntCnt wishGoods guildCode');
|
let userGuild = await getUserGuildWithRefActive(roleId, 'wishDntCnt wishGoods guildCode');
|
||||||
if (!userGuild)
|
if (!userGuild)
|
||||||
return resResult(STATUS.WRONG_PARMS);
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
const { guildCode: code, wishDntCnt, wishGoods } = userGuild;
|
let res = await getWishPool(userGuild);
|
||||||
let userGuilds = await UserGuildModel.getWishPoolGoods(code, ' wishDntCnt wishGoods roleId');
|
return resResult(STATUS.SUCCESS, );
|
||||||
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 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 许愿
|
// 许愿
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { CHANNEL_PREFIX, MSG_SOURCE, CHANNEL_TYPE } from './../../../consts/cons
|
|||||||
import {Application, BackendSession} from 'pinus';
|
import {Application, BackendSession} from 'pinus';
|
||||||
import { resResult } from '../../../pubUtils/util';
|
import { resResult } from '../../../pubUtils/util';
|
||||||
import { DEFAULT_MSG_PER_PAGE, STATUS, TASK_TYPE } from '../../../consts';
|
import { DEFAULT_MSG_PER_PAGE, STATUS, TASK_TYPE } from '../../../consts';
|
||||||
import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos } from '../../../services/chatService';
|
import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs } from '../../../services/chatService';
|
||||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||||
import { checkTaskWithArgs } from '../../../services/taskService';
|
import { checkTaskWithArgs } from '../../../services/taskService';
|
||||||
|
|
||||||
@@ -148,6 +148,21 @@ export class ChatHandler {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取群组聊天记录
|
||||||
|
* @param {{}} msg
|
||||||
|
* @param session
|
||||||
|
*/
|
||||||
|
async getGroupMessages(msg: {}, session: BackendSession) {
|
||||||
|
const serverId: number = session.get('serverId');
|
||||||
|
const guildCode: string = session.get('guildCode');
|
||||||
|
|
||||||
|
const worldMsgs = await recentWorldMsgs(serverId);
|
||||||
|
const sysMsgs = await recentSysMsgs(serverId);
|
||||||
|
const guildMsgs = await recentGuildMsgs(guildCode);
|
||||||
|
|
||||||
|
return resResult(STATUS.SUCCESS, { worldMsgs, sysMsgs, guildMsgs })
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 获取私聊历史消息
|
* @description 获取私聊历史消息
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export class GuildRemote {
|
|||||||
private DEMOTION = 'onDemotion';
|
private DEMOTION = 'onDemotion';
|
||||||
private PROMOTION = 'onPromotion';
|
private PROMOTION = 'onPromotion';
|
||||||
private GUILD_REC_ADD = 'onGuildRecAdd';
|
private GUILD_REC_ADD = 'onGuildRecAdd';
|
||||||
|
private GUILD_BOSS_OPEN = 'onGuildBossOpen';
|
||||||
private GATE_ACT_RANK = 'onGuildGateRankUpdate'; // 军团活动排行榜
|
private GATE_ACT_RANK = 'onGuildGateRankUpdate'; // 军团活动排行榜
|
||||||
private CITY_ACT_RANK = 'onGuildCityRankUpdate'; // 军团活动排行榜
|
private CITY_ACT_RANK = 'onGuildCityRankUpdate'; // 军团活动排行榜
|
||||||
private GUILD_GATE_ACT_HP = 'onGuildGateHpUpdate'; // 军团活动蛮夷入侵排行榜
|
private GUILD_GATE_ACT_HP = 'onGuildGateHpUpdate'; // 军团活动蛮夷入侵排行榜
|
||||||
@@ -271,4 +272,14 @@ export class GuildRemote {
|
|||||||
this.pushMessage(guildCode, this.GUILD_RACE_EVENT, { timestamp: Date.now(), events });
|
this.pushMessage(guildCode, this.GUILD_RACE_EVENT, { timestamp: Date.now(), events });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 当团长开启演武台时
|
||||||
|
* @param guildCode
|
||||||
|
* @param warId
|
||||||
|
* @param bossHp
|
||||||
|
* @param status
|
||||||
|
*/
|
||||||
|
public async pushBossOpen(guildCode: string, warId: number, bossHp: number, status: number) {
|
||||||
|
this.pushMessage(guildCode, this.GUILD_BOSS_OPEN, { guildCode, warId, bossHp, status });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { STATUS } from './../../../consts/statusCode';
|
import { STATUS } from './../../../consts/statusCode';
|
||||||
import { EquipModel } from './../../../db/Equip';
|
import { EquipModel } from './../../../db/Equip';
|
||||||
import { RoleModel } from './../../../db/Role';
|
import { RoleModel, RoleType } from './../../../db/Role';
|
||||||
import { UserModel } from '../../../db/User';
|
import { UserModel } from '../../../db/User';
|
||||||
import { GMUserModel } from '../../../db/GMUser';
|
import { GMUserModel } from '../../../db/GMUser';
|
||||||
import { Application } from 'pinus';
|
import { Application } from 'pinus';
|
||||||
@@ -61,6 +61,53 @@ export class EntryHandler {
|
|||||||
}
|
}
|
||||||
let serverName = this.app.getServerId();
|
let serverName = this.app.getServerId();
|
||||||
await roleLogin(role.roleId, user.userCode, serverName, user.pkgName, role.funcs || []); // 保存在线用户
|
await roleLogin(role.roleId, user.userCode, serverName, user.pkgName, role.funcs || []); // 保存在线用户
|
||||||
|
await this.addSession(role, session);
|
||||||
|
|
||||||
|
let channelService = self.app.get('channelService');
|
||||||
|
let channel = channelService.getChannel(role.roleId, true);
|
||||||
|
if (channel.getMembers().indexOf(role.roleId) === -1) {
|
||||||
|
channel.add(role.roleId, self.app.get('serverId'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// put user into channel
|
||||||
|
// console.log(JSON.stringify(self.app.rpc.battle))
|
||||||
|
// await self.app.rpc.battle.battleRemote.add.route(session)(role.roleId, self.app.get('serverId'), role.serverId, true);
|
||||||
|
addRoleToSysChannel(role.roleId, self.app.get('serverId'), role.serverId);
|
||||||
|
addRoleToWorldChannel(role.roleId, self.app.get('serverId'), role.serverId);
|
||||||
|
await self.app.rpc.chat.chatRemote.addWorldChannel.route(session)(role.roleId, serverId, self.app.get('serverId'));
|
||||||
|
let heros = await HeroModel.findByRole(role.roleId, [], HERO_SELECT.ENTRY, true);
|
||||||
|
let equips = await EquipModel.findbyRole(role.roleId);
|
||||||
|
let items = await ItemModel.findbyRole(role.roleId);
|
||||||
|
await chackFunOpenWhenLogin(role, session);
|
||||||
|
if (role.hasInit) await loginRefresh(role.roleId);
|
||||||
|
reportOneOnline(role.roleId, user.userCode, self.app.get('serverId'), user.pkgName);
|
||||||
|
|
||||||
|
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
|
||||||
|
r.setRankWithRoleInfo(role.roleId, role.heroNum, role.heroNumUpdatedAt, role);
|
||||||
|
let r2 = new Rank(REDIS_KEY.SUM_CE_RANK, { serverId });
|
||||||
|
r2.setRankWithRoleInfo(role.roleId, role.lv, role.updatedAt.getTime(), role);
|
||||||
|
|
||||||
|
// 任务
|
||||||
|
checkTaskWithRole(serverId, role.roleId, self.app.get('serverId'), role.funcs, TASK_TYPE.LOGIN_SUM, role);
|
||||||
|
checkTaskWithRole(serverId, role.roleId, self.app.get('serverId'), role.funcs, TASK_TYPE.LOGIN_SERIES, role);
|
||||||
|
// 推送数据
|
||||||
|
pushData(role, session);
|
||||||
|
|
||||||
|
role['heros'] = heros;
|
||||||
|
role['equips'] = equips;
|
||||||
|
role['consumeGoods'] = items;
|
||||||
|
let apJson = await getAp(Date.now(), role.roleId);
|
||||||
|
role['apJson'] = apJson;
|
||||||
|
if (!role.showLineup) role.showLineup = role.topLineup.map(cur => cur.hid);
|
||||||
|
role.heads = role.heads.filter(cur => cur.status);
|
||||||
|
role.frames = role.frames.filter(cur => cur.status);
|
||||||
|
role.spines = role.spines.filter(cur => cur.status);
|
||||||
|
|
||||||
|
return resResult(STATUS.SUCCESS, { role });
|
||||||
|
}
|
||||||
|
|
||||||
|
async addSession(role: RoleType, session: FrontendSession) {
|
||||||
|
const self = this;
|
||||||
await session.abind(role.roleId);
|
await session.abind(role.roleId);
|
||||||
session.set('uid', role.roleId);
|
session.set('uid', role.roleId);
|
||||||
session.set('roleId', role.roleId);
|
session.set('roleId', role.roleId);
|
||||||
@@ -87,82 +134,6 @@ export class EntryHandler {
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
session.on('closed', this.onUserLeave.bind(this));
|
session.on('closed', this.onUserLeave.bind(this));
|
||||||
|
|
||||||
let channelService = self.app.get('channelService');
|
|
||||||
let channel = channelService.getChannel(role.roleId, true);
|
|
||||||
if (channel.getMembers().indexOf(role.roleId) === -1) {
|
|
||||||
channel.add(role.roleId, self.app.get('serverId'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// put user into channel
|
|
||||||
// console.log(JSON.stringify(self.app.rpc.battle))
|
|
||||||
// await self.app.rpc.battle.battleRemote.add.route(session)(role.roleId, self.app.get('serverId'), role.serverId, true);
|
|
||||||
addRoleToSysChannel(role.roleId, self.app.get('serverId'), role.serverId);
|
|
||||||
addRoleToWorldChannel(role.roleId, self.app.get('serverId'), role.serverId);
|
|
||||||
await self.app.rpc.chat.chatRemote.addWorldChannel.route(session)(role.roleId, serverId, self.app.get('serverId'));
|
|
||||||
let heros = await HeroModel.findByRole(role.roleId, [], HERO_SELECT.ENTRY, true);
|
|
||||||
let equips = await EquipModel.findbyRole(role.roleId);
|
|
||||||
let items = await ItemModel.findbyRole(role.roleId);
|
|
||||||
let mails = await getMails(role.roleId, serverId)
|
|
||||||
await chackFunOpenWhenLogin(role, session);
|
|
||||||
if (role.hasInit) await loginRefresh(role.roleId);
|
|
||||||
reportOneOnline(role.roleId, user.userCode, self.app.get('serverId'), user.pkgName);
|
|
||||||
|
|
||||||
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
|
|
||||||
r.setRankWithRoleInfo(role.roleId, role.heroNum, role.heroNumUpdatedAt, role);
|
|
||||||
let r2 = new Rank(REDIS_KEY.SUM_CE_RANK, { serverId });
|
|
||||||
r2.setRankWithRoleInfo(role.roleId, role.lv, role.updatedAt.getTime(), role);
|
|
||||||
|
|
||||||
// 任务
|
|
||||||
checkTaskWithRole(serverId, role.roleId, self.app.get('serverId'), role.funcs, TASK_TYPE.LOGIN_SUM, role);
|
|
||||||
checkTaskWithRole(serverId, role.roleId, self.app.get('serverId'), role.funcs, TASK_TYPE.LOGIN_SERIES, role);
|
|
||||||
// 推送数据
|
|
||||||
pushData(role, session);
|
|
||||||
|
|
||||||
role['heros'] = heros;
|
|
||||||
role['equips'] = equips;
|
|
||||||
role['consumeGoods'] = items;
|
|
||||||
let apJson = await getAp(Date.now(), role.roleId);
|
|
||||||
role['apJson'] = apJson;
|
|
||||||
role['mails'] = mails;
|
|
||||||
if (!role.showLineup) role.showLineup = role.topLineup.map(cur => cur.hid);
|
|
||||||
role.heads = role.heads.filter(cur => cur.status);
|
|
||||||
role.frames = role.frames.filter(cur => cur.status);
|
|
||||||
role.spines = role.spines.filter(cur => cur.status);
|
|
||||||
|
|
||||||
const recentPrivateChats = await recentPrivateChatInfos(role.roleId, role.roleName);
|
|
||||||
if (recentPrivateChats) {
|
|
||||||
role['recentPrivateChats'] = recentPrivateChats;
|
|
||||||
}
|
|
||||||
role['worldMsgs'] = await recentWorldMsgs(role.serverId);
|
|
||||||
role['sysMsgs'] = await recentSysMsgs(role.serverId);
|
|
||||||
|
|
||||||
if (role.hasGuild) {
|
|
||||||
let userGuild = await UserGuildModel.getMyGuild(role.roleId, USER_GUILD_SELECT.ENTRY);
|
|
||||||
if (userGuild) {
|
|
||||||
let guild = await GuildModel.findGuild(userGuild.guildCode, role.serverId, GUILD_SELECT.ENTRY);
|
|
||||||
if (guild) {
|
|
||||||
addRoleToGuildChannel(role.roleId, self.app.get('serverId'), userGuild.guildCode);
|
|
||||||
role['guildMsgs'] = await recentGuildMsgs(userGuild.guildCode);
|
|
||||||
role['guildAuth'] = userGuild.auth;
|
|
||||||
role['guildCode'] = userGuild.guildCode;
|
|
||||||
let { lv: guildLv, memberCnt } = guild;
|
|
||||||
let dicGuild = gameData.centerBase.get(guildLv);
|
|
||||||
if (dicGuild && memberCnt >= dicGuild.peopleNum) {
|
|
||||||
role['guildMemberMax'] = true;
|
|
||||||
} else {
|
|
||||||
role['guildMemberMax'] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 任务
|
|
||||||
let { mainTask, dailyTask, achievement } = await getCurTask(role.roleId, session);
|
|
||||||
role['mainTask'] = mainTask;
|
|
||||||
role['dailyTask'] = dailyTask;
|
|
||||||
role['achievement'] = achievement;
|
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { role });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,12 +3,10 @@ import { MailModel } from '../../../db/Mail';
|
|||||||
import { GroupMailModel } from '../../../db/GroupMail';
|
import { GroupMailModel } from '../../../db/GroupMail';
|
||||||
import { resResult } from '../../../pubUtils/util';
|
import { resResult } from '../../../pubUtils/util';
|
||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
import { findWhere } from 'underscore';
|
|
||||||
import { MAIL_STATUS, MAIL_TEM_TYPE, MAIL_TYPE } from '../../../consts/constModules/mailConst';
|
import { MAIL_STATUS, MAIL_TEM_TYPE, MAIL_TYPE } from '../../../consts/constModules/mailConst';
|
||||||
import { handleCost, addItems } from '../../../services/rewardService';
|
import { addItems } from '../../../services/rewardService';
|
||||||
import { mongoose } from '@typegoose/typegoose';
|
|
||||||
const { ObjectId } = mongoose.Types;
|
|
||||||
import { nowSeconds } from '../../../pubUtils/timeUtil';
|
import { nowSeconds } from '../../../pubUtils/timeUtil';
|
||||||
|
import { getMails } from '../../../services/mailService';
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
return new MailHandler(app);
|
return new MailHandler(app);
|
||||||
}
|
}
|
||||||
@@ -18,6 +16,14 @@ export class MailHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getMails(msg:{}, session: BackendSession) {
|
||||||
|
const roleId: string = session.get('roleId');
|
||||||
|
const serverId: number = session.get('serverId');
|
||||||
|
|
||||||
|
const list = await getMails(roleId, serverId);
|
||||||
|
return resResult(STATUS.SUCCESS, { list });
|
||||||
|
}
|
||||||
|
|
||||||
public async refrshMails(msg:{}) {
|
public async refrshMails(msg:{}) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import { Application, BackendSession } from "pinus";
|
import { Application, BackendSession } from "pinus";
|
||||||
import { resResult } from "../../../pubUtils/util";
|
import { resResult } from "../../../pubUtils/util";
|
||||||
import { STATUS, REDIS_KEY, RANK_TYPE_TO_KEY, ROLE_SELECT, RANK_TYPE, HERO_SELECT, GUILD_SELECT } from "../../../consts";
|
import { STATUS, RANK_TYPE_TO_KEY, ROLE_SELECT, RANK_TYPE, HERO_SELECT, GUILD_SELECT } from "../../../consts";
|
||||||
import { RoleModel } from "../../../db/Role";
|
import { RoleModel } from "../../../db/Role";
|
||||||
import { UserGuildModel } from "../../../db/UserGuild";
|
import { UserGuildModel } from "../../../db/UserGuild";
|
||||||
import { GuildModel } from "../../../db/Guild";
|
import { GuildModel } from "../../../db/Guild";
|
||||||
import { UserModel } from "../../../db/User";
|
import { Rank, getGeneralRank } from "../../../services/rankService";
|
||||||
import { Rank } from "../../../services/rankService";
|
|
||||||
import { nowSeconds } from "../../../pubUtils/timeUtil";
|
import { nowSeconds } from "../../../pubUtils/timeUtil";
|
||||||
import { GeneralRankParamRole, GeneralRankParamBattle, RoleRankInfo } from "../../../domain/rank";
|
|
||||||
import { gameData } from "../../../pubUtils/data";
|
import { gameData } from "../../../pubUtils/data";
|
||||||
import { addItems } from "../../../services/rewardService";
|
import { addItems } from "../../../services/rewardService";
|
||||||
import { HeroModel, HeroUpdate } from "../../../db/Hero";
|
import { HeroModel, HeroUpdate } from "../../../db/Hero";
|
||||||
@@ -29,39 +27,7 @@ export class RoleHandler {
|
|||||||
let role = await RoleModel.findByRoleId(roleId, 'rankReceived');
|
let role = await RoleModel.findByRoleId(roleId, 'rankReceived');
|
||||||
if(!role) return resResult(STATUS.WRONG_PARMS);
|
if(!role) return resResult(STATUS.WRONG_PARMS);
|
||||||
|
|
||||||
let { rankReceived = []} = role;
|
let res = await getGeneralRank(role, serverId);
|
||||||
|
|
||||||
let res = {
|
|
||||||
role: new Array<GeneralRankParamRole>(),
|
|
||||||
battle: new Array<GeneralRankParamBattle>()
|
|
||||||
};
|
|
||||||
|
|
||||||
for(let { id, general } of gameData.rank) {
|
|
||||||
let redisKey = RANK_TYPE_TO_KEY.get(id);
|
|
||||||
if(redisKey) {
|
|
||||||
let received = rankReceived.filter(rewardId => {
|
|
||||||
let dic = gameData.generalRankReward.get(rewardId);
|
|
||||||
return dic && dic.rankId == id;
|
|
||||||
});
|
|
||||||
if(general == 1) {
|
|
||||||
let r = new Rank(redisKey, { serverId }, false, 1);
|
|
||||||
let ranks = <RoleRankInfo[]> await r.getRankByRange();
|
|
||||||
if(ranks.length > 0) {
|
|
||||||
let param = new GeneralRankParamRole(id, ranks[0]||new RoleRankInfo({}, false), received);
|
|
||||||
res.role.push(param);
|
|
||||||
}
|
|
||||||
} else if (general = 2) {
|
|
||||||
let r = new Rank(redisKey, { serverId }, false, 1);
|
|
||||||
let ranks = <RoleRankInfo[]> await r.getRankByRange();
|
|
||||||
let hero: HeroUpdate;
|
|
||||||
if(ranks.length > 0) {
|
|
||||||
hero = await HeroModel.getMyTopHero(ranks[0].roleId, 'hid skins');
|
|
||||||
let param = new GeneralRankParamBattle(id, ranks[0]||new RoleRankInfo({}, false), hero, received);
|
|
||||||
res.battle.push(param);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, res);
|
return resResult(STATUS.SUCCESS, res);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { getAtrrNameById } from '../../../consts/constModules/abilityConst'
|
|||||||
import { findIndex } from 'underscore';
|
import { findIndex } from 'underscore';
|
||||||
import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
|
import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
|
||||||
import { SchoolModel } from '../../../db/School';
|
import { SchoolModel } from '../../../db/School';
|
||||||
import { checkTeraphMaterialEnough } from '../../../services/roleService'
|
import { checkTeraphMaterialEnough, getSchoolList } from '../../../services/roleService'
|
||||||
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
|
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
|
||||||
import { HERO_SYSTEM_TYPE, LINEUP_NUM, ROLE_SELECT, REDIS_KEY, TASK_TYPE, DEFAULT_HEROES, DEFAULT_HERO_LV, DEFAULT_ITEMS, DEFAULT_EQUIPS, DEFAULT_GOLD, DEFAULT_COIN } from '../../../consts';
|
import { HERO_SYSTEM_TYPE, LINEUP_NUM, ROLE_SELECT, REDIS_KEY, TASK_TYPE, DEFAULT_HEROES, DEFAULT_HERO_LV, DEFAULT_ITEMS, DEFAULT_EQUIPS, DEFAULT_GOLD, DEFAULT_COIN } from '../../../consts';
|
||||||
import { checkBattleHeroesByHid } from '../../../services/normalBattleService';
|
import { checkBattleHeroesByHid } from '../../../services/normalBattleService';
|
||||||
@@ -189,38 +189,7 @@ export class RoleHandler {
|
|||||||
// 获得百家学宫
|
// 获得百家学宫
|
||||||
async getSchoolList(msg: {}, session: BackendSession) {
|
async getSchoolList(msg: {}, session: BackendSession) {
|
||||||
let roleId = session.get('roleId');
|
let roleId = session.get('roleId');
|
||||||
|
let school = await getSchoolList(roleId);
|
||||||
const dicPosition = decodeIdCntArrayStr(SCHOOL.SCHOOL_POSITION, 1); // id=>isOpen
|
|
||||||
|
|
||||||
const userSchoolList = await SchoolModel.findByRoleId(roleId);
|
|
||||||
|
|
||||||
let school = new Array<SclResultInter>();
|
|
||||||
gameData.school.forEach((dicSchool) => {
|
|
||||||
let position = new Array<SclPosInter>();
|
|
||||||
dicPosition.forEach((isOpen, dicId) => {
|
|
||||||
let id = parseInt(dicId);
|
|
||||||
|
|
||||||
let userSchool = userSchoolList.find(cur => cur.schoolId == dicSchool.id && cur.positionId == id);
|
|
||||||
if (userSchool) {
|
|
||||||
position.push({
|
|
||||||
id,
|
|
||||||
hid: userSchool.hid,
|
|
||||||
isOpen: userSchool.isOpen
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
position.push({
|
|
||||||
id,
|
|
||||||
hid: 0,
|
|
||||||
isOpen: !!isOpen
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
school.push({
|
|
||||||
id: dicSchool.id,
|
|
||||||
position
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { school });
|
return resResult(STATUS.SUCCESS, { school });
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,13 @@ import { gameData } from "../../../pubUtils/data";
|
|||||||
import { resResult } from "../../../pubUtils/util";
|
import { resResult } from "../../../pubUtils/util";
|
||||||
import { STATUS, GUILD_STRUCTURE, ITID, CONSUME_TYPE, HERO_QUALITY_TYPE, HERO_GROW_MAX } from "../../../consts";
|
import { STATUS, GUILD_STRUCTURE, ITID, CONSUME_TYPE, HERO_QUALITY_TYPE, HERO_GROW_MAX } from "../../../consts";
|
||||||
import { DicShopListModel } from "../../../db/DicShopList";
|
import { DicShopListModel } from "../../../db/DicShopList";
|
||||||
import { ShopItem } from "../../../domain/dbGeneral";
|
|
||||||
import { ShopItemListParam } from '../../../domain/roleField/shop';
|
|
||||||
import { UserShopModel } from "../../../db/UserShop";
|
import { UserShopModel } from "../../../db/UserShop";
|
||||||
import { handleCost, addItems } from "../../../services/rewardService";
|
import { handleCost, addItems } from "../../../services/rewardService";
|
||||||
import { GuildModel } from "../../../db/Guild";
|
import { GuildModel } from "../../../db/Guild";
|
||||||
import { SHOP } from "../../../pubUtils/dicParam";
|
import { SHOP } from "../../../pubUtils/dicParam";
|
||||||
import { getHonourObject } from "../../../pubUtils/itemUtils";
|
import { getHonourObject } from "../../../pubUtils/itemUtils";
|
||||||
import { HeroModel } from "../../../db/Hero";
|
import { HeroModel } from "../../../db/Hero";
|
||||||
|
import { getShopListById } from "../../../services/shopService";
|
||||||
|
|
||||||
export default function(app: Application) {
|
export default function(app: Application) {
|
||||||
return new ShopHandler(app);
|
return new ShopHandler(app);
|
||||||
@@ -29,46 +28,7 @@ export class ShopHandler {
|
|||||||
return resResult(STATUS.WRONG_PARMS);
|
return resResult(STATUS.WRONG_PARMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
let shopItemList = new Array<ShopItemListParam>(); // 返回
|
const shopItemList = await getShopListById(shopId, roleId);
|
||||||
let dbDicShop = await DicShopListModel.findByShopId(shopId);
|
|
||||||
let userShopRecs = await UserShopModel.findMapByShopId(roleId, shopId);
|
|
||||||
// console.log(JSON.stringify([...userShopRecs]))
|
|
||||||
|
|
||||||
|
|
||||||
if(!dbDicShop || dbDicShop.useJson) { // 完全使用json中配置的商品,数据库只做排序用,数据库内没有的排到最后
|
|
||||||
let items = dbDicShop?.items||[];
|
|
||||||
let map = new Map<number, ShopItem>();
|
|
||||||
for(let item of items) {
|
|
||||||
map.set(item.id, item);
|
|
||||||
}
|
|
||||||
let dicShop = gameData.shop.get(shopId)||[];
|
|
||||||
for(let { id, type } of dicShop) {
|
|
||||||
let buyCount = userShopRecs.has(id)?userShopRecs.get(id).count: 0;
|
|
||||||
if(map.has(id)) {
|
|
||||||
let item = map.get(id);
|
|
||||||
let param = new ShopItemListParam(id, item.discount, type, buyCount, item.order);
|
|
||||||
shopItemList.push(param);
|
|
||||||
} else {
|
|
||||||
let param = new ShopItemListParam(id, 1, type, buyCount, 0);
|
|
||||||
shopItemList.push(param);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else { // 只返回数据库内的商品
|
|
||||||
let items = dbDicShop?.items||[];
|
|
||||||
for(let item of items) {
|
|
||||||
let { id, order, discount } = item;
|
|
||||||
let buyCount = userShopRecs.has(id)?userShopRecs.get(id).count: 0;
|
|
||||||
let dicShop = gameData.shopItem.get(id);
|
|
||||||
if(dicShop) {
|
|
||||||
let param = new ShopItemListParam(id, discount, dicShop.type, buyCount, order);
|
|
||||||
shopItemList.push(param);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
shopItemList = shopItemList.sort((a, b) => b.order - a.order);
|
|
||||||
|
|
||||||
return resResult(STATUS.SUCCESS, { shopItemList });
|
return resResult(STATUS.SUCCESS, { shopItemList });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,13 @@ export class ShopHandler {
|
|||||||
constructor(private app: Application) {
|
constructor(private app: Application) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async getTaskList(msg:{}, session: BackendSession) {
|
||||||
|
const roleId: string = session.get('roleId');
|
||||||
|
|
||||||
|
const res = await getCurTask(roleId, session);
|
||||||
|
return resResult(STATUS.SUCCESS, res);
|
||||||
|
}
|
||||||
|
|
||||||
// 领取主线任务、每日任务、成就单条任务
|
// 领取主线任务、每日任务、成就单条任务
|
||||||
async receiveTask(msg: { type: number, id: number }, session: BackendSession) {
|
async receiveTask(msg: { type: number, id: number }, session: BackendSession) {
|
||||||
const roleId: string = session.get('roleId');
|
const roleId: string = session.get('roleId');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { MailModel, MailType } from './../db/Mail';
|
import { MailModel, MailType } from './../db/Mail';
|
||||||
import { DividendModel } from './../db/Dividend';
|
import { DividendModel } from './../db/Dividend';
|
||||||
import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME, DIVIDEND_CODE_LEN, DIVIDEND_STATUS, LOT_STATUS, MAIL_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, STATUS, DIVIDENDWEEKENDRATE, DIVIDENDMAXRATIO, DIVIDENDPOSITIONMAXRATIO, ROLE_RECEIVE_STATUS, AUCTION_BID_STATUS } from './../consts';
|
import { LOT_CODE_LEN, AUCTION_STAGE, AUCTION_TIME, DIVIDEND_CODE_LEN, DIVIDEND_STATUS, LOT_STATUS, MAIL_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, STATUS, DIVIDENDWEEKENDRATE, DIVIDENDMAXRATIO, DIVIDENDPOSITIONMAXRATIO, ROLE_RECEIVE_STATUS, AUCTION_BID_STATUS, DEBUG_MAGIC_WORD } from './../consts';
|
||||||
import { DividendRec, ItemReward } from "../domain/dbGeneral";
|
import { DividendRec, ItemReward } from "../domain/dbGeneral";
|
||||||
import { genCode, resResult } from '../pubUtils/util';
|
import { genCode, resResult } from '../pubUtils/util';
|
||||||
import { LotModel, LotParam } from '../db/Lot';
|
import { LotModel, LotParam } from '../db/Lot';
|
||||||
@@ -9,7 +9,7 @@ import { gameData, getGoodById } from '../pubUtils/data';
|
|||||||
import { DividendParam, DividendType } from '../db/Dividend';
|
import { DividendParam, DividendType } from '../db/Dividend';
|
||||||
import { pushMail } from '../pubUtils/interface';
|
import { pushMail } from '../pubUtils/interface';
|
||||||
import { getMailContent } from './mailService';
|
import { getMailContent } from './mailService';
|
||||||
import { pinus, BackendSession } from 'pinus';
|
import { pinus, BackendSession, FrontendOrBackendSession } from 'pinus';
|
||||||
import { participants } from './guildActivityService';
|
import { participants } from './guildActivityService';
|
||||||
import { Member } from '../domain/battleField/guildActivity';
|
import { Member } from '../domain/battleField/guildActivity';
|
||||||
|
|
||||||
@@ -33,13 +33,13 @@ export function auctionStage() {
|
|||||||
if (curTime > todayWorldEnd().getTime()) return AUCTION_STAGE.END;
|
if (curTime > todayWorldEnd().getTime()) return AUCTION_STAGE.END;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function debugAuctionLots(session: BackendSession, begin: Date) {
|
export async function debugAuctionLots(session: FrontendOrBackendSession, begin: Date) {
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
const lots = await LotModel.findWorldLotsByBegin(serverId, begin);
|
const lots = await LotModel.findWorldLotsByBegin(serverId, begin);
|
||||||
return lots;
|
return lots;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function officialAuctionLots(session: BackendSession, begin: Date) {
|
export async function officialAuctionLots(session: FrontendOrBackendSession, begin: Date) {
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
const guildCode = session.get('guildCode');
|
const guildCode = session.get('guildCode');
|
||||||
const stage = auctionStage();
|
const stage = auctionStage();
|
||||||
@@ -278,3 +278,17 @@ export async function sendUngotDividend(debug = false) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取拍卖行数据
|
||||||
|
* @param guildCode
|
||||||
|
* @param session
|
||||||
|
* @param magicWord
|
||||||
|
*/
|
||||||
|
export async function getAuction(guildCode: string, session: FrontendOrBackendSession, magicWord?: string) {
|
||||||
|
const begin = todayGuildBegin();
|
||||||
|
let lots = magicWord === DEBUG_MAGIC_WORD ? await debugAuctionLots(session, begin) : await officialAuctionLots(session, begin);
|
||||||
|
|
||||||
|
const dividends = await DividendModel.findGuildDividendsByBegin(guildCode, begin);
|
||||||
|
return { lots, dividends };
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import { HeroModel } from './../db/Hero';
|
import { HeroModel } from './../db/Hero';
|
||||||
import { HangUpRecordModel } from './../db/HangUpRecord';
|
import { HangUpRecordModel } from './../db/HangUpRecord';
|
||||||
import { pinus } from 'pinus';
|
import { pinus } from 'pinus';
|
||||||
import { HANG_UP_CONSTS, TOWER_TASK_CONST, REDIS_KEY, TASK_TYPE, TIME_OUTPUT_TYPE } from './../consts';
|
import { HANG_UP_CONSTS, TOWER_TASK_CONST, REDIS_KEY, TASK_TYPE, TIME_OUTPUT_TYPE, GOLD_COST_RATIO } from './../consts';
|
||||||
import { BattleRecordModel } from './../db/BattleRecord';
|
import { BattleRecordModel } from './../db/BattleRecord';
|
||||||
import { TowerRecordModel } from './../db/TowerRecord';
|
import { TowerRecordModel } from './../db/TowerRecord';
|
||||||
import { RoleModel } from './../db/Role';
|
import { RoleModel, RoleType } from './../db/Role';
|
||||||
import { shouldRefresh, resResult, cal, getRandEelmWithWeight } from '../pubUtils/util';
|
import { shouldRefresh, resResult, cal, getRandEelmWithWeight, calculateNum, genCode } from '../pubUtils/util';
|
||||||
import { STATUS } from '../consts/statusCode';
|
import { STATUS } from '../consts/statusCode';
|
||||||
import { HangUpSpdUpRecModel } from '../db/HangUpSpdUpRec';
|
import { HangUpSpdUpRecModel } from '../db/HangUpSpdUpRec';
|
||||||
import { TowerTaskRecModel } from '../db/TowerTaskRec';
|
import { TowerTaskRecModel } from '../db/TowerTaskRec';
|
||||||
@@ -16,6 +16,96 @@ import { getRandExpedition, gameData } from '../pubUtils/data';
|
|||||||
import { ItemInter, RewardInter } from '../pubUtils/interface';
|
import { ItemInter, RewardInter } from '../pubUtils/interface';
|
||||||
import { getTimeFunM } from '../pubUtils/timeUtil';
|
import { getTimeFunM } from '../pubUtils/timeUtil';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前镇念塔状态
|
||||||
|
* @param role
|
||||||
|
*/
|
||||||
|
export async function getTowerStatus(role: RoleType) {
|
||||||
|
let { towerLv, roleId, serverId } = role;
|
||||||
|
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: '天梯记录异常' };
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
canHungUp: towerLv >= HANG_UP_CONSTS.ENABLE_LV,
|
||||||
|
hungUpEnableLv: HANG_UP_CONSTS.ENABLE_LV,
|
||||||
|
canSendTask: true,
|
||||||
|
curLv: towerLv,
|
||||||
|
usedHeroes: towerRec.heroes,
|
||||||
|
progress: towerRec.warStatus
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取镇念塔挂机收益
|
||||||
|
* @param roleId
|
||||||
|
*/
|
||||||
|
export async function getHungupRewards(roleId: string) {
|
||||||
|
const result = await calcuHangUpReward(roleId);
|
||||||
|
if(result.status == -1) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
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 {
|
||||||
|
status: 0,
|
||||||
|
resResult: null,
|
||||||
|
data: {
|
||||||
|
startTime, hangUpPassTime: Math.floor(deltaTime/1000), hangUpSpdUpCnt, nextCostGold, rewards: timeReward
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取派遣任务列表
|
||||||
|
* @param role
|
||||||
|
*/
|
||||||
|
export async function getTasks(role: RoleType) {
|
||||||
|
let { roleId, roleName, towerLv, towerTaskRefTime, towerTaskReCnt = 0 } = role;
|
||||||
|
let curTime = new Date();
|
||||||
|
let curTasks = await TowerTaskRecModel.getCurTasks(roleId); // 当前显示中的任务
|
||||||
|
|
||||||
|
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 {curTasks: treatTask(curTasks, curTime), refRemainTime, nextCostGold}
|
||||||
|
}
|
||||||
|
|
||||||
export async function checkTowerWar(roleId: string, battleId: number, heroes: Array<number>) {
|
export async function checkTowerWar(roleId: string, battleId: number, heroes: Array<number>) {
|
||||||
let { towerLv } = await RoleModel.findByRoleId(roleId);
|
let { towerLv } = await RoleModel.findByRoleId(roleId);
|
||||||
const towerInfo = gameData.tower.get(towerLv);
|
const towerInfo = gameData.tower.get(towerLv);
|
||||||
|
|||||||
@@ -223,6 +223,7 @@ export async function recentSysMsgs(serverId: number, count?: number) {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export async function recentGuildMsgs(guildCode: string, count?: number) {
|
export async function recentGuildMsgs(guildCode: string, count?: number) {
|
||||||
|
if(!guildCode) return [];
|
||||||
const result = await recentGroupMsgs(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), count);
|
const result = await recentGroupMsgs(groupRoomId(CHANNEL_PREFIX.GUILD, guildCode), count);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,6 +170,15 @@ export async function getRealReward(blueprtId: number, roleSt: RoleStatus) {
|
|||||||
return fixReward;
|
return fixReward;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getAllAssistCnt(roleId: string) {
|
||||||
|
let cntMap = await getAssistTimesByQuality(roleId);
|
||||||
|
let cnt = [];
|
||||||
|
for (let i = 0; i < COM_BTL_QUALITY.length; ++i) {
|
||||||
|
cnt[i] = cntMap.get(i + 1) || 0;
|
||||||
|
}
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
|
|
||||||
export async function getAssistTimesByQuality(roleId: string, qualityArr?: number[]) {
|
export async function getAssistTimesByQuality(roleId: string, qualityArr?: number[]) {
|
||||||
let teams = await ComBattleTeamModel.getAssistTeamsByTime(roleId, qualityArr, getZeroPointD(), true);
|
let teams = await ComBattleTeamModel.getAssistTeamsByTime(roleId, qualityArr, getZeroPointD(), true);
|
||||||
let cntMap = new Map<number, number>();
|
let cntMap = new Map<number, number>();
|
||||||
|
|||||||
@@ -9,26 +9,26 @@ import { RoleType } from '../db/Role';
|
|||||||
import { FrontendOrBackendSession, pinus } from 'pinus';
|
import { FrontendOrBackendSession, pinus } from 'pinus';
|
||||||
import { resResult } from '../pubUtils/util';
|
import { resResult } from '../pubUtils/util';
|
||||||
import { STATUS, USER_GUILD_SELECT, GUILD_SELECT } from '../consts';
|
import { STATUS, USER_GUILD_SELECT, GUILD_SELECT } from '../consts';
|
||||||
// import { getAllShopList } from './shopService';
|
import { getAllShopList } from './shopService';
|
||||||
// import { getGeneralRank } from './rankService';
|
import { getGeneralRank } from './rankService';
|
||||||
import { getFriendList, getApplyList } from './friendService';
|
import { getFriendList, getApplyList } from './friendService';
|
||||||
// import { getDailyBattleList } from './dailyBattleService';
|
import { getDailyBattleList } from './dailyBattleService';
|
||||||
// import { getExpeditionStatus } from './expeditionService';
|
import { getExpeditionStatus } from './expeditionService';
|
||||||
// import { getTowerStatus, getHungupRewards, getTasks } from './battleService';
|
import { getTowerStatus, getHungupRewards, getTasks } from './battleService';
|
||||||
// import { getAllAssistCnt } from './comBattleService';
|
import { getAllAssistCnt } from './comBattleService';
|
||||||
// import { getDungeonData } from './dungeonService';
|
import { getDungeonData } from './dungeonService';
|
||||||
// import { PvpSeasonResultModel } from '../db/PvpSeasonResult';
|
import { PvpSeasonResultModel } from '../db/PvpSeasonResult';
|
||||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||||
// import { getGachaList } from './gachaService';
|
import { getGachaList } from './gachaService';
|
||||||
// import { getSchoolList } from './roleService';
|
import { getSchoolList } from './roleService';
|
||||||
// import { addRoleToGuildChannel } from './chatChannelService';
|
import { addRoleToGuildChannel } from './chatChannelService';
|
||||||
// import { getMyGuildInfo, getGuildWithRefActive, getUserGuildWithRefActive, getWishPool } from './guildService';
|
import { getMyGuildInfo, getGuildWithRefActive, getUserGuildWithRefActive, getWishPool } from './guildService';
|
||||||
// import { getAuction } from './auctionService';
|
import { getAuction } from './auctionService';
|
||||||
// import { getGuildTrainInstance } from './guildTrainService';
|
import { getGuildTrainInstance } from './guildTrainService';
|
||||||
// import { BossInstanceModel } from '../db/BossInstance';
|
import { BossInstanceModel } from '../db/BossInstance';
|
||||||
// import { getBossInstanceInfo } from './guildBossService';
|
import { getBossInstanceInfo } from './guildBossService';
|
||||||
// import { getEvent } from './eventSercive';
|
import { getEvent } from './eventSercive';
|
||||||
// import { getBattleListOfMain } from './normalBattleService';
|
import { getBattleListOfMain } from './normalBattleService';
|
||||||
|
|
||||||
export async function pushData(role: RoleType, session: FrontendOrBackendSession) {
|
export async function pushData(role: RoleType, session: FrontendOrBackendSession) {
|
||||||
try{
|
try{
|
||||||
@@ -37,78 +37,78 @@ export async function pushData(role: RoleType, session: FrontendOrBackendSession
|
|||||||
|
|
||||||
pushEntryStart(roleId, sid);
|
pushEntryStart(roleId, sid);
|
||||||
|
|
||||||
// // 商店
|
// 商店
|
||||||
// const shop = await getAllShopList(roleId);
|
const shop = await getAllShopList(roleId);
|
||||||
// pushEntryData('shop', roleId, sid, shop);
|
pushEntryData('shop', roleId, sid, shop);
|
||||||
// // 排行榜
|
// 排行榜
|
||||||
// const rank = await getGeneralRank(role, serverId);
|
const rank = await getGeneralRank(role, serverId);
|
||||||
// pushEntryData('rank', roleId, sid, rank);
|
pushEntryData('rank', roleId, sid, rank);
|
||||||
// // 邮件
|
// 邮件
|
||||||
// const mails = await getMails(roleId, serverId);
|
const mails = await getMails(roleId, serverId);
|
||||||
// pushEntryData('mail', roleId, sid, mails);
|
pushEntryData('mail', roleId, sid, mails);
|
||||||
// 好友
|
// 好友
|
||||||
const friendList = await getFriendList(role);
|
const friendList = await getFriendList(role);
|
||||||
const applyList = await getApplyList(roleId);
|
const applyList = await getApplyList(roleId);
|
||||||
pushEntryData('friend', roleId, sid, { friendList, applyList });
|
pushEntryData('friend', roleId, sid, { friendList, applyList });
|
||||||
// // 每日关卡
|
// 每日关卡
|
||||||
// const daily = await getDailyBattleList(role);
|
const daily = await getDailyBattleList(role);
|
||||||
// pushEntryData('daily', roleId, sid, daily);
|
pushEntryData('daily', roleId, sid, daily);
|
||||||
// // 远征
|
// 远征
|
||||||
// const expedition = await getExpeditionStatus(roleId, roleName);
|
const expedition = await getExpeditionStatus(roleId, roleName);
|
||||||
// pushEntryData('expedition', roleId, sid, expedition);
|
pushEntryData('expedition', roleId, sid, expedition);
|
||||||
// // 镇念塔
|
// 镇念塔
|
||||||
// const tower = await getTowerEntryData(role);
|
const tower = await getTowerEntryData(role);
|
||||||
// pushEntryData('tower', roleId, sid, tower);
|
pushEntryData('tower', roleId, sid, tower);
|
||||||
// // 寻宝
|
// 寻宝
|
||||||
// const assistCnt = await getAllAssistCnt(roleId);
|
const assistCnt = await getAllAssistCnt(roleId);
|
||||||
// pushEntryData('comBattle', roleId, sid, { assistCnt })
|
pushEntryData('comBattle', roleId, sid, { assistCnt })
|
||||||
// // 秘境
|
// 秘境
|
||||||
// const dungeon = await getDungeonData(role);
|
const dungeon = await getDungeonData(role);
|
||||||
// pushEntryData('dungeon', roleId, sid, dungeon);
|
pushEntryData('dungeon', roleId, sid, dungeon);
|
||||||
// // PVP
|
// PVP
|
||||||
// const hasSeasonReward = await getPvpEntryData(roleId);
|
const hasSeasonReward = await getPvpEntryData(roleId);
|
||||||
// pushEntryData('pvp', roleId, sid, { hasSeasonReward });
|
pushEntryData('pvp', roleId, sid, { hasSeasonReward });
|
||||||
// // 招募
|
// 招募
|
||||||
// const gacha = await getGachaList(roleId);
|
const gacha = await getGachaList(roleId);
|
||||||
// pushEntryData('gacha', roleId, sid, gacha);
|
pushEntryData('gacha', roleId, sid, gacha);
|
||||||
// // 百家学宫
|
// 百家学宫
|
||||||
// const school = await getSchoolList(roleId);
|
const school = await getSchoolList(roleId);
|
||||||
// pushEntryData('school', roleId, sid, school);
|
pushEntryData('school', roleId, sid, school);
|
||||||
// // 军团
|
// 军团
|
||||||
// const { hasGuild, guild, userGuild, guildResult } = await getGuildEntryData(role, sid, session);
|
const { hasGuild, guild, userGuild, guildResult } = await getGuildEntryData(role, sid, session);
|
||||||
// if(hasGuild) {
|
if(hasGuild) {
|
||||||
// pushEntryData('guild', roleId, sid, guildResult);
|
pushEntryData('guild', roleId, sid, guildResult);
|
||||||
// // 拍卖
|
// 拍卖
|
||||||
// const auction = await getAuction(guildCode, session);
|
const auction = await getAuction(guildCode, session);
|
||||||
// pushEntryData('auction', roleId, sid, auction);
|
pushEntryData('auction', roleId, sid, auction);
|
||||||
// // 练兵场
|
// 练兵场
|
||||||
// const train = await getGuildTrainInstance(roleId, guild, userGuild);
|
const train = await getGuildTrainInstance(roleId, guild, userGuild);
|
||||||
// pushEntryData('train', roleId, sid, train);
|
pushEntryData('train', roleId, sid, train);
|
||||||
// // 演武台boss
|
// 演武台boss
|
||||||
// const bossInstance = await BossInstanceModel.findBossInstance(guild.code);
|
const bossInstance = await BossInstanceModel.findBossInstance(guild.code);
|
||||||
// if(bossInstance) {
|
if(bossInstance) {
|
||||||
// const boss = await getBossInstanceInfo(bossInstance, roleId);
|
const boss = await getBossInstanceInfo(bossInstance, roleId);
|
||||||
// pushEntryData('boss', roleId, sid, boss);
|
pushEntryData('boss', roleId, sid, boss);
|
||||||
// }
|
}
|
||||||
// // 许愿池
|
// 许愿池
|
||||||
// const wishPool = await getWishPool(userGuild);
|
const wishPool = await getWishPool(userGuild);
|
||||||
// pushEntryData('wishPool', roleId, sid, wishPool);
|
pushEntryData('wishPool', roleId, sid, wishPool);
|
||||||
// }
|
}
|
||||||
// // 任务
|
// 任务
|
||||||
// const { mainTask, dailyTask, achievement } = await getCurTask(role.roleId, session);
|
const { mainTask, dailyTask, achievement } = await getCurTask(role.roleId, session);
|
||||||
// pushEntryData('task', roleId, sid, { mainTask, dailyTask, achievement });
|
pushEntryData('task', roleId, sid, { mainTask, dailyTask, achievement });
|
||||||
// // 聊天
|
// 聊天
|
||||||
// const worldMsgs = await recentWorldMsgs(serverId);
|
const worldMsgs = await recentWorldMsgs(serverId);
|
||||||
// const sysMsgs = await recentSysMsgs(serverId);
|
const sysMsgs = await recentSysMsgs(serverId);
|
||||||
// const guildMsgs = await recentGuildMsgs(guildCode);
|
const guildMsgs = await recentGuildMsgs(guildCode);
|
||||||
// const recentPrivateChats = await recentPrivateChatInfos(roleId, roleName);
|
const recentPrivateChats = await recentPrivateChatInfos(roleId, roleName);
|
||||||
// pushEntryData('chat', roleId, sid, { worldMsgs, sysMsgs, guildMsgs, recentPrivateChats });
|
pushEntryData('chat', roleId, sid, { worldMsgs, sysMsgs, guildMsgs, recentPrivateChats });
|
||||||
// // 奇遇
|
// 奇遇
|
||||||
// const event = await getEvent(role.eventStatus, roleId, roleName);
|
const event = await getEvent(role.eventStatus, roleId, roleName);
|
||||||
// pushEntryData('event', roleId, sid, event);
|
pushEntryData('event', roleId, sid, event);
|
||||||
// // 主线关卡列表
|
// 主线关卡列表
|
||||||
// const battle = await getBattleListOfMain(role);
|
const battle = await getBattleListOfMain(role);
|
||||||
// pushEntryData('battle', roleId, sid, battle);
|
pushEntryData('battle', roleId, sid, battle);
|
||||||
|
|
||||||
pushEntryEnd(roleId, sid);
|
pushEntryEnd(roleId, sid);
|
||||||
}catch(e) {
|
}catch(e) {
|
||||||
@@ -133,54 +133,55 @@ function pushEntryEnd(roleId: string, sid: string) {
|
|||||||
pinus.app.channelService.pushMessageByUids('onEntryDataEnd', resResult(STATUS.SUCCESS), uids);//通知在线玩家练兵场重置,
|
pinus.app.channelService.pushMessageByUids('onEntryDataEnd', resResult(STATUS.SUCCESS), uids);//通知在线玩家练兵场重置,
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * 镇念塔初始数据
|
|
||||||
// * @param role
|
|
||||||
// */
|
|
||||||
// async function getTowerEntryData(role: RoleType) {
|
|
||||||
// const { roleId } = role;
|
|
||||||
// const status = await getTowerStatus(role);
|
|
||||||
// const hungUp = await getHungupRewards(roleId);
|
|
||||||
// const tasks = await getTasks(role);
|
|
||||||
// if(hungUp.status == -1) {
|
|
||||||
// return { status, hungUp: {}, tasks }
|
|
||||||
// } else {
|
|
||||||
// return { status, hungUp: hungUp.data, tasks }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * 获取是否存在pvp赛季奖励
|
* 镇念塔初始数据
|
||||||
// * @param roleId
|
* @param role
|
||||||
// */
|
*/
|
||||||
// async function getPvpEntryData(roleId: string) {
|
async function getTowerEntryData(role: RoleType) {
|
||||||
// let pvpSeasonResult = await PvpSeasonResultModel.getPvpSeasonResult(roleId);
|
const { roleId } = role;
|
||||||
// if(!pvpSeasonResult) return false;
|
const status = await getTowerStatus(role);
|
||||||
|
const hungUp = await getHungupRewards(roleId);
|
||||||
|
const tasks = await getTasks(role);
|
||||||
|
if(hungUp.status == -1) {
|
||||||
|
return { status, hungUp: {}, tasks }
|
||||||
|
} else {
|
||||||
|
return { status, hungUp: hungUp.data, tasks }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// let { oldSeasonData, show} = pvpSeasonResult;
|
/**
|
||||||
// // 旧赛季结算的时候,会在pvpSeasonResult表中存上一赛季的时间,并更新show字段
|
* 获取是否存在pvp赛季奖励
|
||||||
// return oldSeasonData.seasonEndTime <= nowSeconds() && show;
|
* @param roleId
|
||||||
// }
|
*/
|
||||||
|
async function getPvpEntryData(roleId: string) {
|
||||||
|
let pvpSeasonResult = await PvpSeasonResultModel.getPvpSeasonResult(roleId);
|
||||||
|
if(!pvpSeasonResult) return false;
|
||||||
|
|
||||||
// /**
|
let { oldSeasonData, show} = pvpSeasonResult;
|
||||||
// * 获取军团信息,并加入军团频道
|
// 旧赛季结算的时候,会在pvpSeasonResult表中存上一赛季的时间,并更新show字段
|
||||||
// * @param role
|
return oldSeasonData.seasonEndTime <= nowSeconds() && show;
|
||||||
// * @param sid
|
}
|
||||||
// * @param session
|
|
||||||
// */
|
|
||||||
// async function getGuildEntryData(role: RoleType, sid: string, session: FrontendOrBackendSession) {
|
|
||||||
|
|
||||||
// if (role.hasGuild) {
|
/**
|
||||||
// let userGuild = await getUserGuildWithRefActive(role.roleId, 'job auth guildCode receivedActive activeRecord activeDaily activeWeekly wishDntCnt wishGoods');
|
* 获取军团信息,并加入军团频道
|
||||||
// if (userGuild) {
|
* @param role
|
||||||
// let guild = await getGuildWithRefActive(userGuild.guildCode, role.serverId);
|
* @param sid
|
||||||
// if (guild) {
|
* @param session
|
||||||
// addRoleToGuildChannel(role.roleId, sid, userGuild.guildCode);
|
*/
|
||||||
|
async function getGuildEntryData(role: RoleType, sid: string, session: FrontendOrBackendSession) {
|
||||||
|
|
||||||
// let result = await getMyGuildInfo(role.roleId, sid, userGuild, guild, role.serverId, session);
|
if (role.hasGuild) {
|
||||||
// return { hasGuild: true, guild, userGuild, guildResult: result};
|
let userGuild = await getUserGuildWithRefActive(role.roleId, 'job auth guildCode receivedActive activeRecord activeDaily activeWeekly wishDntCnt wishGoods');
|
||||||
// }
|
if (userGuild) {
|
||||||
// }
|
let guild = await getGuildWithRefActive(userGuild.guildCode, role.serverId);
|
||||||
// }
|
if (guild) {
|
||||||
// return { hasGuild: false }
|
addRoleToGuildChannel(role.roleId, sid, userGuild.guildCode);
|
||||||
// }
|
|
||||||
|
let result = await getMyGuildInfo(role.roleId, sid, userGuild, guild, role.serverId, session);
|
||||||
|
return { hasGuild: true, guild, userGuild, guildResult: result};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { hasGuild: false }
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,9 +5,53 @@
|
|||||||
import DailyRecord, { DailyRecordModel } from '../db/DailyRecord';
|
import DailyRecord, { DailyRecordModel } from '../db/DailyRecord';
|
||||||
import { resResult } from '../pubUtils/util';
|
import { resResult } from '../pubUtils/util';
|
||||||
import { STATUS } from '../consts/statusCode';
|
import { STATUS } from '../consts/statusCode';
|
||||||
import { RoleModel } from '../db/Role';
|
import { RoleModel, RoleType } from '../db/Role';
|
||||||
import { gameData } from '../pubUtils/data';
|
import { gameData } from '../pubUtils/data';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取全部每日关卡列表
|
||||||
|
* @param role
|
||||||
|
*/
|
||||||
|
export async function getDailyBattleList(role: RoleType) {
|
||||||
|
let { roleId, warStar } = role;
|
||||||
|
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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// 检查每日本次数checkBattle使用
|
// 检查每日本次数checkBattle使用
|
||||||
export async function checkDaily(roleId: string, battleId: number, inc: number) {
|
export async function checkDaily(roleId: string, battleId: number, inc: number) {
|
||||||
let dailyWar = gameData.war.get(battleId);
|
let dailyWar = gameData.war.get(battleId);
|
||||||
|
|||||||
@@ -2,10 +2,30 @@
|
|||||||
* 每日本相关
|
* 每日本相关
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { resResult, shouldRefresh } from '../pubUtils/util';
|
import { resResult, shouldRefresh, calculateNum } from '../pubUtils/util';
|
||||||
import { STATUS } from '../consts/statusCode';
|
import { STATUS } from '../consts/statusCode';
|
||||||
import { RoleModel } from '../db/Role';
|
import { RoleModel, RoleType } from '../db/Role';
|
||||||
import { DUNGEON_CONST } from '../consts';
|
import { DUNGEON_CONST, GOLD_COST_RATIO } from '../consts';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取秘境本数据
|
||||||
|
* @param role
|
||||||
|
*/
|
||||||
|
export async function getDungeonData(role: RoleType) {
|
||||||
|
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime, dungeonHeroes=[] } = role;
|
||||||
|
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 {
|
||||||
|
nextCostGold,
|
||||||
|
dungeonHeroes,
|
||||||
|
battleCount: DUNGEON_CONST.MAX_CNT + dungeonBuyCnt - dungeonCnt,
|
||||||
|
buyCount: DUNGEON_CONST.MAX_BUY_CNT - dungeonBuyCnt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 检查秘境本次数checkBattle使用
|
// 检查秘境本次数checkBattle使用
|
||||||
export async function checkDungeonNum(roleId: string, inc: number) {
|
export async function checkDungeonNum(roleId: string, inc: number) {
|
||||||
|
|||||||
@@ -3,13 +3,56 @@ import { ExpeditionPointModel } from '../db/ExpeditionPoint';
|
|||||||
import Role, { RoleModel, RoleType } from '../db/Role';
|
import Role, { RoleModel, RoleType } from '../db/Role';
|
||||||
import { PvpDefenseModel } from '../db/PvpDefense';
|
import { PvpDefenseModel } from '../db/PvpDefense';
|
||||||
|
|
||||||
import { shouldRefresh } from '../pubUtils/util';
|
import { shouldRefresh, calculateSumCE } from '../pubUtils/util';
|
||||||
import { EXPEDITION_CONST } from '../consts';
|
import { EXPEDITION_CONST, LINEUP_NUM, EXPEDITION_WAR_RECORD_STATUS } from '../consts';
|
||||||
import { ExpeditionWarRecordModel } from '../db/ExpeditionWarRecord';
|
import { ExpeditionWarRecordModel } from '../db/ExpeditionWarRecord';
|
||||||
import { HeroType } from '../db/Hero';
|
import { HeroType } from '../db/Hero';
|
||||||
import { gameData } from '../pubUtils/data';
|
import { gameData } from '../pubUtils/data';
|
||||||
import { getPlayerAttribute, getRobotAttribute } from './pvpService';
|
import { getPlayerAttribute, getRobotAttribute } from './pvpService';
|
||||||
import { getTimeFunD } from '../pubUtils/timeUtil';
|
import { getTimeFunD } from '../pubUtils/timeUtil';
|
||||||
|
import { ExpeditionRecordModel } from '../db/ExpeditionRecord';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取远征关卡列表
|
||||||
|
* @param roleId
|
||||||
|
* @param roleName
|
||||||
|
*/
|
||||||
|
export async function getExpeditionStatus(roleId: string, roleName: string) {
|
||||||
|
// 获取远征关卡状态
|
||||||
|
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 { 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 {
|
||||||
|
expeditionCode,
|
||||||
|
curLv,
|
||||||
|
expeditionWarRecord,
|
||||||
|
pointRewards,
|
||||||
|
heroes: heroes.map(cur => { return { "dataId": cur.seqId, "hp": cur.hp, "ap": cur.ap } }),
|
||||||
|
resetCnt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据存下的战力获取当前远征关卡的对手
|
* 根据存下的战力获取当前远征关卡的对手
|
||||||
|
|||||||
@@ -1,12 +1,31 @@
|
|||||||
import { GachaData, Floor, GachaResult, Hope } from "../domain/activityField/gachaField";;
|
import { GachaData, Floor, GachaResult, Hope, GachaListReturn } from "../domain/activityField/gachaField";;
|
||||||
import { ActivityModel } from "../db/Activity";
|
import { ActivityModel } from "../db/Activity";
|
||||||
import { DicGacha } from "../pubUtils/dictionary/DicGacha";
|
import { DicGacha } from "../pubUtils/dictionary/DicGacha";
|
||||||
import { UserGachaType, UserGachaModel } from "../db/UserGacha";
|
import { UserGachaType, UserGachaModel } from "../db/UserGacha";
|
||||||
import { shouldRefresh, getRandEelm, getRandEelmWithWeight } from "../pubUtils/util";
|
import { shouldRefresh, getRandEelm, getRandEelmWithWeight } from "../pubUtils/util";
|
||||||
import { REFRESH_TIME, GACHA_TO_FLOOR, GACHA_FLOOR_TYPE, GACHA_CONTENT_TYPE, HERO_QUALITY_TYPE, GACHA_OCCUPY_HID, IT_TYPE, ITID, CONSUME_TYPE, SPECIAL_ATTR, TIME_OUTPUT_TYPE } from "../consts";
|
import { REFRESH_TIME, GACHA_TO_FLOOR, GACHA_FLOOR_TYPE, GACHA_CONTENT_TYPE, HERO_QUALITY_TYPE, GACHA_OCCUPY_HID, IT_TYPE, ITID, CONSUME_TYPE, SPECIAL_ATTR, TIME_OUTPUT_TYPE, GACHA_ID } from "../consts";
|
||||||
import { getTimeFunD, getZeroPointD } from "../pubUtils/timeUtil";
|
import { getTimeFunD, getZeroPointD } from "../pubUtils/timeUtil";
|
||||||
import { gameData, getDicGachaFloor } from "../pubUtils/data";
|
import { gameData, getDicGachaFloor } from "../pubUtils/data";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取招募列表
|
||||||
|
* @param roleId
|
||||||
|
*/
|
||||||
|
export async function getGachaList(roleId: string) {
|
||||||
|
let userGachaList = await UserGachaModel.findAllByRole(roleId);
|
||||||
|
let list: GachaListReturn[] = [];
|
||||||
|
for (let [id, dicGacha] of gameData.gacha) {
|
||||||
|
if (id == GACHA_ID.TIMELIMIT) continue; // 不包括限时
|
||||||
|
|
||||||
|
let userGacha = userGachaList.find(cur => cur.gachaId == id);
|
||||||
|
if (userGacha)
|
||||||
|
userGacha = await refreshGacha(dicGacha, userGacha);
|
||||||
|
let param = new GachaListReturn(dicGacha, userGacha);
|
||||||
|
list.push(param);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取活动页签里的限时卡池
|
* 获取活动页签里的限时卡池
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import { gameData, getGuildActiveWeekReward, getGuildActiveByIdAndType, getGoodById } from "../pubUtils/data";
|
import { gameData, getGuildActiveWeekReward, getGuildActiveByIdAndType, getGoodById } from "../pubUtils/data";
|
||||||
import { GuildModel } from "../db/Guild";
|
import { GuildModel, GuildType } from "../db/Guild";
|
||||||
import { resResult, shouldRefresh } from "../pubUtils/util";
|
import { resResult, shouldRefresh } from "../pubUtils/util";
|
||||||
import { STATUS, MAIL_TYPE, GUILD_AUTH, GUILD_JOB, REDIS_KEY, CHAT_SERVER, TASK_TYPE } from "../consts";
|
import { STATUS, MAIL_TYPE, GUILD_AUTH, GUILD_JOB, REDIS_KEY, CHAT_SERVER, TASK_TYPE } from "../consts";
|
||||||
import { RoleModel } from "../db/Role";
|
import { RoleModel, RoleType } from "../db/Role";
|
||||||
import { UserGuildModel, UserGuildType } from "../db/UserGuild";
|
import { UserGuildModel, UserGuildType } from "../db/UserGuild";
|
||||||
import { UserGuildApplyModel } from "../db/UserGuildApply";
|
import { UserGuildApplyModel } from "../db/UserGuildApply";
|
||||||
import { SystemConfigModel } from "../db/SystemConfig";
|
import { SystemConfigModel } from "../db/SystemConfig";
|
||||||
import { nowSeconds } from "../pubUtils/timeUtil";
|
import { nowSeconds } from "../pubUtils/timeUtil";
|
||||||
import { pinus, BackendSession } from "pinus";
|
import { pinus, BackendSession, FrontendOrBackendSession } from "pinus";
|
||||||
import { ARMY } from "../pubUtils/dicParam";
|
import { ARMY } from "../pubUtils/dicParam";
|
||||||
import { sendMail } from "./mailService";
|
import { sendMail } from "./mailService";
|
||||||
import { initSingleRank, getRoleOnlineInfo, updateUserInfo } from "./redisService";
|
import { initSingleRank, getRoleOnlineInfo, updateUserInfo, isRoleOnline } from "./redisService";
|
||||||
import { GuildRankParam, GuildLeader } from "../domain/rank";
|
import { GuildRankParam, GuildLeader } from "../domain/rank";
|
||||||
import { lockData, lockDataNoRetry } from '../services/redLockService';
|
import { lockData, lockDataNoRetry } from '../services/redLockService';
|
||||||
import { ErrLogModel } from '../db/ErrLog';
|
import { ErrLogModel } from '../db/ErrLog';
|
||||||
@@ -22,6 +22,30 @@ import { addRoleToGuildChannel } from "./chatService";
|
|||||||
import { Rank } from "./rankService";
|
import { Rank } from "./rankService";
|
||||||
import { checkActivityTask, checkTask } from "./taskService";
|
import { checkActivityTask, checkTask } from "./taskService";
|
||||||
|
|
||||||
|
export async function getMyGuildInfo(roleId: string, sid: string, userGuild: UserGuildType, guild: GuildType, serverId: number, session: FrontendOrBackendSession) {
|
||||||
|
|
||||||
|
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 });
|
||||||
|
|
||||||
|
let { lv: guildLv, memberCnt } = guild;
|
||||||
|
let dicGuild = gameData.centerBase.get(guildLv);
|
||||||
|
let guildMemberMax = dicGuild && memberCnt >= dicGuild.peopleNum;
|
||||||
|
|
||||||
|
// 返回
|
||||||
|
return { hasGuild: true, guildMemberMax, ...guild, leader: { ...leader, isOnline: leaderIsOnline }, rank, myInfo: {...userGuild }};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 检查该玩家是否有权限做操作
|
* @description 检查该玩家是否有权限做操作
|
||||||
* @param func 操作id
|
* @param func 操作id
|
||||||
@@ -292,3 +316,17 @@ export async function settleGuildWeekly() {
|
|||||||
await SystemConfigModel.updateSystemConfig({ settleGuildWeeklyTime: nowSeconds() }); // 记录一下
|
await SystemConfigModel.updateSystemConfig({ settleGuildWeeklyTime: nowSeconds() }); // 记录一下
|
||||||
console.log('————— settleGuildWeekly结束 —————');
|
console.log('————— settleGuildWeekly结束 —————');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export async function getWishPool(userGuild: UserGuildType) {
|
||||||
|
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 { list, wishDntCnt:wishDntCnt||0, wishGoods };
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { UserGuildModel } from '../db/UserGuild';
|
import { UserGuildModel, UserGuildType } from '../db/UserGuild';
|
||||||
import { getArmyTrainJuDian, getTrainBaseByLv } from '../pubUtils/data';
|
import { getArmyTrainJuDian, getTrainBaseByLv } from '../pubUtils/data';
|
||||||
import { nowSeconds, getZeroPoint } from '../pubUtils/timeUtil';
|
import { nowSeconds, getZeroPoint } from '../pubUtils/timeUtil';
|
||||||
import { GUILD_STRUCTURE } from '../consts';
|
import { GUILD_STRUCTURE } from '../consts';
|
||||||
import { GuildTrainType, GuildTrainModel, TrainInstance } from '../db/GuildTrain';
|
import { GuildTrainType, GuildTrainModel, TrainInstance } from '../db/GuildTrain';
|
||||||
import { GuildModel } from '../db/Guild';
|
import { GuildModel, GuildType } from '../db/Guild';
|
||||||
import { findWhere } from 'underscore';
|
import { findWhere } from 'underscore';
|
||||||
import { ARMY } from '../pubUtils/dicParam';
|
import { ARMY } from '../pubUtils/dicParam';
|
||||||
import { lockData } from './redLockService';
|
import { lockData } from './redLockService';
|
||||||
@@ -185,3 +185,22 @@ export async function checkResetTrain(roleId: string, serverId: number) {
|
|||||||
export async function removeTrainRank(guildCode: string, roleId: string, trainId: number) {
|
export async function removeTrainRank(guildCode: string, roleId: string, trainId: number) {
|
||||||
await GuildTrainModel.removeTrainRank(guildCode, roleId, trainId);
|
await GuildTrainModel.removeTrainRank(guildCode, roleId, trainId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取军团练兵场
|
||||||
|
* @param roleId
|
||||||
|
* @param guild
|
||||||
|
* @param userGuild
|
||||||
|
*/
|
||||||
|
export async function getGuildTrainInstance(roleId: string, guild: GuildType, userGuild: UserGuildType) {
|
||||||
|
let { trainId, trainLv, code } = guild;
|
||||||
|
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;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
|
|
||||||
import { HeroModel } from '../db/Hero';
|
import { HeroModel } from '../db/Hero';
|
||||||
import Role, { RoleModel } from '../db/Role'
|
import Role, { RoleModel, RoleType } from '../db/Role'
|
||||||
import { getLvByExp, getExpByLv, gameData } from '../pubUtils/data';
|
import { getLvByExp, getExpByLv, gameData } from '../pubUtils/data';
|
||||||
import { updateUserInfo } from './redisService';
|
import { updateUserInfo } from './redisService';
|
||||||
import { switchOnFunc } from './funcSwitchService';
|
import { switchOnFunc } from './funcSwitchService';
|
||||||
import { FUNC_OPT_TYPE, TASK_TYPE } from '../consts';
|
import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE } from '../consts';
|
||||||
import { BackendSession } from 'pinus';
|
import { BackendSession } from 'pinus';
|
||||||
import { REDIS_KEY } from '../consts';
|
import { REDIS_KEY } from '../consts';
|
||||||
import { Rank } from './rankService';
|
import { Rank } from './rankService';
|
||||||
import { checkActivityTask, checkTask } from './taskService';
|
import { checkActivityTask, checkTask } from './taskService';
|
||||||
|
import { accomplishTask } from '../pubUtils/taskUtil';
|
||||||
|
import { RScriptRecordModel } from '../db/RScriptRecord';
|
||||||
|
|
||||||
export async function roleLevelup(roleId: string, kingExp: number, session: BackendSession) {
|
export async function roleLevelup(roleId: string, kingExp: number, session: BackendSession) {
|
||||||
const serverId = session.get('serverId');
|
const serverId = session.get('serverId');
|
||||||
@@ -104,3 +106,50 @@ export async function updateWarStar(roleId: string, battleId: number, warType: n
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getBattleListOfMain(role: RoleType) {
|
||||||
|
let types = [ WAR_TYPE.NORMAL, WAR_TYPE.VESTIGE, WAR_TYPE.MAIN_ELITE ];
|
||||||
|
let result = [];
|
||||||
|
for(let type of types) {
|
||||||
|
let list = await getBattleList(role, type);
|
||||||
|
result.push({ type, list });
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getBattleList(role: RoleType, type: number) {
|
||||||
|
let { roleId, 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 });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -20,6 +20,11 @@ import { pinus } from 'pinus';
|
|||||||
import { PvpHistoryOppModel, PvpHistoryOppType } from '../db/PvpHistoryOpp';
|
import { PvpHistoryOppModel, PvpHistoryOppType } from '../db/PvpHistoryOpp';
|
||||||
import { Rank } from './rankService';
|
import { Rank } from './rankService';
|
||||||
|
|
||||||
|
export async function getPvpData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function initPvpInfo(role: RoleType) {
|
export async function initPvpInfo(role: RoleType) {
|
||||||
let heroes: Array<Heroes> = [];
|
let heroes: Array<Heroes> = [];
|
||||||
//初始化最强5人阵容
|
//初始化最强5人阵容
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { KeyName, KeyNameParam, RankParam, GuildRankParam, RoleRankInfo, GuildRankInfo, GuildLeader, LineupParam, myIdInter } from "../domain/rank";
|
import { KeyName, KeyNameParam, RankParam, GuildRankParam, RoleRankInfo, GuildRankInfo, GuildLeader, LineupParam, myIdInter, GeneralRankParamRole, GeneralRankParamBattle } from "../domain/rank";
|
||||||
import { REDIS_RANK_TO_INFO, ROLE_SELECT, GUILD_SELECT, REDIS_KEY, REDIS_RANK_TO_EXTRA, HERO_SELECT, COMPOSE_FIELD_TYPE, KEY_TO_COMPOSE_FIELD, RANK_TYPE } from "../consts";
|
import { REDIS_RANK_TO_INFO, ROLE_SELECT, GUILD_SELECT, REDIS_KEY, REDIS_RANK_TO_EXTRA, HERO_SELECT, COMPOSE_FIELD_TYPE, KEY_TO_COMPOSE_FIELD, RANK_TYPE_TO_KEY } from "../consts";
|
||||||
import { redisClient, setUserInfo } from "./redisService";
|
import { redisClient, setUserInfo } from "./redisService";
|
||||||
import { RoleType, RoleModel } from "../db/Role";
|
import { RoleType, RoleModel } from "../db/Role";
|
||||||
import { GuildType, GuildModel } from "../db/Guild";
|
import { GuildType, GuildModel } from "../db/Guild";
|
||||||
import { HeroModel, HeroType } from "../db/Hero";
|
import { HeroModel, HeroType, HeroUpdate } from "../db/Hero";
|
||||||
import { SystemConfigModel } from "../db/SystemConfig";
|
import { SystemConfigModel } from "../db/SystemConfig";
|
||||||
import { PvpDefenseModel } from "../db/PvpDefense";
|
import { PvpDefenseModel } from "../db/PvpDefense";
|
||||||
import { gameData } from "../pubUtils/data";
|
import { gameData } from "../pubUtils/data";
|
||||||
@@ -794,3 +794,45 @@ export async function setRankRedisFromDb(type: string, args?: {serverId?: number
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取排行榜总览
|
||||||
|
* @param role 玩家数据
|
||||||
|
* @param serverId 所在服务器
|
||||||
|
*/
|
||||||
|
export async function getGeneralRank(role: RoleType&{rankReceived: number[]}, serverId: number) {
|
||||||
|
let { rankReceived = []} = role;
|
||||||
|
|
||||||
|
let res = {
|
||||||
|
role: new Array<GeneralRankParamRole>(),
|
||||||
|
battle: new Array<GeneralRankParamBattle>()
|
||||||
|
};
|
||||||
|
|
||||||
|
for(let { id, general } of gameData.rank) {
|
||||||
|
let redisKey = RANK_TYPE_TO_KEY.get(id);
|
||||||
|
if(redisKey) {
|
||||||
|
let received = rankReceived.filter(rewardId => {
|
||||||
|
let dic = gameData.generalRankReward.get(rewardId);
|
||||||
|
return dic && dic.rankId == id;
|
||||||
|
});
|
||||||
|
if(general == 1) {
|
||||||
|
let r = new Rank(redisKey, { serverId }, false, 1);
|
||||||
|
let ranks = <RoleRankInfo[]> await r.getRankByRange();
|
||||||
|
if(ranks.length > 0) {
|
||||||
|
let param = new GeneralRankParamRole(id, ranks[0]||new RoleRankInfo({}, false), received);
|
||||||
|
res.role.push(param);
|
||||||
|
}
|
||||||
|
} else if (general = 2) {
|
||||||
|
let r = new Rank(redisKey, { serverId }, false, 1);
|
||||||
|
let ranks = <RoleRankInfo[]> await r.getRankByRange();
|
||||||
|
let hero: HeroUpdate;
|
||||||
|
if(ranks.length > 0) {
|
||||||
|
hero = await HeroModel.getMyTopHero(ranks[0].roleId, 'hid skins');
|
||||||
|
let param = new GeneralRankParamBattle(id, ranks[0]||new RoleRankInfo({}, false), hero, received);
|
||||||
|
res.battle.push(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
import { ChannelUser } from './../domain/ChannelUser';
|
import { ChannelUser } from './../domain/ChannelUser';
|
||||||
import { Channel } from 'pinus';
|
import { Channel } from 'pinus';
|
||||||
import { getRandValueByMinMax, getRandEelm } from '../pubUtils/util';
|
import { getRandValueByMinMax, getRandEelm, decodeIdCntArrayStr } from '../pubUtils/util';
|
||||||
import { TERAPH_RANDOM } from "../consts";
|
import { TERAPH_RANDOM } from "../consts";
|
||||||
import { DicTeraph } from '../pubUtils/dictionary/DicTeraph';
|
import { DicTeraph } from '../pubUtils/dictionary/DicTeraph';
|
||||||
import { Teraph, RoleModel } from '../db/Role';
|
import { Teraph, RoleModel } from '../db/Role';
|
||||||
import { ROLE_SELECT } from '../consts';
|
import { ROLE_SELECT } from '../consts';
|
||||||
|
import { SCHOOL } from '../pubUtils/dicParam';
|
||||||
|
import { gameData } from '../pubUtils/data';
|
||||||
|
import { SchoolModel } from '../db/School';
|
||||||
|
import { SclResultInter, SclPosInter } from '../pubUtils/interface';
|
||||||
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||||
/**
|
/**
|
||||||
* 计算强化次数和消耗
|
* 计算强化次数和消耗
|
||||||
@@ -98,3 +102,43 @@ export async function getSimpleRoleInfos(roleIds: string[]) {
|
|||||||
let roles = await RoleModel.findRoleByField('roleId', roleIds, ROLE_SELECT.SHOW_SIMPLE, true);
|
let roles = await RoleModel.findRoleByField('roleId', roleIds, ROLE_SELECT.SHOW_SIMPLE, true);
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 百家学宫
|
||||||
|
* @param roleId
|
||||||
|
*/
|
||||||
|
export async function getSchoolList(roleId: string) {
|
||||||
|
|
||||||
|
const dicPosition = decodeIdCntArrayStr(SCHOOL.SCHOOL_POSITION, 1); // id=>isOpen
|
||||||
|
|
||||||
|
const userSchoolList = await SchoolModel.findByRoleId(roleId);
|
||||||
|
|
||||||
|
let school = new Array<SclResultInter>();
|
||||||
|
gameData.school.forEach((dicSchool) => {
|
||||||
|
let position = new Array<SclPosInter>();
|
||||||
|
dicPosition.forEach((isOpen, dicId) => {
|
||||||
|
let id = parseInt(dicId);
|
||||||
|
|
||||||
|
let userSchool = userSchoolList.find(cur => cur.schoolId == dicSchool.id && cur.positionId == id);
|
||||||
|
if (userSchool) {
|
||||||
|
position.push({
|
||||||
|
id,
|
||||||
|
hid: userSchool.hid,
|
||||||
|
isOpen: userSchool.isOpen
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
position.push({
|
||||||
|
id,
|
||||||
|
hid: 0,
|
||||||
|
isOpen: !!isOpen
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
school.push({
|
||||||
|
id: dicSchool.id,
|
||||||
|
position
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return school;
|
||||||
|
}
|
||||||
58
game-server/app/services/shopService.ts
Normal file
58
game-server/app/services/shopService.ts
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import { gameData } from "../pubUtils/data";
|
||||||
|
import { DicShopListModel } from "../db/DicShopList";
|
||||||
|
import { ShopItem } from "../domain/dbGeneral";
|
||||||
|
import { ShopItemListParam } from '../domain/roleField/shop';
|
||||||
|
import { UserShopModel } from "../db/UserShop";
|
||||||
|
|
||||||
|
export async function getShopListById(shopId: number, roleId: string) {
|
||||||
|
|
||||||
|
let shopItemList = new Array<ShopItemListParam>(); // 返回
|
||||||
|
let dbDicShop = await DicShopListModel.findByShopId(shopId);
|
||||||
|
let userShopRecs = await UserShopModel.findMapByShopId(roleId, shopId);
|
||||||
|
// console.log(JSON.stringify([...userShopRecs]))
|
||||||
|
|
||||||
|
|
||||||
|
if(!dbDicShop || dbDicShop.useJson) { // 完全使用json中配置的商品,数据库只做排序用,数据库内没有的排到最后
|
||||||
|
let items = dbDicShop?.items||[];
|
||||||
|
let map = new Map<number, ShopItem>();
|
||||||
|
for(let item of items) {
|
||||||
|
map.set(item.id, item);
|
||||||
|
}
|
||||||
|
let dicShop = gameData.shop.get(shopId)||[];
|
||||||
|
for(let { id, type } of dicShop) {
|
||||||
|
let buyCount = userShopRecs.has(id)?userShopRecs.get(id).count: 0;
|
||||||
|
if(map.has(id)) {
|
||||||
|
let item = map.get(id);
|
||||||
|
let param = new ShopItemListParam(id, item.discount, type, buyCount, item.order);
|
||||||
|
shopItemList.push(param);
|
||||||
|
} else {
|
||||||
|
let param = new ShopItemListParam(id, 1, type, buyCount, 0);
|
||||||
|
shopItemList.push(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { // 只返回数据库内的商品
|
||||||
|
let items = dbDicShop?.items||[];
|
||||||
|
for(let item of items) {
|
||||||
|
let { id, order, discount } = item;
|
||||||
|
let buyCount = userShopRecs.has(id)?userShopRecs.get(id).count: 0;
|
||||||
|
let dicShop = gameData.shopItem.get(id);
|
||||||
|
if(dicShop) {
|
||||||
|
let param = new ShopItemListParam(id, discount, dicShop.type, buyCount, order);
|
||||||
|
shopItemList.push(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shopItemList = shopItemList.sort((a, b) => b.order - a.order);
|
||||||
|
return shopItemList;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getAllShopList(roleId: string) {
|
||||||
|
let shopLists: {shopId: number, shopItemList: ShopItemListParam[]}[] = [];
|
||||||
|
for(let [ shopId ] of gameData.shopList) {
|
||||||
|
let shopItemList = await getShopListById(shopId, roleId);
|
||||||
|
shopLists.push({ shopId, shopItemList });
|
||||||
|
}
|
||||||
|
return shopLists;
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
export enum ROLE_SELECT {
|
export enum ROLE_SELECT {
|
||||||
// 初始登录数据
|
// 初始登录数据
|
||||||
ENTRY = 'serverId userInfo.uid userInfo.tel userInfo.serverType ce topLineup topLineupCe teraphs roleId roleName tili lv exp gold coin vLv title hasGuild funcs eventStatus heads head frames frame spines spine guildCode frdCnt showLineup updatedAt heroNum heroNumUpdatedAt loginTime hasInit',
|
ENTRY = 'serverId userInfo.uid userInfo.tel userInfo.serverType ce topLineup topLineupCe teraphs roleId roleName tili lv exp gold coin vLv title hasGuild funcs eventStatus heads head frames frame spines spine guildCode frdCnt showLineup updatedAt heroNum heroNumUpdatedAt loginTime hasInit rankReceived',
|
||||||
// 玩家列表显示基础数据
|
// 玩家列表显示基础数据
|
||||||
SHOW_SIMPLE = 'roleId roleName ce head frame spine lv title job quitTime loginTime vLv guildName serverId userInfo.serverType',
|
SHOW_SIMPLE = 'roleId roleName ce head frame spine lv title job quitTime loginTime vLv guildName serverId userInfo.serverType',
|
||||||
// 显示申请需要的信息
|
// 显示申请需要的信息
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ export default class Activity_Pop_Up_Shop extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//删除活动领取记录
|
//删除活动领取记录
|
||||||
public static async deleteActivity(_serverId: number, activityId: number, roleId: string, id: number) {
|
public static async deleteActivity(serverId: number, activityId: number, roleId: string, id: number) {
|
||||||
|
console.log(serverId)
|
||||||
let nowDate = new Date();
|
let nowDate = new Date();
|
||||||
await ActivityPopUpShopModel.deleteMany({
|
await ActivityPopUpShopModel.deleteMany({
|
||||||
roleId, activityId, id,
|
roleId, activityId, id,
|
||||||
|
|||||||
Reference in New Issue
Block a user