Merge branch 'feature/activity'

This commit is contained in:
陆莹
2022-03-22 11:48:07 +08:00
107 changed files with 3505 additions and 3919 deletions

View File

@@ -1,7 +1,6 @@
import { Application, BackendSession, HandlerService, pinus, } from 'pinus';
import { aesEncrypt, aesEncryptcfb, resResult } from '../../../pubUtils/util';
import { ENCRYPT_IV, ENCRYPT_KEY, STATUS, TASK_TYPE } from '../../../consts';
import { checkActivityTask } from '../../../services/taskService';
import { ActivityGroupModel } from '../../../db/ActivityGroup';
import { ServerlistModel } from '../../../db/Serverlist';
import { getActivity, getActivityById } from '../../../services/activity/activityService';
@@ -58,50 +57,6 @@ export class ActivityHandler {
return resResult(STATUS.SUCCESS, { playerActivityArray, playerGroupArray });
}
//测试活动任务数据
async testActivityTask(msg: { hid: number, lv: number }, session: BackendSession) {
const { lv } = msg;
const roleId = session.get('roleId');
const serverId = session.get('serverId');
const sid: string = session.get('sid');
let heroNum = 1;
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_QUALITY, heroNum, { heroes: [{ quality: 3 }] })
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT, 1, { oldQuality: 1, quality: 2 })
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_WAKE_UP_STAR_UP_COUNT, 1, { quality: 1, colorStar: 1 })
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_MAIN_ELITE, 1, { mainEliteWarId: 9001 })
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_DUNGEON_WAR, 1, { warId: 5001 })
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_EXPEDITION_BOX, 1)
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_LV, 100)
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.PVP, 1)
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_TOWER_LV, 1, { towerLv: lv })
// await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GASHA, 1)
// if (lv == 2) {
// await GTCreateListMessage('批量推送测试11', 259200000, '哈哈哈哈哈11', '噢噢噢噢噢噢噢噢11')
// }
// if (lv == 3) {
// await GTPushListCidMessage('RASL_0630_da707a0c484d4ee39f2d462d5f52984', ['ba64ee9a9d516bbd341267d685baceb4'], true);
// }
// if (lv == 1) {
// await GTPushSingleCidMessage('ba64ee9a9d516bbd341267d685baceb4', 259200000, '哈哈哈哈哈', '噢噢噢噢噢噢噢噢');
// }
// let beginTime = 1624050000000;
// let interval = 86400;
// console.log('ddddddbbbbbbbbbbbbbb', moment(new Date).valueOf(), (moment(new Date).valueOf() - beginTime), ((moment(new Date).valueOf() - beginTime) % (interval * 1000)), 24 * 60 * 60 * 1000, ((moment(new Date).valueOf() - beginTime) % (interval * 1000)) / (24 * 60 * 60 * 1000))
// let aaa = Math.ceil(((moment(new Date).valueOf() - beginTime) / (24 * 60 * 60 * 1000)));
// console.log('xxxxxxxxxxxxxxxxxxx', aaa);
//aesEncryptcfb
console.log('13121622738', await aesEncryptcfb("13121622738", ENCRYPT_KEY, ENCRYPT_IV))
//18612532385:cc80b189dc03cff31fe75d
//13636354764:cc8bb18bd805c9f51be95c,Z6ArLdom2c
//13121622738:cc8bb68adf00cef31bec50
return resResult(STATUS.SUCCESS,);
}
async debugActivityMemory(msg: {}, session: BackendSession) {
const { } = msg;
const roleId = session.get('roleId');

View File

@@ -5,7 +5,7 @@ import { ActivityMonopolyModel, ActivityMonopolyModelType } from '../../../db/Ac
import { ActivityMonopolyLandModel, ActivityMonopolyLandModelType } from '../../../db/ActivityMonopolyLand';
import { getPlayerMonopolyData, nextPosition } from '../../../services/activity/monopolyService';
import { random } from 'underscore';
import { handleCost } from '../../../services/rewardService';
import { handleCost } from '../../../services/role/rewardService';
import { addReward, stringToConsumeParam, stringToRewardParam } from '../../../services/activity/giftPackageService';
import { getPlayerRefreshShopDataByRoundIndex } from '../../../services/activity/refreshShopService';
import { ActivityRefreshShopModel } from '../../../db/ActivityRefreshShop';

View File

@@ -65,7 +65,7 @@ export class DailyChallengesHandler {
return resResult(STATUS.ACTIVITY_REWARDED);
}
await ActivityDailyChallengesModel.addCellRecord(serverId, activityId, roleId, dayIndex, cellIndex, type, 1);
await ActivityDailyChallengesModel.addCellRecord(serverId, activityId, roleId, dayIndex, cellIndex, 1);
let rewardParamArr: Array<RewardParam> = stringToRewardParam(dailyItemData.reward);
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.DAILY_CHALLENGE_REWARD)

View File

@@ -1,14 +1,13 @@
import { Application, BackendSession, HandlerService } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { ACTIVITY_RESOURCES_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, ITEM_CHANGE_REASON, STATUS } from '../../../consts';
import { handleCost } from '../../../services/rewardService';
import { getGoldObject, handleCost } from '../../../services/role/rewardService';
import { getPlayerDailyCoinData, mergeData } from '../../../services/activity/dailyCoinService';
import { ConsumeExchangeFormulaItem, CoinRewardFormulaItem } from '../../../domain/activityField/dailyCoinField';
import { ActivityDailyCoinModel } from '../../../db/ActivityDailyCoin';
import { addReward, stringToRewardParam } from '../../../services/activity/giftPackageService';
import { RewardParam } from '../../../domain/activityField/rewardField';
import { ItemInter } from '../../../pubUtils/interface';
import { getGoldObject } from '../../../pubUtils/itemUtils';
import { RoleModel } from '../../../db/Role';
import moment = require('moment');

View File

@@ -1,7 +1,7 @@
import { Application, BackendSession, HandlerService, } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { STATUS, ACTIVITY_RESOURCES_TYPE, ITEM_CHANGE_REASON } from '../../../consts';
import { handleCost } from '../../../services/rewardService';
import { handleCost } from '../../../services/role/rewardService';
import { getPlayerDailyGiftsData } from '../../../services/activity/dailyGiftsService';
import { DailyGiftItem } from '../../../domain/activityField/dailyGiftsField';
import { ActivityDailyGiftsModel } from '../../../db/ActivityDailyGifts';

View File

@@ -1,7 +1,7 @@
import { Application, BackendSession, HandlerService, } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { ITEM_CHANGE_REASON, STATUS } from '../../../consts';
import { handleCost } from '../../../services/rewardService';
import { handleCost } from '../../../services/role/rewardService';
import { getPlayerDailyMealData } from '../../../services/activity/dailyMealService';
import { DailyMealItem } from '../../../domain/activityField/dailyMealField';
import { ActivityDailyMealModel } from '../../../db/ActivityDailyMeal';

View File

@@ -7,13 +7,13 @@ import { UserGachaModel } from "../../../db/UserGacha";
import { refreshGacha, getGachaList, getVisitedHeroList, getAllHeroByQuality, GachaPull } from "../../../services/activity/gachaService";
import { RoleModel } from "../../../db/Role";
import { HeroModel } from "../../../db/Hero";
import { handleCost, createHeroes, addItems } from "../../../services/rewardService";
import { handleCost, addItems } from "../../../services/role/rewardService";
import { getZeroPointD, getTimeFun } from "../../../pubUtils/timeUtil";
import { UserGachaRecModel } from "../../../db/UserGachaRec";
import { ActivityModel } from "../../../db/Activity";
import { checkActivityTask, checkTask } from "../../../services/taskService";
import { RECRUIT } from "../../../pubUtils/dicParam";
import { getActivityById } from "../../../services/activity/activityService";
import { checkTaskInGacha } from "../../../services/task/taskService";
import { createHeroes } from "../../../services/role/createHero";
export default function (app: Application) {
new HandlerService(app, {});
@@ -98,16 +98,7 @@ export class GachaHandler {
});
await UserGachaRecModel.createRec(roleId, gachaId, activityId, count, resultList);
// 任务
await checkTask(roleId, sid, TASK_TYPE.GASHA, count, true, {});
//活动统计
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GASHA, count)
for (let hero of resultHeroes) {
activityData.push({ hid: hero.hid, quality: hero.quality });
}
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GACHA_QUALITY_COUNT, count, { heroes: activityData })
await checkTaskInGacha(serverId, roleId, sid, count, resultHeroes);
return resResult(STATUS.SUCCESS, {
gachaId, activityId,
freeCount, refFreeTime: userGacha.refFreeTime, count: userGacha.count, point: userGacha.point, floor, hope,
@@ -470,13 +461,7 @@ export class GachaHandler {
await UserGachaRecModel.createRec(roleId, gachaId, 0, count, resultList);
// 任务
await checkTask(roleId, sid, TASK_TYPE.GASHA, count, true, {});
//活动统计
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GASHA, count)
for (let hero of resultHeroes) {
activityData.push({ hid: hero.hid, quality: hero.quality });
}
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GACHA_QUALITY_COUNT, count, { heroes: activityData })
await checkTaskInGacha(serverId, roleId, sid, count, resultHeroes);
return resResult(STATUS.SUCCESS, {
hasInit: !!role.gachaHasGuide,

View File

@@ -66,7 +66,7 @@ export class GrowthHandler {
return resResult(STATUS.ACTIVITY_REWARDED);
}
await ActivityGrowthModel.addCellRecord(serverId, activityId, roleId, dayIndex, cellIndex, type, 1);
await ActivityGrowthModel.addCellRecord(serverId, activityId, roleId, dayIndex, cellIndex, 1);
let rewardParamArr: Array<RewardParam> = stringToRewardParam(growthItemData.reward);
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.GROWTH_REWARD)

View File

@@ -6,7 +6,7 @@ import { addReward, stringToConsumeParam, stringToRewardParam } from '../../../s
import { ActivityShopModel } from '../../../db/ActivityShop';
import moment = require('moment');
import { RoleModel } from '../../../db/Role';
import { handleCost } from '../../../services/rewardService';
import { handleCost } from '../../../services/role/rewardService';
export default function (app: Application) {
new HandlerService(app, {});

View File

@@ -2,7 +2,7 @@ import { Application, BackendSession, HandlerService, } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { ITEM_CHANGE_REASON, STATUS } from '../../../consts';
import { getPlayerLuckyTurntableDataShow, getPlayerLuckyTurntableData } from '../../../services/activity/luckyTurntableService';
import { addItems, combineItems, handleCost } from '../../../services/rewardService';
import { addItems, handleCost } from '../../../services/role/rewardService';
import { ActivityTurntableModel } from '../../../db/ActivityTurntableRec';
import { pick } from 'underscore';
import { addReward, stringToRewardInter, stringToRewardParam } from '../../../services/activity/giftPackageService';

View File

@@ -5,10 +5,11 @@ import { getPlayerNewHeroGachaData } from '../../../services/activity/newHeroGac
import { RoleModel } from '../../../db/Role';
import { HeroModel } from '../../../db/Hero';
import { GachaPull } from '../../../services/activity/gachaService';
import { addItems, createHeroes, handleCost } from '../../../services/rewardService';
import { addItems, handleCost } from '../../../services/role/rewardService';
import { ActivityNewHeroGachaModel } from '../../../db/ActivityNewHeroGacha';
import { addReward, stringToRewardParam } from '../../../services/activity/giftPackageService';
import { RewardParam } from '../../../domain/activityField/rewardField';
import { createHeroes } from '../../../services/role/createHero';
export default function (app: Application) {

View File

@@ -7,7 +7,7 @@ import { ActivityPopUpShopModel, ActivityPopUpShopModelType } from '../../../db/
import { PopUpShopData } from '../../../domain/activityField/popUpShopField';
import { addReward, stringToConsumeParam, stringToRewardParam } from '../../../services/activity/giftPackageService';
import { RewardParam } from '../../../domain/activityField/rewardField';
import { handleCost } from '../../../services/rewardService';
import { handleCost } from '../../../services/role/rewardService';
import moment = require('moment');
import { getActivityById } from '../../../services/activity/activityService';

View File

@@ -6,7 +6,7 @@ import { RechargeMoneyPool } from '../../../domain/activityField/rechargeMoneyFi
import { addReward, stringToRewardParam } from '../../../services/activity/giftPackageService';
import { RewardParam } from '../../../domain/activityField/rewardField';
import { ActivityRechargeMoneyModel } from '../../../db/ActivityRechargeMoney';
import { addItems } from '../../../services/rewardService';
import { addItems } from '../../../services/role/rewardService';
export default function (app: Application) {

View File

@@ -4,7 +4,7 @@ import { ITEM_CHANGE_REASON, STATUS } from '../../../consts';
import { getPlayerRefreshShopData } from '../../../services/activity/refreshShopService';
import { addReward, stringToConsumeParam, stringToRewardParam } from '../../../services/activity/giftPackageService';
import { ActivityRefreshShopModel } from '../../../db/ActivityRefreshShop';
import { handleCost } from '../../../services/rewardService';
import { handleCost } from '../../../services/role/rewardService';
export default function (app: Application) {
new HandlerService(app, {});

View File

@@ -68,7 +68,7 @@ export class RefreshTaskHandler {
return resResult(STATUS.ACTIVITY_REWARDED);
}
await ActivityRefreshTaskModel.addReceiveRecord(serverId, activityId, roleId, roundIndex, pageIndex, id, type, 1);
await ActivityRefreshTaskModel.addReceiveRecord(serverId, activityId, roleId, roundIndex, pageIndex, id, 1);
let rewardParamArr: Array<RewardParam> = stringToRewardParam(dailyItemData.reward);
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.REFRESH_TASK_REWARD)

View File

@@ -2,7 +2,7 @@ import { Application, BackendSession, HandlerService, } from 'pinus';
import { resResult, splitString } from '../../../pubUtils/util';
import { ITEM_CHANGE_REASON, STATUS, } from '../../../consts';
import { SelfServiceShopData } from '../../../domain/activityField/selfServiceShopField';
import { handleCost } from '../../../services/rewardService';
import { handleCost } from '../../../services/role/rewardService';
import { ActivitySelfServiceShopModel, ActivitySelfServiceShopModelType } from '../../../db/ActivitySelfServiceShop';
import { ActivitySelfServiceModel } from '../../../db/ActivitySelfService';
import { ActivitySelfServiceGoodsModel } from '../../../db/ActivitySelfServiceGoods';

View File

@@ -1,7 +1,7 @@
import { Application, BackendSession, HandlerService, } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { STATUS, ACTIVITY_RESOURCES_TYPE, ITEM_CHANGE_REASON } from '../../../consts';
import { handleCost } from '../../../services/rewardService';
import { handleCost } from '../../../services/role/rewardService';
import { ActivityGrowthModel } from '../../../db/ActivityGrowth';
import { ActivityDailyGiftsModel } from '../../../db/ActivityDailyGifts';
import { addReward, stringToRewardParam } from '../../../services/activity/giftPackageService';
@@ -70,7 +70,7 @@ export class SevenDaysHandler {
return resResult(STATUS.ACTIVITY_REWARDED);
}
await ActivityGrowthModel.addCellRecord(serverId, activityId, roleId, dayIndex, cellIndex, type, 1);
await ActivityGrowthModel.addCellRecord(serverId, activityId, roleId, dayIndex, cellIndex, 1);
let rewardParamArr: Array<RewardParam> = stringToRewardParam(growthItemData.reward);
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.GROWTH_REWARD)
@@ -152,7 +152,7 @@ export class SevenDaysHandler {
return resResult(STATUS.ACTIVITY_REWARDED);
}
await ActivityDailyChallengesModel.addCellRecord(serverId, activityId, roleId, dayIndex, cellIndex, type, 1);
await ActivityDailyChallengesModel.addCellRecord(serverId, activityId, roleId, dayIndex, cellIndex, 1);
let rewardParamArr: Array<RewardParam> = stringToRewardParam(dailyItemData.reward);
let result = await addReward(roleId, roleName, sid, serverId, rewardParamArr, ITEM_CHANGE_REASON.DAILY_CHALLENGE_REWARD)

View File

@@ -2,7 +2,7 @@ import { Application, BackendSession, HandlerService, } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { STATUS, ACTIVITY_TYPE, SERVER_OPEN_TIME, ITEM_CHANGE_REASON, } from '../../../consts';
import { canBuyVip, getPlayerSignInData } from '../../../services/activity/signInService';
import { handleCost } from '../../../services/rewardService';
import { handleCost } from '../../../services/role/rewardService';
import { SignInItem } from '../../../domain/activityField/signInField';
import { ActivitySignInModel } from '../../../db/ActivitySignIn';
import moment = require('moment');

View File

@@ -8,7 +8,7 @@ import { nowSeconds } from '../../../pubUtils/timeUtil';
import { addReward, stringToConsumeParam, stringToRewardParam } from '../../../services/activity/giftPackageService';
import { ItemInter } from '../../../pubUtils/interface';
import { isNumber, pick } from 'underscore';
import { handleCost } from '../../../services/rewardService';
import { handleCost } from '../../../services/role/rewardService';
export default function (app: Application) {
new HandlerService(app, {});

View File

@@ -1,10 +1,7 @@
import { Application, BackendSession, HandlerService, } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { DEBUG_MAGIC_WORD, getRedisKeyByRankType, HERO_SELECT, ITEM_CHANGE_REASON, RANK_TYPE, ROLE_SELECT, STATUS } from '../../../consts';
import { addItems, combineItems, handleCost } from '../../../services/rewardService';
import { ActivityTurntableModel } from '../../../db/ActivityTurntableRec';
import { pick } from 'underscore';
import { addReward, stringToRewardInter, stringToRewardParam } from '../../../services/activity/giftPackageService';
import { getTimeLimitRankData, getTimeLimitRankDataShow, sendRankMail, takeSnapshot } from '../../../services/activity/timeLimitRankService';
import { getRankInHandler, Rank } from '../../../services/rankService';
import { getActivityById } from '../../../services/activity/activityService';

View File

@@ -4,7 +4,7 @@ import { ITEM_CHANGE_REASON, STATUS, } from '../../../consts';
import { getPlayerTreasureHuntData, getTreasureHuntData, getPlayerTreasureHuntShopData, getPlayerTreasureHuntTaskData, getPlayerTreasureHuntTreasureShopData, getPlayerTreasureHuntChallengeData, getPlayerTreasureHuntFirstPageData } from '../../../services/activity/treasureHuntService';
import { ActivityTreasureHuntShopModel } from '../../../db/ActivityTreasureHuntShop';
import { ActivityTreasureHuntTaskModel } from '../../../db/ActivityTreasureHuntTask';
import { handleCost } from '../../../services/rewardService';
import { handleCost } from '../../../services/role/rewardService';
import { addReward, stringToConsumeParam, stringToRewardParam } from '../../../services/activity/giftPackageService';
import { RewardParam } from '../../../domain/activityField/rewardField';
import { ActivityTreasureHuntTreasureShopModel } from '../../../db/ActivityTreasureHuntTreasureShop';

View File

@@ -2,7 +2,7 @@ import { Application, ChannelService, HandlerService, } from 'pinus';
import { ActivityModel, ActivityModelType } from '../../../db/Activity';
import { ServerlistModel } from '../../../db/Serverlist';
import { reloadResources } from '../../../pubUtils/data';
import { _getActivitiesByType, _getActivityById, _getActivities } from '../../../services/activity/activityService';
import { _getActivitiesByType, _getActivityById, _getActivities, _getActivitiesByServerId } from '../../../services/activity/activityService';
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
import { taflush } from '../../../services/sdkService';
import { ActivityInRemote } from '../../../domain/activityField/activityField';
@@ -173,6 +173,14 @@ export class ActivityRemote {
}
}
public getActivitiesByServerId(serverId: number) {
try {
return _getActivitiesByServerId(serverId);
} catch(e) {
errlogger.error(`remote ${__filename} \n ${e.stack}`);
}
}
public getActivities() {
try {
return _getActivities();

View File

@@ -13,7 +13,7 @@ import { Application, BackendSession } from 'pinus';
import { resResult, getRandSingleEelm, cal } from '../../../pubUtils/util';
import { RoleStatus, ComBattleTeamModel, ComBattleTeamType, BossHp, ComRoleStatusHero } from '../../../db/ComBattleTeam';
import { ItemModel, ItemType } from '../../../db/Item';
import { addItems, handleCost } from '../../../services/rewardService';
import { addItems, handleCost } from '../../../services/role/rewardService';
import { checkRoleInQueue, rmRoleFromQueue, setTeamSearchReq } from '../../../services/redisService';
import { getRandBlueprtId, clearComBtlTimer, getFrd, updateRobotHurtByTime, comBtlLvInvalid, clearRobotHurtTimer, setDismissTimer, dismissTeam, handleComBtlProgress, getComBattleFriendAdd, teammateInBlackList, blueprtIdValid, hasEnoughBlueprt, addRoleToTeam, addRoleStToTeam, addValidSearchingRoles, validToJoin, addRobotsToTeam, addRobotsLater, teamIsFullToStart, oneTeamNotInBlack, getAllAssistCnt, checkHasMyTeam } from '../../../services/comBattleService';
import { setAp } from '../../../services/actionPointService';
@@ -24,7 +24,7 @@ import { pushComBtlTeamMsg, pushFriendTeamInviteMsg, pushNormalItemMsg, pushTeam
import { EXTERIOR } from '../../../pubUtils/dicParam';
import { getZeroPointD, getTimeFunD, getSeconds, nowSeconds } from '../../../pubUtils/timeUtil';
import { FriendParams } from '../../../domain/roleField/friend';
import { checkActivityTask, checkTask, checkTaskInComBattleStart, checkTaskWithArgs, checkTaskWithGoods } from '../../../services/taskService';
import { checkTask, checkTaskInComBattleStart } from '../../../services/task/taskService';
import { gameData, getWarByBlueprtId } from '../../../pubUtils/data';
import { HeroModel } from '../../../db/Hero';
@@ -461,7 +461,7 @@ export class ComBattleHandler {
updateRobotHurtByTime(teamStatus, st, COM_BTL_CONST.ROBOT_BASE_TIME_INTERVAL + idx, channel, this.robotHurtTimer, this.teamMap);
}
});
await checkTaskInComBattleStart(teamStatus.roleStatus, teamStatus.capId);
await checkTaskInComBattleStart(teamStatus.roleStatus, teamStatus.capId, teamStatus.blueprtId);
return resResult(STATUS.SUCCESS);
}
@@ -565,6 +565,7 @@ export class ComBattleHandler {
let roleName = session.get('roleName');
let sid = session.get('sid');
let ip = session.get('ip');
let serverId = session.get('serverId');
let { teamCode } = msg;
let team = await ComBattleTeamModel.getTeamByCode(teamCode);
@@ -582,7 +583,7 @@ export class ComBattleHandler {
if (!warInfo) return resResult(STATUS.BATTLE_MISS_INFO);
let role = await RoleModel.findByRoleId(roleId, 'lv');
let apJson = await setAp(roleId, ip, role.lv, -1 * warInfo.cost, sid, ITEM_CHANGE_REASON.COM_BATTLE_END); // 扣除体力
let apJson = await setAp(serverId, roleId, ip, role.lv, -1 * warInfo.cost, sid, ITEM_CHANGE_REASON.COM_BATTLE_END); // 扣除体力
if(!apJson) {
return resResult(STATUS.BATTLE_ACTION_POINT_LACK);
}
@@ -598,8 +599,6 @@ export class ComBattleHandler {
await ComBattleTeamModel.updateRewardSt(teamCode, roleId, true);
const goods = await addItems(roleId, roleName, sid, roleSt.fixReward, ITEM_CHANGE_REASON.COM_BATTLE_END);
let actordata = await roleLevelup(KING_EXP_RATIO_TYPE.BATTLE, roleId, warInfo.kingExp, session);// 主公升级经验
// 任务
await checkTaskWithGoods(roleId, sid, TASK_TYPE.COM_BATTLE_DROP, goods);
return resResult(STATUS.SUCCESS, { battleGoods: goods, ...actordata, teamInfo: {status, teamCode, roleStatus, bossHpArr} });
}
@@ -692,10 +691,7 @@ export class ComBattleHandler {
}
// 任务
await checkTaskWithArgs(roleId, sid, TASK_TYPE.CHAT, [getChannelType(CHANNEL_PREFIX.TEAM)]);
//活动任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.CHAT, 1, { chatType: getChannelType(CHANNEL_PREFIX.TEAM) })
await checkTask(serverId, roleId, sid, TASK_TYPE.CHAT, { chatType: getChannelType(CHANNEL_PREFIX.TEAM) });
return resResult(STATUS.SUCCESS);
}

View File

@@ -4,8 +4,7 @@ import { STATUS } from '../../../consts/statusCode';
import { resResult } from '../../../pubUtils/util';
import { RoleModel } from '../../../db/Role';
import { getDailyNum, getDailyBattleList, getDailyBuyCountCost } from '../../../services/dailyBattleService';
import { handleCost } from '../../../services/rewardService';
import { getGoldObject } from '../../../pubUtils/itemUtils';
import { getGoldObject, handleCost } from '../../../services/role/rewardService';
import { gameData } from '../../../pubUtils/data';
import { DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON } from '../../../consts';

View File

@@ -2,8 +2,7 @@ import { Application, BackendSession } from 'pinus';
import { STATUS } from '../../../consts/statusCode';
import { resResult, shouldRefresh } from '../../../pubUtils/util';
import { RoleModel } from '../../../db/Role';
import { handleCost } from '../../../services/rewardService';
import { getGoldObject } from '../../../pubUtils/itemUtils';
import { getGoldObject, handleCost } from '../../../services/role/rewardService';
import { getDungeonData, getDungeonBuyCountCost } from '../../../services/dungeonService';
import * as dicParam from '../../../pubUtils/dicParam';
import { DungeonFirstModel } from '../../../db/DungeonFirst';

View File

@@ -3,10 +3,10 @@ import { EventRecordModel } from '../../../db/EventRecord';
import { RoleModel } from '../../../db/Role';
import { EVENT_STATUS, EVENT_RECORD_STATUS, EVENT_ANSWER_STATUS, TASK_TYPE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON } from '../../../consts';
import { checkEventStatus, getEventSuccessStatus, getEvent, checkQuiz, startEvent, refreshEvent, getEventTime } from '../../../services/eventSercive';
import { addItems } from '../../../services/rewardService';
import { addItems } from '../../../services/role/rewardService';
import { STATUS } from '../../../consts/statusCode';
import { resResult } from '../../../pubUtils/util';
import { checkActivityTask, checkTask } from '../../../services/taskService';
import { checkTask } from '../../../services/task/taskService';
import { gameData } from '../../../pubUtils/data';
export default function (app: Application) {
@@ -123,9 +123,7 @@ export class EventBattleHandler {
// 推送消息刷新
// await checkEvent(session, true);
// 任务
await checkTask(roleId, sid, TASK_TYPE.BATTLE_EVENT, 1, true, { eventType: dicEvent.eventType })
// 活动任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_EVENT, 1, { eventType: dicEvent.eventType })
await checkTask(serverId, roleId, sid, TASK_TYPE.BATTLE_EVENT, { eventType: dicEvent.eventType });
return resResult(STATUS.SUCCESS, {
isSuccess,
eventCode: result.eventCode,

View File

@@ -8,12 +8,12 @@ import { calculateSumCE, genCode, getWarTypeName } from '../../../pubUtils/util'
import { getPointRewardStatus, getResetRemainCnt, findOrCreateEnemies, getExpeditionStatus } from '../../../services/expeditionService';
import { DEBUG_MAGIC_WORD, EXPEDITION_WAR_RECORD_STATUS, ITEM_CHANGE_REASON, KING_EXP_RATIO_TYPE, LINEUP_NUM, TASK_TYPE, TA_EVENT } from '../../../consts';
import { WarReward } from '../../../services/warRewardService';
import { addItems } from '../../../services/rewardService';
import { addItems } from '../../../services/role/rewardService';
import { getAp, setAp } from '../../../services/actionPointService';
import { STATUS } from '../../../consts/statusCode';
import { resResult } from '../../../pubUtils/util';
import { calculateWarStar, checkBattleHeroes, roleLevelup } from '../../../services/normalBattleService';
import { checkActivityTask, checkTask, checkTaskInBattleEnd } from '../../../services/taskService';
import { checkTask, checkTaskInBattleEnd } from '../../../services/task/taskService';
import { gameData } from '../../../pubUtils/data';
import * as dicParam from '../../../pubUtils/dicParam';
import { getSeconds, nowSeconds } from '../../../pubUtils/timeUtil';
@@ -209,7 +209,7 @@ export class ExpeditionBattleHandler {
}
let role = await RoleModel.findByRoleId(roleId, 'lv');
let apJson = await setAp(roleId, ip, role.lv, isSuccess?-1 * warInfo.cost: 0, sid, ITEM_CHANGE_REASON.EXPEDITION_BATTLE_END); // 扣除体力
let apJson = await setAp(serverId, roleId, ip, role.lv, isSuccess?-1 * warInfo.cost: 0, sid, ITEM_CHANGE_REASON.EXPEDITION_BATTLE_END); // 扣除体力
if (!apJson) {
return resResult(STATUS.BATTLE_ACTION_POINT_LACK);
}
@@ -315,8 +315,7 @@ export class ExpeditionBattleHandler {
let pointRewards = await getPointRewardStatus(roleId);
// 任务
await checkTask(roleId, sid, TASK_TYPE.BATTLE_EXPEDITION_BOX, 1, true, { point });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_EXPEDITION_BOX, 1)
await checkTask(serverId, roleId, sid, TASK_TYPE.BATTLE_EXPEDITION_BOX, { point });
let goods = await addItems(roleId, roleName, sid, curDicExpeditionPoint.reward, ITEM_CHANGE_REASON.EXPEDITION_POINT_REWARD);

View File

@@ -19,7 +19,7 @@ import { gameData } from '../../../pubUtils/data';
import { pushMysteryFirstMsg, pushTowerMsg, pushVestigeFirstMsg } from '../../../services/chatService';
import { getSeconds, nowSeconds } from '../../../pubUtils/timeUtil';
import { Rank } from '../../../services/rankService';
import { checkTaskWithWar, checkTaskInBattleEnd, checkActivityTask, checkTaskInBattleSweep } from '../../../services/taskService';
import { checkTaskInBattleEnd, checkTaskInBattleSweep } from '../../../services/task/taskService';
import { ActivitySelfServiceModel } from '../../../db/ActivitySelfService';
import { getSelfServiceShopActivityData } from '../../../services/activity/selfServiceShopActivityService';
import { challengeDailyGK } from '../../../services/activity/dailyGKService';
@@ -28,7 +28,7 @@ import { reportTAEvent } from '../../../services/sdkService';
import { getVipRegretCnt } from '../../../services/activity/monthlyTicketService';
import { isArray, isNumber } from 'underscore';
import { RewardInter } from '../../../pubUtils/interface';
import { addItems } from '../../../services/rewardService';
import { addItems } from '../../../services/role/rewardService';
export default function (app: Application) {
new HandlerService(app, {});
@@ -164,7 +164,7 @@ export class NormalBattleHandler {
}
let role = await RoleModel.findByRoleId(roleId, 'lv');
let apJson = await setAp(roleId, ip, role.lv, isSuccess? -1 * warInfo.cost: 0, sid, getReasonByWarType(warInfo.warType)); // 扣除体力
let apJson = await setAp(serverId, roleId, ip, role.lv, isSuccess? -1 * warInfo.cost: 0, sid, getReasonByWarType(warInfo.warType)); // 扣除体力
if (!apJson) {
return resResult(STATUS.BATTLE_ACTION_POINT_LACK);
}
@@ -218,7 +218,6 @@ export class NormalBattleHandler {
if (role) {
let r = new Rank(REDIS_KEY.MAIN_ELITE_RANK, { serverId });
await r.setRankWithRoleInfo(roleId, role.mainEliteWarId, role.mainEliteUpdatedAt, role);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_MAIN_ELITE, 1, { mainEliteWarId: battleId })
}
} else if (warInfo.warType == WAR_TYPE.ACT_SELF_SHOP) {
//糜家商队挑战成功后记录挑战次数
@@ -305,7 +304,7 @@ export class NormalBattleHandler {
// 扣体力
let role = await RoleModel.findByRoleId(roleId, 'lv');
let apJson = await setAp(roleId, ip, role.lv, -1 * warInfo.cost * count, sid, getReasonByWarType(warInfo.warType)); // 扣除体力
let apJson = await setAp(serverId, roleId, ip, role.lv, -1 * warInfo.cost * count, sid, getReasonByWarType(warInfo.warType)); // 扣除体力
if (!apJson) {
return resResult(STATUS.BATTLE_ACTION_POINT_LACK);
}

View File

@@ -10,12 +10,11 @@ import { PvpDefenseModel, pvpUpdateInter } from '../../../db/PvpDefense';
import { PvpSeasonResultModel } from '../../../db/PvpSeasonResult';
import { PVPConfigModel } from '../../../db/SystemConfig';
import { Rank } from '../../../services/rankService';
import { checkActivityTask, checkTask, checkTaskInPvpEnd } from '../../../services/taskService';
import { checkTask, checkTaskInPvpEnd } from '../../../services/task/taskService';
import { Attack, AttackHero, Defense, DefenseHero, PvpDataReturn } from '../../../domain/battleField/pvp';
import { DEBUG_MAGIC_WORD, FIGURE_UNLOCK_CONDITION, ITEM_CHANGE_REASON, LINEUP_NUM, REDIS_KEY, TASK_TYPE } from '../../../consts';
import { PVP } from '../../../pubUtils/dicParam';
import { getGoldObject } from '../../../pubUtils/itemUtils';
import { addItems, handleCost, unlockFigure } from '../../../services/rewardService';
import { addItems, getGoldObject, handleCost, unlockFigure } from '../../../services/role/rewardService';
import { pick } from "underscore";
import { HeroModel } from '../../../db/Hero';
import PvpHistoryOpp, { PvpHistoryOppModel } from '../../../db/PvpHistoryOpp';
@@ -42,7 +41,7 @@ export class PvpHandler {
let pvpDefense = await PvpDefenseModel.findByRoleIdIncludeAll(roleId);
if(!pvpDefense) {
let role = await RoleModel.findByRoleId(roleId);
pvpDefense = await PvpDefenseModel.createPvpDefense({ roleId: role.roleId, roleName: role.roleName, role: role._id });
pvpDefense = await PvpDefenseModel.createPvpDefense({ serverId: role.serverId, roleId: role.roleId, roleName: role.roleName, role: role._id });
}
// 如果没有发过,将上赛季的奖励发下
pvpDefense = await sendLastSeasonRewardIfNotSent(pvpDefense);
@@ -149,6 +148,7 @@ export class PvpHandler {
const { warId, roleId: oppRoleId } = msg;
let roleId = session.get('roleId');
let roleName = session.get('roleName');
let serverId = session.get('serverId');
let sid = session.get('sid');
let warInfo = gameData.war.get(warId);
@@ -180,7 +180,7 @@ export class PvpHandler {
record: { heroes, pos: curOpp.pos, oppRoleId }
}
}, true);
await checkTask(roleId, sid, TASK_TYPE.PVP, 1, true, {});
await checkTask(serverId, roleId, sid, TASK_TYPE.PVP);
// 对手记录更新
await PvpHistoryOppModel.setStatus(roleId, oppRoleId, 1);
@@ -276,12 +276,7 @@ export class PvpHandler {
let myRank = await r.getMyRank({ roleId });
result.setMyRank(myRank);
await checkTaskInPvpEnd(roleId, sid, isSuccess, pvpDefense.heroScores);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.PVP, 1)
if (isSuccess) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.PVP_WIN, 1)
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.PVP_WIN_SERIES, 1)
}
await checkTaskInPvpEnd(serverId, roleId, sid, isSuccess, pvpDefense.heroScores);
if(hisWinStreakNum < pvpDefense.hisWinStreakNum) {
await unlockFigure(sid, roleId, [{ type: FIGURE_UNLOCK_CONDITION.PVP_WIN_SERIES, paramWinStreakNum: pvpDefense.hisWinStreakNum }]);
}
@@ -519,6 +514,7 @@ export class PvpHandler {
let { id } = msg;
let roleId = session.get('roleId');
let sid: string = session.get('sid');
let serverId = session.get('serverId');
let roleName = session.get('roleName');
let seasonEndTime: number = this.app.get('pvpSeasonEndTime');
@@ -536,7 +532,7 @@ export class PvpHandler {
await PvpDefenseModel.updateInfo(roleId, { receivedBox, challengeCnt, challengeRefTime });
let result = await addItems(roleId, roleName, sid, pvpBox.reward, ITEM_CHANGE_REASON.PVP_BOX_REWARD);
// 任务
await checkTask(roleId, sid, TASK_TYPE.PVP_RECEIVE_BOX, 1, true, {});
await checkTask(serverId, roleId, sid, TASK_TYPE.PVP_RECEIVE_BOX);
return resResult(STATUS.SUCCESS, { goods: result, receivedBox, challengeCnt, challengeRefTime });
}
@@ -554,6 +550,7 @@ export class PvpHandler {
let { heroScores: addHeroScores } = msg;
let roleId = session.get('roleId');
let sid = session.get('sid');
let serverId = session.get('serverId');
let { heroScores, hisScore } = await PvpDefenseModel.findByRoleId(roleId);
let score = 0;
@@ -584,7 +581,7 @@ export class PvpHandler {
await r.setRankWithRoleInfo(roleId, pvpDefense.score, pvpDefense.updatedAt.getTime(), role);
// 任务
await checkTask(roleId, sid, TASK_TYPE.PVP_HERO_SCORE, 0, false, { heroScores });
await checkTask(serverId, roleId, sid, TASK_TYPE.PVP_HERO_SCORE, { heroScores });
return resResult(STATUS.SUCCESS, { score, hisScore, heroScores });
}

View File

@@ -8,9 +8,8 @@ import { TowerRecordModel } from './../../../db/TowerRecord';
import { Application, BackendSession } from 'pinus';
import { resResult, genCode, shouldRefresh } from '../../../pubUtils/util';
import { calcuHangUpReward, refreshTasks, treatTask, getRemainTime, getTowerStatus, getHungupRewards, getTasks, checkTaskRewards, getTowerTaskCostGold, getHangSpdUpCostGold, getManyHangSpdUpCostGold, getTaskStatus, checkForbiddenChar, checkAndStartHungUp, createNewTowerRecord, getTowerRecByLv } from '../../../services/battleService';
import { addItems, handleCost } from '../../../services/rewardService';
import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService';
import { checkBattleHeroes } from '../../../services/normalBattleService';
import { getGoldObject } from '../../../pubUtils/itemUtils';
import { gameData } from '../../../pubUtils/data';
import * as dicParam from '../../../pubUtils/dicParam';
import { isNumber } from 'underscore';

View File

@@ -4,7 +4,7 @@ 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';
import { getSimpleRoleInfo } from '../../../services/roleService';
import { checkActivityTask, checkTaskWithArgs } from '../../../services/taskService';
import { checkTask } from '../../../services/task/taskService';
import { RoleModel } from '../../../db/Role';
@@ -99,10 +99,7 @@ export class ChatHandler {
await pushGroupMsgToRoom(msgData);
// 任务
await checkTaskWithArgs(roleId, sid, TASK_TYPE.CHAT, [getChannelType(channel)]);
//活动任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.CHAT, 1, { chatType: getChannelType(channel) })
await checkTask(serverId, roleId, sid, TASK_TYPE.CHAT, { chatType: getChannelType(channel) });
return resResult(STATUS.SUCCESS, msgData);
}
@@ -125,10 +122,7 @@ export class ChatHandler {
if (!msgData) return resResult(STATUS.WRONG_PARMS);
// 任务
await checkTaskWithArgs(roleId, sid, TASK_TYPE.CHAT, [getChannelType('private')]);
//活动任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.CHAT, 1, { chatType: getChannelType('private') })
await checkTask(serverId, roleId, sid, TASK_TYPE.CHAT, { chatType: getChannelType('private') });
return resResult(STATUS.SUCCESS, msgData);
}

View File

@@ -7,16 +7,13 @@ import { FrontendSession } from 'pinus';
import { HeroModel } from './../../../db/Hero';
import { genCode, generateStr, resResult } from '../../../pubUtils/util';
import { COM_BTL_QUALITY, HERO_SELECT, DEBUG_MAGIC_WORD, REDIS_KEY, TASK_TYPE, ENTERY_ROLE_PICK, COUNTER, DEFAULT_LV, TA_USERSET_TYPE, LOG_TYPE } from '../../../consts';
import { getAp } from '../../../services/actionPointService';
import { ItemModel } from '../../../db/Item';
import { SkinModel } from '../../../db/Skin';
// import { loginRefresh } from '../../../services/playerEventService';
import { nowSeconds, getZeroPoint } from '../../../pubUtils/timeUtil';
import { rmRoleFromQueue, roleLeave, getRoleOnlineInfo, roleLogin } from '../../../services/redisService';
import { addRoleToGuildChannel, addRoleToSysChannel, addRoleToWorldChannel, leaveGuildAuctionChannel, leaveGuildChannel, leaveSysChannel, leaveWorldAuctionChannel, leaveWorldChannel, recentGuildMsgs, recentPrivateChatInfos, recentSysMsgs, recentWorldMsgs } from '../../../services/chatService';
import { reportOneOnline, savePlayTime } from '../../../services/authenticateService';
import { checkTaskWithRole, } from '../../../services/taskService';
import { checkTaskInEntry, } from '../../../services/task/taskService';
import { pushData, everydayRefresh, kickUser } from '../../../services/connectorService';
// import { setComBtlOnUserLeave } from '../../../services/comBattleService';
import Counter from '../../../db/Counter';
@@ -65,7 +62,7 @@ export class EntryHandler {
}
}
let serverName = this.app.getServerId();
await roleLogin(role.roleId, user.userCode, serverName, user.pkgName); // 保存在线用户
await roleLogin(role.roleId, user.userCode, serverName, user.pkgName, role.createTime); // 保存在线用户
await this.addSession(role, session);
saveLoginAndOutLog(LOG_TYPE.LOGIN, session);
@@ -75,9 +72,7 @@ export class EntryHandler {
reportOneOnline(role.roleId, user.userCode, self.app.get('serverId'), true, user);
// 任务
checkTaskWithRole(serverId, role.roleId, self.app.get('serverId'), TASK_TYPE.LOGIN_SUM, role);
checkTaskWithRole(serverId, role.roleId, self.app.get('serverId'), TASK_TYPE.LOGIN_SERIES, role);
checkTaskInEntry(serverId, role.roleId, self.app.get('serverId'), role);
if (role.hasGuild) {
addRoleToGuildChannel(role.roleId, self.app.get('serverId'), role.guildCode);
}
@@ -154,8 +149,7 @@ export class EntryHandler {
let { serverId } = role;
// 任务
checkTaskWithRole(serverId, role.roleId, self.app.get('serverId'), TASK_TYPE.LOGIN_SUM, role);
checkTaskWithRole(serverId, role.roleId, self.app.get('serverId'), TASK_TYPE.LOGIN_SERIES, role);
checkTaskInEntry(serverId, role.roleId, self.app.get('serverId'), role);
// 推送数据
pushData(role.hasInit, role, session, 'refresh');

View File

@@ -2,7 +2,7 @@ import { Application, BackendSession, pinus } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { STATUS } from '../../../consts/statusCode';
import { getRoleOnlineInfo, updateUserInfo } from '../../../services/redisService';
import { addItems, createHeroes } from '../../../services/rewardService';
import { addItems } from '../../../services/role/rewardService';
import { RewardInter } from '../../../pubUtils/interface';
import { gameData, getExpByLv, getHeroExpByLv, getHeroLvByExp, getLvByExp } from '../../../pubUtils/data';
import { RoleModel, RoleType } from '../../../db/Role';
@@ -22,6 +22,7 @@ import { calAllHeroCe, calPlayerCeAndSave } from '../../../services/playerCeServ
import { SkinModel } from '../../../db/Skin';
import { PvpDefenseModel } from '../../../db/PvpDefense';
import { calculatetopLineup } from '../../../pubUtils/playerCe';
import { createHeroes } from '../../../services/role/createHero';
let timer: NodeJS.Timer;
export default function (app: Application) {

View File

@@ -5,7 +5,7 @@ import { LotModel } from "../../../db/Lot";
import { ItemReward } from "../../../domain/dbGeneral";
import { genCode, resResult } from "../../../pubUtils/util";
import { auctionStage, calculateDividend, genAuction, sendUngotDividend, startGuildAuction, startWorldAuction, stopAuction, todayGuildBegin, getBasePrice, debugAuctionLots, officialAuctionLots, auctionBidStatus, getMaxPrice, guildBidStatus, getAuction, pushAuctionOver, treatSingleLotTime, treatLotsTime } from "../../../services/auctionService";
import { addItems, handleCost } from '../../../services/rewardService';
import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService';
import { getSimpleRoleInfo } from '../../../services/roleService';
import { getRoleOnlineInfo } from '../../../services/redisService';
import { lockData } from '../../../services/redLockService';
@@ -20,7 +20,6 @@ import { gameData, getAuctionRewardByPoolId } from '../../../pubUtils/data';
import { addRoleToGuildAuctionChannel, addRoleToWorldAuctionChannel, channelServer, groupRoomId, leaveGuildAuctionChannel } from '../../../services/chatService';
import { RewardInter } from '../../../pubUtils/interface';
import { sendMailByContent } from '../../../services/mailService';
import { getGoldObject } from '../../../pubUtils/itemUtils';
import { reportTAEvent } from '../../../services/sdkService';
export default function (app: Application) {

View File

@@ -9,12 +9,11 @@ import { leaveCityChannel, addRoleToCityChannel, getCityChannelSid } from "../..
import { UserGuildModel } from "../../../db/UserGuild";
import { GuildActivityRecordModel } from "../../../db/GuildActivityRec";
import { nowSeconds, getTimeFun } from "../../../pubUtils/timeUtil";
import { getGoldObject } from "../../../pubUtils/itemUtils";
import { GUILDACTIVITY, SERVER_DEBUG_MODE } from "../../../pubUtils/dicParam";
import { handleCost } from "../../../services/rewardService";
import { getGoldObject, handleCost } from "../../../services/role/rewardService";
import { addActive } from "../../../services/guildService";
import { Rank } from "../../../services/rankService";
import { checkActivityTask, checkTask } from "../../../services/taskService";
import { checkTask } from "../../../services/task/taskService";
import { guildInter } from "../../../pubUtils/interface";
import { dispatch } from "../../../pubUtils/dispatcher";
import { ServerRecordModel } from "../../../db/ServerRecords";
@@ -191,9 +190,7 @@ export class CityActivityHandler {
await ServerRecordModel.addActiveGuild(serverId, guildCode);
// 任务
await checkTask(roleId, sid, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid });
//成长任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_ACTIVITY, 1, { aid: this.aid })
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_ACTIVITY, { aid: this.aid });
// 前一天中位数战力
let medianCe = await getPreDayActiveData(serverId);

View File

@@ -6,13 +6,13 @@ import { DonationModel } from '../../../db/Donation';
import { nowSeconds } from '../../../pubUtils/timeUtil';
import { getArmyDonateBaseByLv, getArmyDonateBoxBaseById } from '../../../pubUtils/data';
import { GuildModel } from '../../../db/Guild';
import { handleCost, addItems } from '../../../services/rewardService';
import { handleCost, addItems } from '../../../services/role/rewardService';
import { CHAT_SERVER, GUILD_POINT_WAYS } from '../../../consts';
import { addFund, getDonation } from '../../../services/donateService';
import { getUserGuildWithRefActive, refreshUserGuild } from '../../../services/guildService';
import { ARMY } from '../../../pubUtils/dicParam';
import { addActive } from '../../../services/guildService'
import { checkActivityTask, checkTask } from '../../../services/taskService';
import { checkTask } from '../../../services/task/taskService';
import { guildInter } from '../../../pubUtils/interface';
import { lockData } from '../../../services/redLockService';
import { getVipDonateConsume } from '../../../services/activity/monthlyTicketService';
@@ -102,10 +102,7 @@ export class DonationHandler {
await addActive(roleId, serverId, GUILD_POINT_WAYS.DONATE, id);
// 任务
await checkTask(roleId, sid, TASK_TYPE.GUILD_DONATE, 1, true, {});
//活动任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_DONATE, 1);
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_DONATE);
res.releaseCallback();
return resResult(STATUS.SUCCESS, { donateFund, reports, donateCnt, simpleGoods: goods });
} catch (e) {

View File

@@ -14,7 +14,7 @@ import { UserGuildModel } from "../../../db/UserGuild";
import { GuildActivityCityModel } from "../../../db/GuildActivityCity";
import { Rank } from "../../../services/rankService";
import { getTimeFun, getZeroPointD } from "../../../pubUtils/timeUtil";
import { checkActivityTask, checkTask } from "../../../services/taskService";
import { checkTask } from "../../../services/task/taskService";
import { guildInter } from "../../../pubUtils/interface";
import { ServerRecordModel } from "../../../db/ServerRecords";
@@ -97,10 +97,7 @@ export class GateActivityHandler {
await ServerRecordModel.addActiveGuild(serverId, guildCode);
// 任务
await checkTask(roleId, sid, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid });
//成长任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_ACTIVITY, 1, { aid: this.aid })
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_ACTIVITY, { aid: this.aid });
return resResult(STATUS.SUCCESS, {
code,
...statusResult,

View File

@@ -14,11 +14,10 @@ import { GuildModel } from '../../../db/Guild';
import { gameData, getAuctionRewardByPoolId, getBossByLv } from '../../../pubUtils/data';
import { lockData } from '../../../services/redLockService';
import { pushGuildBossSucMsg, getGuildChannelSid } from '../../../services/chatService';
import { checkTask } from '../../../services/taskService';
import { checkTask } from '../../../services/task/taskService';
import { guildInter } from '../../../pubUtils/interface';
import { addItems, handleCost } from '../../../services/rewardService';
import { addItems, getGoldObject, handleCost } from '../../../services/role/rewardService';
import * as dicParam from '../../../pubUtils/dicParam';
import { getGoldObject } from '../../../pubUtils/itemUtils';
import { RoleModel } from '../../../db/Role';
import { sendMailToGuildByContent } from '../../../services/mailService';
import { genAuction } from '../../../services/auctionService';
@@ -128,7 +127,7 @@ export class GuildHandler {
}
let { myChallengeCnt: newMyChallengeCnt } = await refreshUserGuildOfBoss(userGuild, 0, 1);
// 任务
await checkTask(roleId, sid, TASK_TYPE.GUILD_BOSS, 1, true, {});
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_BOSS);
return resResult(STATUS.SUCCESS, { battleCode, bossCode: bossInstance.code, myChallengeCnt: newMyChallengeCnt });
}

View File

@@ -6,8 +6,7 @@ import { checkAuth, joinGuild, getGuildWithRefActive, getUserGuildWithRefActive,
import { GuildModel, GuildType, GuildUpdateParam } from '../../../db/Guild';
import { RoleModel, RoleType } from '../../../db/Role';
import { ARMY } from '../../../pubUtils/dicParam';
import { handleCost, addItems } from '../../../services/rewardService';
import { getGoldObject } from '../../../pubUtils/itemUtils';
import { handleCost, addItems, getGoldObject } from '../../../services/role/rewardService';
import { nowSeconds, getTimeFun, getSeconds } from '../../../pubUtils/timeUtil';
import { GuildListInfo, GuildMemberParam } from '../../../domain/battleField/guild';
import { GuildLeader } from '../../../domain/rank';
@@ -23,7 +22,7 @@ import { removeBossRank } from '../../../services/guildBossService';
import { removeTrainRank } from '../../../services/guildTrainService';
import { pushGuildNoticeUpdateMsg, pushGuildUpStructureMsg, addRoleToGuildChannel, getGuildChannelSid, createGroupMsg, pushGroupMsgToRoom } from '../../../services/chatService';
import { Rank } from '../../../services/rankService';
import { checkActivityTask, checkTask } from '../../../services/taskService';
import { checkTask } from '../../../services/task/taskService';
import { guildInter } from '../../../pubUtils/interface';
import * as dicParam from '../../../pubUtils/dicParam';
import { reportTAEvent } from '../../../services/sdkService';
@@ -99,8 +98,7 @@ export class GuildHandler {
// 返回
const result = { ...guild, rank, myInfo: { ...userGuild, isOnline: true } };
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_JOIN, 1);
await checkTask(roleId, sid, TASK_TYPE.GUILD_JOIN, 1, true, {});
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_JOIN);
return resResult(STATUS.SUCCESS, result);
}
@@ -877,9 +875,7 @@ export class GuildHandler {
userGuild = await UserGuildModel.updateInfo(roleId, { receivedActive: userGuild.receivedActive }, {}, 'receivedActive');
// 任务
await checkTask(roleId, sid, TASK_TYPE.GUILD_RECEIVE_BOX, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_RECEIVE_BOX, 1);
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_RECEIVE_BOX);
return resResult(STATUS.SUCCESS, { goods, receivedActive: userGuild.receivedActive });
}

View File

@@ -5,7 +5,7 @@ import { STATUS, GUILD_OPERATE, TASK_TYPE, ITEM_CHANGE_REASON, ITID, CONSUME_TYP
import { GuildRefineModel } from '../../../db/GuildRefine';
import { gameData, getArmyDevelopConsumeById, getGoodById } from '../../../pubUtils/data';
import { nowSeconds } from '../../../pubUtils/timeUtil';
import { handleCost, addItems, checkGoods } from '../../../services/rewardService';
import { handleCost, addItems, checkGoods } from '../../../services/role/rewardService';
import { GuildModel } from '../../../db/Guild';
import { findIndex, findWhere } from 'underscore';
import { lockData } from '../../../services/redLockService';
@@ -13,7 +13,7 @@ import { ARMY } from '../../../pubUtils/dicParam';
import { CURRENCY_BY_TYPE, CURRENCY_TYPE } from '../../../consts/constModules/itemConst';
import { checkEquipProduceStructureLv, openGuildRefine, refreshRefinCnt } from '../../../services/guildRefineService';
import { DATA_NAME } from '../../../consts/dataName';
import { checkTask } from '../../../services/taskService';
import { checkTask } from '../../../services/task/taskService';
import { guildInter } from '../../../pubUtils/interface';
import { DicArmyDevelopConsume } from '../../../pubUtils/dictionary/DicArmyDevelopConsume';
@@ -51,6 +51,7 @@ export class GuildRefineHandler {
const roleId: string = session.get('roleId');
const sid: string = session.get('sid');
const roleName: string = session.get('roleName');
const serverId: number = session.get('serverId');
let dicGoods = gameData.goods.get(id);
if(!dicGoods) return resResult(STATUS.DIC_DATA_NOT_FOUND);
@@ -92,7 +93,7 @@ export class GuildRefineHandler {
let goods = await addItems(roleId, roleName, sid, [{ id, count }], ITEM_CHANGE_REASON.REFINE_EQUIP);
// 任务
await checkTask(roleId, sid, TASK_TYPE.GUILD_REFINE, 1, true, { quality: dicGoods.quality });
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_REFINE, { quality: dicGoods.quality, count });
return resResult(STATUS.SUCCESS, { goods, refineCnt });
}
/**
@@ -193,7 +194,7 @@ export class GuildRefineHandler {
res.releaseCallback();
// 任务
await checkTask(roleId, sid, TASK_TYPE.GUILD_ASSIST_REFINE, 1, true, {});
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_ASSIST_REFINE);
return resResult(STATUS.SUCCESS, { scienceTrees });
}

View File

@@ -12,13 +12,13 @@ import { UserGuildModel } from '../../../db/UserGuild';
import { GuildModel } from '../../../db/Guild';
import { getArmyTrainJuDian, getTrainBaseByLv, gameData } from '../../../pubUtils/data';
import { CURRENCY_BY_TYPE, CURRENCY_TYPE } from '../../../consts/constModules/itemConst';
import { handleCost, addItems } from '../../../services/rewardService';
import { handleCost, addItems } from '../../../services/role/rewardService';
import { ARMY } from '../../../pubUtils/dicParam';
import { addActive } from '../../../services/guildService';
import { GuildTrainReportModel } from '../../../db/GuildTrainReport';
import { DATA_NAME } from '../../../consts/dataName';
import { pushGuildTrainSucMsg } from '../../../services/chatService';
import { checkActivityTask, checkTask } from '../../../services/taskService';
import { checkTaskInGuildTrain } from '../../../services/task/taskService';
import { sendPopUpActivityData } from '../../../services/guildActivity/guildActivityService';
import { guildInter, RewardInter } from '../../../pubUtils/interface';
import { getGuildTrainGkInfo } from '../../../pubUtils/data';
@@ -243,10 +243,6 @@ export class GuildTrainHandler {
// guildTrain = await GuildTrainModel.updateGuildTrain(code, trainId, { ranks });
res.releaseCallback();//解锁
}
if (isComplete) {//解锁下一关,弹出礼包 // 1 true true 6Sjkgp(trainId, isComplete, needLockNext, code)
let pushMessage = await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_TRAIN_COUNT, 1, { trainId, code })
await sendPopUpActivityData(code, serverId, pushMessage);
}
await GuildTrainReportModel.pushGuildTrainReports(code, trainId, reports);//增加战报
let { trainCount, trainRewards } = userGuild;
@@ -256,12 +252,7 @@ export class GuildTrainHandler {
await addActive(roleId, serverId, GUILD_POINT_WAYS.TRAIN);
// 任务
if (isSuccess) {
await checkTask(roleId, sid, TASK_TYPE.GUILD_TRAIN_SUCESS, 1, true, {});
}
await checkTask(roleId, sid, TASK_TYPE.GUILD_TRAIN, 1, true, {});
//成长任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_TRAIN, 1)
await checkTaskInGuildTrain(serverId, roleId, sid, battleRecord.battleId, isSuccess, isComplete);
return resResult(STATUS.SUCCESS, result);

View File

@@ -7,7 +7,7 @@ import { GuildActivityRecordModel } from "../../../db/GuildActivityRec";
import { UserGuildActivityRecModel } from "../../../db/UserGuildActivityRec";
import { addActive } from "../../../services/guildService";
import { Rank } from "../../../services/rankService";
import { checkActivityTask, checkTask } from "../../../services/taskService";
import { checkTask } from "../../../services/task/taskService";
import { guildInter } from "../../../pubUtils/interface";
import { getGuildChannelSid } from "../../../services/chatService";
import { ServerRecordModel } from "../../../db/ServerRecords";
@@ -93,10 +93,7 @@ export class RaceActivityHandler {
// 全服活跃统计
await ServerRecordModel.addActiveGuild(serverId, guildCode);
// 任务
await checkTask(roleId, sid, TASK_TYPE.GUILD_ACTIVITY, 1, true, { aid: this.aid });
//成长任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_ACTIVITY, 1, { aid: this.aid })
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_ACTIVITY, { aid: this.aid });
return resResult(STATUS.SUCCESS, {
code: myGuildActivityRec.code,

View File

@@ -5,7 +5,7 @@ import { WishPoolReportModel } from '../../../db/WishPoolReport';
import { resResult, genCode } from '../../../pubUtils/util';
import { ITEM_CHANGE_REASON, STATUS } from '../../../consts';
import { getArmyWishPoolBaseByLv, getGoodById, getWishPoolReward } from '../../../pubUtils/data';
import { addItems, checkGoods, checkHeroEquips, checkHeroes } from '../../../services/rewardService';
import { addItems, checkGoods, checkHeroEquips, checkHeroes, getHonourObject } from '../../../services/role/rewardService';
import { ITID, CONSUME_TYPE } from '../../../consts/constModules/itemConst';
import { GUILD_STRUCTURE } from '../../../consts/constModules/guildConst';
import { refreshUserGuild, getWishPool, getUserGuildWithRefActive } from '../../../services/guildService';
@@ -15,7 +15,6 @@ import { getRoleOnlineInfo } from '../../../services/redisService';
import { ARMY } from '../../../pubUtils/dicParam';
import { guildInter } from '../../../pubUtils/interface';
import { getSeconds, getZeroPoint, nowSeconds } from '../../../pubUtils/timeUtil';
import { getHonourObject } from '../../../pubUtils/itemUtils';
export default function(app: Application) {
return new WishPoolHandler(app);
}

View File

@@ -10,7 +10,6 @@ import { applyOrder37 } from '../../../services/pay/37Pay';
import { settleOrder, settleOrderAli, settleOrderWx } from '../../../services/orderService';
import { addRechargeMoney } from '../../../services/activity/rechargeMoneyService';
import { addVipRechargeMoney } from '../../../services/activity/vipRechargeMoneyService';
import { checkActivityTask } from '../../../services/taskService';
import { getActivityById } from '../../../services/activity/activityService';
import { reportTAEvent } from '../../../services/sdkService';

View File

@@ -3,19 +3,20 @@ import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, TASK_TYPE } from "../../.
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
import { resResult, parseGoodStr } from "../../../pubUtils/util";
import { addItems, handleCost, combineItems, CheckMeterial } from "../../../services/rewardService";
import { addItems, getJewelRandSe, handleCost } from "../../../services/role/rewardService";
import { HeroModel, EPlace } from "../../../db/Hero";
import { calPlayerCeAndSave } from "../../../services/playerCeService";
import { gameData, getEquipByJobClassAndEPlace, getNextEquipQuality, getEquipStarIdByEquipId, getNextEquipStar } from "../../../pubUtils/data";
import { BAG, EQUIP } from "../../../pubUtils/dicParam";
import { getRandSeResult, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip, checkTaskInComposeEquip, checkTaskInEquipLvUp, checkTaskInComposeStone, checkTaskInEquipReset, checkTaskInEquipQuench, isLocked } from "../../../services/equipService";
import { getRandSeResult, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip, isLocked } from "../../../services/equipService";
import { isNumber, pick } from 'underscore';
import { JewelModel, RandSe } from "../../../db/Jewel";
import { getJewelRandSe } from "../../../pubUtils/itemUtils";
import { checkTaskInEquipQualityUp, checkTaskInEquipStarUp, checkTaskInPutJewel, checkTaskInPutStone } from '../../../services/equipService';
import { checkTaskInComposeEquip, checkTaskInEquipLvUp, checkTaskInComposeStone, checkTaskInEquipReset, checkTaskInEquipQuench, checkTaskInEquipQualityUp, checkTaskInEquipStarUp, checkTaskInPutJewel, checkTaskInPutStone } from '../../../services/task/taskService';
import { pushEquipQualityMax, pushEquipStarMax } from "../../../services/sysChatService";
import { addConsumeToHero } from "../../../services/roleService";
import { CheckMeterial } from "../../../services/role/checkMaterial";
import { combineItems } from "../../../services/role/util";
export default function (app: Application) {
new HandlerService(app, {});
@@ -57,7 +58,7 @@ export class EquipHandler {
consumes: addConsumeToHero(hero.consumes, dicEquip.composeMaterial),
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.COMPOSE_EQUIP, sid, roleId, hero, update, [ePlaceId]);
await checkTaskInComposeEquip(serverId, roleId, sid, oldEplace, newEplace, ePlaceId);
await checkTaskInComposeEquip(serverId, roleId, sid, oldEplace, newEplace);
return resResult(STATUS.SUCCESS, {
curHero: {

View File

@@ -11,8 +11,7 @@ import { isRoleOnline, getServerName, getRoleOnlineInfo } from "../../../service
import { increaseFrdCnt, getRecommendType, sortByBeSentHeart, getApplyList, getFriendList, getMyApplyParam, getMyParamAsFriend } from "../../../services/friendService";
import { FriendPointModel } from "../../../db/FriendPoint";
import { gameData, getDicFriendByLv } from "../../../pubUtils/data";
import { addItems, handleCost } from "../../../services/rewardService";
import { getFriendPointObject } from "../../../pubUtils/itemUtils";
import { addItems, getFriendPointObject, handleCost } from "../../../services/role/rewardService";
import { RewardInter } from "../../../pubUtils/interface";
import { FriendPresentLogModel } from '../../../db/FriendPresentLog';
import { HeroModel, EPlace } from "../../../db/Hero";
@@ -21,7 +20,7 @@ import { FRIEND } from "../../../pubUtils/dicParam";
import { PlayerDetail, PlayerDetailHero } from "../../../domain/battleField/guild";
import { createPrivateMsg, pushMsgToRole, pushPresent } from "../../../services/chatService";
import { Rank } from "../../../services/rankService";
import { checkTaskWithRoles, checkTask, checkActivityTask } from "../../../services/taskService";
import { checkTaskWithRoles, checkTask } from "../../../services/task/taskService";
import { ComBattleTeamModel } from "../../../db/ComBattleTeam";
import { JewelModel } from "../../../db/Jewel";
@@ -256,13 +255,6 @@ export class FriendHandler {
roles.push(role);
// 任务
await checkTaskWithRoles(serverId, roleId, sid, TASK_TYPE.FRIEND_NUM, roles);
for(let curRole of roles) {
if(curRole.roleId == role.roleId) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.FRIEND_NUM, curRole.friendCnt);
} else {
await checkActivityTask(serverId, null, curRole.roleId, TASK_TYPE.FRIEND_NUM, curRole.friendCnt);
}
}
// 特殊处理:如果他点一键同意,有很多人,这个单独的人就不做这个额外的提示,直接把他好友申请删掉就好
if (str == getResStr(STATUS.FRIEND_HAS_ADD) && resultApplyCodeList.length > 1) str = '';
@@ -435,9 +427,6 @@ export class FriendHandler {
// 任务
await checkTaskWithRoles(serverId, roleId, sid, TASK_TYPE.FRIEND_NUM, [role, friend]);
await checkActivityTask(serverId, sid, role.roleId, TASK_TYPE.FRIEND_NUM, role.friendCnt);
if(friend) await checkActivityTask(serverId, null, friend.roleId, TASK_TYPE.FRIEND_NUM, friend.friendCnt);
return resResult(STATUS.SUCCESS, {
frdRoleIds, blackRoleIds,
isSuccess: str == '',
@@ -507,11 +496,9 @@ export class FriendHandler {
// 更新情谊值
frdPointRec = await FriendPointModel.updateSendCntToday(roleId, roleName, todaySendInc, max, FRIEND_DROP_TYPE.SEND_GIFT);
// 任务
await checkTask(roleId, sid, TASK_TYPE.FRIEND_SEND_HEART, todaySendInc, true, {});
// 活动任务
if (todaySendInc > 0) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.FRIEND_SEND_HEART, todaySendInc);
await checkTask(serverId, roleId, sid, TASK_TYPE.FRIEND_SEND_HEART, { count: todaySendInc });
}
return resResult(STATUS.SUCCESS, {

View File

@@ -1,5 +1,5 @@
import { Application, BackendSession, ChannelService, HandlerService, } from 'pinus';
import { handleCost, addItems, unlockFigure, createHeroes, createHero, CheckMeterial } from '../../../services/rewardService';
import { handleCost, addItems, unlockFigure, getCoinObject, getGoldObject } from '../../../services/role/rewardService';
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
import { resResult, deepCopy, reduceCe } from '../../../pubUtils/util';
import { STATUS } from '../../../consts/statusCode';
@@ -13,14 +13,15 @@ import { getDropItems, FIGURE_UNLOCK_CONDITION } from '../../../consts/constModu
import { pushComposeOrangeHero, pushHeroQualityUpMsg, pushHeroStarMax, pushHeroWakeUp } from '../../../services/chatService';
import { calculatetopLineup } from '../../../pubUtils/playerCe';
import { PvpDefenseModel } from '../../../db/PvpDefense';
import { checkTaskWithHero, checkTask, checkActivityTask } from '../../../services/taskService';
import { checkTask, checkTaskInHeroQUalityUp, checkTaskInHeroStarUp, checkTaskInHeroTrain, checkTaskInHeroWakeUp } from '../../../services/task/taskService';
import { isNumber, pick } from 'underscore';
import { updateEplaces } from '../../../services/equipService';
import { addConsumeToHero } from '../../../services/roleService';
import { getCoinObject, getGoldObject } from '../../../pubUtils/itemUtils';
import { JewelModel, jewelUpdate } from '../../../db/Jewel';
import { CalHeroCe } from '../../../domain/roleField/calCe';
import { REBORN } from '../../../pubUtils/dicParam';
import { createHero, createHeroes } from '../../../services/role/createHero';
import { CheckMeterial } from '../../../services/role/checkMaterial';
export default function (app: Application) {
new HandlerService(app, {});
@@ -128,8 +129,7 @@ export class HeroHandler {
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.LVUP, sid, roleId, hero, update);
// 任务
await checkTaskWithHero(roleId, sid, TASK_TYPE.HERO_LV, hero, [oldLv]);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_LV, 1, { hid, lv: update.lv });
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_LV, { oldLv, hero });
const curHero = {
hid, lv: hero.lv, exp: hero.exp
@@ -194,12 +194,7 @@ export class HeroHandler {
if (isUpStar) {
await calAllHeroCe(HERO_SYSTEM_TYPE.STAR, sid, roleId, {}, [hid, isUpStar ? 1 : 0]); // 升星可能影响到百家学院全局加成
// 任务
await checkTaskWithHero(roleId, sid, TASK_TYPE.HERO_STAR_UP, hero);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_STAR_UP, 1);
await checkTaskWithHero(roleId, sid, TASK_TYPE.HERO_QUALITY_STAR_UP, hero);
//成长任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_QUALITY_STAR_UP, 1, { quality: dicHero.quality, star: hero.star });
await checkTaskInHeroStarUp(serverId, roleId, sid, hero, oldStar);
}
const curHero = {
@@ -254,11 +249,7 @@ export class HeroHandler {
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.QUALITY, sid, roleId, hero, update);
await calAllHeroCe(HERO_SYSTEM_TYPE.QUALITY, sid, roleId, {}, [hid, 0]); // 升品可能影响到百家学院全局加成
// 任务
await checkTaskWithHero(roleId, sid, TASK_TYPE.HERO_QUALITY_UP, hero);
// 任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT, 1, { oldQuality: dicHero.quality, quality: hero.quality });
await checkTaskInHeroQUalityUp(serverId, roleId, sid, hero);
const curHero = {
hid,
@@ -330,14 +321,10 @@ export class HeroHandler {
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.COLORSTAR, sid, roleId, hero, update);
if (isUpStar) {
await calAllHeroCe(HERO_SYSTEM_TYPE.COLORSTAR, sid, roleId, {}, [hid, isUpStar ? 1 : 0]); // 升星可能影响到百家学院全局加成
;
// 任务
await checkTaskWithHero(roleId, sid, TASK_TYPE.HERO_STAR_UP, hero);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_STAR_UP, 1);
await checkTask(roleId, sid, TASK_TYPE.HERO_WAKE_UP, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_QUALITY_WAKE_UP_COUNT, 1, { quality: hero.quality });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_WAKE_UP_COUNT, 1, { hid: hid });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_WAKE_UP_STAR_UP_COUNT, 1, { quality: dicHero.quality, colorStar: update.colorStar });
await checkTaskInHeroWakeUp(serverId, roleId, sid, hero, oldColorStar);
}
const curHero = {
hid,
@@ -373,6 +360,7 @@ export class HeroHandler {
let newJobStage = hero.jobStage;
let oldJobStage = hero.jobStage, oldJob = hero.job;
let max = isOneClick ? dicJob.maxStage: hero.jobStage + 1;
let trainCount = 0;
let check = new CheckMeterial(roleId);
for(let i = hero.jobStage; i < max; i++) {
let singleConsume = dicJob.trainingConsume[i];
@@ -381,6 +369,7 @@ export class HeroHandler {
let isEnough = await check.decrease([singleConsume]);
if(!isEnough) break; // 消耗不足
newJobStage ++;
trainCount++;
}
if (newJobStage == hero.jobStage) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
let consumes = check.getConsume();
@@ -395,11 +384,7 @@ export class HeroHandler {
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.TRAIN, sid, roleId, hero, update);
// 任务
await checkTaskWithHero(roleId, sid, TASK_TYPE.HERO_TRAIN, hero, [oldJob, oldJobStage]);
await checkTask(roleId, sid, TASK_TYPE.HERO_TRAIN_SUM, newJobStage - oldJobStage, true, {});
//活动统计
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_TRAIN_SUM, newJobStage - oldJobStage);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_TRAIN, newJobStage - oldJobStage, { hid })
await checkTaskInHeroTrain(serverId, roleId, sid, hero, trainCount);
return resResult(STATUS.SUCCESS, { curHero: { hid: hero.hid, job: hero.job, jobStage: hero.jobStage } });
}
@@ -436,8 +421,7 @@ export class HeroHandler {
}
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.STAGEUP, sid, roleId, hero, update);
// 任务
await checkTaskWithHero(roleId, sid, TASK_TYPE.HERO_STAGE_UP, hero);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_STAGE_UP, 1, { job: hero.job });
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_STAGE_UP, { hero, stageUpCnt: 1 })
return resResult(STATUS.SUCCESS, { curHero: { hid: hero.hid, job: hero.job, jobStage: hero.jobStage } });
}
@@ -446,6 +430,7 @@ export class HeroHandler {
async heroConectionActivate(msg: { shipId: number }, session: BackendSession) {
let roleId: string = session.get('roleId');
let sid: string = session.get('sid');
let serverId: number = session.get('serverId');
let { shipId } = msg;
let shipHidAndLevel = gameData.friendShipHidAandIds.get(shipId);
@@ -493,7 +478,7 @@ export class HeroHandler {
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.CONNECT, sid, roleId, hero, update, [shipId]);
// 任务
await checkTask(roleId, sid, TASK_TYPE.HERO_CONNECT, 1, true, { connectLv: level })
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_CONNECT, { connectLv: level })
return resResult(STATUS.SUCCESS, { curHero: { hid: hero.hid, connections: hero.connections } });
}
@@ -573,8 +558,7 @@ export class HeroHandler {
hero = await calPlayerCeAndSave(HERO_SYSTEM_TYPE.FAVOUR, sid, roleId, hero, update, [oldLv]);
// 任务
await checkTaskWithHero(roleId, sid, TASK_TYPE.HERO_FAVOUR_LV, hero, [oldLv]);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_FAVOUR_LV, 1, { lv: newLv, oldLv });
await checkTask(serverId, roleId, sid, TASK_TYPE.HERO_FAVOUR_LV, { hero, oldFavourLv: oldLv });
} else {
hero = await HeroModel.updateHeroInfo(roleId, hero.hid, update);
}

View File

@@ -3,7 +3,7 @@ import { STATUS, CONSUME_TYPE, DEBUG_MAGIC_WORD, GIFT_GENERATE_TYPE, ITEM_CHANGE
import { RewardInter } from "../../../pubUtils/interface";
import { resResult } from "../../../pubUtils/util";
import { addItems, handleCost } from "../../../services/rewardService";
import { addItems, handleCost } from "../../../services/role/rewardService";
import { RoleModel } from "../../../db/Role";
import { gameData } from "../../../pubUtils/data";
import { ITID } from "../../../consts/constModules/itemConst";
@@ -67,6 +67,7 @@ export class ItemHandler {
const roleId = session.get('roleId');
const sid = session.get('sid');
const ip = session.get('ip');
const serverId = session.get('serverId');
if (count > 0) {
let dicGoods = gameData.goods.get(id);
@@ -90,7 +91,7 @@ export class ItemHandler {
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }], ITEM_CHANGE_REASON.USE_MEAT);
if (!consumeResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
let apJson = await setAp(roleId, ip, role.lv, dicGoods.value * count, sid, ITEM_CHANGE_REASON.USE_MEAT);
let apJson = await setAp(serverId, roleId, ip, role.lv, dicGoods.value * count, sid, ITEM_CHANGE_REASON.USE_MEAT);
return resResult(STATUS.SUCCESS, {
apJson
@@ -191,9 +192,10 @@ export class ItemHandler {
const roleId = session.get('roleId');
const sid = session.get('sid');
const ip = session.get('ip');
const serverId = session.get('serverId');
let role = await RoleModel.findByRoleId(roleId, 'lv');
let apJson = await setAp(roleId, ip, role.lv, msg.ap, sid, ITEM_CHANGE_REASON.DEBUG);
let apJson = await setAp(serverId, roleId, ip, role.lv, msg.ap, sid, ITEM_CHANGE_REASON.DEBUG);
if (!apJson) return resResult(STATUS.BATTLE_ACTION_POINT_LACK)
return resResult(STATUS.SUCCESS, { apJson });
}

View File

@@ -4,7 +4,7 @@ import { GroupMailModel, GroupMailType } from '../../../db/GroupMail';
import { resResult } from '../../../pubUtils/util';
import { STATUS } from '../../../consts/statusCode';
import { MAIL_STATUS, GM_MAIL_TYPE } from '../../../consts/constModules/mailConst';
import { addItems } from '../../../services/rewardService';
import { addItems } from '../../../services/role/rewardService';
import { checkMailGoods, getMails } from '../../../services/mailService';
import { ServerMailModel, ServerMailType } from '../../../db/ServerMail';
import { MailParam } from '../../../domain/roleField/mail';

View File

@@ -7,7 +7,7 @@ import { GuildModel } from "../../../db/Guild";
import { Rank, getGeneralRank, getRankFirstReward, getRankInHandler } from "../../../services/rankService";
import { nowSeconds } from "../../../pubUtils/timeUtil";
import { gameData } from "../../../pubUtils/data";
import { addItems } from "../../../services/rewardService";
import { addItems } from "../../../services/role/rewardService";
import { HeroModel, HeroUpdate } from "../../../db/Hero";
import { RewardInter } from "../../../pubUtils/interface";
import { GuildRankInfo, RoleAndGuildRankInfo, RoleRankInfo } from "../../../domain/rank";

View File

@@ -3,7 +3,7 @@ import { RoleModel, RoleUpdate } from './../../../db/Role';
import { HeroModel, HeroUpdate } from '../../../db/Hero';
import { resResult, decodeIdCntArrayStr, parseGoodStr, genCode } from '../../../pubUtils/util';
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
import { handleCost, addItems } from '../../../services/rewardService';
import { handleCost, addItems, getGoldObject, getCoinObject } from '../../../services/role/rewardService';
import { getTitle, getTeraph, gameData, getScollByStar, getFriendLvByExp, getHeroExpByLv, getExpByLv } from '../../../pubUtils/data';
import { SCHOOL, SCROLL, EXTERIOR, SCRIPT } from '../../../pubUtils/dicParam';
import { getAtrrNameById } from '../../../consts/constModules/abilityConst'
@@ -16,17 +16,16 @@ import { HERO_SYSTEM_TYPE, LINEUP_NUM, ROLE_SELECT, REDIS_KEY, TASK_TYPE, DEFAUL
import { checkBattleHeroesByHid, roleLevelup } from '../../../services/normalBattleService';
import { Rank } from '../../../services/rankService';
import { updateUserInfo } from '../../../services/redisService';
import { checkTaskWithHero, checkTask, checkTaskWithArgs, checkActivityTask } from '../../../services/taskService';
import { getGoldObject, getCoinObject } from '../../../pubUtils/itemUtils';
import { checkTask, checkTaskInActiveScroll } from '../../../services/task/taskService';
import { RScriptRecordModel } from '../../../db/RScriptRecord';
import { SkinModel, SkinUpdate } from '../../../db/Skin';
import { CreateHeroes, deletRole } from '../../../pubUtils/roleUtil';
import { Figure } from '../../../domain/dbGeneral';
import { getActivities } from '../../../services/activity/activityService';
import * as dicParam from '../../../pubUtils/dicParam';
import Counter from '../../../db/Counter';
import { UserModel } from '../../../db/User';
import { checkFilterWords, reportTAEvent, treatRoleName } from '../../../services/sdkService';
import { CreateHeroes } from '../../../services/role/createHero';
export default function (app: Application) {
new HandlerService(app, {});
@@ -61,9 +60,8 @@ export class RoleHandler {
infos.set(heroInfo.hid, { heroInfo, skinInfo });
}
await createHero.createWithInitInfo(infos, initInfos.figureInfo);
await createHero.clearTask(await getActivities());
await createHero.pushMessage(pinus, sid);
await createHero.updateRedisRank(Rank);
await createHero.pushMessage(sid);
await createHero.updateRedisRank();
let heroes = createHero.getResultHeroes();
session.set('roleName', roleName);
@@ -112,10 +110,7 @@ export class RoleHandler {
let calResult = await calAllHeroCe(HERO_SYSTEM_TYPE.TITLE, sid, roleId, update);
// 任务
await checkTask(roleId, sid, TASK_TYPE.ROLE_TITLE, 1, false, { oldTitle: title, title: update.title });
//成长任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_TITLE, update.title)
await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TITLE, { oldTitle: title, title: update.title });
return resResult(STATUS.SUCCESS, { roleId: calResult.role, title: role.title });
}
@@ -148,8 +143,7 @@ export class RoleHandler {
let calResult = await calAllHeroCe(HERO_SYSTEM_TYPE.TERAPH, sid, roleId, { teraphs }, [id]);
// 任务
await checkTask(roleId, sid, TASK_TYPE.ROLE_TERAPH_STRENGTHEN, count, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_TERAPH_STRENGTHEN, count);
await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TERAPH_STRENGTHEN, { count });
return resResult(STATUS.SUCCESS, { roleId, teraphs: calResult.role.teraphs, criAttr });
}
@@ -193,7 +187,7 @@ export class RoleHandler {
let calResult = await calAllHeroCe(HERO_SYSTEM_TYPE.TERAPH_UP, sid, roleId, { teraphs }, [id]);
// 神像进阶,进阶一次就触发一次礼包弹框
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_TERAPH_STAGE_UP, 1)
await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_TERAPH_STAGE_UP);
return resResult(STATUS.SUCCESS, { roleId, teraphs: calResult.role.teraphs });
}
@@ -250,11 +244,7 @@ export class RoleHandler {
await calAllHeroCe(HERO_SYSTEM_TYPE.SCHOOL, sid, roleId, {}, [schoolId, hid, preHid]);
// 任务
await checkTaskWithArgs(roleId, sid, TASK_TYPE.ROLE_SCHOOL_UNLOCK, [hid, preHid]);
if (hid > 0) {
//成长任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_SCHOOL_PUT_HERO, 1)
}
await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_SCHOOL_PUT_HERO, { hid, preHid });
return resResult(STATUS.SUCCESS, {
schoolId, positionId, hid, preHid, isOpen
@@ -292,8 +282,7 @@ export class RoleHandler {
curSchool = await SchoolModel.updateBySclAndPos(roleId, schoolId, positionId, { isOpen: true })
// 任务
await checkTask(roleId, sid, TASK_TYPE.ROLE_SCHOOL_UNLOCK, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_SCHOOL_UNLOCK, 1)
await checkTask(serverId, roleId, sid, TASK_TYPE.ROLE_SCHOOL_UNLOCK);
return resResult(STATUS.SUCCESS, {
schoolId, positionId, hid: curSchool.hid, isOpen: curSchool.isOpen
@@ -325,7 +314,6 @@ export class RoleHandler {
update.scrollStar = dicHero.initialStars;
update.scrollQuality = dicHero.quality;
update.scrollColorStar = 0;
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.HERO_UNLOCK, 1, { dicHeroes: [dicHero] })
} else {
if (star > scrollStar) { // 可以升星
update.scrollStar++;
@@ -347,10 +335,7 @@ export class RoleHandler {
await calAllHeroCe(HERO_SYSTEM_TYPE.SCROLL, sid, roleId, {}, [hid]); // 全局增加战力
// 任务
if (!scrollActive) {
await checkTask(roleId, sid, TASK_TYPE.ROLE_SCROLL_ACTIVE, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.ROLE_SCROLL_ACTIVE, 1);
}
await checkTaskInActiveScroll(serverId, roleId, sid, scrollActive, hero);
return resResult(STATUS.SUCCESS, {
curHero: {

View File

@@ -4,10 +4,9 @@ import { parseGoodStr, resResult } from "../../../pubUtils/util";
import { STATUS, GUILD_STRUCTURE, ITID, CONSUME_TYPE, HERO_QUALITY_TYPE, HERO_GROW_MAX, ITEM_CHANGE_REASON } from "../../../consts";
import { DicShopListModel } from "../../../db/DicShopList";
import { UserShopModel } from "../../../db/UserShop";
import { handleCost, addItems } from "../../../services/rewardService";
import { handleCost, addItems } from "../../../services/role/rewardService";
import { GuildModel } from "../../../db/Guild";
import { SHOP } from "../../../pubUtils/dicParam";
import { getHonourObject } from "../../../pubUtils/itemUtils";
import { HeroModel } from "../../../db/Hero";
import { getShopListById } from "../../../services/shopService";
import { RewardInter } from "../../../pubUtils/interface";

View File

@@ -1,13 +1,13 @@
import { Application, BackendSession, pinus, HandlerService, } from "pinus";
import { resResult, parseGoodStr, getRandSingleEelm } from "../../../pubUtils/util";
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, KING_EXP_RATIO_TYPE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON, ACTIVITY_TYPE } from "../../../consts";
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, KING_EXP_RATIO_TYPE, DEBUG_MAGIC_WORD, ITEM_CHANGE_REASON, ACTIVITY_TYPE, TASK_TYPE } from "../../../consts";
import { gameData } from "../../../pubUtils/data";
import { UserTaskRecModel } from "../../../db/UserTaskRec";
import { addItems } from "../../../services/rewardService";
import { addItems } from "../../../services/role/rewardService";
import { UserTaskModel } from "../../../db/UserTask";
import { nowSeconds, getZeroPointD } from "../../../pubUtils/timeUtil";
import { DicDailyTask, DicAchievement, DicMainTask } from "../../../pubUtils/dictionary/DicTask";
import { getMainTask, refDailyTaskBox, removeHistoryTask, getCurTask, checkTask, getPvpTask } from "../../../services/taskService";
import { getMainTask, refDailyTaskBox, removeHistoryTask, getCurTask, checkTask, getPvpTask } from "../../../services/task/taskService";
import { TASK } from "../../../pubUtils/dicParam";
import { ActivityTaskPointModel, ActivityTaskPointModelType } from "../../../db/ActivityTaskPoint";
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
@@ -15,6 +15,8 @@ import { RoleModel } from "../../../db/Role";
import { roleLevelup } from "../../../services/normalBattleService";
import _ = require("underscore");
import { addActvityTaskPoint } from "../../../services/activity/activityService";
import { CheckTask } from "../../../services/task/taskObj";
import { ServerlistModel } from "../../../db/Serverlist";
export default function (app: Application) {
new HandlerService(app, {});
@@ -226,7 +228,7 @@ export class ShopHandler {
tasks.push(task);
}
let task = getRandSingleEelm(tasks);
await checkTask(roleId, sid, task.taskType, task.condition, false, { isDebug: true });
// await checkTask(roleId, sid, task.taskType, task.condition, false, { isDebug: true });
return resResult(STATUS.SUCCESS, {
task
});
@@ -323,4 +325,13 @@ export class ShopHandler {
console.log('******', _.isEqual([1,2], [1,2,2]))
return resResult(STATUS.SUCCESS, { tasks: [...gameData.taskType]});
}
async test(msg: { magicWord: string }, session: BackendSession) {
let roleId = session.get('roleId');
let serverId = session.get('serverId');
let sid = session.get('sid');
let role = await RoleModel.findByRoleId(roleId);
let server = await ServerlistModel.findByServerId(serverId);
return resResult(STATUS.SUCCESS)
}
}

View File

@@ -5,7 +5,6 @@ import { HeroUpdate } from '../../../db/Hero';
import { RoleUpdate } from '../../../db/Role';
import { SkinUpdate } from '../../../db/Skin';
import { RankFirstModel, RankFirstType } from '../../../db/RankFirst';
import { getInitRoleInfo } from '../../../pubUtils/roleUtil';
import { DEFAULT_HEROES } from '../../../consts';
import { Figure } from '../../../domain/dbGeneral';
import { getDefaultRoleInfo } from '../../../services/roleService';
@@ -13,6 +12,7 @@ import { PVPConfigModel, PVPConfigType } from '../../../db/SystemConfig';
import { treatRoleName, taflush } from '../../../services/sdkService';
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
import { errlogger } from '../../../util/logger';
import { getInitRoleInfo } from '../../../services/role/initRoleService';
export default function (app: Application) {
new HandlerService(app, {});

View File

@@ -4,7 +4,7 @@
import { ActionPointModel, ActionPointType } from '../db/ActionPoint';
import { TASK_TYPE, STATUS, TA_EVENT, ITEM_CHANGE_REASON } from '../consts';
import { checkActivityTask, checkTask } from './taskService';
import { checkTask } from './task/taskService';
import { getDicApByLv } from '../pubUtils/data';
import { pinus } from 'pinus';
import { resResult, shouldRefresh } from '../pubUtils/util';
@@ -68,7 +68,7 @@ function getApWithDataAp(roleId: string, ip: string, lv: number, dataAp: ActionP
* @param changeAp 体力变化,正是加,负是减
* @param sid
*/
export async function setAp(roleId: string, ip: string, lv: number, changeAp: number, sid: string, reason: ITEM_CHANGE_REASON) {
export async function setAp(serverId: number, roleId: string, ip: string, lv: number, changeAp: number, sid: string, reason: ITEM_CHANGE_REASON) {
// console.log('***** setAp', roleId, ip, lv, changeAp)
const now = Date.now();
const dicAp = getDicApByLv(lv);
@@ -89,9 +89,7 @@ export async function setAp(roleId: string, ip: string, lv: number, changeAp: nu
}
if (changeAp < 0) {
await checkTask(roleId, sid, TASK_TYPE.BATTLE_COST_AP, -1 * changeAp, true, {});
let { serverId } = await RoleModel.findByRoleId(roleId);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_COST_AP, -1 * changeAp,);
await checkTask(serverId, roleId, sid, TASK_TYPE.BATTLE_COST_AP, { count: -changeAp });
// reportTAEvent(roleId, TA_EVENT.AP_CONSUME, { change_count: -1 * changeAp, change_after: ap, change_reason: reason }, ip)
} else {
reportTAEvent(roleId, TA_EVENT.AP_GET, { change_count: changeAp, change_after: ap, change_reason: reason }, ip)

View File

@@ -235,13 +235,15 @@ export async function getActivityById(activityId: number) {
export async function getActivitiesByType(serverId: number, type: number) {
let serverType = pinus.app.getServerType();
let activities: ActivityInRemote[] = [];
if(serverType == 'activity') {
return _getActivitiesByType(serverId, type);
activities = _getActivitiesByType(serverId, type);
} else {
let servers = pinus.app.getServersByType('activity');
let server = getRandSingleEelm(servers);
return <ActivityModelType[]>await pinus.app.rpc.activity.activityRemote.getActivitiesByType.toServer(server.id, serverId, type);
activities = await pinus.app.rpc.activity.activityRemote.getActivitiesByType.toServer(server.id, serverId, type);
}
return activities.map(transActivityInRemoteToModelType);
}
export async function getActivities() {
@@ -255,6 +257,19 @@ export async function getActivities() {
}
}
export async function getActivityByServerId(serverId: number) {
let activities: ActivityInRemote[] = [];
let serverType = pinus.app.getServerType();
if(serverType == 'activity') {
activities = _getActivitiesByServerId(serverId);
} else {
let servers = pinus.app.getServersByType('activity');
let server = getRandSingleEelm(servers);
activities = await pinus.app.rpc.activity.activityRemote.getActivitiesByServerId.toServer(server.id, serverId);
}
return activities.map(transActivityInRemoteToModelType);
}
export function _getActivityById(activityId: number) {
return <ActivityInRemote>pinus.app.get('activities')?.get(activityId);
}
@@ -262,11 +277,24 @@ export function _getActivityById(activityId: number) {
export function _getActivitiesByType(serverId: number, type: number) {
let activityByType = pinus.app.get('activityByType')?.get(serverId)?.get(type)||[];
let activities: Map<number, ActivityInRemote> = pinus.app.get('activities');
let result: ActivityModelType[] = [];
let result: ActivityInRemote[] = [];
for(let activityId of activityByType) {
let activity = activities.get(activityId);
if(activity && activity.beginTime <= Date.now()) {
result.push(transActivityInRemoteToModelType(activity));
result.push(activity);
}
}
return result;
}
export function _getActivitiesByServerId(serverId: number) {
let activityByServerId = pinus.app.get('activityByServer')?.get(serverId)||[]
let activities: Map<number, ActivityInRemote> = pinus.app.get('activities');
let result: ActivityInRemote[] = [];
for(let activityId of activityByServerId) {
let activity = activities.get(activityId);
if(activity && activity.beginTime <= Date.now()) {
result.push(activity);
}
}
return result;

View File

@@ -8,10 +8,10 @@ import { gameData, getDicGachaFloor } from "../../pubUtils/data";
import { RoleModel } from "../../db/Role";
import { RewardInter } from "../../pubUtils/interface";
import { CreateHeroParam } from "../../domain/roleField/hero";
import { transPiece } from "../../pubUtils/itemUtils";
import { HeroType } from "../../db/Hero";
import { NewHeroGachaItem } from "../../domain/activityField/newHeroGachaField";
import { getActivityById } from "./activityService";
import { transPiece } from "../role/util";
/**
* 获取招募列表

View File

@@ -1,11 +1,12 @@
import { GIFT_PACKAGE_TYPE, ACTIVITY_RESOURCES_TYPE, ITEM_CHANGE_REASON } from '../../consts';
import { gameData } from '../../pubUtils/data';
import { addItems, createHeroes } from './../rewardService';
import { addItems } from '../role/rewardService';
import { RewardParam } from '../../domain/activityField/rewardField';
import { CreateHeroParam } from '../../domain/roleField/hero';
import { DicGiftPackage } from '../../pubUtils/dictionary/DicGiftPackage';
import { ItemInter, RewardInter } from '../../pubUtils/interface';
import { decodeArrayListStr } from '../../pubUtils/util';
import { createHeroes } from '../role/createHero';

View File

@@ -10,10 +10,10 @@ import { sendMailByContent } from './../mailService';
import { RoleModel, RoleType } from '../../db/Role';
import { getActivityById } from './activityService';
import { RewardInter } from '../../pubUtils/interface';
import { getGoldId } from '../../pubUtils/itemUtils';
import { DUNGEON_CONST, PVP, VIP } from '../../pubUtils/dicParam';
import { cal } from '../../pubUtils/util';
import { pinus } from 'pinus';
import { getGoldId } from '../role/rewardService';
/**
* 获取活动数据

View File

@@ -39,7 +39,7 @@ export async function getPopUpShopDataShow(activityId: number, serverId: number,
return null
}
export async function checkPopUpConditionInCreateHero(serverId, roleId, heroes: HeroType[]) {
export async function checkPopUpConditionInCreateHero(serverId: number, roleId: string, heroes: HeroType[]) {
let conditions = heroes.map(hero => ({ conditionType: POP_UP_SHOP_CONDITION_TYPE.GET_HERO_BY_QUALITY, param: { quality: hero.quality } }));
return await checkPopUpConditions(serverId, roleId, conditions);
}

View File

@@ -9,7 +9,7 @@ import { STATUS } from '../consts/statusCode';
import { HangUpSpdUpRecModel } from '../db/HangUpSpdUpRec';
import { TaskHero, TowerTaskRecModel, TowerTaskRecType } from '../db/TowerTaskRec';
import { Rank } from './rankService';
import { checkActivityTask, checkTask } from './taskService';
import { checkTask } from './task/taskService';
import { getRandExpedition, gameData } from '../pubUtils/data';
import { ItemInter, RewardInter } from '../pubUtils/interface';
import { getTimeFunM } from '../pubUtils/timeUtil';
@@ -237,8 +237,7 @@ export async function towerBattleEnd(sid: string, roleId: string, serverId: numb
if (reward) towerReward = reward;
await checkAndStartHungUp(roleId, roleName, role.towerLv - 1);
// 任务
await checkTask(roleId, sid, TASK_TYPE.BATTLE_TOWER_LV, role.towerLv - 1, false, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_TOWER_LV, 1, { towerLv: role.towerLv - 1 });
await checkTask(serverId, roleId, sid, TASK_TYPE.BATTLE_TOWER_LV, { towerLv: role.towerLv - 1 });
}
return {
status: 0,

View File

@@ -18,7 +18,7 @@ import { addUserToChannel } from './roleService';
import { ChannelUser } from '../domain/ChannelUser';
import { getRewardByBlueprtId, gameData, getBossHpByBlueprtId, getDicBlueprtById } from '../pubUtils/data';
import { getZeroPointD, nowSeconds } from '../pubUtils/timeUtil';
import { handleCost } from './rewardService';
import { handleCost } from './role/rewardService';
/**
* 在给定的品质列表中随机返回一定数量的藏宝图Id

View File

@@ -3,7 +3,7 @@
*/
import { getMails } from './mailService';
import { recentGuildMsgs, recentPrivateChatInfos, recentSysMsgs, recentWorldMsgs } from './chatService';
import { getCurTask, getPvpTask } from './taskService';
import { getCurTask, getPvpTask } from './task/taskService';
import { RoleType } from '../db/Role';
import { Application, FrontendOrBackendSession, pinus, RpcClient } from 'pinus';

View File

@@ -2,10 +2,8 @@ import { getRandEelm, } from '../pubUtils/util';
import { EPlace, Stone } from "../db/Hero";
import { gameData, getRandEffectByGroupAndLevel } from "../pubUtils/data";
import { JewelType, RandSe } from '../db/Jewel';
import { getJewelRandSe } from '../pubUtils/itemUtils';
import { checkActivityTask, checkTask, checkTaskWithEplaces, checkTaskWithEplace } from './taskService';
import { TASK_TYPE } from '../consts';
import { DicRandomEffectPool } from '../pubUtils/dictionary/DicRandomEffectPool';
import { getJewelRandSe } from './role/rewardService';
export function getRandSeResult(id: number, randSe: RandSe[], originSe: RandSe[] = [], originId?: number) {
let { randomEffect, effectCount, lv } = gameData.jewel.get(id);
@@ -129,98 +127,21 @@ export function checkStoneCanPutOnEquip(equip: EPlace, id: number, stone: number
return true;
}
export async function checkTaskInComposeEquip(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number) {
await checkTask(roleId, sid, TASK_TYPE.EQUIP_COMPOSE, newEplace.length - oldEplace.length, true, {});
await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_COMPOSE_CNT, oldEplace, newEplace, [ePlaceId]);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_COMPOSE, newEplace.length - oldEplace.length);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_COMPOSE_CNT, 1, { oldEplace, newEplace });
}
export async function checkTaskInEquipLvUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceIds: number[]) {
await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_LV_TO, oldEplace, newEplace, ePlaceIds);
await checkTask(roleId, sid, TASK_TYPE.EQUIP_LV_UP, ePlaceIds.length, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_LV_TO, 1, { oldEplace, newEplace, ePlaceIds });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_LV_UP, ePlaceIds.length, true);
}
export async function checkTaskInPutJewel(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, originJewel: JewelType, curJewel: JewelType) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL, oldEquip, newEquip, { jewels: [originJewel, curJewel ] });
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_JEWEL_CNT, oldEquip, newEquip);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, oldEquip, newEquip, { jewels: [originJewel, curJewel ] });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_JEWEL, 1, { oldEquip, newEquip, jewels: [originJewel, curJewel ] });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_JEWEL_CNT, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, 1, { oldEquip, newEquip, jewels: [originJewel, curJewel ] });
}
export async function checkTaskInPutStone(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, jewel: JewelType) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_STONE, oldEquip, newEquip);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_PUT_STONE_CNT, oldEquip, newEquip);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STONE_CNT, oldEquip, newEquip);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STONE_CNT_LV, oldEquip, newEquip);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, oldEquip, newEquip, { jewels: [ jewel ] });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_STONE, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_PUT_STONE_CNT, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STONE_CNT, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STONE_CNT_LV, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, 1, { oldEquip, newEquip, jewels: [ jewel ] });
}
export async function checkTaskInEquipStarUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpStar: boolean) {
if(isUpStar) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_STAR_UP_TO, oldEquip, newEquip);
await checkTaskWithEplaces(roleId, sid, TASK_TYPE.EQUIP_SUIT_SEID_NUM, oldEplace, newEplace, [ePlaceId], { hid });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STAR_UP_TO, 1, { oldEquip, newEquip });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_SUIT_SEID_NUM, 1, { oldEplace, newEplace, ePlaceId, hid });
}
await checkTask(roleId, sid, TASK_TYPE.EQUIP_STAR_UP_CNT, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_STAR_UP_CNT, 1, {});
}
export async function checkTaskInEquipQualityUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpQuality: boolean) {
if(isUpQuality) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP, oldEquip, newEquip, { hid });
await checkTaskWithEplace(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP_TO, oldEquip, newEquip);
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP, 1, { ePlaceId, hid });
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP_TO, 1, { oldEquip, newEquip, hid });
}
await checkTask(roleId, sid, TASK_TYPE.EQUIP_QUALITY_UP_CNT, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.EQUIP_QUALITY_UP_CNT, 1);
}
export async function checkTaskInEquipReset(serverId: number, roleId: string, sid: string) {
await checkTask(roleId, sid, TASK_TYPE.JEWEL_RESET, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_RESET, 1);
}
export async function checkTaskInEquipQuench(serverId: number, roleId: string, sid: string, isSuccess: boolean) {
await checkTask(roleId, sid, TASK_TYPE.JEWEL_QUENCH, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_QUENCH, 1);
if(isSuccess) {
await checkTask(roleId, sid, TASK_TYPE.JEWEL_QUENCH_SUCCESS, 1, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.JEWEL_QUENCH_SUCCESS, 1);
}
}
export async function checkTaskInComposeStone(serverId: number, roleId: string, sid: string, count: number) {
await checkTask(roleId, sid, TASK_TYPE.STONE_COMPOSE, count, true, {});
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.STONE_COMPOSE, count);
}
function getEquipById(oldEplace: EPlace[], newEplace: EPlace[], eplaceId: number) {
let oldEquip = oldEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0);
let newEquip = newEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0);
return { oldEquip, newEquip }
}
export function isLocked(randSe: RandSe[]) {
for(let { locked } of randSe) {
if(locked) return true;
}
return false;
}
export function getEquipById(oldEplace: EPlace[], newEplace: EPlace[], eplaceId: number) {
let oldEquip = oldEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0);
let newEquip = newEplace.find(cur => cur.id == eplaceId)||new EPlace(eplaceId, 0);
return { oldEquip, newEquip }
}
export function getJewelByEquip(oldEquip: EPlace, newEquip: EPlace, jewels: JewelType[]) {
let oldJewel = jewels.find(cur => cur && cur.seqId == oldEquip.jewel);
let newJewel = jewels.find(cur => cur && cur.seqId == newEquip.jewel);
return { oldJewel, newJewel }
}

View File

@@ -15,7 +15,6 @@ import { pinus } from "pinus";
import { GuildActivityRecordModel } from "../../db/GuildActivityRec";
import { genAuction } from "../auctionService";
import { sendMailByContent } from "../mailService";
import { getHonourObject } from '../../pubUtils/itemUtils';
import { GuildActivityCityType, GuildActivityCityModel } from "../../db/GuildActivityCity";
import { DicCityActivity } from "../../pubUtils/dictionary/DicCityActivity";
import { CityActivityObject } from "./cityActivityObj";
@@ -26,9 +25,9 @@ import { BossInstanceModel } from "../../db/BossInstance";
import { UserGuildModel } from "../../db/UserGuild";
import { raceActivityEnd } from "../timeTaskService";
import { addActive } from "../guildService";
import { checkTask, checkActivityTask } from "../taskService";
import { ActivePlayer, GuildRecord, ServerRecordModel } from "../../db/ServerRecords";
import { Attack } from "../../domain/battleField/pvp";
import { getHonourObject } from "../role/rewardService";
let gateActivityObj: GateActivityObject;
let cityActivityObj: CityActivityObject;

View File

@@ -16,7 +16,7 @@ import { ErrLogModel } from '../db/ErrLog';
import { DATA_NAME } from '../consts/dataName';
import { addRoleToGuildChannel } from "./chatService";
import { Rank } from "./rankService";
import { checkActivityTask, checkTask } from "./taskService";
import { checkTask } from "./task/taskService";
import { CounterModel } from "../db/Counter";
import { getAuction } from "./auctionService";
import { changeGuildActivity } from "./activity/guildPayService";
@@ -126,8 +126,7 @@ export async function joinGuild(code: string, guildName: string, lv: number, rol
}
//成长任务-加入军团
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_JOIN, 1);
await checkTask(roleId, sid, TASK_TYPE.GUILD_JOIN, 1, true, {});
await checkTask(serverId, roleId, sid, TASK_TYPE.GUILD_JOIN);
return { status: 0, guild, userGuild, roleName: role.roleName, memberCnt: guild.memberCnt, guildCe: guild.guildCe }
}
@@ -316,7 +315,7 @@ export async function settleGuildWeekly() {
});
await sendMailByContent(MAIL_TYPE.GUILD_ACTIVE_REWARD, roleId, { goods: reward });
// 任务
await checkTask(roleId, null, TASK_TYPE.GUILD_JOB, 1, false, { job });
await checkTask(serverId, roleId, null, TASK_TYPE.GUILD_JOB, { guildJob: job });
}
await GuildModel.updateInfo(code, { activeWeekly: 0 }, {});

View File

@@ -8,8 +8,7 @@ import { FUNC_OPT_TYPE, TASK_TYPE, WAR_TYPE, STATUS, KING_EXP_RATIO_TYPE, ITEM_C
import { BackendSession, pinus } from 'pinus';
import { REDIS_KEY } from '../consts';
import { Rank } from './rankService';
import { checkActivityTask, checkTask } from './taskService';
import { accomplishTask } from '../pubUtils/taskUtil';
import { checkTask } from './task/taskService';
import { RScriptRecordModel } from '../db/RScriptRecord';
import { setAp } from './actionPointService';
import { resResult } from '../pubUtils/util';
@@ -45,9 +44,7 @@ export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kin
await r.setRankWithRoleInfo(roleId, newLv, Date.now(), role);
// 任务
await checkTask(roleId, session.get('sid'), TASK_TYPE.ROLE_LV, newLv, false, {});
//成长任务
await checkActivityTask(serverId, session.get('sid'), roleId, TASK_TYPE.ROLE_LV, newLv);
await checkTask(serverId, roleId, session.get('sid'), TASK_TYPE.ROLE_LV, { oldLv: lv, lv: newLv });
// 弹出礼包
await checkPopUpCondition(serverId, roleId, POP_UP_SHOP_CONDITION_TYPE.LV_TO, { oldLv: lv, newLv })
@@ -71,7 +68,7 @@ export async function roleLevelup(type: KING_EXP_RATIO_TYPE, roleId: string, kin
});
if(i != lv) { // 升级加体力
let dicAp = getDicApByLv(i);
await setAp(roleId, ip, i, dicAp.restoreAp, sid, ITEM_CHANGE_REASON.LV_UP);
await setAp(serverId, roleId, ip, i, dicAp.restoreAp, sid, ITEM_CHANGE_REASON.LV_UP);
}
}
// 推送

View File

@@ -22,7 +22,7 @@ import { resResult } from '../pubUtils/util';
import { checkOrderWX } from './pay/weixinPay';
import { addRechargeMoney } from './activity/rechargeMoneyService';
import { addVipRechargeMoney } from './activity/vipRechargeMoneyService';
import { checkActivityTask } from './taskService';
import { checkTask } from './task/taskService';
import { checkOrderALI } from './pay/aliPay';
import { getRoleOnlineInfo } from './redisService';
import { PayCallback37Data } from '../domain/sdk';
@@ -183,7 +183,7 @@ export async function settleOrder(order: UserOrderModelType, serverId: number, s
addVipRechargeMoney(order.roleId, serverId, order.price);
addGuildPay(result.roleInfo, order.price)
//成长任务
await checkActivityTask(serverId, sid, order.roleId, TASK_TYPE.ACTIVITY_RMB, order.price, { activityId: order.activityId });
await checkTask(serverId, order.roleId, sid, TASK_TYPE.ACTIVITY_RMB, { count: order.price });
if(order.payType != PAY_TYPE.TEST) {
reportTAEvent(order.roleId, TA_EVENT.RECHARGE_SUCCESS, { pay_id: order.localOrderID, charge_id: order.productID, pay_name: order.message, pay_amount: order.price, pay_channel: order.payType })
reportTAUserSet(TA_USERSET_TYPE.SET_ONCE, order.roleId, { first_pay_time: new Date() });

View File

@@ -22,7 +22,7 @@ import { Rank } from './rankService';
import { CounterModel } from '../db/Counter';
import { DicRankRewads } from '../pubUtils/dictionary/DicPvpRankReward';
import { PvpSeasonResultModel, PvpSeasonResultType } from '../db/PvpSeasonResult';
import { checkTask } from '../services/taskService';
import { checkTask } from './task/taskService';
import { sendMailByContent } from './mailService';
import { RoleRankInfo } from '../domain/rank';
import { reportTAEvent } from './sdkService';
@@ -630,8 +630,8 @@ export async function savePvpSeasonResult(pvpDefense: PvpDefenseType, seasonNum:
}
// 更新任务
await checkTask(pvpDefense.roleId, null, TASK_TYPE.PVP_HERO_SCORE, 0, false, { heroScores: pvpDefense.heroScores });
await checkTask(pvpDefense.roleId, null, TASK_TYPE.PVP_RANK, 1, false, { rankLv });
await checkTask(pvpDefense.serverId, pvpDefense.roleId, null, TASK_TYPE.PVP_HERO_SCORE, { heroScores: pvpDefense.heroScores });
await checkTask(pvpDefense.serverId, pvpDefense.roleId, null, TASK_TYPE.PVP_RANK, { pvpRank: rankLv });
return pvpSeasonResult;
}

View File

@@ -179,7 +179,7 @@ export class Rank {
* @param hero 武将数据库
* @param isInc 得分是累加上的还是直接设置的
*/
public async setRankWithHeroInfo(roleId: string, hid: number, score: number, timestamp: number, hero?: HeroType, isInc = false) {
public async setRankWithHeroInfo(roleId: string, hid: number, score: number, timestamp: number, hero?: HeroUpdate, isInc = false) {
// 如果没有信息,更新玩家信息
for (let infoKey of [this.infoKey, ...this.extraKeys]) {
await this.generParamAndSet(infoKey, { roleId, hid }, { hero });
@@ -235,7 +235,7 @@ export class Rank {
* @param fields 玩家id
* @param db 数据库内的数据
*/
public async generParamAndSet(infoKey: string, fields: myIdInter, db: { role?: RoleType, guild?: GuildType, hero?: HeroType }) {
public async generParamAndSet(infoKey: string, fields: myIdInter, db: { role?: RoleType, guild?: GuildType, hero?: HeroUpdate }) {
let { roleId, guildCode, hid } = fields;
let { role, guild, hero } = db;

View File

@@ -307,8 +307,8 @@ export async function clearChannelServers() {
* @param userCode user表唯一字符串标识
* @param sid connector服的那个sid
*/
export async function roleLogin(roleId: string, userCode: string, sid: string, pkgName: string) {
let param = { userCode, sid, pkgName };
export async function roleLogin(roleId: string, userCode: string, sid: string, pkgName: string, createTime: number) {
let param = { userCode, sid, pkgName, createTime };
return await redisClient().hsetAsync(REDIS_KEY.ONLINE_USERS, roleId, JSON.stringify(param));
}
@@ -344,7 +344,8 @@ export async function getRoleOnlineInfo(roleId: string) {
isOnline: true,
userCode: result.userCode,
sid: result.sid,
pkgName: result.pkgName
pkgName: result.pkgName,
createtime: result.createTime
}
} catch(e) {
return { isOnline: false }
@@ -354,6 +355,15 @@ export async function getRoleOnlineInfo(roleId: string) {
}
}
export async function getRoleCreateTime(roleId: string) {
let onlineInfo = await getRoleOnlineInfo(roleId);
if(onlineInfo.isOnline) {
return onlineInfo.createtime;
} else {
return null
}
}
/**
* 获得所有在线的玩家
*/
@@ -440,16 +450,16 @@ export async function readDataBase() {
async function setServerList() {
const serverList = await ServerlistModel.getAllServerList();
await redisClient().delAsync(REDIS_KEY.DB_GAME);
await redisClient().delAsync(REDIS_KEY.SERVER);
for(let { id, name } of serverList) {
for(let { id, name, openTime } of serverList) {
// console.log(roleId);
await redisClient().hsetAsync(REDIS_KEY.DB_GAME, `${id}`, name);
await redisClient().hsetAsync(REDIS_KEY.SERVER, `${id}`, `${name}|${openTime}`);
}
}
export async function getAllServers() {
let servers = await redisClient().hgetallAsync(REDIS_KEY.DB_GAME);
let servers = await redisClient().hgetallAsync(REDIS_KEY.SERVER);
let serverlist = new Array<number>();
for(let serverStr in servers) {
let serverId = parseInt(serverStr);
@@ -462,10 +472,17 @@ export async function getAllServers() {
}
export async function getServerName(serverId: number) {
let name = await redisClient().hgetAsync(REDIS_KEY.DB_GAME, `${serverId}`);
let value = await redisClient().hgetAsync(REDIS_KEY.SERVER, `${serverId}`);
let name = value.split('|')[0];
return name||'常山少年'
}
export async function getServerCreateTime(serverId: number) {
let value = await redisClient().hgetAsync(REDIS_KEY.SERVER, `${serverId}`);
let time = value.split('|')[1];
return parseInt(time);
}
export function redisClient() {
const client: Redis.RedisClient = pinus.app.get('redis');
return client;

View File

@@ -3,7 +3,7 @@ import { STATUS } from '../consts/statusCode';
import { resResult, shouldRefresh, shouldRefreshWeek } from '../pubUtils/util';
import { nowSeconds } from "../pubUtils/timeUtil";
// import { RoleModel } from '../db/Role';
import { refDailyTask, refDailyTaskBox } from './taskService'
import { refDailyTask, refDailyTaskBox } from './task/taskService'
// import { EVENT_STATUS, FUNCS_ID } from "../consts";
// import { startEvent } from "./eventSercive";
import * as dicParam from '../pubUtils/dicParam';

View File

@@ -1,644 +0,0 @@
import { ITID, CONSUME_TYPE, ITEM_TABLE, CURRENCY, CURRENCY_TYPE, MAIL_TYPE, HANDLE_REWARD_TYPE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE, ITEM_CHANGE_REASON, TA_USERSET_TYPE, TA_EVENT, POP_UP_SHOP_CONDITION_TYPE } from './../consts';
import { getRandSingleEelm, resResult } from '../pubUtils/util';
import { RoleModel, RoleType } from '../db/Role';
import { setAp } from './actionPointService';
import { pushCalAllHeroCe, calPlayerCeAndSave } from './playerCeService';
import { ItemModel, ItemType } from '../db/Item';
import { STATUS } from '../consts/statusCode';
import { pinus } from 'pinus';
import { addJewels, addBags, addSkin, addFigure, unlockFigure as pubUnlockFigure, transPiece, getGoldObject, getCoinObject, getApObject } from '../pubUtils/itemUtils';
import { ItemInter, RewardInter, } from '../pubUtils/interface';
import { gameData } from '../pubUtils/data';
import { uniq } from 'underscore';
import { EPlace, HeroModel, HeroType, HeroUpdate } from '../db/Hero';
import { Figure } from '../domain/dbGeneral';
import { Rank } from './rankService';
import { pushTaskUpdate } from './taskService';
import { CreateHeroParam, HeroShowParam } from '../domain/roleField/hero';
import { HeroSkin } from '../db/Hero';
import { errlogger } from '../util/logger';
import { BAG } from '../pubUtils/dicParam';
import { sendMailByContent } from './mailService';
import { CreateHeroes } from '../pubUtils/roleUtil';
import { SkinUpdate } from '../db/Skin';
import { getInitHeroById } from './roleService';
import { getActivities } from './activity/activityService';
import { reportTAEvent, reportTAUserSet } from './sdkService';
import { saveCoinChangeLog, saveFigureInfoLog, saveGoldChangeLog, saveItemChangeLog } from '../pubUtils/logUtil';
import { JewelModel, JewelType } from '../db/Jewel';
import { updateEplaces } from './equipService';
import { checkPopUpConditionInCreateHero } from './activity/popUpShopService';
export class CheckMeterial {
private roleId: string;
private itemsIndb: Map<number, number> = new Map(); // 玩家已有的东西
private notEnoughItems: Map<number, number> = new Map(); // 缺少的数量
private consumes: ItemInter[] = []; // 消耗,正向数
private goldId = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD);
private coinId = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN);
constructor(roleId: string, role?: RoleType, items?: ItemType[]) {
this.roleId = roleId;
if(role) {
this.itemsIndb.set(this.goldId, role.gold);
this.itemsIndb.set(this.coinId, role.coin);
}
if(items && items.length) {
for(let {id, count} of items) {
this.itemsIndb.set(id, count);
}
}
}
private pushToNotEnoughItems(id: number, count: number) {
if(!this.notEnoughItems.has(id)) {
this.notEnoughItems.set(id, 0);
}
this.notEnoughItems.set(id, this.notEnoughItems.get(id) + count);
}
private getNotEnoughItems() {
let map = new Map<number, number>();
for(let [ id, count ] of this.notEnoughItems) {
map.set(id, count);
}
return map;
}
public async decrease(goods: {id: number, count: number}[]) {
this.notEnoughItems.clear();
let { items, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
let isEnough = true;
for(let { id, count} of items) {
if(!this.itemsIndb.has(id)) {
let item = await ItemModel.findbyRoleAndGid(this.roleId, id);
if(!item) {
this.pushToNotEnoughItems(id, count);
isEnough = false; break;
}
this.itemsIndb.set(id, item.count);
}
if(this.itemsIndb.get(id) < count) {
this.pushToNotEnoughItems(id, count - this.itemsIndb.get(id));
isEnough = false; break;
}
this.itemsIndb.set(id, this.itemsIndb.get(id) - count);
}
if(gold.length > 0) {
if(!this.itemsIndb.has(this.goldId)) {
let role = await RoleModel.findByRoleId(this.roleId, 'gold coin');
this.itemsIndb.set(this.goldId, role.gold);
this.itemsIndb.set(this.coinId, role.coin);
}
let goldCost = gold.reduce((pre, cur) => { return pre + cur.count }, 0);
if(this.itemsIndb.get(this.goldId) < goldCost) {
this.pushToNotEnoughItems(this.goldId, goldCost - this.itemsIndb.get(this.goldId));
isEnough = false;
}
this.itemsIndb.set(this.goldId, this.itemsIndb.get(this.goldId) - goldCost);
}
if(isEnough && coin.length > 0) {
if(!this.itemsIndb.has(this.coinId)) {
let role = await RoleModel.findByRoleId(this.roleId, 'gold coin');
this.itemsIndb.set(this.goldId, role.gold);
this.itemsIndb.set(this.coinId, role.coin);
}
let coinCost = coin.reduce((pre, cur) => pre + cur, 0);
if(this.itemsIndb.get(this.coinId) < coinCost) {
this.pushToNotEnoughItems(this.coinId, coinCost - this.itemsIndb.get(this.coinId));
isEnough = false;
}
this.itemsIndb.set(this.coinId, this.itemsIndb.get(this.coinId) - coinCost);
}
if(isEnough) this.consumes.push(...goods);
return isEnough;
}
private getMaterialEnough(materials: RewardInter[], notEnoughItems: Map<number, number>) {
let newMaterials: RewardInter[] = [];
for(let {id, count} of materials) {
if(notEnoughItems.has(id)) {
newMaterials.push({ id, count: count - notEnoughItems.get(id) });
} else {
newMaterials.push({ id, count });
}
}
return newMaterials;
}
// 检查地玉石是否可以合成
public async composeStone(id: number, count: number) {
let dicStone = gameData.stone.get(id);
if(!dicStone || dicStone.composeMaterial.length <= 0) return false; // 1阶石头不能再从下合成返回不行
let materials = dicStone.composeMaterial.map(cur => ({...cur, count: cur.count * count }));
let isEnough = await this.decrease(materials);
if(!isEnough) {
let notEnoughItems = this.getNotEnoughItems();
let newMaterials = this.getMaterialEnough(materials, notEnoughItems);
let isEnough = await this.decrease(newMaterials); // 消耗掉除了不足的部分以外的其他部分
if(!isEnough) return false;
let isAllOK = true; // 如果有石头不足向下补充isAllOK标识不足的都能补充上
for(let [id, count] of notEnoughItems) {
let isEnough = await this.composeStone(id, count);
if(!isEnough) {
isAllOK = false; break;
}
}
return isAllOK;
} else {
return true;
}
}
public getConsume() {
return this.consumes;
}
}
export async function handleCost(roleId: string, sid: string, goods: Array<ItemInter>, reason: ITEM_CHANGE_REASON) {
let uids = [{ uid: roleId, sid }];
let { items, jewels, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
let jewelSeqIds = jewels.map(cur => cur.seqId);
let resJewels: JewelType[] = [];
// 检查货币是否充足
let role = await RoleModel.findByRoleId(roleId);
if (gold.length > 0 || coin.length > 0) {
let { gold: originGold, coin: originCoin } = role;
for(let {count} of gold) { originGold -= count };
for(let count of coin) { originCoin -= count };
if(originGold < 0 || originCoin < 0) return false;
}
//检查装备是否存在
if (jewels.length > 0) {
resJewels = await JewelModel.findbySeqIds(jewelSeqIds);
if (resJewels.length < jewels.length)
return false;
}
//检查并修改道具
if (items.length > 0) {
let { hasError, result } = await ItemModel.decreaseItems(roleId, items);
if (hasError) return false;
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, { goods: result.map(cur => ({...cur, reason })) }), uids);
saveItemChangeLog(roleId, result, reason);
}
//删除装备
if (resJewels.length > 0) {
let heroMap = new Map<number, { hero: HeroType, jewels: JewelType[]}>();
for(let jewel of resJewels) {
if(jewel.hid > 0) {
if(!heroMap.has(jewel.hid)) {
let hero = await HeroModel.findByHidAndRole(jewel.hid, roleId);
heroMap.set(jewel.hid, { hero, jewels: [] });
}
heroMap.get(jewel.hid).jewels.push(jewel);
}
}
for(let [_hid, {hero, jewels} ] of heroMap) {
// 脱下天晶石
let update = new Map<number, Partial<EPlace>>();
for(let jewel of jewels) {
await JewelModel.putOnOrOff(jewel.id, 0, 0);
let curEquip = hero.ePlace.find(cur => cur.jewel == jewel.id);
if(!!curEquip) {
update.set(curEquip.id, { jewel: 0 });
}
}
let { newEplace } = updateEplaces(hero.ePlace, update);
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, sid, roleId, hero, { ePlace: newEplace }, [...update.keys()]);
}
let jewels = await JewelModel.deleteBySeqIds(roleId, jewelSeqIds);
saveItemChangeLog(roleId, jewels.map(jewel => ({ id: jewel.id, count: 1, inc: -1 })), reason);
pinus.app.get('channelService').pushMessageByUids('onJewelDel', resResult(STATUS.SUCCESS, { jewels: jewels.map(jewel => ({ seqId: jewel.seqId, id: jewel.id, inc: -1, reason })) }), uids);
}
//消耗玩家货币
if (gold.length > 0 || coin.length > 0) {
let costGold = gold.reduce((pre, cur) => pre + cur.count, 0);
let costCoin = coin.reduce((pre, cur) => pre + cur, 0);
role = await RoleModel.decreaseGoldAndCoin(roleId, gold, costCoin);
pinus.app.get('channelService').pushMessageByUids('onPlayerDataChange', resResult(STATUS.SUCCESS, {
gold: role.gold, coin: role.coin, totalCost: role.totalCost
}), uids);
if(costGold > 0) {
reportTAEvent(roleId, TA_EVENT.ITEM_CONSUME, getGoldEventProperties(costGold, role.gold, reason));
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_gold: role.gold });
saveGoldChangeLog(roleId, role.gold, -1 * costGold, reason);
}
if(costCoin > 0) {
reportTAEvent(roleId, TA_EVENT.ITEM_CONSUME, getCoinEventProperties(costCoin, role.coin, reason));
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_coin: role.coin });
saveCoinChangeLog(roleId, role.coin, -1 * costCoin, reason);
}
}
return true;
}
// TODO: sid 在方法内部获取,且不一定存在
export async function addItems(roleId: string, roleName: string, sid: string, goods: Array<ItemInter>, reason: ITEM_CHANGE_REASON) {
let uids = [{ uid: roleId, sid }];
let { items, jewels, gold, coin, ap, skins, figures } = sortItems(goods, HANDLE_REWARD_TYPE.RECEIVE);
let showItems: { id: number, seqId?: number, count: number, isBag?: boolean }[] = [];
let role = await RoleModel.findByRoleId(roleId);
// 1. 装备处理
if(jewels.length > 0) {
let { jewelCount = 0 } = role;
let incJewels = jewels, mailJewels: { id?: number, hid?: number, seqId?: number }[] = [];
if(jewels.length + jewelCount > BAG.BAG_EQUIP_UPLIMITED) { // 装备上限
let inc = BAG.BAG_EQUIP_UPLIMITED - jewelCount;
if(inc < 0) inc = 0;
incJewels = jewels.slice(0, inc);
mailJewels = jewels.slice(inc);
}
// 直接加的
let { jewels: jewelInfos, pushMessages } = await addJewels(roleId, roleName, <{id: number, hid?: number}[]>incJewels, reason);
for (let jewel of jewelInfos) {
showItems.push({ seqId: jewel.seqId, id: jewel.id, count: 1, isBag: true });
}
for(let jewel of combineItems(mailJewels)) {
showItems.push({ id: jewel.id, count: jewel.count, isBag: false });
}
//装备推送
if (!!jewelInfos.length)
pinus.app.get('channelService').pushMessageByUids('onJewelAdd', resResult(STATUS.SUCCESS, { jewelInfos }), uids);
pushTaskUpdate(roleId, sid, pushMessages);
//统计装备
if (jewelInfos.length > 0) {
saveItemChangeLog(roleId, jewelInfos, reason);
}
// 发邮件的
if(mailJewels.length > 0) {
await sendMailByContent(MAIL_TYPE.EQUIP_OVER, roleId, { goods: combineItems(mailJewels) });
}
}
// 2. 道具处理
if(items.length > 0) {
let { items: itemInfos } = await addBags(roleId, roleName, items, reason);
for (let item of items) {
showItems.push({ id: item.id, count: item.count });
}
//背包除去装备推送
if (!!itemInfos.length) {
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, { goods: itemInfos }), uids);
saveItemChangeLog(roleId, itemInfos, reason);
}
}
// 3. 货币推送
if(gold.length > 0 || coin.length > 0 || ap > 0) {
await setAp(roleId, null, role.lv, ap, sid, reason);
let incCoin = coin.reduce((pre, cur) => pre + cur, 0);
let incGold = gold.reduce((pre, cur) => pre + cur.count, 0);
role = await RoleModel.increaseGoldAndCoin(roleId, gold, incCoin);
pinus.app.get('channelService').pushMessageByUids('onPlayerDataChange', resResult(STATUS.SUCCESS, {
gold: role.gold, coin: role.coin
}), uids);
if(gold.length > 0) {
gold.forEach(({ count }) => {
showItems.push(getGoldObject(count));
});
reportTAEvent(roleId, TA_EVENT.ITEM_GET, getGoldEventProperties(incGold, role.gold, reason));
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_gold: role.gold });
saveGoldChangeLog(roleId, role.gold, incGold, reason );
}
if(coin.length > 0) {
coin.forEach(count => {
showItems.push(getCoinObject(count));
});
reportTAEvent(roleId, TA_EVENT.ITEM_GET, getCoinEventProperties(incCoin, role.coin, reason));
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_coin: role.coin });
saveCoinChangeLog(roleId, role.coin, incCoin, reason);
}
if(ap > 0) {
showItems.push(getApObject(ap));
}
}
// 4. 皮肤处理
let figureInfos:{ heads: Figure[], frames: Figure[], spines: Figure[] }[] = []; // 头像变化推送信息
if(skins.length > 0) {
let heroskins: {skins: HeroSkin[], hid: number}[] = []; // 皮肤推送信息
let skinInfos: {id: number, hid: number, count: number, inc: number, reason: number }[] = [];
let calAllHeroResult = undefined; // 全局战力变化推送
for (let skinId of skins) {//皮肤推送
let result = await addSkin(roleId, roleName, skinId, false);
if (!!result) {
showItems.push({ id: skinId, count: 1 });
figureInfos.push(result.figureInfo);
if(result.hero) {
heroskins.push({ skins: result.hero.skins, hid: result.hero.hid });
if(result.calAllHeroResult) calAllHeroResult = result.calAllHeroResult;
}
skinInfos.push({ id: skinId, hid: result.hero?.hid||0, count: 1, inc: 1, reason })
}
}
if (!!skinInfos.length) {
pushHeroSkinMsg(heroskins, skinInfos, uids); // 推送onHeroSkinChange
saveItemChangeLog(roleId, skinInfos, reason);
}
// 推送全局加成信息
if(calAllHeroResult) await pushCalAllHeroCe(roleId, sid, calAllHeroResult);
}
// 5. 获得头像和相框等
if(figures.length > 0) {
let figureInfo = await addFigure(roleId, figures, reason);
if(figureInfo) figureInfos.push(figureInfo);
for (let id of figures) {//皮肤推送
showItems.push({ id, count: 1 });
}
}
// 获得头像或相框或形象推送
if(!!figureInfos && figureInfos.length > 0) {
for(let figureInfo of figureInfos) {
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
saveFigureInfoLog(roleId, figureInfo, reason)
}
}
return showItems;
}
function getGoldEventProperties(inc: number, count: number, reason: ITEM_CHANGE_REASON) {
let id = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD);
let dicGoods = gameData.goods.get(id);
return { item_id: id, item_name: dicGoods.name, item_itid: dicGoods.itid, change_count: inc, change_after: count, change_reason: reason }
}
function getCoinEventProperties(inc: number, count: number, reason: ITEM_CHANGE_REASON) {
let id = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN);
let dicGoods = gameData.goods.get(id);
return { item_id: id, item_name: dicGoods.name, item_itid: dicGoods.itid, change_count: inc, change_after: count, change_reason: reason }
}
export function combineItems(items: { id?: number, count?: number }[]) {
let result: { id: number, count: number }[] = [];
for(let { id, count = 1 } of items) {
let index = result.findIndex(cur => cur.id == id);
if(index == -1) {
result.push({ id, count });
} else {
result[index].count += count;
}
}
return result;
}
export function combineItemAndJewels(items: { id?: number, count?: number }[]) {
let result: { id: number, count: number }[] = [];
for(let { id, count = 1 } of items) {
let dicGoods = gameData.goods.get(id);
let dicItid = ITID.get(dicGoods.itid);
if(dicItid.table != 'jewel') {
let index = result.findIndex(cur => cur.id == id);
if(index == -1) {
result.push({ id, count });
} else {
result[index].count += count;
}
} else {
result.push({ id, count });
}
}
return result;
}
function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) {
let items: { id: number, count: number }[] = []; // 可叠加道具
let jewels: { seqId?: number, id?: number, hid?: number }[] = []; // 不可叠加装备
let gold: { count: number, isPay: boolean }[] = []; // 金币
let coin: number[] = [];
let ap: number = 0;
let skins: number[] = [];
let figures: number[] = [];
for(let good of goods) {
if(good.count == 0) continue;
let dicGood = gameData.goods.get(good.id);
if(!dicGood) {
errlogger.error(`物品 ${good.id} 未配置`);
continue;
}
let dicItid = ITID.get(dicGood.itid);
if(!dicItid) {
errlogger.error(`itid ${dicGood.itid} 未配置`);
continue;
}
let { type, table, isCurrency } = dicItid;
if(table == ITEM_TABLE.JEWEL) { // 装备
if(handleType == HANDLE_REWARD_TYPE.RECEIVE) {
for(let i = 0; i < good.count; i++) {
jewels.push({ id: good.id, hid: good.hid })
}
} else {
if(!!good.seqId) {
jewels.push({ seqId: good.seqId });
}
}
} else if (table == ITEM_TABLE.ITEM) { // 可叠加道具
let index = items.findIndex(cur => cur.id == good.id);
if(index > 0) {
items[index].count += good.count;
} else {
items.push({ id: good.id, count: good.count });
}
} else if (table == ITEM_TABLE.SKIN) { // 皮肤,不可重复获得,不可删
if(handleType == HANDLE_REWARD_TYPE.RECEIVE) {
let index = skins.indexOf(good.id);
if (index == -1) {
skins.push(good.id);
}
}
} else if (table == ITEM_TABLE.ROLE) {
if(isCurrency) { // 3种货币
let dicCurrency = CURRENCY.get(good.id);
if(dicCurrency) {
if(dicCurrency.type == CURRENCY_TYPE.GOLD) { // 金币,区分付费和免费,默认免费
let index = gold.findIndex(cur => cur.isPay == !!good.isPay);
if(index > 0) {
gold[index].count += good.count;
} else {
gold.push({ count: good.count, isPay: !!good.isPay });
}
} else if (dicCurrency.type == CURRENCY_TYPE.COIN) { // 铜钱
coin.push(good.count);
} else if (dicCurrency.type == CURRENCY_TYPE.ACTION_POINT) { // 体力
ap += good.count;
}
}
} else {
if (type == CONSUME_TYPE.HEAD || type == CONSUME_TYPE.FRAME || type == CONSUME_TYPE.SPINE) { // 头像等,不可重复获得,不可删
let index = figures.indexOf(good.id);
if (index == -1) {
figures.push(good.id);
}
}
}
}
}
return { items, jewels, gold, coin, ap, skins, figures }
}
export async function checkGoods(roleId: string, goodIds: Array<number>) {
let jewelSeqIds: Array<number> = [];
let itemIds: Array<number> = [];
let hids: Array<number> = [];
goodIds = uniq(goodIds);
for (let goodId of goodIds) {
let goodInfo = gameData.goods.get(goodId);
if (!!goodInfo) {
let { table } = ITID.get(goodInfo.itid);
if (table == ITEM_TABLE.EQUIP) {
jewelSeqIds.push(goodId);
} else if (table == ITEM_TABLE.ITEM) {
itemIds.push(goodId);
}
}
}
//检查装备是否存在
if (!!jewelSeqIds.length) {
let resJewels = await JewelModel.findbySeqIds(jewelSeqIds);
resJewels = uniq(resJewels, function (resEquip) {
return resEquip.id;
});
if (resJewels.length < jewelSeqIds.length)
return false;
}
//检查并修改道具
if (itemIds.length > 0) {
let items = await ItemModel.findbyRoleAndIds(roleId, itemIds);
if (items.length < itemIds.length)
return false;
}
return true;
}
export async function checkHeroes(roleId: string, hids: number[]) {
if (!!hids.length) {
let heros = await HeroModel.findByHidRange(hids, roleId);
if (heros.length < hids.length)
return false;
}
return true
}
export async function checkHeroEquips(roleId: string, quality: number) {
return await HeroModel.checkEquipByQuality(roleId, quality);
}
export async function unlockFigure(sid: string, roleId: string, conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number, paramWinStreakNum?: number }[], role?: RoleType) {
let figureInfo = await pubUnlockFigure(roleId, conditions, role);
await pushFigureUpdate(roleId, sid, figureInfo);
}
export async function pushFigureUpdate(roleId: string, sid: string, figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }) {
if (!!figureInfo && (figureInfo.heads.length > 0 || figureInfo.frames.length > 0 || figureInfo.spines.length > 0)) {
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
}
}
/**
* 创建多个武将
* @param roleId
* @param sid
* @param serverId
* @param heroInfo
*/
export async function createHeroes(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam[]) {
let hids = heroInfo.map(cur => cur.hid);
let userHeroesMap = await HeroModel.findMapByHidRange(hids, roleId);
let infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }> = new Map(), pieces: ItemInter[] = [];
for (let h of heroInfo) {
let heroCount = h.count || 1;
if (userHeroesMap.has(h.hid)) {
let { pieceId, count } = transPiece(h.hid);
pieces.push({ id: pieceId, count: count * heroCount });
} else {
let initInfo: { heroInfo: HeroUpdate, skinInfo: SkinUpdate };
if(pinus.app.getServerType() == 'role') {
initInfo = getInitHeroById(h.hid);
} else {
let roleServers = pinus.app.getServersByType('role');
let server = getRandSingleEelm(roleServers);
initInfo = await pinus.app.rpc.role.roleRemote.getInitHeroById.toServer(server.id, h.hid);
}
initInfo.heroInfo = { ...initInfo.heroInfo, ...h };
infos.set(h.hid, initInfo);
userHeroesMap.set(h.hid, null);
if (heroCount > 1) {
let { pieceId, count } = transPiece(h.hid);
pieces.push({ id: pieceId, count: count * (heroCount - 1) });
}
}
}
let resultHeroes: HeroType[] = [], resultItems: RewardInter[] = [], heroes: HeroShowParam[] = [];
if (infos.size > 0) {
let createHero = new CreateHeroes(roleId, roleName, serverId);
await createHero.createWithHeroInfo(infos);
await createHero.clearTask(await getActivities())
await createHero.pushMessage(pinus, sid);
await createHero.updateRedisRank(Rank);
heroes = createHero.getShowHeroes();
resultHeroes = createHero.getResultHeroes();
await checkPopUpConditionInCreateHero(serverId, roleId, resultHeroes);
}
if (pieces.length > 0) {
let goods = await addItems(roleId, roleName, sid, pieces, ITEM_CHANGE_REASON.HERO_TRANSFER_PIECE);
resultItems = goods;
}
return { heroes, resultHeroes, goods: resultItems }
}
export async function createHero(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam) {
let result = await createHeroes(roleId, roleName, sid, serverId, [heroInfo]);
return result;
}
/**
* 皮肤数据变化去重、推送
* @param heroskins 推送的皮肤
* @param uids 玩家
*/
function pushHeroSkinMsg(heroskins: {skins: HeroSkin[], hid: number}[], skinInfos: {id: number, hid: number }[], uids: {uid: string, sid: string}[]) {
let pushSkinInfos: {skins: HeroSkin[], hid: number}[] = []; // 可能会有重复的
for(let { skins, hid } of heroskins) {
let index = pushSkinInfos.findIndex(cur => cur.hid == hid);
if(index == -1) {
pushSkinInfos.push({skins, hid});
} else {
if(skins.length > pushSkinInfos[index].skins.length) {
pushSkinInfos[index] = {skins, hid};
}
}
}
if(pushSkinInfos.length > 0 || skinInfos.length > 0) {
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, { heros: heroskins, skins: skinInfos }), uids);
}
}

View File

@@ -0,0 +1,136 @@
import { CURRENCY_TYPE, HANDLE_REWARD_TYPE, CURRENCY_BY_TYPE } from '../../consts';
import { RoleModel, RoleType } from '../../db/Role';
import { ItemModel, ItemType } from '../../db/Item';
import { ItemInter, RewardInter, } from '../../pubUtils/interface';
import { gameData } from '../../pubUtils/data';
import { sortItems } from './util';
export class CheckMeterial {
private roleId: string;
private itemsIndb: Map<number, number> = new Map(); // 玩家已有的东西
private notEnoughItems: Map<number, number> = new Map(); // 缺少的数量
private consumes: ItemInter[] = []; // 消耗,正向数
private goldId = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD);
private coinId = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN);
constructor(roleId: string, role?: RoleType, items?: ItemType[]) {
this.roleId = roleId;
if(role) {
this.itemsIndb.set(this.goldId, role.gold);
this.itemsIndb.set(this.coinId, role.coin);
}
if(items && items.length) {
for(let {id, count} of items) {
this.itemsIndb.set(id, count);
}
}
}
private pushToNotEnoughItems(id: number, count: number) {
if(!this.notEnoughItems.has(id)) {
this.notEnoughItems.set(id, 0);
}
this.notEnoughItems.set(id, this.notEnoughItems.get(id) + count);
}
private getNotEnoughItems() {
let map = new Map<number, number>();
for(let [ id, count ] of this.notEnoughItems) {
map.set(id, count);
}
return map;
}
public async decrease(goods: {id: number, count: number}[]) {
this.notEnoughItems.clear();
let { items, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
let isEnough = true;
for(let { id, count} of items) {
if(!this.itemsIndb.has(id)) {
let item = await ItemModel.findbyRoleAndGid(this.roleId, id);
if(!item) {
this.pushToNotEnoughItems(id, count);
isEnough = false; break;
}
this.itemsIndb.set(id, item.count);
}
if(this.itemsIndb.get(id) < count) {
this.pushToNotEnoughItems(id, count - this.itemsIndb.get(id));
isEnough = false; break;
}
this.itemsIndb.set(id, this.itemsIndb.get(id) - count);
}
if(gold.length > 0) {
if(!this.itemsIndb.has(this.goldId)) {
let role = await RoleModel.findByRoleId(this.roleId, 'gold coin');
this.itemsIndb.set(this.goldId, role.gold);
this.itemsIndb.set(this.coinId, role.coin);
}
let goldCost = gold.reduce((pre, cur) => { return pre + cur.count }, 0);
if(this.itemsIndb.get(this.goldId) < goldCost) {
this.pushToNotEnoughItems(this.goldId, goldCost - this.itemsIndb.get(this.goldId));
isEnough = false;
}
this.itemsIndb.set(this.goldId, this.itemsIndb.get(this.goldId) - goldCost);
}
if(isEnough && coin.length > 0) {
if(!this.itemsIndb.has(this.coinId)) {
let role = await RoleModel.findByRoleId(this.roleId, 'gold coin');
this.itemsIndb.set(this.goldId, role.gold);
this.itemsIndb.set(this.coinId, role.coin);
}
let coinCost = coin.reduce((pre, cur) => pre + cur, 0);
if(this.itemsIndb.get(this.coinId) < coinCost) {
this.pushToNotEnoughItems(this.coinId, coinCost - this.itemsIndb.get(this.coinId));
isEnough = false;
}
this.itemsIndb.set(this.coinId, this.itemsIndb.get(this.coinId) - coinCost);
}
if(isEnough) this.consumes.push(...goods);
return isEnough;
}
private getMaterialEnough(materials: RewardInter[], notEnoughItems: Map<number, number>) {
let newMaterials: RewardInter[] = [];
for(let {id, count} of materials) {
if(notEnoughItems.has(id)) {
newMaterials.push({ id, count: count - notEnoughItems.get(id) });
} else {
newMaterials.push({ id, count });
}
}
return newMaterials;
}
// 检查地玉石是否可以合成
public async composeStone(id: number, count: number) {
let dicStone = gameData.stone.get(id);
if(!dicStone || dicStone.composeMaterial.length <= 0) return false; // 1阶石头不能再从下合成返回不行
let materials = dicStone.composeMaterial.map(cur => ({...cur, count: cur.count * count }));
let isEnough = await this.decrease(materials);
if(!isEnough) {
let notEnoughItems = this.getNotEnoughItems();
let newMaterials = this.getMaterialEnough(materials, notEnoughItems);
let isEnough = await this.decrease(newMaterials); // 消耗掉除了不足的部分以外的其他部分
if(!isEnough) return false;
let isAllOK = true; // 如果有石头不足向下补充isAllOK标识不足的都能补充上
for(let [id, count] of notEnoughItems) {
let isEnough = await this.composeStone(id, count);
if(!isEnough) {
isAllOK = false; break;
}
}
return isAllOK;
} else {
return true;
}
}
public getConsume() {
return this.consumes;
}
}

View File

@@ -0,0 +1,277 @@
import { FIGURE_UNLOCK_CONDITION, ITEM_CHANGE_REASON, REDIS_KEY, STATUS, TASK_TYPE, HERO_SYSTEM_TYPE } from "../../consts";
import { SkinModel } from "../../db/Skin";
import { HeroModel, HeroSkin, HeroType, HeroUpdate } from "../../db/Hero";
import { RoleModel, RoleType, RoleUpdate } from "../../db/Role";
import { SkinUpdate } from "../../db/Skin";
import { Figure, TopHero } from "../../domain/dbGeneral";
import { TaskListReturn } from "../../domain/roleField/task";
import { GuildModel, GuildType } from "../../db/Guild";
import { PvpDefenseModel } from "../../db/PvpDefense";
import { pick } from "underscore";
import { calculatetopLineup } from "../../pubUtils/playerCe";
import { nowSeconds } from "../../pubUtils/timeUtil";
import { saveCeChangeLog } from "../../pubUtils/logUtil";
import { getRandSingleEelm, reduceCe, resResult } from "../../pubUtils/util";
import { AttributeCal } from "../../domain/roleField/attribute";
import { CreateHeroParam, HeroShowParam } from "../../domain/roleField/hero";
import { pinus } from "pinus";
import { Rank } from "../rankService";
import { checkTaskInCreateHero } from "../task/taskService";
import { ItemInter, RewardInter } from "../../pubUtils/interface";
import { transPiece } from "./util";
import { getInitHeroById } from "../roleService";
import { addItems, combineFigureInfo, unlockFigureWithoutSave } from "./rewardService";
export class UpdateHeroes {
roleId: string;
roleName: string;
serverId: number;
incHeroNum: number = 0;
incRoleCe: number = 0;
pushHeroes: {hid: number, incHeroCe: number, ce: number, hero: HeroUpdate}[] = [];
roleUpdate: RoleUpdate;
role: RoleType;
guild: GuildType;
constructor(roleId: string, roleName: string, serverId: number) {
this.roleId = roleId;
this.roleName = roleName;
this.serverId = serverId;
}
public setRole(role: RoleType) {
this.role = role;
}
public async getRole() {
if(!this.role) {
this.role = await RoleModel.findByRoleId(this.roleId);
}
return this.role;
}
public addRoleUpdateParam(param: RoleUpdate) {
this.roleUpdate = {...this.roleUpdate, ...param};
}
public async updateDbCe(isCreate: boolean, heroInfo: HeroUpdate, originCe = 0) {
let role = await this.getRole();
if(isCreate) this.incHeroNum ++;
if(heroInfo != originCe) this.incRoleCe += heroInfo.ce - originCe;
this.addRoleUpdateParam(await calculatetopLineup(role, heroInfo.hid, heroInfo.ce, heroInfo._id ));
this.pushHeroes.push({ hid: heroInfo.hid, incHeroCe: heroInfo.ce - originCe, ce: heroInfo.ce, hero: heroInfo });
}
// 更新战力相关的各个表
public async saveCeToDb() {
let role = await this.getRole();
// 更新role表
this.role = await RoleModel.updateRoleInfo(this.roleId, {
heroNum: this.incHeroNum + role.heroNum, ce: this.incRoleCe + role.ce, heroNumUpdatedAt: nowSeconds(), ...this.roleUpdate
});
// 更新guild表
if(role.hasGuild) {
this.guild = await GuildModel.updateCe(this.roleId, this.incRoleCe, true); // 公会更新战力
}
for(let { hid, incHeroCe } of this.pushHeroes) {
await PvpDefenseModel.updateCe(this.roleId, hid, incHeroCe); // 更新pvp防守阵战力
}
saveCeChangeLog(this.role, this.incRoleCe, this.role.ce, HERO_SYSTEM_TYPE.INIT, this.pushHeroes.map(cur => cur.hid));
}
public async updateRedisRank() {
let role = await this.getRole();
let { serverId, roleId, pushHeroes } = this;
// 更新军团信息
if(this.guild) {
let r = new Rank(REDIS_KEY.GUILD_INFO, { guildCode: this.guild.code });
await r.generParamAndSet(REDIS_KEY.GUILD_INFO, { guildCode: this.guild.code }, { guild: this.guild });
}
// 武将数量
if(this.incHeroNum > 0) {
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
await r.setRankWithRoleInfo(roleId, role.heroNum, role.heroNumUpdatedAt, role);
}
// 最强阵容
let r = new Rank(REDIS_KEY.TOP_LINEUP_RANK, { serverId });
await r.setRankWithRoleInfo(roleId, reduceCe(role.topLineupCe), 0, role);
// 最强武将
for(let { hid, ce, hero } of pushHeroes) {
let r2 = new Rank(REDIS_KEY.TOP_HERO_RANK, { serverId });
await r2.setRankWithHeroInfo(roleId, hid, reduceCe(ce), 0, hero);
let r4 = new Rank(REDIS_KEY.HERO_RANK, { serverId, hid });
await r4.setRankWithHeroInfo(roleId, hid, reduceCe(ce), 0, hero);
}
// 总战力
let r3 = new Rank(REDIS_KEY.SUM_CE_RANK, { serverId });
await r3.setRankWithRoleInfo(roleId, reduceCe(role.ce), 0, role);
// 更新最强五人阵容信息
let r5 = new Rank(REDIS_KEY.TOP_LINEUP_INFO, { serverId });
await r5.generParamAndSet(REDIS_KEY.TOP_LINEUP_INFO, { roleId }, { role });
}
public async pushMessage(pinus: any, sid: string) {
let role = await this.getRole();
let uids = [{ uid: this.roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: this.pushHeroes.map(cur => { return {...cur, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }}), topLineupCe: reduceCe(role.topLineupCe) }), uids);
}
}
export class CreateHeroes extends UpdateHeroes {
private resultHeroes: HeroType[] = [];
private heroNum = 0;
// 推送信息
private taskPushMessage: TaskListReturn[] = [];
private activityTaskPushMessage = [];
private figureInfos: { heads: Figure[], frames: Figure[], spines: Figure[] }[] = [];
private skinPushMessages: { heros: {skins: HeroSkin[], hid: number}[], skins: {id: number, hid: number, inc: number, reason: number }[]} = { heros: [], skins: [] };
private async getSkinsOfThisHero(hid: number, initSkinInfo: SkinUpdate, isInit: boolean) {
let allSkins = isInit? []: await SkinModel.findbyRoleAndHid(this.roleId, hid);
let skin = await SkinModel.insertSkins(this.roleId, this.roleName, [initSkinInfo]);
let skinInfos = skin.map(cur => ({ id: cur.id, hid, inc: 1, reason: ITEM_CHANGE_REASON.GET_HERO_UNLOCK_SKIN}))
this.skinPushMessages.skins.push(...skinInfos);
if(skin) allSkins.push(...skin);
let skins: { id: number, skin: string, enable: boolean, skinId: number }[] = [];
for(let skin of allSkins) {
skins.push({ id: skin.id, skin: skin._id, enable: skin.id == initSkinInfo.id, skinId: skin.skinId });
}
return skins
}
// game-server里面创建武将
public async createWithHeroInfo(infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }>) {
let role = await this.getRole();
// 数据处理
let conditions = new Array<{ type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }>(); // 解锁头像条件
let initHeroInfos: HeroUpdate[] = [];
for (let [ hid, { heroInfo, skinInfo }] of infos) {
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: heroInfo.hid });
this.updateDbCe(true, heroInfo);
// 皮肤使用初始加载进内存的数据
let skins = await this.getSkinsOfThisHero(hid, { ...skinInfo, _id: new SkinModel()._id }, false);
let newAttr = new AttributeCal();
newAttr.setLv(heroInfo.lv);
newAttr.setByDbData(role.attr, heroInfo.attr);
let heroCe = newAttr.calCe(); // 计算最终战力
initHeroInfos.push({ ...heroInfo, skins, _id: new HeroModel()._id, ce: heroCe });
this.heroNum ++;
}
// 武将使用初始加载数据插入
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, initHeroInfos);
let heroSkins = this.resultHeroes.map(cur => { return pick(cur, ['hid', 'skins']) });
this.skinPushMessages.heros.push(...heroSkins);
// 头像解锁
let { figureInfo, frames, heads, spines } = unlockFigureWithoutSave(conditions, role);
this.figureInfos.push(figureInfo);
this.addRoleUpdateParam({ frames, heads, spines });
// 更新战力
await this.saveCeToDb();
}
// 创建初始账号时候的初始
public async createWithInitInfo(infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }>, figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }) {
this.figureInfos.push(figureInfo);
let heroeInfos: HeroUpdate[] = [];
for (let [ hid, { heroInfo, skinInfo }] of infos) {
this.updateDbCe(true, heroInfo);
let model = new SkinModel();
let skins = await this.getSkinsOfThisHero(hid, { ...skinInfo, _id: model._id }, true);
heroeInfos.push({ ...heroInfo, skins, _id: new HeroModel()._id});
this.heroNum ++;
}
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, heroeInfos);
}
public async pushMessage(sid: string) {
let role = await this.getRole();
let uids = [{ uid: this.roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: this.pushHeroes.map(cur => { return {...cur, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }}), topLineupCe: reduceCe(role.topLineupCe) }), uids);
let figureInfo = combineFigureInfo(this.figureInfos);
if (!!figureInfo && (figureInfo.heads.length > 0 || figureInfo.frames.length > 0 || figureInfo.spines.length > 0)) {
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
}
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, this.skinPushMessages), uids);
pinus.app.get('channelService').pushMessageByUids('onHeroUpdate', resResult(STATUS.SUCCESS, { heroes: this.getResultHeroes() }), uids);
checkTaskInCreateHero(this.serverId, this.roleId, sid, this.heroNum, this.resultHeroes)
}
public getResultHeroes() {
return this.resultHeroes.map(cur => ({...cur, ce: reduceCe(cur.ce)}))
}
public getShowHeroes() {
return this.resultHeroes.map(cur => {
let hero = new HeroShowParam(cur);
return { ...hero, ce: reduceCe(cur.ce)}
});
}
}
/**
* 创建多个武将
* @param roleId
* @param sid
* @param serverId
* @param heroInfo
*/
export async function createHeroes(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam[]) {
let hids = heroInfo.map(cur => cur.hid);
let userHeroesMap = await HeroModel.findMapByHidRange(hids, roleId);
let infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }> = new Map(), pieces: ItemInter[] = [];
for (let h of heroInfo) {
let heroCount = h.count || 1;
if (userHeroesMap.has(h.hid)) {
let { pieceId, count } = transPiece(h.hid);
pieces.push({ id: pieceId, count: count * heroCount });
} else {
let initInfo: { heroInfo: HeroUpdate, skinInfo: SkinUpdate };
if(pinus.app.getServerType() == 'role') {
initInfo = getInitHeroById(h.hid);
} else {
let roleServers = pinus.app.getServersByType('role');
let server = getRandSingleEelm(roleServers);
initInfo = await pinus.app.rpc.role.roleRemote.getInitHeroById.toServer(server.id, h.hid);
}
initInfo.heroInfo = { ...initInfo.heroInfo, ...h };
infos.set(h.hid, initInfo);
userHeroesMap.set(h.hid, null);
if (heroCount > 1) {
let { pieceId, count } = transPiece(h.hid);
pieces.push({ id: pieceId, count: count * (heroCount - 1) });
}
}
}
let resultHeroes: HeroType[] = [], resultItems: RewardInter[] = [], heroes: HeroShowParam[] = [];
if (infos.size > 0) {
let createHero = new CreateHeroes(roleId, roleName, serverId);
await createHero.createWithHeroInfo(infos);
await createHero.pushMessage(sid);
await createHero.updateRedisRank();
heroes = createHero.getShowHeroes();
resultHeroes = createHero.getResultHeroes();
}
if (pieces.length > 0) {
let goods = await addItems(roleId, roleName, sid, pieces, ITEM_CHANGE_REASON.HERO_TRANSFER_PIECE);
resultItems = goods;
}
return { heroes, resultHeroes, goods: resultItems }
}
export async function createHero(roleId: string, roleName: string, sid: string, serverId: number, heroInfo: CreateHeroParam) {
let result = await createHeroes(roleId, roleName, sid, serverId, [heroInfo]);
return result;
}

View File

@@ -0,0 +1,61 @@
import { DEFAULT_HEROES, DEFAULT_HERO_LV, FIGURE_UNLOCK_CONDITION, HERO_SYSTEM_TYPE, LINEUP_NUM } from "../../consts";
import { HeroModel, HeroUpdate } from "../../db/Hero";
import { RoleModel, RoleUpdate } from "../../db/Role";
import { SkinModel, SkinUpdate } from "../../db/Skin";
import { TopHero } from "../../domain/dbGeneral";
import { CalHeroCe, CalRoleCe } from "../../domain/roleField/calCe";
import { gameData, getHeroExpByLv } from "../../pubUtils/data";
import { unlockFigureWithoutSave } from "./rewardService";
// 储存在内存中的初始数据
export function getInitRoleInfo() {
let topLineup: TopHero[] = [], topLineupCe = 0, allCe = 0,
heroes: HeroUpdate[] = [], initHeroes: HeroUpdate[] = [], initSkins: SkinUpdate[] = [], heroNum = 0,
conditions: {type: FIGURE_UNLOCK_CONDITION, paramHid: number }[] = [];
let role = new RoleModel();
let calRoleCe = new CalRoleCe(role);
let roleAttr = calRoleCe.cal(HERO_SYSTEM_TYPE.INIT);
for(let { actorId: hid } of gameData.recruit) {
let { quality, initialStars: star, jobid: job, name: hName, initialSkin } = gameData.hero.get(hid);
// 皮肤
let skin = new SkinModel();
let dicFashion = gameData.fashion.get(initialSkin);
if(!dicFashion) {
console.log(`not found skin: ${initialSkin} of ${hid}`);
continue;
}
let skinInfo = { ...skin.toJSON(), id: initialSkin, hid, skinName: dicFashion.name, skinId: dicFashion.heroId };
initSkins.push(skinInfo);
// 武将
let hero = new HeroModel();
let heroInfo = {...hero.toJSON(), hid, star, quality, hName, job, skins: [{ id: initialSkin, skin: skinInfo._id, enable: true, skinId: skinInfo.skinId }], skinId: skinInfo.skinId, lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0 };
let calHeroCe = new CalHeroCe(hid, heroInfo);
let heroAttr = calHeroCe.cal(HERO_SYSTEM_TYPE.INIT);
let ce = calHeroCe.getCalculatedCe(roleAttr);
heroes.push({ ...heroInfo, attr: heroAttr, ce, historyCe: ce });
// 更新role表
if(DEFAULT_HEROES.includes(hid)) {
// 头像
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: hid });
allCe += ce;
heroNum++;
initHeroes.push({ ...heroInfo, attr: heroAttr, ce, historyCe: ce });
}
}
let { figureInfo, heads, frames, spines } = unlockFigureWithoutSave(conditions, role);
// 最强阵容
initHeroes.sort((a, b) => { return b.ce - a.ce });
for(let i = 0; i < LINEUP_NUM; i++) {
if(initHeroes[i]) {
let { hid, ce, _id } = initHeroes[i];
topLineup.push({ hid, ce, hero: _id });
topLineupCe += ce;
}
}
let initRole: RoleUpdate = { topLineupCe, topLineup, attr: roleAttr, ce: allCe, heroNum, heroNumUpdatedAt: Date.now(), heads, frames, spines };
return {
role: initRole, heroes, skins: initSkins, figureInfo
}
}

View File

@@ -0,0 +1,662 @@
import { ITID, CONSUME_TYPE, ITEM_TABLE, CURRENCY, CURRENCY_TYPE, MAIL_TYPE, HANDLE_REWARD_TYPE, HERO_SYSTEM_TYPE, CURRENCY_BY_TYPE, ITEM_CHANGE_REASON, TA_USERSET_TYPE, TA_EVENT, POP_UP_SHOP_CONDITION_TYPE, ROLE_SELECT, FIGURE_UNLOCK_CONDITION } from '../../consts';
import { getDecimalCnt, getRandEelm, getRandEelmWithWeight, getRandSingleEelm, getRandValueByMinMax, resResult } from '../../pubUtils/util';
import { RoleModel, RoleType } from '../../db/Role';
import { setAp } from '../actionPointService';
import { pushCalAllHeroCe, calPlayerCeAndSave, calAllHeroCe } from '../playerCeService';
import { ItemModel, ItemType } from '../../db/Item';
import { STATUS } from '../../consts/statusCode';
import { pinus } from 'pinus';
import { ItemInter, RewardInter, } from '../../pubUtils/interface';
import { gameData } from '../../pubUtils/data';
import { uniq } from 'underscore';
import { EPlace, HeroModel, HeroType, HeroUpdate } from '../../db/Hero';
import { Figure } from '../../domain/dbGeneral';
import { CreateHeroParam, HeroShowParam } from '../../domain/roleField/hero';
import { HeroSkin } from '../../db/Hero';
import { errlogger } from '../../util/logger';
import { BAG } from '../../pubUtils/dicParam';
import { sendMailByContent } from '../mailService';
import { SkinModel, SkinUpdate } from '../../db/Skin';
import { getInitHeroById } from '../roleService';
import { getActivities } from '../activity/activityService';
import { reportTAEvent, reportTAUserSet } from '../sdkService';
import { saveCoinChangeLog, saveFigureInfoLog, saveGoldChangeLog, saveItemChangeLog } from '../../pubUtils/logUtil';
import { JewelModel, JewelType, jewelUpdate, RandSe } from '../../db/Jewel';
import { updateEplaces } from '../equipService';
import { checkPopUpConditionInCreateHero } from '../activity/popUpShopService';
import { CreateHeroes } from './createHero';
import { combineItems, getCoinEventProperties, getGoldEventProperties, sortItems } from './util';
import { nowSeconds } from '../../pubUtils/timeUtil';
export async function handleCost(roleId: string, sid: string, goods: Array<ItemInter>, reason: ITEM_CHANGE_REASON) {
let uids = [{ uid: roleId, sid }];
let { items, jewels, gold, coin } = sortItems(goods, HANDLE_REWARD_TYPE.COST);
let jewelSeqIds = jewels.map(cur => cur.seqId);
let resJewels: JewelType[] = [];
// 检查货币是否充足
let role = await RoleModel.findByRoleId(roleId);
if (gold.length > 0 || coin.length > 0) {
let { gold: originGold, coin: originCoin } = role;
for(let {count} of gold) { originGold -= count };
for(let count of coin) { originCoin -= count };
if(originGold < 0 || originCoin < 0) return false;
}
//检查装备是否存在
if (jewels.length > 0) {
resJewels = await JewelModel.findbySeqIds(jewelSeqIds);
if (resJewels.length < jewels.length)
return false;
}
//检查并修改道具
if (items.length > 0) {
let { hasError, result } = await ItemModel.decreaseItems(roleId, items);
if (hasError) return false;
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, { goods: result.map(cur => ({...cur, reason })) }), uids);
saveItemChangeLog(roleId, result, reason);
}
//删除装备
if (resJewels.length > 0) {
let heroMap = new Map<number, { hero: HeroType, jewels: JewelType[]}>();
for(let jewel of resJewels) {
if(jewel.hid > 0) {
if(!heroMap.has(jewel.hid)) {
let hero = await HeroModel.findByHidAndRole(jewel.hid, roleId);
heroMap.set(jewel.hid, { hero, jewels: [] });
}
heroMap.get(jewel.hid).jewels.push(jewel);
}
}
for(let [_hid, {hero, jewels} ] of heroMap) {
// 脱下天晶石
let update = new Map<number, Partial<EPlace>>();
for(let jewel of jewels) {
await JewelModel.putOnOrOff(jewel.id, 0, 0);
let curEquip = hero.ePlace.find(cur => cur.jewel == jewel.id);
if(!!curEquip) {
update.set(curEquip.id, { jewel: 0 });
}
}
let { newEplace } = updateEplaces(hero.ePlace, update);
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.EQUIP_STRENGTH, sid, roleId, hero, { ePlace: newEplace }, [...update.keys()]);
}
let jewels = await JewelModel.deleteBySeqIds(roleId, jewelSeqIds);
saveItemChangeLog(roleId, jewels.map(jewel => ({ id: jewel.id, count: 1, inc: -1 })), reason);
pinus.app.get('channelService').pushMessageByUids('onJewelDel', resResult(STATUS.SUCCESS, { jewels: jewels.map(jewel => ({ seqId: jewel.seqId, id: jewel.id, inc: -1, reason })) }), uids);
}
//消耗玩家货币
if (gold.length > 0 || coin.length > 0) {
let costGold = gold.reduce((pre, cur) => pre + cur.count, 0);
let costCoin = coin.reduce((pre, cur) => pre + cur, 0);
role = await RoleModel.decreaseGoldAndCoin(roleId, gold, costCoin);
pinus.app.get('channelService').pushMessageByUids('onPlayerDataChange', resResult(STATUS.SUCCESS, {
gold: role.gold, coin: role.coin, totalCost: role.totalCost
}), uids);
if(costGold > 0) {
reportTAEvent(roleId, TA_EVENT.ITEM_CONSUME, getGoldEventProperties(costGold, role.gold, reason));
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_gold: role.gold });
saveGoldChangeLog(roleId, role.gold, -1 * costGold, reason);
}
if(costCoin > 0) {
reportTAEvent(roleId, TA_EVENT.ITEM_CONSUME, getCoinEventProperties(costCoin, role.coin, reason));
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_coin: role.coin });
saveCoinChangeLog(roleId, role.coin, -1 * costCoin, reason);
}
}
return true;
}
// TODO: sid 在方法内部获取,且不一定存在
export async function addItems(roleId: string, roleName: string, sid: string, goods: Array<ItemInter>, reason: ITEM_CHANGE_REASON) {
let uids = [{ uid: roleId, sid }];
let { items, jewels, gold, coin, ap, skins, figures } = sortItems(goods, HANDLE_REWARD_TYPE.RECEIVE);
let showItems: { id: number, seqId?: number, count: number, isBag?: boolean }[] = [];
let role = await RoleModel.findByRoleId(roleId);
// 1. 装备处理
if(jewels.length > 0) {
let { jewelCount = 0 } = role;
let incJewels = jewels, mailJewels: { id?: number, hid?: number, seqId?: number }[] = [];
if(jewels.length + jewelCount > BAG.BAG_EQUIP_UPLIMITED) { // 装备上限
let inc = BAG.BAG_EQUIP_UPLIMITED - jewelCount;
if(inc < 0) inc = 0;
incJewels = jewels.slice(0, inc);
mailJewels = jewels.slice(inc);
}
// 直接加的
let { jewels: jewelInfos } = await addJewels(roleId, roleName, <{id: number, hid?: number}[]>incJewels, reason);
for (let jewel of jewelInfos) {
showItems.push({ seqId: jewel.seqId, id: jewel.id, count: 1, isBag: true });
}
for(let jewel of combineItems(mailJewels)) {
showItems.push({ id: jewel.id, count: jewel.count, isBag: false });
}
//装备推送
if (!!jewelInfos.length)
pinus.app.get('channelService').pushMessageByUids('onJewelAdd', resResult(STATUS.SUCCESS, { jewelInfos }), uids);
//统计装备
if (jewelInfos.length > 0) {
saveItemChangeLog(roleId, jewelInfos, reason);
}
// 发邮件的
if(mailJewels.length > 0) {
await sendMailByContent(MAIL_TYPE.EQUIP_OVER, roleId, { goods: combineItems(mailJewels) });
}
}
// 2. 道具处理
if(items.length > 0) {
let { items: itemInfos } = await addBags(roleId, roleName, items, reason);
for (let item of items) {
showItems.push({ id: item.id, count: item.count });
}
//背包除去装备推送
if (!!itemInfos.length) {
pinus.app.get('channelService').pushMessageByUids('onItemUpdate', resResult(STATUS.SUCCESS, { goods: itemInfos }), uids);
saveItemChangeLog(roleId, itemInfos, reason);
}
}
// 3. 货币推送
if(gold.length > 0 || coin.length > 0 || ap > 0) {
await setAp(role.serverId, roleId, null, role.lv, ap, sid, reason);
let incCoin = coin.reduce((pre, cur) => pre + cur, 0);
let incGold = gold.reduce((pre, cur) => pre + cur.count, 0);
role = await RoleModel.increaseGoldAndCoin(roleId, gold, incCoin);
pinus.app.get('channelService').pushMessageByUids('onPlayerDataChange', resResult(STATUS.SUCCESS, {
gold: role.gold, coin: role.coin
}), uids);
if(gold.length > 0) {
gold.forEach(({ count }) => {
showItems.push(getGoldObject(count));
});
reportTAEvent(roleId, TA_EVENT.ITEM_GET, getGoldEventProperties(incGold, role.gold, reason));
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_gold: role.gold });
saveGoldChangeLog(roleId, role.gold, incGold, reason );
}
if(coin.length > 0) {
coin.forEach(count => {
showItems.push(getCoinObject(count));
});
reportTAEvent(roleId, TA_EVENT.ITEM_GET, getCoinEventProperties(incCoin, role.coin, reason));
reportTAUserSet(TA_USERSET_TYPE.SET, roleId, { current_coin: role.coin });
saveCoinChangeLog(roleId, role.coin, incCoin, reason);
}
if(ap > 0) {
showItems.push(getApObject(ap));
}
}
// 4. 皮肤处理
let figureInfos:{ heads: Figure[], frames: Figure[], spines: Figure[] }[] = []; // 头像变化推送信息
if(skins.length > 0) {
let heroskins: {skins: HeroSkin[], hid: number}[] = []; // 皮肤推送信息
let skinInfos: {id: number, hid: number, count: number, inc: number, reason: number }[] = [];
let calAllHeroResult = undefined; // 全局战力变化推送
for (let skinId of skins) {//皮肤推送
let hero = await addSkin(roleId, roleName, sid, skinId, false);
if (!!hero) {
showItems.push({ id: skinId, count: 1 });
skinInfos.push({ id: skinId, hid: hero?.hid||0, count: 1, inc: 1, reason })
}
}
if (!!skinInfos.length) {
pushHeroSkinMsg(heroskins, skinInfos, uids); // 推送onHeroSkinChange
saveItemChangeLog(roleId, skinInfos, reason);
}
// 推送全局加成信息
if(calAllHeroResult) await pushCalAllHeroCe(roleId, sid, calAllHeroResult);
}
// 5. 获得头像和相框等
if(figures.length > 0) {
let figureInfo = await addFigure(roleId, figures, reason);
if(figureInfo) figureInfos.push(figureInfo);
for (let id of figures) {//皮肤推送
showItems.push({ id, count: 1 });
}
}
// 获得头像或相框或形象推送
if(!!figureInfos && figureInfos.length > 0) {
for(let figureInfo of figureInfos) {
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
saveFigureInfoLog(roleId, figureInfo, reason)
}
}
return showItems;
}
export async function checkGoods(roleId: string, goodIds: Array<number>) {
let jewelSeqIds: Array<number> = [];
let itemIds: Array<number> = [];
let hids: Array<number> = [];
goodIds = uniq(goodIds);
for (let goodId of goodIds) {
let goodInfo = gameData.goods.get(goodId);
if (!!goodInfo) {
let { table } = ITID.get(goodInfo.itid);
if (table == ITEM_TABLE.EQUIP) {
jewelSeqIds.push(goodId);
} else if (table == ITEM_TABLE.ITEM) {
itemIds.push(goodId);
}
}
}
//检查装备是否存在
if (!!jewelSeqIds.length) {
let resJewels = await JewelModel.findbySeqIds(jewelSeqIds);
resJewels = uniq(resJewels, function (resEquip) {
return resEquip.id;
});
if (resJewels.length < jewelSeqIds.length)
return false;
}
//检查并修改道具
if (itemIds.length > 0) {
let items = await ItemModel.findbyRoleAndIds(roleId, itemIds);
if (items.length < itemIds.length)
return false;
}
return true;
}
export async function checkHeroes(roleId: string, hids: number[]) {
if (!!hids.length) {
let heros = await HeroModel.findByHidRange(hids, roleId);
if (heros.length < hids.length)
return false;
}
return true
}
export async function checkHeroEquips(roleId: string, quality: number) {
return await HeroModel.checkEquipByQuality(roleId, quality);
}
/**
* 解锁头像/相框
* @param roleId 玩家id
* @param conditions 解锁条件
* @param role 如果已查询过role表就直接可以使用
*/
export async function unlockFigure(sid: string, roleId: string, conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number, paramWinStreakNum?: number }[], role?: RoleType) {
if (!role || !role.heads || !role.frames) {
role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
}
let { figureInfo, heads, frames, spines } = unlockFigureWithoutSave(conditions, role);
role = await RoleModel.updateRoleInfo(roleId, { heads, frames, spines });
if (!!figureInfo && (figureInfo.heads.length > 0 || figureInfo.frames.length > 0 || figureInfo.spines.length > 0)) {
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
}
}
/**
* 皮肤数据变化去重、推送
* @param heroskins 推送的皮肤
* @param uids 玩家
*/
function pushHeroSkinMsg(heroskins: {skins: HeroSkin[], hid: number}[], skinInfos: {id: number, hid: number }[], uids: {uid: string, sid: string}[]) {
let pushSkinInfos: {skins: HeroSkin[], hid: number}[] = []; // 可能会有重复的
for(let { skins, hid } of heroskins) {
let index = pushSkinInfos.findIndex(cur => cur.hid == hid);
if(index == -1) {
pushSkinInfos.push({skins, hid});
} else {
if(skins.length > pushSkinInfos[index].skins.length) {
pushSkinInfos[index] = {skins, hid};
}
}
}
if(pushSkinInfos.length > 0 || skinInfos.length > 0) {
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, { heros: heroskins, skins: skinInfos }), uids);
}
}
/**
* 只插入皮肤,不管那么多的
* @param roleId
* @param roleName
* @param skinId
* @returns
*/
export async function increaseSkin(roleId:string, roleName: string, skinId: number) {
let dicSkin = gameData.fashion.get(skinId);
if (!dicSkin) return false;
let skin = await SkinModel.increaseSkin(roleId, skinId, { roleId, roleName, id: skinId, skinName: dicSkin.name, hid: dicSkin.actorId, skinId: dicSkin.heroId });
if(!skin) return false; // 插入失败
return skin
}
/**
* 添加皮肤
* @param roleId 玩家id
* @param roleName 玩家名
* @param id 皮肤id
* @param hero 武将如果已经查询过这个武将就不用再查询一次主意要select skins字段
* @returns {{ hero, figureInfo, calAllHeroResult }} hero添加皮肤后的武将 figureInfo: 触发头像添加信息 calAllHeroResult全局战力加成后结果
*/
export async function addSkin(roleId: string, roleName: string, sid: string, skinId: number, enable: boolean, hero?: HeroType) {
let skin = await increaseSkin(roleId, roleName, skinId);
if(!skin) return false;
if(skin.hid && !hero) hero = await HeroModel.findByHidAndRole(skin.hid, roleId);
let condition = { type: FIGURE_UNLOCK_CONDITION.GET_SKIN, paramSkinId: skinId };
await unlockFigure(sid, roleId, [condition]); // 解锁头像
await calAllHeroCe(HERO_SYSTEM_TYPE.ADD_SKIN, sid, roleId, {}, [skinId]); // 全局加成
if (hero) { // 有武将的,将皮肤链接到武将上
let curSkin = hero.skins.find(cur => cur.id == skinId);
if (!curSkin) {
hero.skins.push({ id: skinId, skin: skin._id, enable, skinId: skin.skinId });
await HeroModel.updateHeroInfo(roleId, hero.hid, hero);
}
return hero;
} else {
return null
}
}
export async function addBags(roleId: string, roleName: string, datas: { id: number, count: number }[], reason: number) {
let items: { id: number, count: number, inc: number }[] = [];
for(let data of datas) {
let item = await addBag(roleId, roleName, data, reason);
items.push(item)
}
return { items }
}
export async function addBag(roleId: string, roleName: string, data: { id: number, count: number }, reason: number) {
let { id, count } = data;
let { name: itemName, itid, hid } = gameData.goods.get(id);
let { type } = ITID.get(itid);
let item = await ItemModel.increaseItem(roleId, id, count, { roleId, roleName, itemName, id, type, hid });
return { id: item.id, count: item.count, inc: count, reason };
}
export async function addJewels(roleId: string, roleName: string, jewels: { id: number, }[], reason: number) {
let jewelInfo: jewelUpdate[] = [];
for(let jewel of jewels) {
let info = await getAddJewelInfo(roleId, roleName, jewel);
jewelInfo.push(info);
}
const jewelResult = await JewelModel.createJewels(roleId, jewelInfo);
return { jewels: jewelResult.map(jewel => {
return { ...jewel, count: 1, inc: 1, reason }
})}
}
export async function getAddJewelInfo(roleId: string, roleName: string, jewel: { id: number, }) {
let { id, } = jewel;
let { name, randomEffect, effectCount } = gameData.jewel.get(id);
// 随机属性
let randomResult: number[] = getRandEelm(randomEffect, effectCount);
let randSe: Array<RandSe> = randomResult.map((id: number, index: number) => {
return getJewelRandSe(index + 1, id);
});
return { roleId, roleName, id, name, randSe };
}
/**
* 天晶石已知词条随机值
* @param id 词条位置,第几条
* @param seid 词条id
* @returns
*/
export function getJewelRandSe(id: number, seid: number) {
let dicRandom = gameData.randomEffectPool.get(seid)
let rand = 0;
if (dicRandom.id > 0) {
let randRange = getRandEelmWithWeight(dicRandom.rate);
let randResult = getRandValueByMinMax(randRange.dic.min, randRange.dic.max, getDecimalCnt(dicRandom.gap));
let n = Math.floor((randResult - dicRandom.Min)/dicRandom.gap);
rand = dicRandom.Min + n * dicRandom.gap;
}
return new RandSe(id, dicRandom.id, rand);
}
export function getGoldId() {
return CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD);
}
/**
* @description 获取元宝物品 { id, count }
* @param count 元宝数量
*/
export function getGoldObject(count: number) {
return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD), count };
}
/**
* @description 获取金币物品 { id, count }
* @param count 元宝数量
*/
export function getCoinObject(count: number) {
return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN), count };
}
/**
* @description 获取体力物品 { id, count }
* @param count 体力数量
*/
export function getApObject(count: number) {
return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.ACTION_POINT), count };
}
/**
* @description 获取友情点物品 { id, count }
* @param count 友情点数量
*/
export function getFriendPointObject(count: number) {
return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.FRIEND_POINT), count };
}
/**
* @description 获取功勋物品 { id, count }
* @param count 功勋数量
*/
export function getHonourObject(count: number) {
return { id: CURRENCY_BY_TYPE.get(CURRENCY_TYPE.HONOUR), count };
}
/**
* 返回 解锁头像/相框
* @param conditions 解锁条件
* @param role 如果已查询过role表就直接可以使用
*/
export function unlockFigureWithoutSave(conditions: { type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number, paramWinStreakNum?: number }[], role: RoleType) {
let { heads, frames, spines } = role;
let figureInfo = { heads: new Array<Figure>(), frames: new Array<Figure>(), spines: new Array<Figure>() };
for (let { type, paramHid, paramFavourLv, paramSkinId, paramWinStreakNum } of conditions) {
let canUnLockList = gameData.figureCondition.get(type);
if (canUnLockList) {
let reason = 0;
for (let { id, params, gid } of canUnLockList) {
let flag = false; // 是否达成条件
if (type == FIGURE_UNLOCK_CONDITION.GET_HERO) {
let [hid] = params;
if (paramHid == hid) flag = true;
reason = ITEM_CHANGE_REASON.GET_HERO_UNLOCK_FIGURE;
} else if (type == FIGURE_UNLOCK_CONDITION.HERO_FAVOR) {
let [hid, favourLv] = params;
if (paramHid == hid && paramFavourLv >= favourLv) flag = true;
reason = ITEM_CHANGE_REASON.HERO_FAVOR_UNLOCK_FIGURE;
} else if (type == FIGURE_UNLOCK_CONDITION.GET_SKIN) {
let [id] = params;
if (paramSkinId == id) flag = true;
reason = ITEM_CHANGE_REASON.ADD_SKIN_UNLOCK_FIGURE;
} else if (type == FIGURE_UNLOCK_CONDITION.PVP_WIN_SERIES) {
let [winStreakNum] = params;
if (paramWinStreakNum >= winStreakNum) flag = true;
reason = ITEM_CHANGE_REASON.PVP_SERIES_UNLOCK_FIGURE;
}
if (!flag) continue;
let dicGood = gameData.goods.get(gid);
if (!dicGood) continue;
let dicItid = ITID.get(dicGood.itid);
if (!dicItid) continue;
if (dicItid.type == CONSUME_TYPE.HEAD) {
let figure = unlockSingleFigure(heads, gid, reason, false, id);
if (figure && figure.unlocked) figureInfo.heads.push(figure);
} else if (dicItid.type == CONSUME_TYPE.FRAME) {
let figure = unlockSingleFigure(frames, gid, reason, false, id);
if (figure && figure.unlocked) figureInfo.frames.push(figure);
} else if (dicItid.type == CONSUME_TYPE.SPINE) {
let figure = unlockSingleFigure(spines, gid, reason, false, id);
if (figure && figure.unlocked) figureInfo.spines.push(figure);
} else {
continue;
}
}
}
}
return { figureInfo, heads, frames, spines };
}
// 直接获得形象/相框
export async function addFigure(roleId: string, ids: number[], reason: number) {
let role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_HEADS);
if (!role) return false;
let { heads, frames, spines } = role;
let figureInfo = { heads: [], frames: [], spines: [] };
for (let gid of ids) {
let dicGoods = gameData.goods.get(gid);
if (!dicGoods) continue;
let dicItid = ITID.get(dicGoods.itid);
if (!dicItid) continue;
if (dicItid.type == CONSUME_TYPE.HEAD) {
let figure = unlockSingleFigure(heads, gid, reason, true);
if (figure && figure.unlocked) figureInfo.heads.push(figure);
} else if (dicItid.type == CONSUME_TYPE.FRAME) {
let figure = unlockSingleFigure(frames, gid, reason, true);
if (figure && figure.unlocked) figureInfo.frames.push(figure);
} else if (dicItid.type == CONSUME_TYPE.SPINE) {
let figure = unlockSingleFigure(spines, gid, reason, true);
if (figure && figure.unlocked) figureInfo.spines.push(figure);
} else {
continue;
}
}
role = await RoleModel.updateRoleInfo(roleId, { heads, frames, spines });
return figureInfo;
}
/**
* 根据物品id解锁/获得玩家数据
* @param dbFigures 数据库内字段
* @param id 物品id
* @param unlockDirect 是否不计算解锁条件直接解锁
* @param conditionId 条件id
*/
function unlockSingleFigure(dbFigures: Figure[], id: number, reason: number, unlockDirect = false, conditionId?: number) {
let index = dbFigures.findIndex(cur => cur.id == id);
let figure = dbFigures[index];
if (index == -1) {
figure = new Figure(id, false);
dbFigures.push(figure);
index = dbFigures.length - 1;
}
if (figure.unlocked) return; // 已解锁过
if (!figure.unlockedId) figure.unlockedId = new Array<number>();
let dicGoods = gameData.goods.get(id);
let hasUnlockedAll = true;
if (!unlockDirect) { // 不能直接获得需要通过type解锁
if (figure.unlockedId.includes(conditionId)) return;
figure.unlockedId.push(conditionId);
for (let { id: cid } of dicGoods.condition) {
if (!figure.unlockedId.includes(cid)) {
hasUnlockedAll = false; break;
}
}
}
if (hasUnlockedAll) {
figure.unlocked = true;
delete figure.unlockedId;
if (dicGoods.timeLimit) {
figure.time = nowSeconds() + dicGoods.timeLimit * 86400
}
}
figure.inc = 1;
figure.reason = reason;
dbFigures[index] = figure;
return figure
}
// async function getSkinsOfThisHero(roleId: string, roleName: string, hid: number, initialSkin: number, allSkins?: SkinType[]) {
// if(!allSkins) allSkins = await SkinModel.findbyRoleAndHid(roleId, hid);
// let skin = await increaseSkin(roleId, roleName, initialSkin);
// if(skin) allSkins.push(skin);
// let skins: { id: number, skin: string, enable: boolean }[] = [];
// for(let skin of allSkins) {
// skins.push({ id: skin.id, skin: skin._id, enable: skin.id == initialSkin });
// }
// return skins
// }
export function combineFigureInfo(figureInfos: { heads: Figure[], frames: Figure[], spines: Figure[] }[]) {
let figureInfo = { heads: new Array<Figure>(), frames: new Array<Figure>(), spines: new Array<Figure>() };
for(let {heads, frames, spines} of figureInfos) {
for(let head of heads) {
figureInfo.heads.push(head);
}
for(let frame of frames) {
figureInfo.frames.push(frame);
}
for(let spine of spines) {
figureInfo.spines.push(spine);
}
}
return figureInfo;
}
// export class CreateHero {
// roleId: string;
// roleName: string;
// serverId: number;
// constructor(roleId: string, roleName: string, serverId: number) {
// }
// }

View File

@@ -0,0 +1,133 @@
import { ITID, CONSUME_TYPE, ITEM_TABLE, CURRENCY, CURRENCY_TYPE, HANDLE_REWARD_TYPE, ITEM_CHANGE_REASON, CURRENCY_BY_TYPE } from '../../consts';
import { ItemInter, RewardInter, } from '../../pubUtils/interface';
import { gameData } from '../../pubUtils/data';
import { errlogger } from '../../util/logger';
export function sortItems(goods: ItemInter[], handleType: HANDLE_REWARD_TYPE) {
let items: { id: number, count: number }[] = []; // 可叠加道具
let jewels: { seqId?: number, id?: number, hid?: number }[] = []; // 不可叠加装备
let gold: { count: number, isPay: boolean }[] = []; // 金币
let coin: number[] = [];
let ap: number = 0;
let skins: number[] = [];
let figures: number[] = [];
for(let good of goods) {
if(good.count == 0) continue;
let dicGood = gameData.goods.get(good.id);
if(!dicGood) {
errlogger.error(`物品 ${good.id} 未配置`);
continue;
}
let dicItid = ITID.get(dicGood.itid);
if(!dicItid) {
errlogger.error(`itid ${dicGood.itid} 未配置`);
continue;
}
let { type, table, isCurrency } = dicItid;
if(table == ITEM_TABLE.JEWEL) { // 装备
if(handleType == HANDLE_REWARD_TYPE.RECEIVE) {
for(let i = 0; i < good.count; i++) {
jewels.push({ id: good.id, hid: good.hid })
}
} else {
if(!!good.seqId) {
jewels.push({ seqId: good.seqId });
}
}
} else if (table == ITEM_TABLE.ITEM) { // 可叠加道具
let index = items.findIndex(cur => cur.id == good.id);
if(index > 0) {
items[index].count += good.count;
} else {
items.push({ id: good.id, count: good.count });
}
} else if (table == ITEM_TABLE.SKIN) { // 皮肤,不可重复获得,不可删
if(handleType == HANDLE_REWARD_TYPE.RECEIVE) {
let index = skins.indexOf(good.id);
if (index == -1) {
skins.push(good.id);
}
}
} else if (table == ITEM_TABLE.ROLE) {
if(isCurrency) { // 3种货币
let dicCurrency = CURRENCY.get(good.id);
if(dicCurrency) {
if(dicCurrency.type == CURRENCY_TYPE.GOLD) { // 金币,区分付费和免费,默认免费
let index = gold.findIndex(cur => cur.isPay == !!good.isPay);
if(index > 0) {
gold[index].count += good.count;
} else {
gold.push({ count: good.count, isPay: !!good.isPay });
}
} else if (dicCurrency.type == CURRENCY_TYPE.COIN) { // 铜钱
coin.push(good.count);
} else if (dicCurrency.type == CURRENCY_TYPE.ACTION_POINT) { // 体力
ap += good.count;
}
}
} else {
if (type == CONSUME_TYPE.HEAD || type == CONSUME_TYPE.FRAME || type == CONSUME_TYPE.SPINE) { // 头像等,不可重复获得,不可删
let index = figures.indexOf(good.id);
if (index == -1) {
figures.push(good.id);
}
}
}
}
}
return { items, jewels, gold, coin, ap, skins, figures }
}
export function getGoldEventProperties(inc: number, count: number, reason: ITEM_CHANGE_REASON) {
let id = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD);
let dicGoods = gameData.goods.get(id);
return { item_id: id, item_name: dicGoods.name, item_itid: dicGoods.itid, change_count: inc, change_after: count, change_reason: reason }
}
export function getCoinEventProperties(inc: number, count: number, reason: ITEM_CHANGE_REASON) {
let id = CURRENCY_BY_TYPE.get(CURRENCY_TYPE.COIN);
let dicGoods = gameData.goods.get(id);
return { item_id: id, item_name: dicGoods.name, item_itid: dicGoods.itid, change_count: inc, change_after: count, change_reason: reason }
}
export function combineItems(items: { id?: number, count?: number }[]) {
let result: { id: number, count: number }[] = [];
for(let { id, count = 1 } of items) {
let index = result.findIndex(cur => cur.id == id);
if(index == -1) {
result.push({ id, count });
} else {
result[index].count += count;
}
}
return result;
}
export function combineItemAndJewels(items: { id?: number, count?: number }[]) {
let result: { id: number, count: number }[] = [];
for(let { id, count = 1 } of items) {
let dicGoods = gameData.goods.get(id);
let dicItid = ITID.get(dicGoods.itid);
if(dicItid.table != 'jewel') {
let index = result.findIndex(cur => cur.id == id);
if(index == -1) {
result.push({ id, count });
} else {
result[index].count += count;
}
} else {
result.push({ id, count });
}
}
return result;
}
export function transPiece(hid: number) {
let dicHero = gameData.hero.get(hid);
let count = gameData.heroTransPiece.get(dicHero.quality);
return { pieceId: dicHero.pieceId, count }
}

View File

@@ -8,12 +8,12 @@ import { SCHOOL } from '../pubUtils/dicParam';
import { gameData } from '../pubUtils/data';
import { SchoolModel } from '../db/School';
import { SclResultInter, SclPosInter, RewardInter, ItemInter } from '../pubUtils/interface';
import { CheckMeterial } from './rewardService';
import { HeroUpdate } from '../db/Hero';
import { SkinUpdate } from '../db/Skin';
import { Figure } from '../domain/dbGeneral';
import { pick } from 'underscore';
import { Reward } from '../domain/battleField/pvp';
import { CheckMeterial } from './role/checkMaterial';
export async function getTeraphStrengthenResult(role: RoleType, count: number, dicTeraph: DicTeraph, teraph: Teraph) {
let criAttr: number[] = [], times = 0;

View File

@@ -3,7 +3,6 @@
import { RoleModel, RoleType } from "../db/Role";
import { Chat37Params, CheckGuild37Params, CheckName37Params, GetWordParam } from "../domain/sdk";
import { sendMailByContent, sendMailToGuildByContent } from './mailService';
import { getGoldObject } from '../pubUtils/itemUtils';
import { NAMEPLATE } from '../pubUtils/dicParam';
import { CHANNEL_PREFIX, FILENAME, getSdkChannelId, MAIL_TYPE, REDIS_KEY, SDK_37_ADDR, SDK_37_CONST, SDK_TA_CONST, STATUS, TA_USERSET_TYPE, THINKING_DATA_MODE, THINKING_DATA_MODE_LIST } from "../consts";
import { UserModel } from "../db/User";
@@ -16,6 +15,7 @@ import { getRandSingleEelm, readWordTxt, resResult, writeWordTxt } from "../pubU
const ThinkingAnalytics = require("thinkingdata-node");
import Trie from '../pubUtils/trie';
import _ = require("underscore");
import { getGoldObject } from "./role/rewardService";
// 检查私聊是否合法

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,384 @@
import { RoleModel, RoleType } from '../../db/Role';
import { pinus, FrontendOrBackendSession } from 'pinus';
import { resResult, shouldRefresh } from '../../pubUtils/util';
import { STATUS, TASK_TYPE, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, WAR_TYPE } from '../../consts';
import { TaskParamInter, TaskListReturn } from '../../domain/roleField/task';
import { EPlace, HeroType } from '../../db/Hero';
import { HeroScores } from '../../db/PvpHistoryOpp';
import { ItemInter } from '../../pubUtils/interface';
import { UserTaskModel, UserTaskType } from '../../db/UserTask';
import { UserTaskRecModel } from '../../db/UserTaskRec';
import { UserTaskHistoryModel } from '../../db/UserTaskHistory';
import { gameData } from '../../pubUtils/data';
import { getSeconds, getZeroPointD } from '../../pubUtils/timeUtil';
import { RoleStatus } from '../../db/ComBattleTeam';
import { getActivities } from '../activity/activityService';
import { CheckTask } from './taskObj';
import { getEquipById } from '../equipService';
import { JewelType } from '../../db/Jewel';
import { checkPopUpConditionInCreateHero } from '../activity/popUpShopService';
export async function checkTaskWithRoles(serverId: number, roleId: string, sid: string, taskType: TASK_TYPE, roles: RoleType[]) {
for (let role of roles) {
if (role) {
await checkTask(serverId, role.roleId, role.roleId == roleId ? sid : null, taskType, role);
}
}
}
export async function checkTaskWithRole(serverId: number, roleId: string, sid: string, taskType: TASK_TYPE, role: RoleType, args?: TaskParamInter) {
let task = new CheckTask(serverId, roleId);
task.setRole(role);
task.setParam(taskType, args);
await task.saveAndPush(sid);
}
export async function checkTask(serverId: number, roleId: string, sid: string, taskType: TASK_TYPE, args?: TaskParamInter) {
let task = new CheckTask(serverId, roleId);
task.setParam(taskType, args);
await task.saveAndPush(sid);
}
export async function checkTaskInEntry(serverId: number, roleId: string, sid: string, role: RoleType) {
let task = new CheckTask(serverId, roleId);
task.setRole(role);
task.setParam(TASK_TYPE.LOGIN_SUM, {});
task.setParam(TASK_TYPE.LOGIN_SERIES, {});
await task.saveAndPush(sid);
}
export async function checkTaskInCreateHero(serverId: number, roleId: string, sid: string, heroNum: number, heroes: HeroType[]) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.HERO_NUM, { heroNum });
task.setParam(TASK_TYPE.HERO_QUALITY, { heroes });
task.setParam(TASK_TYPE.HERO_QUALITY_STAR_UP, { heroes });
task.setParam(TASK_TYPE.HERO_LV, { heroes });
await task.saveAndPush(sid);
await checkPopUpConditionInCreateHero(serverId, roleId, heroes);
}
export async function checkTaskInHeroStarUp(serverId: number, roleId: string, sid: string, hero: HeroType, oldStar: number) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.HERO_STAR_UP, { hero });
task.setParam(TASK_TYPE.HERO_QUALITY_STAR_UP, { hero, oldStar });
await task.saveAndPush(sid);
}
export async function checkTaskInHeroWakeUp(serverId: number, roleId: string, sid: string, hero: HeroType, oldColorStar: number) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.HERO_STAR_UP, { hero });
task.setParam(TASK_TYPE.HERO_WAKE_UP, { hero, oldColorStar });
task.setParam(TASK_TYPE.HERO_QUALITY_WAKE_UP_COUNT, { hero, oldColorStar });
task.setParam(TASK_TYPE.HERO_WAKE_UP_COUNT, { hero, oldColorStar });
task.setParam(TASK_TYPE.HERO_WAKE_UP_STAR_UP_COUNT, { hero });
await task.saveAndPush(sid);
}
export async function checkTaskInHeroQUalityUp(serverId: number, roleId: string, sid: string, hero: HeroType) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.HERO_QUALITY_UP, { hero });
task.setParam(TASK_TYPE.HERO_QUALITY_TO_QUALITY_COUNT, { hero });
await task.saveAndPush(sid);
}
export async function checkTaskInHeroTrain(serverId: number, roleId: string, sid: string, hero: HeroType, trainCount: number) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.HERO_TRAIN, { hero, trainCount });
task.setParam(TASK_TYPE.HERO_TRAIN_SUM, { hero, trainCount });
await task.saveAndPush(sid);
}
export async function checkTaskInActiveScroll(serverId: number, roleId: string, sid: string, scrollActive: boolean, hero: HeroType) {
if (!scrollActive) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.HERO_UNLOCK, { hero });
task.setParam(TASK_TYPE.ROLE_SCROLL_ACTIVE, { scrollActive });
await task.saveAndPush(sid);
}
}
export async function checkTaskInGuildTrain(serverId: number, roleId: string, sid: string, warId: number, isSuccess: boolean, isComplete: boolean) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.GUILD_TRAIN_SUCESS, { isSuccess });
task.setParam(TASK_TYPE.GUILD_TRAIN, {});
task.setParam(TASK_TYPE.GUILD_TRAIN_COUNT, { isComplete, warId });
await task.saveAndPush(sid);
}
/**
* battle.normalBattleHandler.battleEnd 中会触发的任务,因为有点多提出来了
*/
export async function checkTaskInBattleEnd(serverId: number, roleId: string, sid: string, warId: number, battleHeroes: number[], battleStar: number) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.BATTLE_WITH_HERO, { warId, battleHeroes });
task.setParam(TASK_TYPE.BATTLE_MAIN, { warId, count: 1 });
task.setParam(TASK_TYPE.BATTLE_DAILY_STAR, { warId, battleStar });
task.setParam(TASK_TYPE.BATTLE_DAILY, { warId, count: 1 });
task.setParam(TASK_TYPE.BATTLE_DUNGEON, { warId, count: 1 });
task.setParam(TASK_TYPE.BATTLE_DUNGEON_WAR, { warId, count: 1 });
task.setParam(TASK_TYPE.BATTLE_TOWER, { warId, count: 1 });
task.setParam(TASK_TYPE.BATTLE_VESTIGE, { warId, count: 1 });
task.setParam(TASK_TYPE.BATTLE_EXPEDITION, { warId, count: 1 });
task.setParam(TASK_TYPE.BATTLE_MAIN_ELITE, { warId, count: 1 });
await task.saveAndPush(sid);
}
export async function checkTaskInBattleSweep(serverId: number, roleId: string, sid: string, warId: number, count: number) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.BATTLE_MAIN_SWEEP, { warId, count });
task.setParam(TASK_TYPE.BATTLE_MAIN, { warId, count });
task.setParam(TASK_TYPE.BATTLE_DAILY, { warId, count });
task.setParam(TASK_TYPE.BATTLE_DUNGEON, { warId, count });
task.setParam(TASK_TYPE.BATTLE_DUNGEON_WAR, { warId, count });
task.setParam(TASK_TYPE.BATTLE_TOWER, { warId, count });
task.setParam(TASK_TYPE.BATTLE_VESTIGE, { warId, count });
task.setParam(TASK_TYPE.BATTLE_EXPEDITION, { warId, count });
await task.saveAndPush(sid);
}
export async function checkTaskInComBattleStart(roleStatus: RoleStatus[], capId: string, blueprtId: number) {
// console.log('********', JSON.stringify(roleStatus), capId, quality)
for (let { roleId, isRobot } of roleStatus) {
if (!isRobot) {
let role = await RoleModel.findByRoleId(roleId);
let task = new CheckTask(role.serverId, roleId);
task.setRole(role);
if (roleId == capId && roleStatus.length > 1) { // 招募队友
task.setParam(TASK_TYPE.COM_BATTLE_CREATE_TEAM, {});
} else if (roleId !== capId) { // 协助寻宝
task.setParam(TASK_TYPE.COM_BATTLE_ASSIST_TEAM, {});
}
task.setParam(TASK_TYPE.COM_BATTLE, {});
task.setParam(TASK_TYPE.COM_BATTLE_LV, { gid: blueprtId });
}
}
}
export async function checkTaskInPvpEnd(serverId: number, roleId: string, sid: string, isSuccess: boolean, heroScores: HeroScores[]) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.PVP_WIN, { isSuccess });
task.setParam(TASK_TYPE.PVP_WIN_SERIES, { isSuccess });
task.setParam(TASK_TYPE.PVP_HERO_SCORE, { heroScores });
await task.saveAndPush(sid);
}
export async function checkTaskInGacha(serverId: number, roleId: string, sid: string, count: number, heroes: HeroType[]) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.GACHA, { count });
task.setParam(TASK_TYPE.GACHA_QUALITY_COUNT, { heroes });
await task.saveAndPush(sid);
}
export async function checkTaskInComposeEquip(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[]) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.EQUIP_COMPOSE, { count: newEplace.length - oldEplace.length });
task.setParam(TASK_TYPE.EQUIP_COMPOSE_CNT, { oldEplace, newEplace });
await task.saveAndPush(sid);
}
export async function checkTaskInEquipLvUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceIds: number[]) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.EQUIP_LV_TO, { oldEplace, newEplace, ePlaceIds });
task.setParam(TASK_TYPE.EQUIP_LV_UP, { count: ePlaceIds.length });
await task.saveAndPush(sid);
}
export async function checkTaskInPutJewel(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, originJewel: JewelType, curJewel: JewelType) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.EQUIP_PUT_JEWEL, { oldEquip, newEplace, jewels: [originJewel, curJewel ] });
task.setParam(TASK_TYPE.EQUIP_PUT_JEWEL_CNT, { oldEquip, newEquip });
task.setParam(TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, { oldEquip, newEplace, jewels: [originJewel, curJewel ] });
await task.saveAndPush(sid);
}
export async function checkTaskInPutStone(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, jewel: JewelType) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.EQUIP_PUT_STONE, { oldEquip, newEquip });
task.setParam(TASK_TYPE.EQUIP_PUT_STONE_CNT, { oldEquip, newEquip });
task.setParam(TASK_TYPE.EQUIP_STONE_CNT, { oldEquip, newEquip });
task.setParam(TASK_TYPE.EQUIP_STONE_CNT_LV, { oldEquip, newEquip });
task.setParam(TASK_TYPE.EQUIP_JEWEL_RANDSE_CNT, { oldEquip, newEplace, jewels: [jewel ] });
await task.saveAndPush(sid);
}
export async function checkTaskInEquipStarUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpStar: boolean) {
let task = new CheckTask(serverId, roleId);
if(isUpStar) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
task.setParam(TASK_TYPE.EQUIP_STAR_UP_TO, { oldEquip, newEquip });
task.setParam(TASK_TYPE.EQUIP_SUIT_SEID_NUM, { oldEplace, newEplace, ePlaceId, hid });
}
task.setParam(TASK_TYPE.EQUIP_STAR_UP_CNT, { hid, ePlaceId });
await task.saveAndPush(sid);
}
export async function checkTaskInEquipQualityUp(serverId: number, roleId: string, sid: string, oldEplace: EPlace[], newEplace: EPlace[], ePlaceId: number, hid: number, isUpQuality: boolean) {
let task = new CheckTask(serverId, roleId);
if(isUpQuality) {
let { oldEquip, newEquip } = getEquipById(oldEplace, newEplace, ePlaceId);
task.setParam(TASK_TYPE.EQUIP_QUALITY_UP, { hid, ePlaceId });
task.setParam(TASK_TYPE.EQUIP_QUALITY_UP_TO, { oldEquip, newEquip })
}
task.setParam(TASK_TYPE.EQUIP_QUALITY_UP_CNT, {});
await task.saveAndPush(sid);
}
export async function checkTaskInEquipReset(serverId: number, roleId: string, sid: string) {
await checkTask(serverId, roleId, sid, TASK_TYPE.JEWEL_RESET);
}
export async function checkTaskInEquipQuench(serverId: number, roleId: string, sid: string, isSuccess: boolean) {
let task = new CheckTask(serverId, roleId);
task.setParam(TASK_TYPE.JEWEL_QUENCH, {});
if(isSuccess) {
task.setParam(TASK_TYPE.JEWEL_QUENCH_SUCCESS, { isSuccess });
}
await task.saveAndPush(sid);
}
export async function checkTaskInComposeStone(serverId: number, roleId: string, sid: string, count: number) {
await checkTask(serverId, roleId, sid, TASK_TYPE.STONE_COMPOSE, { count });
}
// 获取task状态
export async function getCurTask(roleId: string, session: FrontendOrBackendSession) {
let userTask = await UserTaskModel.findByRole(roleId);
let { dailyTaskRefWeekly, dailyTaskRef } = userTask;
let curWeekStart = getZeroPointD(SHOP_REFRESH_TYPE.WEEKLY);
if (dailyTaskRefWeekly < curWeekStart) { // 刷新周宝箱
dailyTaskRefWeekly = curWeekStart;
}
session.set('refWeekly', getSeconds(dailyTaskRefWeekly));
session.push('refWeekly', () => { });
if (shouldRefresh(dailyTaskRef, new Date())) {
dailyTaskRef = new Date();
userTask = await UserTaskModel.updateInfo(roleId, { dailyTaskRef });
await removeHistoryTask(roleId, TASK_FUN_TYPE.DAILY);
}
session.set('refDaily', getSeconds(dailyTaskRef));
session.push('refDaily', () => { });
let mainTask = await getMainTask(roleId, userTask);
let dailyTask = await getDailyTask(roleId, userTask);
let achievement = await getAchievement(roleId, userTask);
return { mainTask, dailyTask, achievement };
}
export async function getMainTask(roleId: string, userTask: UserTaskType) {
let type = TASK_FUN_TYPE.MAIN;
let { mainTaskStage: stage } = userTask;
let recMap = await UserTaskRecModel.findByRoleAndType(roleId, type); // group=>userTaskRec
let taskList: TaskListReturn[] = [];
for (let [id, dic] of gameData.mainTask) {
if (dic.taskStage == stage) {
let dbRec = recMap.get(dic.taskType)?.get(dic.group);
if (dbRec) {
taskList.push({ type, id, count: dbRec.count, received: dbRec.received.includes(id) });
} else {
taskList.push({ type, id, count: 0, received: false });
}
}
}
return { stage, taskList }
}
export async function getDailyTask(roleId: string, userTask: UserTaskType) {
let type = TASK_FUN_TYPE.DAILY;
let { dailyTaskPoint: point, dailyTaskRefWeekly, dailyTaskPointWeekly: weeklyPoint, dailyTaskBox: box } = userTask;
let curWeekStart = getZeroPointD(SHOP_REFRESH_TYPE.WEEKLY);
if (dailyTaskRefWeekly < curWeekStart) { // 刷新
dailyTaskRefWeekly = curWeekStart;
weeklyPoint = 0;
box = [];
}
let recMap = await UserTaskRecModel.findByRoleAndType(roleId, type); // group=>userTaskRec
let taskList: TaskListReturn[] = [];
for (let [id, dic] of gameData.dailyTask) {
let dbRec = recMap.get(dic.taskType)?.get(dic.group);
if (dbRec) {
taskList.push({ type, id, count: dbRec.count, received: dbRec.received.includes(id) });
} else {
taskList.push({ type, id, count: 0, received: false });
}
}
return { point, weeklyPoint, taskList, box }
}
export async function getAchievement(roleId: string, userTask: UserTaskType) {
let type = TASK_FUN_TYPE.ACHIEVEMENT;
let { achievementBox: box, achievementPoint: point } = userTask;
let recMap = await UserTaskRecModel.findByRoleAndType(roleId, type); // group=>userTaskRec
let taskList: TaskListReturn[] = [];
for (let [id, dic] of gameData.achievement) {
let dbRec = recMap.get(dic.taskType)?.get(dic.group);
if (dbRec) {
taskList.push({ type, id, count: dbRec.count, received: dbRec.received.includes(id) });
} else {
taskList.push({ type, id, count: 0, received: false });
}
}
return { point, taskList, box }
}
export async function getPvpTask(roleId: string) {
let type = TASK_FUN_TYPE.PVP;
let recMap = await UserTaskRecModel.findByRoleAndType(roleId, type); // group=>userTaskRec
let taskList: TaskListReturn[] = [];
for (let [id, dic] of gameData.pvpDailyTask) {
let dbRec = recMap.get(dic.taskType)?.get(dic.group);
if (dbRec) {
taskList.push({ type, id, count: dbRec.count, received: dbRec.received.includes(id) });
} else {
taskList.push({ type, id, count: 0, received: false });
}
}
return { taskList }
}
// 刷新每日任务
export async function refDailyTask(roleId: string, sid: string) {
let userTask = await UserTaskModel.findByRole(roleId);
let taskList = await getDailyTask(roleId, userTask);
// 转移每日任务
await removeHistoryTask(roleId, TASK_FUN_TYPE.DAILY);
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onDailyTaskRefresh', resResult(STATUS.SUCCESS, { taskList }), uids);
}
export async function removeHistoryTask(roleId: string, type: number, today?: Date) {
// 转移每日任务
let history = await UserTaskRecModel.getHistoryRec(roleId, type, today);
if (history.length > 0) {
await UserTaskHistoryModel.pushUserTask(roleId, history);
await UserTaskRecModel.deleteHistory(history);
}
}
// 刷新每日宝箱数量
export async function refDailyTaskBox(roleId: string, sid: string, debug = false) {
let userTask = await UserTaskModel.refreshWeekly(roleId, debug);
if (userTask) {
let { dailyTaskPoint: point, dailyTaskPointWeekly: weeklyPoint, dailyTaskBox: box } = userTask;
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onTaskBoxRefresh', resResult(STATUS.SUCCESS, {
type: TASK_FUN_TYPE.DAILY,
point, weeklyPoint, box
}), uids);
}
}

View File

@@ -1,335 +0,0 @@
import * as taskUtil from '../pubUtils/taskUtil';
import { RoleModel, RoleType } from '../db/Role';
import { pinus, FrontendOrBackendSession } from 'pinus';
import { resResult, shouldRefresh } from '../pubUtils/util';
import { STATUS, TASK_TYPE, TASK_FUN_TYPE, SHOP_REFRESH_TYPE, WAR_TYPE } from '../consts';
import { TaskParam, TaskListReturn } from '../domain/roleField/task';
import { EPlace, HeroType } from '../db/Hero';
import { getRoleOnlineInfo } from './redisService';
import { HeroScores } from '../db/PvpHistoryOpp';
import { ItemInter } from '../pubUtils/interface';
import { UserTaskModel, UserTaskType } from '../db/UserTask';
import { UserTaskRecModel } from '../db/UserTaskRec';
import { UserTaskHistoryModel } from '../db/UserTaskHistory';
import { gameData } from '../pubUtils/data';
import { getSeconds, getZeroPointD } from '../pubUtils/timeUtil';
import { RoleStatus } from '../db/ComBattleTeam';
import { getActivities } from './activity/activityService';
export async function checkTaskWithRoles(serverId: number, roleId: string, sid: string, taskType: number, roles: RoleType[]) {
for (let role of roles) {
if (role) {
await checkTaskWithRole(serverId, role.roleId, role.roleId == roleId ? sid : null, taskType, role);
}
}
}
export async function checkTaskWithRole(serverId: number, roleId: string, sid: string, taskType: number, role: RoleType) {
let pushMessage = await taskUtil.checkTaskWithRole(serverId, roleId, taskType, role);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithHero(roleId: string, sid: string, taskType: number, hero: HeroType, args?: number[]) {
let pushMessage = await taskUtil.checkTaskWithHero(roleId, taskType, hero, args);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithEplaces(roleId: string, sid: string, taskType: number, eplace: EPlace[], newEplace: EPlace[], eplaceIds: number[], params?: any) {
let pushMessage = await taskUtil.checkTaskWithEplaces(roleId, taskType, eplace, newEplace, eplaceIds, params);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithEplace(roleId: string, sid: string, taskType: number, oldEquip: EPlace, newEplace: EPlace, params?: any) {
let pushMessage = await taskUtil.checkTaskWithEplace(roleId, taskType, oldEquip, newEplace, params);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithArgs(roleId: string, sid: string, taskType: number, args: number[]) {
let pushMessage = await taskUtil.checkTaskWithArgs(roleId, taskType, args);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithWar(roleId: string, sid: string, taskType: number, warId: number, heroes: number[], count: number, star: number) {
let pushMessage = await taskUtil.checkTaskWithWar(roleId, taskType, warId, heroes, count, star);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTaskWithGoods(roleId: string, sid: string, taskType: number, goods: ItemInter[]) {
let pushMessage = await taskUtil.checkTaskWithGoods(roleId, taskType, goods);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function checkTask(roleId: string, sid: string, taskType: number, count: number, isInc: boolean, param: TaskParam) {
let pushMessage = await taskUtil.checkTask(roleId, taskType, count, isInc, param);
pushTaskUpdate(roleId, sid, pushMessage);
}
export async function pushTaskUpdate(roleId: string, sid: string, pushMessage: TaskListReturn[]) {
if (pushMessage.length > 0) {
if (!sid) {
let onlineUser = await getRoleOnlineInfo(roleId);
sid = onlineUser.sid;
}
if (!!sid) {
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onTaskUpdate', resResult(STATUS.SUCCESS, pushMessage), uids);
}
}
}
export async function checkActivityTask(serverId: number, sid: string, roleId: string, taskType: TASK_TYPE, count: number, parma?: any) {
let pushMessage = await taskUtil.accomplishTask(serverId, roleId, taskType, count, parma, await getActivities());
pushActivityUpdate(roleId, sid, pushMessage);
return pushMessage;
}
export async function pushActivityUpdate(roleId: string, sid: string, pushMessage: any[]) {
// console.log('pushActivityUpdate', JSON.stringify(pushMessage))
if (pushMessage?.length > 0) {
if (!sid) {
let onlineUser = await getRoleOnlineInfo(roleId);
sid = onlineUser.sid;
}
if (!!sid) {
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onActivityTaskUpdate', resResult(STATUS.SUCCESS, pushMessage), uids);
}
}
}
/**
* battle.normalBattleHandler.battleEnd 中会触发的任务,因为有点多提出来了
*/
export async function checkTaskInBattleEnd(serverId: number, roleId: string, sid: string, battleId: number, heroes: number[], star: number) {
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_WITH_HERO, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_MAIN, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DAILY_STAR, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DAILY, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DUNGEON, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DUNGEON_WAR, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_TOWER, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_VESTIGE, battleId, heroes, 1, star);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_EXPEDITION, battleId, heroes, 1, star);
//成长任务
let dicWar = gameData.war.get(battleId);
if (dicWar) {
if (dicWar.warType == WAR_TYPE.NORMAL) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_MAIN, 1, { warId: battleId })
} else if (dicWar.warType == WAR_TYPE.EXPEDITION) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_EXPEDITION, 1)
} else if (dicWar.warType == WAR_TYPE.MYSTERY || dicWar.warType == WAR_TYPE.MYSTERY_ELITE) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_DUNGEON, 1)
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_DUNGEON_WAR, 1, { warId: battleId })
} else if (dicWar.warType == WAR_TYPE.TOWER) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_TOWER, 1)
} else if (dicWar.warType == WAR_TYPE.DAILY) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_DAILY, 1, { dailyType: dicWar.dailyType })
}
}
}
export async function checkTaskInBattleSweep(serverId: number, roleId: string, sid: string, battleId: number, count: number) {
// 任务
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_MAIN_SWEEP, battleId, [], count, 0);
//活动任务
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_MAIN_SWEEP, count, { battleId })
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_MAIN, battleId, [], count, 0);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DAILY_STAR, battleId, [], count, 0);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DAILY, battleId, [], count, 0);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DUNGEON, battleId, [], count, 0);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_DUNGEON_WAR, battleId, [], count, 0);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_TOWER, battleId, [], count, 0);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_VESTIGE, battleId, [], count, 0);
await checkTaskWithWar(roleId, sid, TASK_TYPE.BATTLE_EXPEDITION, battleId, [], count, 0);
//成长任务
let dicWar = gameData.war.get(battleId);
if (dicWar) {
if (dicWar.warType == WAR_TYPE.NORMAL) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_MAIN, count, { warId: battleId })
} else if (dicWar.warType == WAR_TYPE.EXPEDITION) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_EXPEDITION, count)
} else if (dicWar.warType == WAR_TYPE.MYSTERY || dicWar.warType == WAR_TYPE.MYSTERY_ELITE) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_DUNGEON, count)
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_DUNGEON_WAR, count, { warId: battleId })
} else if (dicWar.warType == WAR_TYPE.TOWER) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_TOWER, count)
} else if (dicWar.warType == WAR_TYPE.DAILY) {
await checkActivityTask(serverId, sid, roleId, TASK_TYPE.BATTLE_DAILY, count, { dailyType: dicWar.dailyType })
}
}
}
export async function checkTaskInComBattleStart(roleStatus: RoleStatus[], capId: string) {
// console.log('********', JSON.stringify(roleStatus), capId, quality)
for (let { roleId, isRobot } of roleStatus) {
if (!isRobot) {
let { serverId } = await RoleModel.findByRoleId(roleId);
if (roleId == capId && roleStatus.length > 1) { // 招募队友
await checkTask(roleId, null, TASK_TYPE.COM_BATTLE_CREATE_TEAM, 1, true, {});
} else if (roleId !== capId) { // 协助寻宝
await checkTask(roleId, null, TASK_TYPE.COM_BATTLE_ASSIST_TEAM, 1, true, {});
//活动任务
await checkActivityTask(serverId, null, roleId, TASK_TYPE.COM_BATTLE_ASSIST_TEAM, 1);
}
await checkTask(roleId, null, TASK_TYPE.COM_BATTLE, 1, true, {});
//活动任务
await checkActivityTask(serverId, null, roleId, TASK_TYPE.COM_BATTLE, 1);
}
}
}
export async function checkTaskInPvpEnd(roleId: string, sid: string, isSuccess: boolean, heroScores: HeroScores[]) {
if (isSuccess) {
await checkTask(roleId, sid, TASK_TYPE.PVP_WIN, 1, true, {});
await checkTask(roleId, sid, TASK_TYPE.PVP_WIN_SERIES, 1, true, {});
} else {
await checkTask(roleId, sid, TASK_TYPE.PVP_WIN_SERIES, 0, false, {});
}
await checkTask(roleId, sid, TASK_TYPE.PVP_HERO_SCORE, 0, false, { heroScores });
}
// 获取task状态
export async function getCurTask(roleId: string, session: FrontendOrBackendSession) {
let userTask = await UserTaskModel.findByRole(roleId);
let { dailyTaskRefWeekly, dailyTaskRef } = userTask;
let curWeekStart = getZeroPointD(SHOP_REFRESH_TYPE.WEEKLY);
if (dailyTaskRefWeekly < curWeekStart) { // 刷新周宝箱
dailyTaskRefWeekly = curWeekStart;
}
session.set('refWeekly', getSeconds(dailyTaskRefWeekly));
session.push('refWeekly', () => { });
if (shouldRefresh(dailyTaskRef, new Date())) {
dailyTaskRef = new Date();
userTask = await UserTaskModel.updateInfo(roleId, { dailyTaskRef });
await removeHistoryTask(roleId, TASK_FUN_TYPE.DAILY);
}
session.set('refDaily', getSeconds(dailyTaskRef));
session.push('refDaily', () => { });
let mainTask = await getMainTask(roleId, userTask);
let dailyTask = await getDailyTask(roleId, userTask);
let achievement = await getAchievement(roleId, userTask);
return { mainTask, dailyTask, achievement };
}
export async function getMainTask(roleId: string, userTask: UserTaskType) {
let type = TASK_FUN_TYPE.MAIN;
let { mainTaskStage: stage } = userTask;
let recMap = await UserTaskRecModel.findByRoleAndType(roleId, type); // group=>userTaskRec
let taskList: TaskListReturn[] = [];
for (let [id, dic] of gameData.mainTask) {
if (dic.taskStage == stage) {
let dbRec = recMap.get(dic.taskType)?.get(dic.group);
if (dbRec) {
taskList.push({ type, id, count: dbRec.count, received: dbRec.received.includes(id) });
} else {
taskList.push({ type, id, count: 0, received: false });
}
}
}
return { stage, taskList }
}
export async function getDailyTask(roleId: string, userTask: UserTaskType) {
let type = TASK_FUN_TYPE.DAILY;
let { dailyTaskPoint: point, dailyTaskRefWeekly, dailyTaskPointWeekly: weeklyPoint, dailyTaskBox: box } = userTask;
let curWeekStart = getZeroPointD(SHOP_REFRESH_TYPE.WEEKLY);
if (dailyTaskRefWeekly < curWeekStart) { // 刷新
dailyTaskRefWeekly = curWeekStart;
weeklyPoint = 0;
box = [];
}
let recMap = await UserTaskRecModel.findByRoleAndType(roleId, type); // group=>userTaskRec
let taskList: TaskListReturn[] = [];
for (let [id, dic] of gameData.dailyTask) {
let dbRec = recMap.get(dic.taskType)?.get(dic.group);
if (dbRec) {
taskList.push({ type, id, count: dbRec.count, received: dbRec.received.includes(id) });
} else {
taskList.push({ type, id, count: 0, received: false });
}
}
return { point, weeklyPoint, taskList, box }
}
export async function getAchievement(roleId: string, userTask: UserTaskType) {
let type = TASK_FUN_TYPE.ACHIEVEMENT;
let { achievementBox: box, achievementPoint: point } = userTask;
let recMap = await UserTaskRecModel.findByRoleAndType(roleId, type); // group=>userTaskRec
let taskList: TaskListReturn[] = [];
for (let [id, dic] of gameData.achievement) {
let dbRec = recMap.get(dic.taskType)?.get(dic.group);
if (dbRec) {
taskList.push({ type, id, count: dbRec.count, received: dbRec.received.includes(id) });
} else {
taskList.push({ type, id, count: 0, received: false });
}
}
return { point, taskList, box }
}
export async function getPvpTask(roleId: string) {
let type = TASK_FUN_TYPE.PVP;
let recMap = await UserTaskRecModel.findByRoleAndType(roleId, type); // group=>userTaskRec
let taskList: TaskListReturn[] = [];
for (let [id, dic] of gameData.pvpDailyTask) {
let dbRec = recMap.get(dic.taskType)?.get(dic.group);
if (dbRec) {
taskList.push({ type, id, count: dbRec.count, received: dbRec.received.includes(id) });
} else {
taskList.push({ type, id, count: 0, received: false });
}
}
return { taskList }
}
// 刷新每日任务
export async function refDailyTask(roleId: string, sid: string) {
let userTask = await UserTaskModel.findByRole(roleId);
let taskList = await getDailyTask(roleId, userTask);
// 转移每日任务
await removeHistoryTask(roleId, TASK_FUN_TYPE.DAILY);
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onDailyTaskRefresh', resResult(STATUS.SUCCESS, { taskList }), uids);
}
export async function removeHistoryTask(roleId: string, type: number, today?: Date) {
// 转移每日任务
let history = await UserTaskRecModel.getHistoryRec(roleId, type, today);
if (history.length > 0) {
await UserTaskHistoryModel.pushUserTask(roleId, history);
await UserTaskRecModel.deleteHistory(history);
}
}
// 刷新每日宝箱数量
export async function refDailyTaskBox(roleId: string, sid: string, debug = false) {
let userTask = await UserTaskModel.refreshWeekly(roleId, debug);
if (userTask) {
let { dailyTaskPoint: point, dailyTaskPointWeekly: weeklyPoint, dailyTaskBox: box } = userTask;
let uids = [{ uid: roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onTaskBoxRefresh', resResult(STATUS.SUCCESS, {
type: TASK_FUN_TYPE.DAILY,
point, weeklyPoint, box
}), uids);
}
}

View File

@@ -6,12 +6,13 @@
import { BattleDropModel } from '../db/BattleDrop';
import { getRandEelmWithWeight, getRandSingleEelm, getReasonByWarType } from '../pubUtils/util';
import { BATTLE_REWARD_TYPE, BLUEPRT_CONST } from '../consts';
import { addItems, combineItemAndJewels } from './rewardService';
import { addItems } from './role/rewardService';
import { RoleModel } from '../db/Role';
import { gameData } from '../pubUtils/data';
import { DicWar } from '../pubUtils/dictionary/DicWar';
import { RewardInter } from '../pubUtils/interface';
import { getZeroPointD } from '../pubUtils/timeUtil';
import { combineItemAndJewels } from './role/util';
export class WarReward {
private roleId: string;

View File

@@ -1,8 +1,8 @@
import { Service } from 'egg';
import * as pubUtils from '@pubUtils/util';
import { HeroUpdate } from '@db/Hero';
import { SkinUpdate } from '@db/Skin';
import { getInitRoleInfo } from '@pubUtils/roleUtil';
// import { HeroUpdate } from '@db/Hero';
// import { SkinUpdate } from '@db/Skin';
// import { getInitRoleInfo } from '@pubUtils/roleUtil';
const csprng = require('csprng');
/**
@@ -13,29 +13,29 @@ export default class Utils extends Service {
constructor(args) {
super(args);
this.setInitRole();
// this.setInitRole();
}
private initHeroes: Map<number, HeroUpdate> = new Map(); // hid => hero
private initSkins: Map<number, SkinUpdate> = new Map(); // hid => skin
// private initHeroes: Map<number, HeroUpdate> = new Map(); // hid => hero
// private initSkins: Map<number, SkinUpdate> = new Map(); // hid => skin
public setInitRole() {
let result = getInitRoleInfo();
let { heroes, skins } = result;
for(let hero of heroes) {
this.initHeroes.set(hero.hid, hero);
}
for(let skin of skins) {
this.initSkins.set(skin.hid, skin);
}
}
// public setInitRole() {
// let result = getInitRoleInfo();
// let { heroes, skins } = result;
// for(let hero of heroes) {
// this.initHeroes.set(hero.hid, hero);
// }
// for(let skin of skins) {
// this.initSkins.set(skin.hid, skin);
// }
// }
public getInitHeroById(hid: number) {
return {
heroInfo: this.initHeroes.get(hid),
skinInfo: this.initSkins.get(hid)
}
}
// public getInitHeroById(hid: number) {
// return {
// heroInfo: this.initHeroes.get(hid),
// skinInfo: this.initSkins.get(hid)
// }
// }
/**
* 生成 len 长度的随机字符串

View File

@@ -3,17 +3,15 @@ import { CeAttrDataRole, RoleModel } from '@db/Role';
import { HeroModel } from '@db/Hero';
import { Service } from 'egg';
import { STATUS, ITEM_CHANGE_REASON, REDIS_KEY, WAR_TYPE } from '@consts';
import { ITID } from '@consts';
import { STATUS, REDIS_KEY, WAR_TYPE } from '@consts';
import { ItemModel } from '@db/Item';
import { gameData, getExpByLv } from '@pubUtils/data';
import { gameData } from '@pubUtils/data';
import { AttributeCal } from '@domain/roleField/attribute';
import { smsModel } from '@db/Sms';
import { isString } from 'underscore';
import { addSkin, addBags } from '@pubUtils/itemUtils';
import { GiftCodeModel } from '@db/GiftCode';
import { GiftCodeDetailModel } from '@db/GiftCodeDetail';
import { CreateHeroes, deletRole } from '@pubUtils/roleUtil';
import { deletRole } from '@pubUtils/roleUtil';
import { RScriptRecordModel } from '@db/RScriptRecord';
import { DicWar } from '@pubUtils/dictionary/DicWar';
import { SearchHeroParam, SearchUserParam, SearchGiftCodeParam, SearchGiftCodeDetailParam, SearchItemParam, SearchGuildParam } from '@domain/backEndField/search';
@@ -143,127 +141,127 @@ export default class GMUsers extends Service {
return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total })
}
public async createHero(uids: Array<string>, _hid: string, _hlv: string) {
const { ctx } = this;
console.log('gm createHero', uids, _hid, _hlv);
let hlv = parseInt(_hlv);
if (isNaN(hlv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
let hids = (_hid as string).split('&').map(cur => parseInt(cur));
for (let hid of hids) {
if (isNaN(hid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
}
// public async createHero(uids: Array<string>, _hid: string, _hlv: string) {
// const { ctx } = this;
// console.log('gm createHero', uids, _hid, _hlv);
// let hlv = parseInt(_hlv);
// if (isNaN(hlv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// let hids = (_hid as string).split('&').map(cur => parseInt(cur));
// for (let hid of hids) {
// if (isNaN(hid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// }
for (let roleId of uids) {
let role = await RoleModel.findByRoleId(roleId);
if (role) {
let heroInfos = new Map();
for (let hid of hids) {
let heroInfo = ctx.service.utils.getInitHeroById(hid);
heroInfos.set(hid, {...heroInfo});
}
// for (let roleId of uids) {
// let role = await RoleModel.findByRoleId(roleId);
// if (role) {
// let heroInfos = new Map();
// for (let hid of hids) {
// let heroInfo = ctx.service.utils.getInitHeroById(hid);
// heroInfos.set(hid, {...heroInfo});
// }
let createHero = new CreateHeroes(roleId, role.roleName, role.serverId);
await createHero.createWithHeroInfo(heroInfos);
// let createHero = new CreateHeroes(roleId, role.roleName, role.serverId);
// await createHero.createWithHeroInfo(heroInfos);
} else {
return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, '未找到角色' + roleId)
}
}
// } else {
// return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, '未找到角色' + roleId)
// }
// }
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
public async createItem(uids: Array<string>, _itemid: string, _itemcount: string) {
const { ctx } = this;
console.log('gm createItem', uids, _itemid, _itemcount);
let itemids = (_itemid as string).split('&').map(cur => parseInt(cur));
for (let itemid of itemids) {
if (isNaN(itemid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
}
let itemcount = parseInt(_itemcount);
if (isNaN(itemcount)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// public async createItem(uids: Array<string>, _itemid: string, _itemcount: string) {
// const { ctx } = this;
// console.log('gm createItem', uids, _itemid, _itemcount);
// let itemids = (_itemid as string).split('&').map(cur => parseInt(cur));
// for (let itemid of itemids) {
// if (isNaN(itemid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// }
// let itemcount = parseInt(_itemcount);
// if (isNaN(itemcount)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
let flag = 0, msg = '创建失败';
let datas: {id: number, count: number }[] = []
for (let itemid of itemids) {
let dicGoods = gameData.goods.get(itemid);
let itidObj = ITID.get(dicGoods.itid);
// let flag = 0, msg = '创建失败';
// let datas: {id: number, count: number }[] = []
// for (let itemid of itemids) {
// let dicGoods = gameData.goods.get(itemid);
// let itidObj = ITID.get(dicGoods.itid);
if (!dicGoods) {
flag = 1, msg = "未找到道具" + itemid;
} else if (!itidObj) {
flag = 1, msg = "未找到道具" + itemid;
} else {
datas.push({ id: itemid, count: itemcount });
}
}
if(flag == 0) {
for (let roleId of uids) {
let role = await RoleModel.findByRoleId(roleId);
if (role) {
await addBags(roleId, role.roleName, datas, ITEM_CHANGE_REASON.DEBUG);
} else {
flag = 1, msg = '未找到角色' + roleId;
}
}
}
// if (!dicGoods) {
// flag = 1, msg = "未找到道具" + itemid;
// } else if (!itidObj) {
// flag = 1, msg = "未找到道具" + itemid;
// } else {
// datas.push({ id: itemid, count: itemcount });
// }
// }
// if(flag == 0) {
// for (let roleId of uids) {
// let role = await RoleModel.findByRoleId(roleId);
// if (role) {
// await addBags(roleId, role.roleName, datas, ITEM_CHANGE_REASON.DEBUG);
// } else {
// flag = 1, msg = '未找到角色' + roleId;
// }
// }
// }
if (flag) {
return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, msg);
} else {
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
}
// if (flag) {
// return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, msg);
// } else {
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
// }
public async addGold(uids: Array<string>, _count: string) {
const { ctx } = this;
console.log('gm addGold', uids, _count);
let count = parseInt(_count);
if (isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
for (let roleId of uids) {
await RoleModel.addGoldFree(roleId, count);
}
// public async addGold(uids: Array<string>, _count: string) {
// const { ctx } = this;
// console.log('gm addGold', uids, _count);
// let count = parseInt(_count);
// if (isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// for (let roleId of uids) {
// await RoleModel.addGoldFree(roleId, count);
// }
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
public async addCoin(uids: Array<string>, _count: string) {
const { ctx } = this;
console.log('gm addCoin', uids, _count);
let count = parseInt(_count);
if (isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
for (let roleId of uids) {
await RoleModel.addCoin(roleId, count);
}
// public async addCoin(uids: Array<string>, _count: string) {
// const { ctx } = this;
// console.log('gm addCoin', uids, _count);
// let count = parseInt(_count);
// if (isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// for (let roleId of uids) {
// await RoleModel.addCoin(roleId, count);
// }
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
public async addSkin(uids: Array<string>, _id: string) {
const { ctx } = this;
console.log('gm addSkin', uids, _id);
let id = parseInt(_id);
if (isNaN(id)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
for (let roleId of uids) {
let role = await RoleModel.findByRoleId(roleId);
await addSkin(roleId, role.roleName, id, false);
}
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
// public async addSkin(uids: Array<string>, _id: string) {
// const { ctx } = this;
// console.log('gm addSkin', uids, _id);
// let id = parseInt(_id);
// if (isNaN(id)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// for (let roleId of uids) {
// let role = await RoleModel.findByRoleId(roleId);
// await addSkin(roleId, role.roleName, id, false);
// }
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
public async levelUp(uids: Array<string>, _lv: string) {
const { ctx } = this;
console.log('gm levelUp', uids, _lv);
let lv = parseInt(_lv);
if (isNaN(lv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
for (let roleId of uids) {
let exp = getExpByLv(lv - 1);
await RoleModel.levelup(roleId, lv, exp ? exp.sum : 0);
}
// public async levelUp(uids: Array<string>, _lv: string) {
// const { ctx } = this;
// console.log('gm levelUp', uids, _lv);
// let lv = parseInt(_lv);
// if (isNaN(lv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// for (let roleId of uids) {
// let exp = getExpByLv(lv - 1);
// await RoleModel.levelup(roleId, lv, exp ? exp.sum : 0);
// }
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
// public async getHeroList(roleId: string) {
// const {ctx} = this;

View File

@@ -211,7 +211,7 @@ export enum REDIS_KEY {
PVP_RANK ="pvpRank", // pvp排行榜
GUILD_INFO ="guildInfo", // 公会信息
GUILD_ACTIVE_RANK ="guildActiveRank", // 公会周活跃排行榜
DB_GAME ='dbGame', // 服务器列表
SERVER ='server', // 服务器列表
ONLINE_USERS ='onlineUsers', // 在线用户情况
ONLINE_TIME ='onlineTime', // 玩家在线时间
CHANNEL_SERVERS ='chat:channelServers', // 渠道对应的 chat 服务器 Id,
@@ -634,7 +634,7 @@ export enum TASK_TYPE {
LOGIN_SUM = 1, // 累计登录
LOGIN_SERIES = 2, // 连续登录
ROLE_LV = 3, // 主公等级
GASHA = 4, // 招募
GACHA = 4, // 招募
HERO_NUM = 5, // 武将数量
HERO_STAR_UP = 6, // 升星次数
HERO_QUALITY = 7, // 拥有品质
@@ -686,7 +686,7 @@ export enum TASK_TYPE {
COM_BATTLE_ASSIST_TEAM = 53, // 队友协助寻宝
COM_BATTLE = 54, // 寻宝
// COM_BATTLE_QUALITY = 55, // 按品质寻宝
COM_BATTLE_DROP = 56, // 寻宝掉落碎片
// COM_BATTLE_DROP = 56, // 寻宝掉落碎片
PVP = 57, // PVP挑战
PVP_WIN = 58, // PVP胜利
PVP_RECEIVE_BOX = 59, // 领取宝箱
@@ -696,7 +696,7 @@ export enum TASK_TYPE {
GUILD_JOB = 63, // 军团官职
GUILD_DONATE = 64, // 军团捐献
GUILD_RECEIVE_BOX = 65, // 领取活跃宝箱
GUILD_REFINE = 66, // 军团炼器
// GUILD_REFINE = 66, // 军团炼器
GUILD_ASSIST_REFINE = 67, // 军团助力加速
GUILD_TRAIN_SUCESS = 68, // 军团练兵场成功压制
GUILD_BOSS = 69, // 军团演武台挑战
@@ -715,7 +715,7 @@ export enum TASK_TYPE {
ROLE_TERAPH_STAGE_UP = 82, // 神像进阶
// EQUIP_QUALITY_COUNT = 83, // 获得*件品质的*装备
HERO_WAKE_UP_COUNT = 84, // *名武将觉醒
GUILD_JOIN_ACTIVITY_END = 85, // 参与*军团活动到结束
// GUILD_JOIN_ACTIVITY_END = 85, // 参与*军团活动到结束
ACTIVITY_RMB = 86, // 累计充值*元
EQUIP_LV_TO = 87, // x件装备强化至x级
EQUIP_PUT_JEWEL = 88, // 多少件装备多少阶天晶石
@@ -738,6 +738,8 @@ export enum TASK_TYPE {
JEWEL_RESET = 105, // 天晶洗练
JEWEL_QUENCH = 106, // 天晶淬炼
JEWEL_QUENCH_SUCCESS = 107, // 天晶淬炼成功
COM_BATTLE_LV = 108, // 军团寻宝
GUILD_REFINE = 109, // 军团兑换
}
// 任务累积类型

View File

@@ -1,5 +1,6 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { UpdateTaskParam } from '../domain/roleField/task';
/**
* 活动系统 - 今日挑战活动
@@ -18,43 +19,46 @@ export default class Activity_Daily_Challenges extends BaseModel {
@prop({ required: true })
cellIndex: number; // 第几天的第几个奖励
@prop({ required: true })
type: number; // 任务类型
taskType: number; // 任务类型
@prop({ required: true })
totalCount: number; // 累计达成次数
@prop({ required: true })
receiveRewardCount: number; // 领取奖励次数
@prop({ required: true })
data: string; // 数据信息
@prop({ required: true, type: String })
records: string[]; // 数据信息
//任务领取记录
public static async addCellRecord(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
public static async addCellRecord(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number, lean = true) {
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
{ $inc: { receiveRewardCount: count } }, { upsert: true, new: true }).lean(lean);
return result;
}
// 更新任务
public static async setOrIncTask(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, taskType: number, param: UpdateTaskParam) {
if(param.set) {
return await this.setTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, taskType, param.set, param.records);
} else if (param.inc) {
return await this.addTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, taskType, param.inc, param.records);
}
}
//根据活动统计完成任务次数
public static async setTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
{ $set: { totalCount: count } }, { upsert: true, new: true }).lean(lean);
public static async setTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, taskType: number, count: number, records?: string[]) {
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
{ $set: { totalCount: count, records, taskType } }, { upsert: true, new: true }).lean();
return result;
}
//根据活动统计完成任务次数
public static async addTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
{ $inc: { totalCount: addCount } }, { upsert: true, new: true }).lean(lean);
public static async addTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, taskType: number, addCount: number, records?: string[]) {
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
{ $inc: { totalCount: addCount }, $set: { records: records||[], taskType } }, { upsert: true, new: true }).lean();
return result;
}
//根据活动记录统计数据
public static async addTaskRecord(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, data: string,) {
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
{ $set: { data: data } }, { upsert: true, new: true }).lean(true);
return result;
}
//根据活动id查询活动数据
public static async findData(serverId: number, activityId: number, roleId: string, lean = true) {
let result: ActivityDailyChallengesModelType[] = await ActivityDailyChallengesModel.find({ serverId, roleId, activityId }).lean(lean);
@@ -68,8 +72,8 @@ export default class Activity_Daily_Challenges extends BaseModel {
}
//查询第几天某个的活动数据
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number) {
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOne({ serverId, roleId, activityId, dayIndex, cellIndex, type }).lean(true);
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number) {
let result: ActivityDailyChallengesModelType = await ActivityDailyChallengesModel.findOne({ serverId, roleId, activityId, dayIndex, cellIndex }).lean(true);
return result;
}

View File

@@ -1,5 +1,6 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { UpdateTaskParam } from '../domain/roleField/task';
/**
* 活动系统 - 成长任务活动
@@ -18,43 +19,45 @@ export default class Activity_Growth extends BaseModel {
@prop({ required: true })
cellIndex: number; // 第几天的第几个奖励
@prop({ required: true })
type: number; // 任务类型
taskType: number; // 任务类型
@prop({ required: true })
totalCount: number; // 累计达成次数
@prop({ required: true })
receiveRewardCount: number; // 领取奖励次数
@prop({ required: true })
data: string; // 数据信息
@prop({ required: true, type: String })
records: string[]; // 数据信息
//任务领取记录
public static async addCellRecord(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number,) {
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
public static async addCellRecord(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, count: number,) {
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
{ $inc: { receiveRewardCount: count } }, { upsert: true, new: true }).lean(true);
return result;
}
public static async setOrIncTask(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, taskType: number, param: UpdateTaskParam) {
if(param.set) {
return await this.setTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, taskType, param.set, param.records);
} else if (param.inc) {
return await this.addTaskCount(serverId, activityId, roleId, dayIndex, cellIndex, taskType, param.inc, param.records);
}
}
//根据活动统计完成任务次数
public static async setTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, count: number, lean = true) {
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
{ $set: { totalCount: count } }, { upsert: true, new: true }).lean(lean);
public static async setTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, taskType: number, count: number, records?: string[]) {
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
{ $set: { totalCount: count, records: records||[], taskType } }, { upsert: true, new: true }).lean();
return result;
}
//根据活动统计完成任务次数
public static async addTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, addCount: number, lean = true) {
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
{ $inc: { totalCount: addCount } }, { upsert: true, new: true }).lean(lean);
public static async addTaskCount(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, taskType: number, addCount: number, records?: string[]) {
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex },
{ $inc: { totalCount: addCount }, $set: { records: records||[], taskType } }, { upsert: true, new: true }).lean();
return result;
}
//根据活动记录统计数据
public static async addTaskRecord(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number, data: string,) {
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOneAndUpdate({ serverId, roleId, activityId, dayIndex, cellIndex, type },
{ $set: { data: data } }, { upsert: true, new: true }).lean(true);
return result;
}
//根据活动id查询活动数据
public static async findData(serverId: number, activityId: number, roleId: string, lean = true) {
let result: ActivityGrowthModelType[] = await ActivityGrowthModel.find({ serverId, roleId, activityId }).lean(lean);
@@ -68,8 +71,8 @@ export default class Activity_Growth extends BaseModel {
}
//查询第几天某个的活动数据
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number, type: number,) {
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOne({ serverId, roleId, activityId, dayIndex, cellIndex, type }).lean(true);
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, dayIndex: number, cellIndex: number) {
let result: ActivityGrowthModelType = await ActivityGrowthModel.findOne({ serverId, roleId, activityId, dayIndex, cellIndex }).lean(true);
return result;
}

View File

@@ -1,5 +1,6 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { UpdateTaskParam } from '../domain/roleField/task';
/**
* 活动系统 - 通用的刷新任务(分页,可刷新,限制领取次数)
@@ -20,39 +21,45 @@ export default class Activity_Refresh_Task extends BaseModel {
@prop({ required: true })
id: number; // id
@prop({ required: true })
type: number; // 任务类型
taskType: number; // 任务类型
@prop({ required: true })
totalCount: number; // 累计达成次数
@prop({ required: true })
receiveRewardCount: number; // 领取奖励次数
@prop({ required: true })
data: string; // 数据信息
@prop({ required: true, type: String })
records: string[]; // 数据信息
//任务领取记录
public static async addReceiveRecord(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, type: number, count: number) {
let result: ActivityRefreshTaskModelType = await ActivityRefreshTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex, id, type },
public static async addReceiveRecord(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, count: number) {
let result: ActivityRefreshTaskModelType = await ActivityRefreshTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex, id },
{ $inc: { receiveRewardCount: count } }, { upsert: true, new: true }).lean(true);
return result;
}
// 更新任务
public static async setOrIncTask(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, taskType: number, param: UpdateTaskParam) {
if(param.set) {
return await this.setTaskCount(serverId, activityId, roleId, roundIndex, pageIndex, id, taskType, param.set, param.records);
} else if (param.inc) {
return await this.addTaskCount(serverId, activityId, roleId, roundIndex, pageIndex, id, taskType, param.inc, param.records);
}
}
//根据活动统计完成任务次数
public static async setTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, type: number, count: number, lean = true) {
let result: ActivityRefreshTaskModelType = await ActivityRefreshTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex, id, type },
{ $set: { totalCount: count } }, { upsert: true, new: true }).lean(lean);
public static async setTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, taskType: number, count: number, records?: string[]) {
let result: ActivityRefreshTaskModelType = await ActivityRefreshTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex, id },
{ $set: { totalCount: count, records: records||[], taskType }}, { upsert: true, new: true }).lean();
return result;
}
//根据活动统计完成任务次数
public static async addTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, type: number, addCount: number, lean = true) {
let result: ActivityRefreshTaskModelType = await ActivityRefreshTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex, id, type },
{ $inc: { totalCount: addCount } }, { upsert: true, new: true }).lean(lean);
return result;
}
//根据活动记录统计数据
public static async addTaskRecord(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, type: number, data: string,) {
let result: ActivityRefreshTaskModelType = await ActivityRefreshTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex, id, type },
{ $set: { data: data } }, { upsert: true, new: true }).lean(true);
public static async addTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, taskType: number, count: number, records?: string[]) {
let result: ActivityRefreshTaskModelType = await ActivityRefreshTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex, id },
{ $inc: { totalCount: count }, $set: { records: records||[], taskType } }, { upsert: true, new: true }).lean();
return result;
}
@@ -64,8 +71,8 @@ export default class Activity_Refresh_Task extends BaseModel {
}
//查询活动数据
public static async findDataById(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number, type: number) {
let result: ActivityRefreshTaskModelType = await ActivityRefreshTaskModel.findOne({ serverId, roleId, activityId, roundIndex, pageIndex, id, type }).lean(true);
public static async findDataById(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, id: number) {
let result: ActivityRefreshTaskModelType = await ActivityRefreshTaskModel.findOne({ serverId, roleId, activityId, roundIndex, pageIndex, id }).lean(true);
return result;
}

View File

@@ -1,5 +1,6 @@
import BaseModel from './BaseModel';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { UpdateTaskParam } from '../domain/roleField/task';
/**
* 30天目标活动
@@ -20,17 +21,15 @@ export default class Activity_Thirty_Days extends BaseModel {
@prop({ required: true })
tab: number; // 具体任务id
@prop({ required: true })
type: number; // 任务类型
taskType: number; // 任务类型
@prop({ required: true })
totalCount: number; // 累计达成次数
@prop({ required: true })
isReceive: boolean; // 是否领取过奖励
@prop({ required: true })
data: string; // 数据信息
@prop({ required: true })
isPush: boolean; // 推送过消
@prop({ required: true, type: String })
records: string[]; // 数据信
//添加领取记录
public static async addRecord(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number) {
@@ -39,34 +38,6 @@ export default class Activity_Thirty_Days extends BaseModel {
return result;
}
//根据活动统计完成任务次数
public static async addTaskCount(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, type: number, addCount: number, lean = true) {
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ serverId, roleId, activityId, pageIndex, cellIndex, tab, type },
{ $inc: { totalCount: addCount } }, { upsert: true, new: true }).lean(lean);
return result;
}
//根据活动记录统计数据
public static async addTaskRecord(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, type: number, data: string,) {
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ serverId, roleId, activityId, pageIndex, cellIndex, tab, type },
{ $set: { data: data } }, { upsert: true, new: true }).lean(true);
return result;
}
//根据活动统计完成任务次数
public static async setTaskCount(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, type: number, count: number, lean = true) {
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ serverId, roleId, activityId, pageIndex, cellIndex, tab, type },
{ $set: { totalCount: count } }, { upsert: true, new: true }).lean(lean);
return result;
}
//推送标记
public static async pushMessage(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, type: number) {
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ serverId, roleId, activityId, pageIndex, cellIndex, tab, type },
{ $set: { isPush: true, } }, { upsert: true, new: true }).lean(true);
return result;
}
//根据活动id查询活动数据
public static async findData(serverId: number, activityId: number, roleId: string, lean = true) {
let result: ActivityThirtyDaysModelType[] = await ActivityThirtyDaysModel.find({ serverId, roleId, activityId }).lean(lean);
@@ -79,15 +50,36 @@ export default class Activity_Thirty_Days extends BaseModel {
return result;
}
// 更新任务
public static async setOrIncTask(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, taskType: number, param: UpdateTaskParam) {
if(param.set) {
return await this.setTaskCount(serverId, activityId, roleId, pageIndex, cellIndex, tab, taskType, param.set, param.records);
} else if (param.inc) {
return await this.addTaskCount(serverId, activityId, roleId, pageIndex, cellIndex, tab, taskType, param.inc, param.records);
}
}
//查询第*页的某个的活动数据
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, type: number,) {
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOne({ serverId, roleId, activityId, pageIndex, cellIndex, tab, type }).lean(true);
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number,) {
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOne({ serverId, roleId, activityId, pageIndex, cellIndex, tab }).lean(true);
return result;
}
//删除活动领取记录
public static async deleteActivity(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number) {
await ActivityThirtyDaysModel.deleteMany({ serverId, roleId, activityId, pageIndex, cellIndex });
//根据活动统计完成任务次数
public static async addTaskCount(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, taskType: number, count: number, records?: string[]) {
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ serverId, roleId, activityId, pageIndex, cellIndex, tab },
{ $inc: { totalCount: count }, $set: { records: records||[], taskType } }, { upsert: true, new: true }).lean();
return result;
}
//根据活动统计完成任务次数
public static async setTaskCount(serverId: number, activityId: number, roleId: string, pageIndex: number, cellIndex: number, tab: number, taskType: number, count: number, records?: string[]) {
let result: ActivityThirtyDaysModelType = await ActivityThirtyDaysModel.findOneAndUpdate({ serverId, roleId, activityId, pageIndex, cellIndex, tab },
{ $set: { totalCount: count, records: records||[], taskType } }, { upsert: true, new: true }).lean();
return result;
}
}

View File

@@ -1,5 +1,6 @@
import ActivityGrowth from './ActivityGrowth';
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { UpdateTaskParam } from '../domain/roleField/task';
/**
* 活动系统 - 寻宝骑兵-备战任务
@@ -27,6 +28,29 @@ export default class Activity_Treasure_Hunt_Task extends ActivityGrowth {
return result;
}
// 更新任务
public static async setOrIncTask(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, taskType: number, param: UpdateTaskParam) {
if(param.set) {
return await this.setTaskCount(serverId, activityId, roleId, roundIndex, cellIndex, taskType, param.set, param.records);
} else if (param.inc) {
return await this.addTaskCount(serverId, activityId, roleId, roundIndex, cellIndex, taskType, param.inc, param.records);
}
}
//根据活动统计完成任务次数
public static async setTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, taskType: number, count: number, records?: string[]) {
let result: ActivityTreasureHuntTaskModelType = await ActivityTreasureHuntTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, cellIndex },
{ $set: { totalCount: count, records: records||[], taskType } }, { upsert: true, new: true }).lean();
return result;
}
//根据活动统计完成任务次数
public static async addTaskCount(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, taskType: number, count: number, records?: string[]) {
let result: ActivityTreasureHuntTaskModelType = await ActivityTreasureHuntTaskModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, cellIndex },
{ $inc: { totalCount: count }, $set: { records: records||[], taskType } }, { upsert: true, new: true }).lean();
return result;
}
//查询活动数据
public static async findDataByCellIndex(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number) {
let result: ActivityTreasureHuntTaskModelType = await ActivityTreasureHuntTaskModel.findOne({ serverId, roleId, activityId, roundIndex, cellIndex }).lean(true);

View File

@@ -8,6 +8,8 @@ import { PVP } from '../pubUtils/dicParam';
@index({ roleId: 1 })
export default class PvpDefense extends BaseModel {
@prop({ required: true })
serverId: number; // 区 id
@prop({ required: true })
roleId: string; // 角色 id
@prop({ required: true })

View File

@@ -3,6 +3,7 @@ import { index, getModelForClass, prop, DocumentType, modelOptions } from '@type
import { TASK_FUN_TYPE } from '../consts';
import { genCode } from '../pubUtils/util';
import { getZeroPointD } from '../pubUtils/timeUtil';
import { UpdateTaskParam } from '../domain/roleField/task';
/**
* 玩家任务记录表
@@ -46,19 +47,25 @@ export default class UserTaskRec extends BaseModel {
}
}
public static async setTaskRec(roleId: string, type: number, taskType: number, group: string, count: number) {
public static async setTaskRec(roleId: string, type: number, taskType: number, group: string, count: number, records?: string[]) {
let condition = this.getRefreshCondition(type);
let rec: UserTaskRecType = await UserTaskRecModel.findOneAndUpdate({ roleId, group, taskType, ...condition }, { $setOnInsert: { code: genCode(8), received: [] }, $set: { count } }, { new: true, upsert: true }).lean();
let rec: UserTaskRecType = await UserTaskRecModel.findOneAndUpdate({ roleId, group, taskType, ...condition }, { $setOnInsert: { code: genCode(8), received: [] }, $set: { count, records: records||[] } }, { new: true, upsert: true }).lean();
return rec;
}
public static async incTaskRec(roleId: string, type: number, taskType: number, group: string, count: number) {
public static async incTaskRec(roleId: string, type: number, taskType: number, group: string, count: number, records?: string[]) {
let condition = this.getRefreshCondition(type);
let rec: UserTaskRecType = await UserTaskRecModel.findOneAndUpdate({ roleId, group, taskType, ...condition }, { $setOnInsert: { code: genCode(8), received: [] }, $inc: { count } }, { new: true, upsert: true }).lean();
let rec: UserTaskRecType = await UserTaskRecModel.findOneAndUpdate({ roleId, group, taskType, ...condition }, { $setOnInsert: { code: genCode(8), received: [] }, $inc: { count }, $set: { records: records||[] } }, { new: true, upsert: true }).lean();
return rec;
}
public static async setOrIncTask(roleId: string, type: number, taskType: number, group: string, param: UpdateTaskParam) {
if(param.set) {
return await this.setTaskRec(roleId, type, taskType, group, param.set, param.records);
} else if (param.inc) {
return await this.incTaskRec(roleId, type, taskType, group, param.inc, param.records);
}
}
public static async checkHistoryAndSetTaskRec(roleId: string, type: number, taskType: number, group: string, count: number) {
let rec: UserTaskRecType = await UserTaskRecModel.findByRoleAndGroup(roleId, type, taskType, group);

View File

@@ -135,7 +135,7 @@ export class ActivityInRemote {
}
}
export function transActivityInRemoteToModelType(activity: ActivityInRemote) {
export function transActivityInRemoteToModelType(activity: ActivityInRemote): ActivityModelType {
if(!activity) return null;
return {
...activity,

View File

@@ -164,8 +164,8 @@ export class GrowthFundData extends ActivityBase {
}
}
constructor(activityData: ActivityModelType, createTime: number) {
super(activityData, createTime)
constructor(activityData: ActivityModelType, createTime: number, serverTime?: number) {
super(activityData, createTime, serverTime)
this.initData(activityData.data)
}
}

View File

@@ -2,6 +2,7 @@ import { TASK_TYPE } from '../../consts';
import { ActivityModelType } from '../../db/Activity';
import { ActivityRefreshTaskModelType } from '../../db/ActivityRefreshTask';
import { ActivityRefreshTaskPointModelType } from '../../db/ActivityRefreshTaskPoint';
import { parseNumberList } from '../../pubUtils/util';
import { ActivityBase } from './activityField';
@@ -17,6 +18,7 @@ export class RefreshTaskItem {
skip: number; //跳转客户端用
point: number; //奖励的点数
taskParamArray: number[] = [];
totalCount: number = 0; //完成任务累计次数
receiveRewardCount: number = 0; //领取奖励次数
@@ -32,6 +34,7 @@ export class RefreshTaskItem {
this.point = data.point;
this.totalCount = 0;
this.receiveRewardCount = 0;
this.taskParamArray = parseNumberList(data.taskParam);
}
}
@@ -78,10 +81,10 @@ export class RefreshTaskData extends ActivityBase {
}
public findTaskByType(type: TASK_TYPE) {
let arr = [];
let arr: RefreshTaskItem[] = [];
for (let pageData of this.list) {
let items = pageData.items.filter(item => { return item.taskType == type });
arr = arr.concat(items)
arr.push(...items);
}
return arr;
}
@@ -90,7 +93,7 @@ export class RefreshTaskData extends ActivityBase {
public setPlayerRecords(data: ActivityRefreshTaskModelType[], pointRecordData: ActivityRefreshTaskPointModelType) {
for (let pageData of this.list) {
for (let item of pageData.items) {
let index = data.findIndex(record => { return item.id == record.id && item.pageIndex == record.pageIndex && item.taskType == record.type })
let index = data.findIndex(record => { return item.id == record.id && item.pageIndex == record.pageIndex && item.taskType == record.taskType })
if (index != -1) {
item.totalCount = data[index].totalCount ? data[index].totalCount : 0;
item.receiveRewardCount = data[index].receiveRewardCount ? data[index].receiveRewardCount : 0;
@@ -128,8 +131,8 @@ export class RefreshTaskData extends ActivityBase {
}
}
constructor(activityData: ActivityModelType, createTime: number) {
super(activityData, createTime)
constructor(activityData: ActivityModelType, createTime: number, serverTime?: number) {
super(activityData, createTime, serverTime)
this.initData(activityData.data)
}
}

View File

@@ -5,7 +5,7 @@ import { ActivityGrowthModelType } from '../../db/ActivityGrowth';
import { ActivityGrowthPointModelType } from '../../db/ActivityGrowthPoint';
import { HeroType } from '../../db/Hero';
import { RoleModel } from '../../db/Role';
import { splitString } from '../../pubUtils/util';
import { parseNumberList, splitString } from '../../pubUtils/util';
import { ActivityDailyGiftsModelType } from '../../db/ActivityDailyGifts';
import { parseResStr } from '../../pubUtils/util';
import { ConsumeResParam } from '../activityField/consumeField';
@@ -18,6 +18,7 @@ export class SevenDaysDailyItem {
name: string; // 任务名称
taskType: number; // 任务类型 dic_zyz_taskType.json
taskParam: string; //任务数据 dic_zyz_taskType.json
taskParamArray: number[] = [];
condition: number; //任务数据条件 dic_zyz_taskType.jsonT
reward: string; // 任务奖励,格式:1&3&1(类型&id&数量) 类型定义:1.英雄2.物品
skip: string; // 跳转
@@ -35,6 +36,7 @@ export class SevenDaysDailyItem {
this.reward = data.reward;
this.skip = data.skip;
this.taskParamArray = parseNumberList(data.taskParam);
this.totalCount = 0;
this.receiveRewardCount = 0;
}
@@ -324,8 +326,8 @@ export class SevenDaysData extends ActivityBase {
this.dailyChallenge = new SevenDaysDailyChallengesData(objData.dailyChallenge)
}
constructor(activityData: ActivityModelType, createTime: number) {
super(activityData, createTime)
constructor(activityData: ActivityModelType, createTime: number, serverCreateTime?: number) {
super(activityData, createTime, serverCreateTime)
this.initData(activityData.data)
}
}

View File

@@ -118,22 +118,8 @@ export class ThirtyDaysData extends ActivityBase {
pointRewardList: Array<ThirtyDaysPointItem> = [];//点数兑换奖励
totalPoint: number = 0;//总共点数
//未完成的任务
public findUncompleteTaskByType(type: number): ThirtyDaysItem[] {
let task = [];
for (let i = 0; i < this.list.length; i++) {
let items = this.list[i].item;
for (let itemData of items) {
if (itemData.taskType == type && !itemData.isComplete) {
task.push(itemData);
}
}
}
return task;
}
public findTaskByType(type: number) {
let task = [];
let task: ThirtyDaysItem[] = [];
for (let i = 0; i < this.list.length; i++) {
let items = this.list[i].item;
for (let itemData of items) {
@@ -256,8 +242,8 @@ export class ThirtyDaysData extends ActivityBase {
}
}
constructor(activityData: ActivityModelType, createTime: number) {
super(activityData, createTime)
constructor(activityData: ActivityModelType, createTime: number, serverTime?: number) {
super(activityData, createTime, serverTime)
this.initData(activityData.data)
}
}

View File

@@ -4,7 +4,7 @@ import { ActivityTreasureHuntShopModelType } from '../../db/ActivityTreasureHunt
import { ActivityTreasureHuntTaskModelType } from '../../db/ActivityTreasureHuntTask';
import { ActivityTreasureHuntTreasureShopModelType } from '../../db/ActivityTreasureHuntTreasureShop';
import { ActivityTreasureHuntFirstPageModelType } from '../../db/ActivityTreasureHuntFirstPage';
import { splitString } from '../../pubUtils/util';
import { parseNumberList, splitString } from '../../pubUtils/util';
import { ActivityBase } from './activityField';
@@ -142,6 +142,7 @@ export class TreasureHuntTaskItem {
fragment: number; //碎片
skip: string;
taskParamArray: number[]; // 任务参数
totalCount: number = 0; //任务统计
isReceive: boolean = false; //是否领取奖励
@@ -150,6 +151,7 @@ export class TreasureHuntTaskItem {
this.name = data.name;
this.taskType = data.taskType;
this.taskParam = data.taskParam;
this.taskParamArray = parseNumberList(data.taskParamArray);
this.condition = data.condition;
this.reward = data.reward;
this.fragment = data.fragment;
@@ -339,8 +341,8 @@ export class TreasureHuntData extends ActivityBase {
}
}
constructor(activityData: ActivityModelType, createTime: number) {
super(activityData, createTime)
constructor(activityData: ActivityModelType, createTime: number, sererTime?: number) {
super(activityData, createTime, sererTime);
this.initData(activityData.data)
}
}

Some files were not shown because too many files have changed in this diff Show More