热更新:handler监听热更新
This commit is contained in:
@@ -213,6 +213,10 @@ app.configure(ALL_ENVS, function () {
|
||||
// bufferMsg:true,
|
||||
// interval:50,
|
||||
});
|
||||
app.set('serverConfig', {
|
||||
'reloadHandlers': true,
|
||||
'reloadRemotes': true,
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: 所有环境打开监听模块和日志
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { aesEncrypt, aesEncryptcfb, resResult } from '../../../pubUtils/util';
|
||||
import { ENCRYPT_IV, ENCRYPT_KEY, STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { checkActivityTask } from '../../../services/taskService';
|
||||
@@ -6,10 +6,9 @@ import { ActivityGroupModel } from '../../../db/ActivityGroup';
|
||||
import { ServerlistModel } from '../../../db/Serverlist';
|
||||
import { getActivity } from '../../../services/activity/activityService';
|
||||
import { ActivityModel } from '../../../db/Activity';
|
||||
import { GTPushSingleCidMessage, GTCreateListMessage, GTPushListCidMessage } from '../../../services/getui/getuiService';
|
||||
import moment = require('moment');
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ActivityHandler(app);
|
||||
}
|
||||
|
||||
@@ -25,6 +24,7 @@ export class ActivityHandler {
|
||||
* @memberof ActivityHandler
|
||||
*/
|
||||
async getAllOpenActivity(msg: {}, session: BackendSession) {
|
||||
|
||||
const { } = msg;
|
||||
const roleId = session.get('roleId');
|
||||
const serverId = session.get('serverId');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { LAND_TYPE, STATUS, CURRENCY_TYPE, CURRENCY_BY_TYPE, BANK_TYPE, ACTIVITY_RESOURCES_TYPE } from '../../../consts';
|
||||
import { ActivityMonopolyModel, ActivityMonopolyModelType } from '../../../db/ActivityMonopoly';
|
||||
@@ -11,6 +11,7 @@ import { getPlayerRefreshShopDataByRoundIndex } from '../../../services/activity
|
||||
import { ActivityRefreshShopModel } from '../../../db/ActivityRefreshShop';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ActivityMonopolyHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { getPlayerDailyChallengesData } from '../../../services/activity/dailyChallengesService';
|
||||
@@ -9,6 +9,7 @@ import { ActivityDailyChallengesModel } from '../../../db/ActivityDailyChallenge
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new DailyChallengesHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { ACTIVITY_RESOURCES_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, STATUS } from '../../../consts';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
@@ -14,6 +14,7 @@ import moment = require('moment');
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new DailyCoinHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { getPlayerDailyGKData } from '../../../services/activity/dailyGKService';
|
||||
@@ -6,6 +6,7 @@ import { DailyGKItem } from '../../../domain/activityField/dailyGKField';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new DailyGKHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, ACTIVITY_RESOURCES_TYPE } from '../../../consts';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
@@ -10,6 +10,7 @@ import { RewardParam } from '../../../domain/activityField/rewardField';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new DailyGiftsHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
@@ -11,6 +11,7 @@ import moment = require('moment');
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new DailyMealHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, } from '../../../consts';
|
||||
import { getPlayerDailyRMBGiftsData, makeDailyRMBGiftsReward } from '../../../services/activity/dailyRMBGiftsService';
|
||||
@@ -8,6 +8,7 @@ import { ActivityDailyRMBGiftsModel } from '../../../db/ActivityDailyRMBGifts';
|
||||
import moment = require('moment');
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new DailyRMBGiftsHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { FIRST_GIFT_STATE, STATUS } from '../../../consts';
|
||||
import { getPlayerFirstGiftData } from '../../../services/activity/firstGiftService';
|
||||
@@ -7,6 +7,7 @@ import { addReward, stringToRewardParam } from '../../../services/activity/giftP
|
||||
import { ActivityFirstGiftModel } from '../../../db/ActivityFirstGift';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new FirstGiftHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { Application, BackendSession, HandlerService, } from "pinus";
|
||||
import { resResult, getRandEelmWithWeight, shouldRefresh, getRandSingleEelm } from "../../../pubUtils/util";
|
||||
import { STATUS, GACHA_ID, HERO_QUALITY_TYPE, TASK_TYPE, REFRESH_TIME, TIME_OUTPUT_TYPE } from "../../../consts";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
@@ -15,6 +15,7 @@ import { checkActivityTask, checkTask } from "../../../services/taskService";
|
||||
import { RECRUIT } from "../../../pubUtils/dicParam";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GachaHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { getPlayerGrowthFundData } from '../../../services/activity/growthFundService';
|
||||
@@ -9,6 +9,7 @@ import { RewardParam } from '../../../domain/activityField/rewardField';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GrowthFundHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { getPlayerGrowthData } from '../../../services/activity/growthService';
|
||||
@@ -10,6 +10,7 @@ import { ActivityGrowthPointModel } from '../../../db/ActivityGrowthPoint';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GrowthHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { ACTIVITY_TYPE, STATUS } from '../../../consts';
|
||||
import { newPlayerLimitPackageActivity, getPlayerLimitPackageData } from '../../../services/activity/limitPackageService';
|
||||
@@ -9,6 +9,7 @@ import { RoleModel } from '../../../db/Role';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new LimitPackageHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE } from '../../../consts';
|
||||
import { getPlayerMonthlyTicketData, makeMonthlyTicketReward, getPlayerMonthlyTicketDayReward } from '../../../services/activity/monthlyTicketService';
|
||||
@@ -6,6 +6,7 @@ import moment = require('moment');
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new MonthlyTicketHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { challengeNewHeroGK, getPlayerNewHeroGKData } from '../../../services/activity/newHeroGKService';
|
||||
@@ -6,6 +6,7 @@ import { NewHeroGKItem } from '../../../domain/activityField/newHeroGKField';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new NewHeroGKHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { getRandEelmWithWeight, resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, GACHA_ID } from '../../../consts';
|
||||
import { getPlayerNewHeroGachaData } from '../../../services/activity/newHeroGachaService';
|
||||
@@ -18,6 +18,7 @@ import { NewHeroGachaData } from '../../../domain/activityField/newHeroGachaFiel
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new NewHeroGachaHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, } from '../../../consts';
|
||||
import { getPlayerNewHeroGiftsData } from '../../../services/activity/newHeroGiftsService';
|
||||
@@ -7,6 +7,7 @@ import { addReward, stringToRewardParam } from '../../../services/activity/giftP
|
||||
import { ActivityNewHeroGiftModel } from '../../../db/ActivityNewHeroGift';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new NewHeroGiftsHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult, splitString } from '../../../pubUtils/util';
|
||||
import { ACTIVITY_RESOURCES_TYPE, CURRENCY_BY_TYPE, CURRENCY, STATUS, CURRENCY_TYPE, } from '../../../consts';
|
||||
import { getPlayerPopUpShopData } from '../../../services/activity/popUpShopService';
|
||||
@@ -11,6 +11,7 @@ import { handleCost } from '../../../services/rewardService';
|
||||
import moment = require('moment');
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new PopUpShopHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE } from '../../../consts';
|
||||
import { addRechargeMoney, getPlayerRechargeMoneyData } from '../../../services/activity/rechargeMoneyService';
|
||||
@@ -9,6 +9,7 @@ import { ActivityRechargeMoneyModel } from '../../../db/ActivityRechargeMoney';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new RechargeMoneyHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { deltaDays, resResult } from '../../../pubUtils/util';
|
||||
import { ACTIVITY_TYPE, STATUS } from '../../../consts';
|
||||
import { getRefreshShopActivity, getPlayerRefreshShopData } from '../../../services/activity/refreshShopService';
|
||||
@@ -9,6 +9,7 @@ import { handleCost } from '../../../services/rewardService';
|
||||
import moment = require('moment');
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new RefreshShopHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { ACTIVITY_TYPE, STATUS } from '../../../consts';
|
||||
import { getPlayerRefreshTaskData } from '../../../services/activity/refreshTaskService';
|
||||
@@ -12,6 +12,7 @@ import { ActivityModel } from '../../../db/Activity';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new RefreshTaskHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult, splitString } from '../../../pubUtils/util';
|
||||
import { STATUS, } from '../../../consts';
|
||||
import { SelfServiceShopData } from '../../../domain/activityField/selfServiceShopField';
|
||||
@@ -13,6 +13,7 @@ import { random } from 'underscore';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new SelfServiceShopHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, ACTIVITY_RESOURCES_TYPE } from '../../../consts';
|
||||
import { handleCost } from '../../../services/rewardService';
|
||||
@@ -13,6 +13,7 @@ import { SevenDaysGrowthItem, SevenDaysPointRewardItem, SevenDaysDailyItem, Seve
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new SevenDaysHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, ACTIVITY_TYPE, SERVER_OPEN_TIME, } from '../../../consts';
|
||||
import { canBuyVip, getPlayerSignInData } from '../../../services/activity/signInService';
|
||||
@@ -12,6 +12,7 @@ import { RewardParam } from '../../../domain/activityField/rewardField';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new SignInHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, ACTIVITY_TYPE } from '../../../consts';
|
||||
import { getPlayerThirtyDaysData, playerThirtyDaysActivityDays } from '../../../services/activity/thirtyDaysService';
|
||||
@@ -11,6 +11,7 @@ import { addReward, stringToRewardParam } from '../../../services/activity/giftP
|
||||
import { RewardParam } from '../../../domain/activityField/rewardField';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ThirtyDaysHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, } from '../../../consts';
|
||||
import { getPlayerTreasureHuntData, getTreasureHuntData, getPlayerTreasureHuntShopData, getPlayerTreasureHuntTaskData, getPlayerTreasureHuntTreasureShopData, getPlayerTreasureHuntChallengeData, getPlayerTreasureHuntFirstPageData } from '../../../services/activity/treasureHuntService';
|
||||
@@ -12,6 +12,7 @@ import { ActivityTreasureHuntFirstPageModel } from '../../../db/ActivityTreasure
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new TreasureHuntHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, } from '../../../consts';
|
||||
import { getPlayerVipRechargeMoneyData, } from '../../../services/activity/vipRechargeMoneyService';
|
||||
@@ -12,6 +12,7 @@ import moment = require('moment');
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new VipRechargeMoneyHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, ACTIVITY_RESOURCES_TYPE, ACTIVITY_TYPE } from '../../../consts';
|
||||
import { yuanbaoActivity, getPlayerYuanbaoShopData } from '../../../services/activity/yuanbaoService';
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new YuanbaoShopHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Application, ChannelService } from 'pinus';
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { reloadResources } from '../../../pubUtils/data';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ActivityRemote(app);
|
||||
}
|
||||
|
||||
@@ -13,7 +14,7 @@ export class ActivityRemote {
|
||||
}
|
||||
|
||||
private channelService: ChannelService;
|
||||
|
||||
|
||||
/**
|
||||
* 重载json资源
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DividendModel } from './../../../db/Dividend';
|
||||
import { Application, BackendSession, ChannelService } from "pinus";
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from "pinus";
|
||||
import { AUCTION_STAGE, DEBUG_MAGIC_WORD, STATUS, OFFER_RATIO, CURRENCY_BY_TYPE, CURRENCY_TYPE, DATA_NAME, LOT_STATUS } from "../../../consts";
|
||||
import { LotModel } from "../../../db/Lot";
|
||||
import { ItemReward } from "../../../domain/dbGeneral";
|
||||
@@ -17,6 +17,7 @@ import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { UserGuildApplyModel } from '../../../db/UserGuildApply';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new AuctionHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE } from '../../../consts';
|
||||
@@ -14,6 +14,7 @@ import { ARMY } from '../../../pubUtils/dicParam';
|
||||
import { addActive } from '../../../services/guildService'
|
||||
import { checkActivityTask, checkTask } from '../../../services/taskService';
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new DonationHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { EventRecordModel } from '../../../db/EventRecord';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { EVENT_STATUS, EVENT_RECORD_STATUS, EVENT_ANSWER_STATUS, TASK_TYPE } from '../../../consts';
|
||||
@@ -10,6 +10,7 @@ import { checkActivityTask, checkTask } from '../../../services/taskService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new EventBattleHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { ExpeditionRecordModel } from '../../../db/ExpeditionRecord';
|
||||
import { ExpeditionWarRecordModel } from '../../../db/ExpeditionWarRecord';
|
||||
@@ -17,6 +17,7 @@ import { checkActivityTask, checkTask, checkTaskInBattleEnd } from '../../../ser
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ExpeditionBattleHandler(app);
|
||||
}
|
||||
|
||||
@@ -33,7 +34,7 @@ export class ExpeditionBattleHandler {
|
||||
let roleName = session.get('roleName');
|
||||
|
||||
let res = await getExpeditionStatus(roleId, roleName);
|
||||
if(!res) return resResult(STATUS.ROLE_IS_NOT_INIT);
|
||||
if (!res) return resResult(STATUS.ROLE_IS_NOT_INIT);
|
||||
|
||||
return resResult(STATUS.SUCCESS, res);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { BossInstanceModel } from '../../../db/BossInstance';
|
||||
@@ -18,6 +18,7 @@ import { pushGuildBossSucMsg, getGuildChannelSid } from '../../../services/chatS
|
||||
import { checkTask } from '../../../services/taskService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildHandler(app);
|
||||
}
|
||||
|
||||
@@ -28,18 +29,18 @@ export class GuildHandler {
|
||||
async debugAddBattleTimes(msg: {}, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let { ranks } = await BossInstanceModel.findBossInstance(code);
|
||||
for (let i = 0;i < ranks.length; i++) {
|
||||
for (let i = 0; i < ranks.length; i++) {
|
||||
let rank = ranks[i];
|
||||
if (rank.roleId == roleId) {
|
||||
rank.time = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let { ranks : resRanks } = await BossInstanceModel.updateBossInstance(code, {ranks});
|
||||
let { ranks: resRanks } = await BossInstanceModel.updateBossInstance(code, { ranks });
|
||||
return resResult(STATUS.SUCCESS, { ranks: resRanks });
|
||||
}
|
||||
|
||||
@@ -47,17 +48,17 @@ export class GuildHandler {
|
||||
async getBossInstance(msg: {}, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let bossInstance = await BossInstanceModel.findBossInstance(code);
|
||||
if (!bossInstance) {
|
||||
return resResult(STATUS.SUCCESS, {status: GUILD_BOSS_STATUS.WAIT_OPEN});//等待团长开启
|
||||
return resResult(STATUS.SUCCESS, { status: GUILD_BOSS_STATUS.WAIT_OPEN });//等待团长开启
|
||||
}
|
||||
let result = await getBossInstanceInfo(bossInstance, roleId);
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
|
||||
//开启演武场
|
||||
async openBossInstance(msg: {}, session: BackendSession) {
|
||||
const roleId: string = session.get('roleId');
|
||||
@@ -65,27 +66,27 @@ export class GuildHandler {
|
||||
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'auth guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
const checkMyResult = await checkAuth(GUILD_OPERATE.OPEN_BOSS, roleId, null, userGuild);
|
||||
if(!checkMyResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
let res:any = await lockData(serverId, DATA_NAME.BOSS_SCRIPT, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
if (!checkMyResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
let res: any = await lockData(serverId, DATA_NAME.BOSS_SCRIPT, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
let bossInstance = await BossInstanceModel.findBossInstance(code);
|
||||
if (!!bossInstance && ( bossInstance.bossHp > 0 || bossInstance.startTime >= getZeroPoint() )) {
|
||||
if (!!bossInstance && (bossInstance.bossHp > 0 || bossInstance.startTime >= getZeroPoint())) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_SCRIPT_IS_OPENED_TODAY);
|
||||
}
|
||||
const guild = await GuildModel.findByCode(code, serverId, 'lv structure');
|
||||
if(!guild) {
|
||||
if (!guild) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_NOT_FOUND);
|
||||
}
|
||||
const { structure } = guild;
|
||||
const curStructure = structure.find(cur => cur.id == GUILD_STRUCTURE.BOSS);
|
||||
if(!curStructure) {
|
||||
if (!curStructure) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_STRUCTURE_NOT_FOUND);
|
||||
}
|
||||
@@ -98,7 +99,7 @@ export class GuildHandler {
|
||||
}
|
||||
await BossInstanceModel.openBossInstance(code, bossHp, warId, bossBase.bossLevel);
|
||||
res.releaseCallback();
|
||||
let result = {warId, ranks: [], myRank: {}, bossHp, status: 3, bossLv: bossBase.bossLevel, isBattled: false};
|
||||
let 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);
|
||||
@@ -110,16 +111,16 @@ export class GuildHandler {
|
||||
const roleId: string = session.get('roleId');
|
||||
const roleName: string = session.get('roleName');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode job');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let bossInstance = await BossInstanceModel.findBossInstance(code);
|
||||
if (!bossInstance)
|
||||
if (!bossInstance)
|
||||
return resResult(STATUS.GUILD_SCRIPT_NOT_OPENED);
|
||||
if (bossInstance.bossHp <= 0)
|
||||
if (bossInstance.bossHp <= 0)
|
||||
return resResult(STATUS.GUILD_SCRIPT_IS_COMPLETE);
|
||||
let myRank = findWhere(bossInstance.ranks, {roleId});
|
||||
if (!!myRank && myRank.time > getZeroPoint())
|
||||
let myRank = findWhere(bossInstance.ranks, { roleId });
|
||||
if (!!myRank && myRank.time > getZeroPoint())
|
||||
return resResult(STATUS.GUILD_SCRIPT_IS_BATTLED);
|
||||
let { warId, ranks } = bossInstance;
|
||||
const battleCode = genCode(8); // 关卡唯一值
|
||||
@@ -127,35 +128,35 @@ export class GuildHandler {
|
||||
$set: {
|
||||
roleId, roleName, battleId: warId,
|
||||
status: 0,
|
||||
record: { heroes:[],recordNum: bossInstance.num, bossHp: bossInstance.bossHp},
|
||||
record: { heroes: [], recordNum: bossInstance.num, bossHp: bossInstance.bossHp },
|
||||
}
|
||||
}, true);
|
||||
const serverId:number = parseInt(session.get('serverId'));
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
await addBossInstance(code, serverId, roleId);
|
||||
if (!findWhere(ranks, {roleId})) {
|
||||
await BossInstanceModel.pushRanks(code, {roleId, score: 0, time: nowSeconds(), job: userGuild.job});
|
||||
if (!findWhere(ranks, { roleId })) {
|
||||
await BossInstanceModel.pushRanks(code, { roleId, score: 0, time: nowSeconds(), job: userGuild.job });
|
||||
} else {
|
||||
await BossInstanceModel.updateRank(code, roleId);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { battleCode });
|
||||
}
|
||||
|
||||
async action (msg: { damage: number, battleCode: string }, session: BackendSession ) {
|
||||
async action(msg: { damage: number, battleCode: string }, session: BackendSession) {
|
||||
const { battleCode, damage } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const roleName: string = session.get('roleName');
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let flag = await checkBossBattleMemberExists(code, serverId, roleId, battleCode);
|
||||
if (!flag) {
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
}
|
||||
//记录伤害
|
||||
let bossInstance = await BossInstanceModel.updateBossHp(code, damage, roleId);
|
||||
if (!bossInstance|| bossInstance.bossHp == 0) {//进入结算
|
||||
if (!bossInstance || bossInstance.bossHp == 0) {//进入结算
|
||||
let flag = await bossResult(code, serverId, DATA_NAME.BOSS_SCRIPT, roleId, damage);
|
||||
if (!flag) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
@@ -175,13 +176,13 @@ export class GuildHandler {
|
||||
const funcs: number[] = session.get('funcs');
|
||||
const serverId: number = parseInt(session.get('serverId'));
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
const battleRecord = await BattleRecordModel.getBattleRecordByCode(battleCode, true);
|
||||
if (!battleRecord || battleRecord.status != 0 || roleId != battleRecord.roleId) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
}
|
||||
await BattleRecordModel.updateBattleRecordByCode(battleCode, {
|
||||
$set: { status: 1 }//战斗结束统一设置成1
|
||||
}, true);
|
||||
@@ -192,5 +193,5 @@ export class GuildHandler {
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_BOSS, 1, true, {});
|
||||
return resResult(STATUS.SUCCESS, result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, ChannelService } from 'pinus';
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from 'pinus';
|
||||
import { resResult, getRandEelm, shouldRefresh, sortArrRandom } from '../../../pubUtils/util';
|
||||
import { STATUS, GUILD_OPERATE, GUILD_AUTH, GUILD_JOB, GUILD_APPLY_TYPE, GUILD_STRUCTURE, GUILD_REC_TYPE, GUILD_STRUCTURE_NAME, MAIL_TYPE, REDIS_KEY, GUILD_SELECT, USER_GUILD_SELECT, TASK_TYPE } from '../../../consts';
|
||||
import { UserGuildModel, UserGuildType } from '../../../db/UserGuild';
|
||||
@@ -25,6 +25,7 @@ import { pushGuildNoticeUpdateMsg, pushGuildUpStructureMsg, addRoleToGuildChanne
|
||||
import { Rank } from '../../../services/rankService';
|
||||
import { checkTask } from '../../../services/taskService';
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
||||
import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, GUILD_OPERATE, TASK_TYPE } from '../../../consts';
|
||||
@@ -17,6 +17,7 @@ import { DATA_NAME } from '../../../consts/dataName';
|
||||
import { checkTask } from '../../../services/taskService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildRefineHandler(app);
|
||||
}
|
||||
|
||||
@@ -32,21 +33,21 @@ export class GuildRefineHandler {
|
||||
async getRefine(msg: {}, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let guildRefine = await GuildRefineModel.getRefine(code);
|
||||
if (!guildRefine) {
|
||||
guildRefine = await openGuildRefine(code);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees: guildRefine.scienceTrees });
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees: guildRefine.scienceTrees });
|
||||
}
|
||||
/**
|
||||
* 炼器
|
||||
* @param msg
|
||||
* @param session
|
||||
*/
|
||||
async refineEquip(msg: {pid: number}, session: BackendSession) {
|
||||
async refineEquip(msg: { pid: number }, session: BackendSession) {
|
||||
let { pid } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const sid: string = session.get('sid');
|
||||
@@ -54,10 +55,10 @@ export class GuildRefineHandler {
|
||||
const funcs: number[] = session.get('funcs');
|
||||
let pieceInfo = getGoodById(pid);
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let { guildCode: code } = userGuild;
|
||||
|
||||
|
||||
let { scienceTrees } = await GuildRefineModel.getRefine(code);
|
||||
let findDevelopConsume;
|
||||
//判断是否可以炼该兵器
|
||||
@@ -70,38 +71,38 @@ export class GuildRefineHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!findDevelopConsume)
|
||||
if (!findDevelopConsume)
|
||||
return resResult(STATUS.GUILD_NOT_REFINE_THE_EQUIP);
|
||||
let result = await handleCost(roleId, sid, findDevelopConsume.honourConsume);
|
||||
if(!result)
|
||||
if (!result)
|
||||
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
let goods = await addItems(roleId, roleName, sid, [{id: pid, count: 1}]);
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id: pid, count: 1 }]);
|
||||
|
||||
// 任务
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_REFINE, 1, true, { quality: pieceInfo.lvLimited });
|
||||
return resResult(STATUS.SUCCESS, { goods });
|
||||
}
|
||||
return resResult(STATUS.SUCCESS, { goods });
|
||||
}
|
||||
/**
|
||||
* 点亮科技树
|
||||
* @param msg
|
||||
* @param session
|
||||
*/
|
||||
async lightUpTree(msg: {id: number}, session: BackendSession) {
|
||||
async lightUpTree(msg: { id: number }, session: BackendSession) {
|
||||
let { id } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const serverId: number = session.get('serverId');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'auth guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const checkMyResult = await checkAuth(GUILD_OPERATE.EQUIP_PRODUCE, roleId, null, userGuild);
|
||||
if(!checkMyResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
if (!checkMyResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
const { guildCode: code } = userGuild;
|
||||
let developConsume = getArmyDevelopConsumeById(id);
|
||||
if (!developConsume)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let res:any = await lockData(serverId, DATA_NAME.GUILD_REFINE, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
let res: any = await lockData(serverId, DATA_NAME.GUILD_REFINE, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
let guildRefine = await GuildRefineModel.getRefine(code);
|
||||
let nowTime = nowSeconds();
|
||||
for (let scienceTree of guildRefine.scienceTrees) {
|
||||
@@ -109,51 +110,51 @@ export class GuildRefineHandler {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_LIGHT_UP_THE_SCIENCETREE);
|
||||
}
|
||||
|
||||
|
||||
if (scienceTree.endTime > nowTime) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_SCIENCETREE_IS_RUNNING);//检查是否有在进行的科技研发,若在研发,不允许研发其他科技树
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (let prePosition of developConsume.prePositions) {
|
||||
let scienceTree = findWhere(guildRefine.scienceTrees, {id: prePosition});
|
||||
if (!scienceTree||scienceTree.endTime > nowTime) {
|
||||
let scienceTree = findWhere(guildRefine.scienceTrees, { id: prePosition });
|
||||
if (!scienceTree || scienceTree.endTime > nowTime) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_PERSITION_TREE_NOT_LIGHT);//前置科技树未点亮
|
||||
}
|
||||
}
|
||||
//点亮消耗
|
||||
const costResult = await GuildModel.costFund(code, developConsume.fundConsume);
|
||||
if(!costResult) {
|
||||
if (!costResult) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_FUND_NOT_ENOUGH);
|
||||
}
|
||||
let scienceTree = { id, endTime: nowTime + developConsume.timeConsume, assistRoleIds: []}
|
||||
let scienceTree = { id, endTime: nowTime + developConsume.timeConsume, assistRoleIds: [] }
|
||||
let { scienceTrees } = await GuildRefineModel.pushRefine(code, scienceTree);
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees });
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees });
|
||||
}
|
||||
/**
|
||||
* 协助点亮科技树
|
||||
* @param msg
|
||||
* @param session
|
||||
*/
|
||||
async assistRefine(msg: {id: number}, session: BackendSession) {
|
||||
async assistRefine(msg: { id: number }, session: BackendSession) {
|
||||
let { id } = msg;
|
||||
const roleId: string = session.get('roleId');
|
||||
const serverId: number = session.get('serverId');
|
||||
const sid: string = session.get('sid');
|
||||
const funcs: number[] = session.get('funcs');
|
||||
let userGuild = await UserGuildModel.getMyGuild(roleId, 'guildCode');
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
if (!userGuild)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
const { guildCode: code } = userGuild;
|
||||
let res:any = await lockData(serverId, DATA_NAME.GUILD_ASSIST_REFINE, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
let res: any = await lockData(serverId, DATA_NAME.GUILD_ASSIST_REFINE, code);//加锁
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
let guildRefine = await GuildRefineModel.getRefine(code);
|
||||
|
||||
|
||||
let index = findIndex(guildRefine.scienceTrees, { id });
|
||||
if (index == -1) {
|
||||
res.releaseCallback();
|
||||
@@ -168,10 +169,10 @@ export class GuildRefineHandler {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_REACH_MAX_ASSIST_COUNT); //协助的人数已经达到最大
|
||||
}
|
||||
let result = await handleCost(roleId, sid, [{id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count: ARMY.ARMY_DEVELOPMENT_SPEEDCOST}]);
|
||||
let result = await handleCost(roleId, sid, [{ id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count: ARMY.ARMY_DEVELOPMENT_SPEEDCOST }]);
|
||||
if (!result) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
}
|
||||
scienceTree.assistRoleIds.push(roleId);
|
||||
scienceTree.endTime = scienceTree.endTime - ARMY.ARMY_DEVELOPMENT_SPEED * 60;
|
||||
@@ -181,6 +182,6 @@ export class GuildRefineHandler {
|
||||
// 任务
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.GUILD_ASSIST_REFINE, 1, true, {});
|
||||
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees });
|
||||
return resResult(STATUS.SUCCESS, { scienceTrees });
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { GuildTrainModel } from '../../../db/GuildTrain';
|
||||
@@ -22,6 +22,7 @@ import { checkActivityTask, checkTask } from '../../../services/taskService';
|
||||
import { sendPopUpActivityData } from '../../../services/guildActivityService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildTrainHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { BattleSweepRecordModel } from '../../../db/BattleSweepRecord';
|
||||
import { genCode } from '../../../pubUtils/util';
|
||||
@@ -26,6 +26,7 @@ import { challengeDailyGK } from '../../../services/activity/dailyGKService';
|
||||
import { challengeNewHeroGK } from '../../../services/activity/newHeroGKService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new NormalBattleHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
||||
import { uniq, findWhere, findIndex } from 'underscore';
|
||||
import { gameData, getPvpBoxs, getPLvByScore } from '../../../pubUtils/data';
|
||||
import { refreshEnemies, getEnemies, getLvByScore, defaultHeroes, comsumeChallengeCnt, refresh, findPvpDefByRoleId, checkRoleIsRobot, getRefOppCnt, findPvpDefAllByRoleId, generPVPOppRecInfo, generMyRecInfo, robotIdComBack } from '../../../services/pvpService';
|
||||
@@ -26,6 +26,7 @@ import { Rank } from '../../../services/rankService';
|
||||
import { checkActivityTask, checkTask, checkTaskInPvpEnd } from '../../../services/taskService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new PvpHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass } from 'pinus';
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass, HandlerService, } from 'pinus';
|
||||
import { reloadResources } from '../../../pubUtils/data';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new BattleRemote(app);
|
||||
}
|
||||
|
||||
@@ -70,7 +71,7 @@ export class BattleRemote {
|
||||
channel.leave(uid, sid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重载json资源
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass } from 'pinus';
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ComBattleRemote(app);
|
||||
}
|
||||
|
||||
@@ -113,7 +114,7 @@ export class ComBattleRemote {
|
||||
channel.pushMessage('onLeave', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
|
||||
public async hurt(uid: string, sid: string, name: string, bossHurt: number, actorHurt: [{actorId: number, actorHurt: number}]) {
|
||||
public async hurt(uid: string, sid: string, name: string, bossHurt: number, actorHurt: [{ actorId: number, actorHurt: number }]) {
|
||||
console.log('hurt channel name: ', name);
|
||||
let channelService = this.app.get('channelService');
|
||||
this.bossHp -= bossHurt;
|
||||
@@ -122,7 +123,7 @@ export class ComBattleRemote {
|
||||
if (this.bossHp < 0) {
|
||||
this.bossHp = 0;
|
||||
}
|
||||
channel.pushMessage('bossHp', resResult(STATUS.SUCCESS, {bossHp: this.bossHp}));
|
||||
channel.pushMessage('bossHp', resResult(STATUS.SUCCESS, { bossHp: this.bossHp }));
|
||||
}
|
||||
return this.bossHp;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CHANNEL_PREFIX, MSG_SOURCE, CHANNEL_TYPE } from './../../../consts/constModules/chatConst';
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { DEFAULT_MSG_PER_PAGE, STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs, updatePrivateMsgIsTop, delPrivateMsg } from '../../../services/chatService';
|
||||
@@ -8,6 +8,7 @@ import { checkActivityTask, checkTaskWithArgs } from '../../../services/taskServ
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ChatHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GroupMessageType } from './../../../db/GroupMessage';
|
||||
import { Application, ChannelService } from 'pinus';
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { ON_ADD_CHANNEL_ROUTE, ON_GROUP_MSG_ROUTE, ON_LEAVE_CHANNEL_ROUTE, STATUS, CHANNEL_PREFIX } from '../../../consts';
|
||||
import { PrivateMessageType } from '../../../db/PrivateMessage';
|
||||
@@ -12,6 +12,7 @@ import { getAllGuildActivityStatus } from '../../../services/guildActivityServic
|
||||
import { MailParam } from '../../../domain/roleField/mail';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ChatRemote(app);
|
||||
}
|
||||
|
||||
@@ -115,7 +116,7 @@ export class ChatRemote {
|
||||
let channel = this.channelService.getChannel(name, false);
|
||||
// leave channel
|
||||
if (!!channel) {
|
||||
channel.pushMessage('onWorldMessage', resResult(STATUS.SUCCESS, param));
|
||||
channel.pushMessage('onWorldMessage', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +182,7 @@ export class ChatRemote {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
channel.pushMessage(this.GUILD_ACTIVITY_END, resResult(STATUS.SUCCESS, { }));
|
||||
channel.pushMessage(this.GUILD_ACTIVITY_END, resResult(STATUS.SUCCESS, {}));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,15 +193,15 @@ export class ChatRemote {
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
channel.pushMessage(this.RACE_ACTIVITY_START, resResult(STATUS.SUCCESS, { }));
|
||||
channel.pushMessage(this.RACE_ACTIVITY_START, resResult(STATUS.SUCCESS, {}));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 全服推送排行榜更新信息
|
||||
* @param serverId
|
||||
*/
|
||||
public async sendRankTopUpdated(serverId: number, rank: (GeneralRankParamRole|GeneralRankParamBattle)&{general: number}) {
|
||||
|
||||
public async sendRankTopUpdated(serverId: number, rank: (GeneralRankParamRole | GeneralRankParamBattle) & { general: number }) {
|
||||
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return;
|
||||
@@ -245,10 +246,10 @@ export class ChatRemote {
|
||||
* @param serverId
|
||||
*/
|
||||
public async sendServerMaintenance(serverId: number) {
|
||||
|
||||
|
||||
let roomId = groupRoomId(CHANNEL_PREFIX.WORLD, serverId);
|
||||
let channel = this.channelService.getChannel(roomId, false);
|
||||
if (!channel) return { result: false, serverId };
|
||||
if (!channel) return { result: false, serverId };
|
||||
channel.pushMessage('onServerMaintenance', resResult(STATUS.SERVER_MAINTENANCE));
|
||||
return { result: true, serverId };
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, ChannelService } from 'pinus';
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS, CHANNEL_PREFIX } from '../../../consts';
|
||||
import { GuildType } from '../../../db/Guild';
|
||||
@@ -9,6 +9,7 @@ import { GuildRankParams, WoodenHorse, Event } from '../../../domain/battleField
|
||||
import { MailParam } from '../../../domain/roleField/mail';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildRemote(app);
|
||||
}
|
||||
|
||||
@@ -301,7 +302,7 @@ export class GuildRemote {
|
||||
* @param path 推送地址
|
||||
* @param data 军团内容
|
||||
*/
|
||||
public async sendMailToGuild(guildCode: string, path: string, data: { mails: MailParam[]}) {
|
||||
public async sendMailToGuild(guildCode: string, path: string, data: { mails: MailParam[] }) {
|
||||
this.pushMessage(guildCode, path, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { EquipModel } from './../../../db/Equip';
|
||||
import { RoleModel, RoleType } from './../../../db/Role';
|
||||
import { UserModel } from '../../../db/User';
|
||||
import { GMUserModel } from '../../../db/GMUser';
|
||||
import { Application } from 'pinus';
|
||||
import { Application, HandlerService, } from 'pinus';
|
||||
import { FrontendSession } from 'pinus';
|
||||
import { HeroModel } from './../../../db/Hero';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
@@ -24,6 +24,7 @@ import { pushData, everydayRefresh } from '../../../services/connectorService';
|
||||
import { pick } from 'lodash';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new EntryHandler(app);
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ export class EntryHandler {
|
||||
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);
|
||||
// 推送数据
|
||||
if(role.hasInit) pushData(role, session);
|
||||
if (role.hasInit) pushData(role, session);
|
||||
|
||||
role['heros'] = heros;
|
||||
role['equips'] = equips;
|
||||
@@ -154,7 +155,7 @@ export class EntryHandler {
|
||||
* @param {Object} msg request message
|
||||
* @param {Object} session current session object
|
||||
*/
|
||||
async refresh(msg: { }, session: FrontendSession) {
|
||||
async refresh(msg: {}, session: FrontendSession) {
|
||||
let self = this;
|
||||
let roleId = session.get('roleId');
|
||||
|
||||
@@ -304,7 +305,7 @@ export class EntryHandler {
|
||||
return resResult(STATUS.TOKEN_ERR);
|
||||
}
|
||||
await everydayRefresh();
|
||||
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Application, ChannelService, FrontendSession, pinus, RemoterClass } from 'pinus';
|
||||
import { Application, ChannelService, FrontendSession, pinus, RemoterClass, HandlerService, } from 'pinus';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { reloadResources } from '../../../pubUtils/data';
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ConnectorRemote(app);
|
||||
}
|
||||
|
||||
@@ -19,21 +20,21 @@ export class ConnectorRemote {
|
||||
let sessionService = this.app.get('sessionService');
|
||||
let sessions = sessionService.getByUid(uid);
|
||||
if (!!sessions) {
|
||||
sessions.forEach(session=>{
|
||||
sessions.forEach(session => {
|
||||
let roleId = session.get('roleId');
|
||||
let sid = session.get('sid');
|
||||
let uids = [{uid: roleId, sid}];
|
||||
this.channelService.pushMessageByUids('onRemoteLogin', resResult(STATUS.SERVER_MAINTENANCE ), uids);
|
||||
let uids = [{ uid: roleId, sid }];
|
||||
this.channelService.pushMessageByUids('onRemoteLogin', resResult(STATUS.SERVER_MAINTENANCE), uids);
|
||||
});
|
||||
}
|
||||
await sessionService.akick(uid);
|
||||
}
|
||||
|
||||
public async pushMessage( uid: string, route: string, data:any) {
|
||||
public async pushMessage(uid: string, route: string, data: any) {
|
||||
let sid = pinus.app.getServerId();
|
||||
if (!!sid) {
|
||||
let uids = [{uid, sid}];
|
||||
this.channelService.pushMessageByUids(route, resResult(STATUS.SUCCESS, {mails:data}), uids);
|
||||
let uids = [{ uid, sid }];
|
||||
this.channelService.pushMessageByUids(route, resResult(STATUS.SUCCESS, { mails: data }), uids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ export class ConnectorRemote {
|
||||
public setServerMainten(maintenServers: number[]) {
|
||||
return this.maintenServers = maintenServers;
|
||||
}
|
||||
|
||||
|
||||
public getServerMainten() {
|
||||
return this.maintenServers;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { STATUS } from './../../../consts/statusCode';
|
||||
import { dispatch } from '../../../util/dispatcher';
|
||||
import { Application , BackendSession} from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GateHandler(app);
|
||||
}
|
||||
|
||||
@@ -18,7 +19,7 @@ export class GateHandler {
|
||||
* @param {Object} session
|
||||
*
|
||||
*/
|
||||
async queryEntry(msg: {userCode: string}, session: BackendSession) {
|
||||
async queryEntry(msg: { userCode: string }, session: BackendSession) {
|
||||
let { userCode } = msg;
|
||||
if (!userCode) {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
@@ -31,6 +32,6 @@ export class GateHandler {
|
||||
}
|
||||
// select connector
|
||||
let res = dispatch(userCode, connectors);
|
||||
return resResult(STATUS.SUCCESS, {host: res.clientHost, port: res.clientPort});
|
||||
return resResult(STATUS.SUCCESS, { host: res.clientHost, port: res.clientPort });
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass } from 'pinus';
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass, HandlerService, } from 'pinus';
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GateRemote(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, ChannelService } from 'pinus';
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { setGmMails, getGmMailById, getGmMails, getGmUseMails } from '../../../pubUtils/gmData/gmDataUtil';
|
||||
@@ -11,6 +11,7 @@ import { MailType } from '../../../db/Mail';
|
||||
import { mongoose } from '@typegoose/typegoose';
|
||||
const { ObjectId } = mongoose.Types;
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GMRemote(app);
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ export class GMRemote {
|
||||
channel.pushMessage('onLeave', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
|
||||
public refreshGmMails(mails:[any]) {
|
||||
public refreshGmMails(mails: [any]) {
|
||||
setGmMails(mails);
|
||||
}
|
||||
|
||||
@@ -109,7 +110,7 @@ export class GMRemote {
|
||||
* @param updatedMailAt
|
||||
* @param serverId
|
||||
*/
|
||||
public getMailsByTime(updatedMailAt: number, serverId: number) {
|
||||
public getMailsByTime(updatedMailAt: number, serverId: number) {
|
||||
let gmMails = getGmMails(updatedMailAt, serverId);
|
||||
return gmMails;
|
||||
}
|
||||
@@ -163,7 +164,7 @@ export class GMRemote {
|
||||
* @param serverId
|
||||
* @param nowTime
|
||||
*/
|
||||
public getUseGmMailById(mailId: string, serverId: number, nowTime: number ) {
|
||||
public getUseGmMailById(mailId: string, serverId: number, nowTime: number) {
|
||||
let gmMail = getGmMailById(mailId, serverId, nowTime);
|
||||
return gmMail;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, ChannelService, BackendSession, pinus } from "pinus";
|
||||
import { Application, ChannelService, BackendSession, pinus, HandlerService, } from "pinus";
|
||||
import { GUILD_ACTIVITY_TYPE, STATUS, REDIS_KEY, GUILD_POINT_WAYS, CITY_STATUS, TASK_TYPE } from "../../../consts";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { getGuildActivityStatus, getCityActivityObj, getCityStatus as pubGetCityStatus, getCities, getCityActivityRank, sendSingleCityActEndMsg, getMedianCe } from "../../../services/guildActivityService";
|
||||
@@ -17,6 +17,7 @@ import { Rank } from "../../../services/rankService";
|
||||
import { checkActivityTask, checkTask } from "../../../services/taskService";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new CityActivityHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, ChannelService, pinus } from "pinus";
|
||||
import { Application, BackendSession, ChannelService, pinus, HandlerService, } from "pinus";
|
||||
import { getMedianCe, getGuildActivityStatus, getRecordScore, getGateActivityObj, sendSingleGateActEndMsg, participants, getGateActivityRank, getCityActivityObj } from "../../../services/guildActivityService";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { STATUS, GUILD_ACTIVITY_TYPE, GUILD_POINT_WAYS, ENEMIES_TYPE, GET_POINT_WAYS, TASK_TYPE } from "../../../consts";
|
||||
@@ -17,6 +17,7 @@ import { getTimeFun } from "../../../pubUtils/timeUtil";
|
||||
import { checkActivityTask, checkTask } from "../../../services/taskService";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GateActivityHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, ChannelService, BackendSession } from "pinus";
|
||||
import { Application, ChannelService, BackendSession, HandlerService, } from "pinus";
|
||||
import { GUILD_ACTIVITY_TYPE, STATUS, GUILD_ACTIVITY_STATUS, GUILD_POINT_WAYS, REDIS_KEY, TASK_TYPE } from "../../../consts";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { getGuildActivityStatus, getRaceActivityObj, getRaceActivityRank, getWoodenHorseList, calWoodenHorseAndSend, raceActivitySettleReward } from "../../../services/guildActivityService";
|
||||
@@ -10,6 +10,7 @@ import { Rank } from "../../../services/rankService";
|
||||
import { checkActivityTask, checkTask } from "../../../services/taskService";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new RaceActivityHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Application, ChannelService } from 'pinus';
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { sendAllGuildRanks, sendGuildActEndMsg, calWoodenHorseAndSend, sendRaceStartMsg } from '../../../services/guildActivityService';
|
||||
import { gameData } from '../../../pubUtils/data';
|
||||
import { setWeek } from '../../../pubUtils/timeUtil';
|
||||
import { getAllServers } from '../../../services/redisService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildActivityRemote(app);
|
||||
}
|
||||
|
||||
@@ -52,7 +53,7 @@ export class GuildActivityRemote {
|
||||
let guildActivity = gameData.guildActivity;
|
||||
let cur = guildActivity.get(aid);
|
||||
|
||||
if(isStart) {
|
||||
if (isStart) {
|
||||
let now = new Date();
|
||||
cur.startMinute = now.getMinutes();
|
||||
cur.startTime = now.getHours();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Application, ChannelService } from 'pinus';
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { reloadResources } from '../../../pubUtils/data';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new GuildRemote(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { genCode, resResult } from '../../../pubUtils/util';
|
||||
import { ACTIVITY_TYPE, DEBUG_MAGIC_WORD, ORDER_STATE, PAY_TYPE, STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { dicRMB } from '../../../pubUtils/dictionary/DicRMB';
|
||||
@@ -14,6 +14,7 @@ import { addVipRechargeMoney } from '../../../services/activity/vipRechargeMoney
|
||||
import { checkActivityTask } from '../../../services/taskService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new orderHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Application, ChannelService } from 'pinus';
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { reloadResources } from '../../../pubUtils/data';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new OrderRemote(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { Application, BackendSession, HandlerService, } from "pinus";
|
||||
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, HERO_GROW_MAX, MSG_SOURCE, JEWEL_PUSH_LV, TASK_TYPE, HERO_CE_RATIO } from "../../../consts";
|
||||
import { ItemInter } from "../../../pubUtils/interface";
|
||||
|
||||
@@ -19,6 +19,7 @@ import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs, ch
|
||||
import { Attribute } from "../../../domain/roleField/attribute";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new EquipHandler(app);
|
||||
}
|
||||
|
||||
@@ -64,8 +65,8 @@ export class EquipHandler {
|
||||
if (specialMaterial.ids.includes(id)) {
|
||||
costCount++;
|
||||
cost.push({ id, seqId, count: 1 });
|
||||
for(let { jewel } of holes) {
|
||||
if(jewel > 0) jewels.push({ id: jewel, count: 1});
|
||||
for (let { jewel } of holes) {
|
||||
if (jewel > 0) jewels.push({ id: jewel, count: 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -476,8 +477,8 @@ export class EquipHandler {
|
||||
if (!goodInfo)
|
||||
return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
|
||||
let holes = equip.holes||[];
|
||||
for(let { jewel } of holes) {
|
||||
let holes = equip.holes || [];
|
||||
for (let { jewel } of holes) {
|
||||
jewels.push({ id: jewel, count: 1 });
|
||||
}
|
||||
goods = goods.concat(goodInfo.decomposeItem);
|
||||
@@ -552,7 +553,7 @@ export class EquipHandler {
|
||||
let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
if(!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let dicJob = gameData.job.get(dicHero.jobid);
|
||||
|
||||
|
||||
@@ -570,29 +571,29 @@ export class EquipHandler {
|
||||
let { ePlace, lv } = hero;
|
||||
|
||||
let curEquips: Array<{ seqId: number, hid: number }> = [];
|
||||
for(let curEPlace of ePlace) {
|
||||
if(!curEPlace.equip) { // 未装备
|
||||
for (let curEPlace of ePlace) {
|
||||
if (!curEPlace.equip) { // 未装备
|
||||
let sortAttrId = equipTypeToSortAttr.get(curEPlace.id);
|
||||
let sortedAndSuitEquips = sortEquips.filter(equipInfos => { // 筛选可穿的
|
||||
let { lvLimited, classId, ePlaceId } = equipInfos;
|
||||
return lv >= lvLimited && classId.indexOf(dicJob.job_class) != -1 && curEPlace.id == ePlaceId;
|
||||
}).sort((a, b) => { // 排序按:战力 => 根据位置看个别属性 => 品质
|
||||
if(b.ce - a.ce != 0) return b.ce - a.ce;
|
||||
let abilityA = a.goodsAbility.get(sortAttrId)||0;
|
||||
let abilityB = b.goodsAbility.get(sortAttrId)||0;
|
||||
if( abilityA - abilityB != 0) return abilityB - abilityA;
|
||||
if (b.ce - a.ce != 0) return b.ce - a.ce;
|
||||
let abilityA = a.goodsAbility.get(sortAttrId) || 0;
|
||||
let abilityB = b.goodsAbility.get(sortAttrId) || 0;
|
||||
if (abilityA - abilityB != 0) return abilityB - abilityA;
|
||||
return b.quality - a.quality;
|
||||
});
|
||||
|
||||
if(sortedAndSuitEquips.length > 0) {
|
||||
if (sortedAndSuitEquips.length > 0) {
|
||||
let { equip } = sortedAndSuitEquips.shift();
|
||||
let curEquip = await dressEquip(serverId, roleId, sid, hero,equip, funcs);
|
||||
if(!!curEquip) curEquips.push(curEquip);
|
||||
let curEquip = await dressEquip(serverId, roleId, sid, hero, equip, funcs);
|
||||
if (!!curEquip) curEquips.push(curEquip);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(curEquips.length > 0) {
|
||||
if (curEquips.length > 0) {
|
||||
//任务
|
||||
//英雄满装备且都镶嵌相同阶数的宝石
|
||||
let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(hero)
|
||||
@@ -878,41 +879,41 @@ export class EquipHandler {
|
||||
* @returns
|
||||
* @memberof ComBattleHandler
|
||||
*/
|
||||
async composeBlueprt(msg: { target: number, original: Array<{id: number, count: number}>}, session: BackendSession) {
|
||||
async composeBlueprt(msg: { target: number, original: Array<{ id: number, count: number }> }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const sid = session.get('sid');
|
||||
const serverId = session.get('serverId');
|
||||
const funcs: number[] = session.get('funcs');
|
||||
|
||||
|
||||
const { target, original } = msg;
|
||||
|
||||
// 原材料检查
|
||||
let originalQuality: number, originalSum: number = 0;
|
||||
for(let {id, count} of original) {
|
||||
for (let { id, count } of original) {
|
||||
const goodInfo = gameData.goods.get(id);
|
||||
if(!originalQuality) originalQuality = goodInfo.quality;
|
||||
if(originalQuality != goodInfo.quality) {
|
||||
if (!originalQuality) originalQuality = goodInfo.quality;
|
||||
if (originalQuality != goodInfo.quality) {
|
||||
return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
}
|
||||
|
||||
if(goodInfo.itid == IT_TYPE.BLUEPRT) {
|
||||
if (goodInfo.itid == IT_TYPE.BLUEPRT) {
|
||||
originalSum += count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const dicCompose = gameData.blurprtCompose.get(originalQuality);
|
||||
if(!dicCompose) {
|
||||
if (!dicCompose) {
|
||||
return resResult(STATUS.COM_BLUEPRT_QUALITY_CANNOT_COMPOSE);
|
||||
}
|
||||
if(originalSum != dicCompose.blueprtNum) {
|
||||
}
|
||||
if (originalSum != dicCompose.blueprtNum) {
|
||||
return resResult(STATUS.COM_BLUEPRT_COUNT_ERROR);
|
||||
}
|
||||
|
||||
let dicTargetInfo = gameData.goods.get(target);
|
||||
if(!dicTargetInfo) return resResult(STATUS.WRONG_PARMS);
|
||||
if(dicTargetInfo.quality != dicCompose.targetQuality) return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
if (!dicTargetInfo) return resResult(STATUS.WRONG_PARMS);
|
||||
if (dicTargetInfo.quality != dicCompose.targetQuality) return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
|
||||
// 添加寻宝币
|
||||
original.push({
|
||||
@@ -922,16 +923,16 @@ export class EquipHandler {
|
||||
// 消耗藏宝图和寻宝币
|
||||
|
||||
let costResult = await handleCost(roleId, sid, original);
|
||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
const reward = [{id: target, count: 1}];
|
||||
const reward = [{ id: target, count: 1 }];
|
||||
const goods = await addItems(roleId, roleName, sid, reward);
|
||||
if (dicCompose.targetQuality >= QUALITY_TYPE.ORANGE) {
|
||||
const { name } = gameData.goods.get(target);
|
||||
pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.ORANGE_BLUEPRT_COMPOSE, target, name);
|
||||
}
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.COM_BATTLE_BLUEPRT, 1, true, { quality: dicCompose.targetQuality });
|
||||
|
||||
|
||||
return resResult(STATUS.SUCCESS, { goods, costGold: 0 });
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, ChannelService } from "pinus";
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from "pinus";
|
||||
import { resResult, getRandEelm, getResStr, shouldRefresh, sortArrRandom } from "../../../pubUtils/util";
|
||||
import { STATUS, ROLE_SELECT, FRIEND_DROP_TYPE, FRIEND_RELATION_TYPE, POPULATE_TYPE, BLOCK_OPEATE, CONSUME_TYPE, ITID, HERO_SELECT, EQUIP_SELECT, REDIS_KEY, MSG_SOURCE, MSG_TYPE, TASK_TYPE } from "../../../consts";
|
||||
import { RoleModel, RoleType } from "../../../db/Role";
|
||||
@@ -26,6 +26,7 @@ import { checkTaskWithRoles, checkTask, checkActivityTask } from "../../../servi
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new FriendHandler(app);
|
||||
}
|
||||
|
||||
@@ -676,9 +677,9 @@ export class FriendHandler {
|
||||
list.push({
|
||||
roleId, roleName, hid, hName, ce, lv, star, colorStar, quality, job,
|
||||
skin: curSkin ? curSkin.id : 0, equips: equips.map(cur => {
|
||||
let curEplace = ePlace.find(ccur => cur.ePlaceId == ccur.id)||new EPlace();
|
||||
let { lv = 0, refineLv = 0} = curEplace;
|
||||
return {...cur, lv, refineLv}
|
||||
let curEplace = ePlace.find(ccur => cur.ePlaceId == ccur.id) || new EPlace();
|
||||
let { lv = 0, refineLv = 0 } = curEplace;
|
||||
return { ...cur, lv, refineLv }
|
||||
}), attributes
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, ChannelService } from 'pinus';
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from 'pinus';
|
||||
import { handleCost, addItems, unlockFigure, createHero } from '../../../services/rewardService';
|
||||
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
|
||||
import { resResult, deepCopy } from '../../../pubUtils/util';
|
||||
@@ -18,6 +18,7 @@ import { addSkin } from '../../../pubUtils/itemUtils';
|
||||
import Skin from '../../../db/Skin';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new HeroHandler(app);
|
||||
}
|
||||
|
||||
@@ -209,7 +210,7 @@ export class HeroHandler {
|
||||
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let { pieceId, jobid } = dicHero;
|
||||
let dicJob = gameData.job.get(jobid);
|
||||
if(!dicJob) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicJob) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.ROLE_HERO_NOT_EXISTS);
|
||||
@@ -224,15 +225,15 @@ export class HeroHandler {
|
||||
// 根据dic_zyz_hero_star 计算需要花的碎片并检查碎片数量
|
||||
const curDicHeroStar = getHeroStarByQuality(dicJob.job_class, quality, oldStar);
|
||||
if (!curDicHeroStar) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
|
||||
let newStarStage = 0;
|
||||
let max = isOneClick? ABI_STAGE.END: oldStarStage + 1;
|
||||
for(let i = 0; i < max; i++ ) {
|
||||
let max = isOneClick ? ABI_STAGE.END : oldStarStage + 1;
|
||||
for (let i = 0; i < max; i++) {
|
||||
let costResult = await handleCost(roleId, sid, [{ id: pieceId, count: curDicHeroStar.advanceUpFragmentNum }]);
|
||||
if (!costResult) break;
|
||||
newStarStage++;
|
||||
}
|
||||
if(newStarStage == 0) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (newStarStage == 0) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let isUpStar = newStarStage == ABI_STAGE.END;
|
||||
|
||||
@@ -350,16 +351,16 @@ export class HeroHandler {
|
||||
if (!curDicHeroStar) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let newColorStarStage = 0;
|
||||
let max = isOneClick? ABI_STAGE.END: oldColorStarStage + 1;
|
||||
for(let i = 0; i < max; i++) {
|
||||
let max = isOneClick ? ABI_STAGE.END : oldColorStarStage + 1;
|
||||
for (let i = 0; i < max; i++) {
|
||||
let { fragmentNum, consume } = curDicHeroStar;
|
||||
|
||||
|
||||
// console.log(JSON.stringify([{id: pieceId, count: fragmentNum}, ...consumeArr]))
|
||||
let costResult = await handleCost(roleId, sid, [{ id: pieceId, count: fragmentNum }, ...consume]);
|
||||
if (!costResult) break;
|
||||
newColorStarStage++;
|
||||
}
|
||||
if(newColorStarStage == 0) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (newColorStarStage == 0) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let isWakeUp = oldColorStar == 0;
|
||||
let isUpStar = isWakeUp || newColorStarStage == ABI_STAGE.END;
|
||||
@@ -540,7 +541,7 @@ export class HeroHandler {
|
||||
|
||||
let { favourLv: oldLv, favour: oldExp, lv } = hero;
|
||||
|
||||
let maxLv = lv > gameData.maxFriendShipLv.max? gameData.maxFriendShipLv.max: lv; // 好感度最大等级
|
||||
let maxLv = lv > gameData.maxFriendShipLv.max ? gameData.maxFriendShipLv.max : lv; // 好感度最大等级
|
||||
if (maxLv <= oldLv)
|
||||
return resResult(STATUS.HERO_FAVOUR_LEVEL_REACH_MAXT);
|
||||
|
||||
@@ -614,14 +615,14 @@ export class HeroHandler {
|
||||
if (!!skin.enable) {
|
||||
return resResult(STATUS.HERO_SKIN_IS_EQUIPED);
|
||||
}
|
||||
newHeroSkins.push({...skin, enable: true});
|
||||
newHeroSkins.push({ ...skin, enable: true });
|
||||
result = true;
|
||||
} else {
|
||||
if (!!skin.enable) {
|
||||
lastSkinId = skin.id;
|
||||
}
|
||||
|
||||
newHeroSkins.push({...skin, enable: false});
|
||||
newHeroSkins.push({ ...skin, enable: false });
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { Application, BackendSession, HandlerService, } from "pinus";
|
||||
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, HERO_GROW_MAX, MSG_SOURCE, JEWEL_PUSH_LV, TASK_TYPE, DEBUG_MAGIC_WORD } from "../../../consts";
|
||||
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
|
||||
|
||||
@@ -24,6 +24,7 @@ import { GiftCodeType, GiftCodeModel } from "../../../db/GiftCode";
|
||||
import UserGiftCode, { UserGiftCodeModel } from "../../../db/UserGiftCode";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ItemHandler(app);
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ export class ItemHandler {
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let { isOver } = await getAp(roleId, role.lv);
|
||||
if(isOver) return resResult(STATUS.AP_IS_FULL);
|
||||
if (isOver) return resResult(STATUS.AP_IS_FULL);
|
||||
|
||||
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }]);
|
||||
if (!consumeResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
@@ -111,7 +112,7 @@ export class ItemHandler {
|
||||
const roleName: string = session.get('roleName');
|
||||
const sid: string = session.get('sid');
|
||||
|
||||
if(count <= 0) return resResult(STATUS.WRONG_PARMS);
|
||||
if (count <= 0) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
if (!dicGoods) {
|
||||
@@ -125,18 +126,18 @@ export class ItemHandler {
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let { buyTimes = 0 } = await getAp(roleId, role.lv);
|
||||
if(buyTimes + count > gameData.apMaxBuyTimes.max) return resResult(STATUS.AP_BUY_TIMES_LACK);
|
||||
if (buyTimes + count > gameData.apMaxBuyTimes.max) return resResult(STATUS.AP_BUY_TIMES_LACK);
|
||||
|
||||
let cost: RewardInter[] = [];
|
||||
for(let i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
let curCost = gameData.apBuy.get(++buyTimes);
|
||||
if(curCost) cost = cost.concat(curCost);
|
||||
if (curCost) cost = cost.concat(curCost);
|
||||
}
|
||||
|
||||
let consumeResult = await handleCost(roleId, sid, cost);
|
||||
if (!consumeResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, [{id, count}]);
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id, count }]);
|
||||
let apJson = await setApBuyTimes(roleId, role.lv, sid, count);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
@@ -153,15 +154,15 @@ export class ItemHandler {
|
||||
|
||||
let giftCodeDetail = await GiftCodeDetailModel.findByCode(code);
|
||||
let giftCode = <GiftCodeType>giftCodeDetail.giftCode;
|
||||
|
||||
if(giftCode.isLimit && giftCodeDetail.usedNum >= giftCode.count) {
|
||||
|
||||
if (giftCode.isLimit && giftCodeDetail.usedNum >= giftCode.count) {
|
||||
return resResult(STATUS.GIFT_CODE_USED_NUM_MAX);
|
||||
}
|
||||
if(giftCode.beginTime > new Date()) return resResult(STATUS.GIFT_CODE_NOT_START);
|
||||
if(giftCode.endTime < new Date()) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED);
|
||||
if (giftCode.beginTime > new Date()) return resResult(STATUS.GIFT_CODE_NOT_START);
|
||||
if (giftCode.endTime < new Date()) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED);
|
||||
|
||||
let userGiftCode = await UserGiftCodeModel.findByCode(roleId, code);
|
||||
if(userGiftCode) {
|
||||
if (userGiftCode) {
|
||||
return resResult(STATUS.YOU_HAVE_USED_THIS_CODE);
|
||||
}
|
||||
|
||||
@@ -185,7 +186,7 @@ export class ItemHandler {
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let apJson = await setAp(roleId, role.lv, msg.ap, sid, funcs);
|
||||
if(!apJson) return resResult(STATUS.BATTLE_ACTION_POINT_LACK)
|
||||
if (!apJson) return resResult(STATUS.BATTLE_ACTION_POINT_LACK)
|
||||
return resResult(STATUS.SUCCESS, { apJson });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { Application, BackendSession, HandlerService, } from "pinus";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { STATUS, RANK_TYPE_TO_KEY, ROLE_SELECT, RANK_TYPE, HERO_SELECT, GUILD_SELECT } from "../../../consts";
|
||||
import { RoleModel } from "../../../db/Role";
|
||||
@@ -12,6 +12,7 @@ import { HeroModel, HeroUpdate } from "../../../db/Hero";
|
||||
import { RewardInter } from "../../../pubUtils/interface";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new RoleHandler(app);
|
||||
}
|
||||
|
||||
@@ -25,7 +26,7 @@ export class RoleHandler {
|
||||
let serverId = session.get('serverId');
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'rankReceived');
|
||||
if(!role) return resResult(STATUS.WRONG_PARMS);
|
||||
if (!role) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let res = await getGeneralRank(role, serverId);
|
||||
|
||||
@@ -38,13 +39,13 @@ export class RoleHandler {
|
||||
|
||||
let { type } = msg;
|
||||
let redisKey = RANK_TYPE_TO_KEY.get(type);
|
||||
if(!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
if (!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
let r = new Rank(redisKey, { serverId });
|
||||
|
||||
let { ranks, myRank } = await r.getRankListWithMyRank({roleId});
|
||||
if(!myRank) {
|
||||
let { ranks, myRank } = await r.getRankListWithMyRank({ roleId });
|
||||
if (!myRank) {
|
||||
let role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.RANK, true);
|
||||
if(type == RANK_TYPE.TOP_LINTUP) {
|
||||
if (type == RANK_TYPE.TOP_LINTUP) {
|
||||
myRank = await r.generMyRankWithRole(roleId, role.topLineupCe, 0, role);
|
||||
} else if (type == RANK_TYPE.TOP_HERO) {
|
||||
let hero = await HeroModel.getMyTopHero(roleId, HERO_SELECT.RANK_LINEUP);
|
||||
@@ -56,7 +57,7 @@ export class RoleHandler {
|
||||
} else if (type == RANK_TYPE.SUM_CE) {
|
||||
myRank = await r.generMyRankWithRole(roleId, role.ce, role.updatedAt.getTime(), role);
|
||||
} else if (type == RANK_TYPE.TOWER) {
|
||||
myRank = await r.generMyRankWithRole(roleId, role.towerLv, role.towerUpTime?.getTime()||0, role);
|
||||
myRank = await r.generMyRankWithRole(roleId, role.towerLv, role.towerUpTime?.getTime() || 0, role);
|
||||
} else if (type == RANK_TYPE.DUNGEON) {
|
||||
myRank = await r.generMyRankWithRole(roleId, role.dungeonWarId, role.dungeonUpdatedAt, role);
|
||||
} else if (type == RANK_TYPE.MAIN) {
|
||||
@@ -78,16 +79,16 @@ export class RoleHandler {
|
||||
let { type } = msg;
|
||||
|
||||
let redisKey = RANK_TYPE_TO_KEY.get(type);
|
||||
if(!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
if (!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let r = new Rank(redisKey, { serverId });
|
||||
const myUserGuild = await UserGuildModel.getMyGuild(roleId, 'auth guildCode');
|
||||
let { ranks, myRank } = await r.getRankListWithMyRank({guildCode: myUserGuild?.guildCode||''});
|
||||
let { ranks, myRank } = await r.getRankListWithMyRank({ guildCode: myUserGuild?.guildCode || '' });
|
||||
if (!myRank) {
|
||||
let guild = await GuildModel.findByCode(myUserGuild.guildCode, serverId, GUILD_SELECT.RANK);
|
||||
if(type == RANK_TYPE.GUILD_LV) {
|
||||
if (type == RANK_TYPE.GUILD_LV) {
|
||||
myRank = await r.generMyRankWithGuild(guild.code, guild.lv, guild.lvUpdateTime, guild);
|
||||
} else if(type == RANK_TYPE.GUILD_ACTIVE) {
|
||||
} else if (type == RANK_TYPE.GUILD_ACTIVE) {
|
||||
myRank = await r.generMyRankWithGuild(guild.code, guild.activeWeekly, guild.activeUpdateTime, guild);
|
||||
}
|
||||
}
|
||||
@@ -102,7 +103,7 @@ export class RoleHandler {
|
||||
|
||||
let { type, hid } = msg;
|
||||
let redisKey = RANK_TYPE_TO_KEY.get(type);
|
||||
if(!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
if (!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let r = new Rank(redisKey, { serverId, hid });
|
||||
let ranks = await r.getRankByRange();
|
||||
@@ -121,9 +122,9 @@ export class RoleHandler {
|
||||
let { type, id } = msg;
|
||||
|
||||
let ids: number[] = [];
|
||||
if(id == 0) {
|
||||
gameData.generalRankReward.forEach((dic, id)=> {
|
||||
if(dic.rankId == type) {
|
||||
if (id == 0) {
|
||||
gameData.generalRankReward.forEach((dic, id) => {
|
||||
if (dic.rankId == type) {
|
||||
ids.push(id);
|
||||
}
|
||||
});
|
||||
@@ -134,25 +135,25 @@ export class RoleHandler {
|
||||
let canReceiveId: number[] = [];
|
||||
let role = await RoleModel.findByRoleId(roleId, 'rankReceived');
|
||||
|
||||
for(let id of ids) {
|
||||
for (let id of ids) {
|
||||
let dicReward = gameData.generalRankReward.get(id);
|
||||
if(!dicReward || dicReward.rankId != type) continue;
|
||||
|
||||
if (!dicReward || dicReward.rankId != type) continue;
|
||||
|
||||
let redisKey = RANK_TYPE_TO_KEY.get(type);
|
||||
let r = new Rank(redisKey, { serverId }, false, 1);
|
||||
let ranks = await r.getRankByRange();
|
||||
let num = ranks.length > 0? ranks[0].num: 0;
|
||||
if(num < dicReward.condition) continue;
|
||||
|
||||
if(role.rankReceived.includes(id)) continue;
|
||||
|
||||
let num = ranks.length > 0 ? ranks[0].num : 0;
|
||||
if (num < dicReward.condition) continue;
|
||||
|
||||
if (role.rankReceived.includes(id)) continue;
|
||||
|
||||
let reward = dicReward.reward;
|
||||
rewards = rewards.concat(reward);
|
||||
canReceiveId.push(id);
|
||||
}
|
||||
|
||||
role = await RoleModel.receiveRankReward(roleId, canReceiveId);
|
||||
if(canReceiveId.length <= 0) return resResult(STATUS.REWARD_CONDITION_NOT_REACH);
|
||||
if (canReceiveId.length <= 0) return resResult(STATUS.REWARD_CONDITION_NOT_REACH);
|
||||
|
||||
let received = role.rankReceived.filter(rewardId => {
|
||||
let dic = gameData.generalRankReward.get(rewardId);
|
||||
@@ -168,12 +169,12 @@ export class RoleHandler {
|
||||
})
|
||||
}
|
||||
|
||||
async test(msg: { }, session: BackendSession) {
|
||||
async test(msg: {}, session: BackendSession) {
|
||||
let roles = await RoleModel.find({}).lean();
|
||||
for(let role of roles) {
|
||||
for (let role of roles) {
|
||||
let heroes = await HeroModel.find({ roleId: role.roleId }).lean();
|
||||
await RoleModel.updateRoleInfo(role.roleId, { heroNum: heroes.length, heroNumUpdatedAt: nowSeconds() });
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { STATUS } from '../../../consts/statusCode';
|
||||
import { RoleModel } from './../../../db/Role';
|
||||
import { HeroModel } from '../../../db/Hero';
|
||||
import { resResult, decodeIdCntArrayStr, parseGoodStr } from '../../../pubUtils/util';
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
||||
import { handleCost, addItems, createHeroes } from '../../../services/rewardService';
|
||||
import { getTitle, getTeraph, gameData, getScollByStar, getFriendLvByExp, getHeroExpByLv } from '../../../pubUtils/data';
|
||||
import { SCHOOL, SCROLL, EXTERIOR, SCRIPT } from '../../../pubUtils/dicParam';
|
||||
@@ -23,6 +23,7 @@ import { checkPvp } from '../../../services/pvpService';
|
||||
import { pushData } from '../../../services/connectorService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new RoleHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, pinus } from "pinus";
|
||||
import { Application, BackendSession, pinus, HandlerService, } from "pinus";
|
||||
import { resResult, parseGoodStr, getRandSingleEelm } from "../../../pubUtils/util";
|
||||
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE } from "../../../consts";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
@@ -16,6 +16,7 @@ import { RoleModel } from "../../../db/Role";
|
||||
import { roleLevelup } from "../../../services/normalBattleService";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ShopHandler(app);
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ export class ShopHandler {
|
||||
}
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, taskReward);
|
||||
if(expItem && expItem.count > 0) {
|
||||
if (expItem && expItem.count > 0) {
|
||||
await roleLevelup(roleId, expItem.count, session);
|
||||
goods.push(expItem);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass } from 'pinus';
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass, HandlerService, } from 'pinus';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
// import { sendRolesMails } from '../../../services/mailService';
|
||||
import { reloadResources } from '../../../pubUtils/data';
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new RoleRemote(app);
|
||||
}
|
||||
|
||||
@@ -19,7 +20,7 @@ export class RoleRemote {
|
||||
// sendGmMailsToRoles(mails) {
|
||||
// sendRolesMails(mails)
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 重载json资源
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user