热更新:handler监听热更新
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { Application, BackendSession, HandlerService, } from "pinus";
|
||||
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, HERO_GROW_MAX, MSG_SOURCE, JEWEL_PUSH_LV, TASK_TYPE, HERO_CE_RATIO } from "../../../consts";
|
||||
import { ItemInter } from "../../../pubUtils/interface";
|
||||
|
||||
@@ -19,6 +19,7 @@ import { checkTaskWithHero, checkTaskWithEquip, checkTask, checkTaskWithArgs, ch
|
||||
import { Attribute } from "../../../domain/roleField/attribute";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new EquipHandler(app);
|
||||
}
|
||||
|
||||
@@ -64,8 +65,8 @@ export class EquipHandler {
|
||||
if (specialMaterial.ids.includes(id)) {
|
||||
costCount++;
|
||||
cost.push({ id, seqId, count: 1 });
|
||||
for(let { jewel } of holes) {
|
||||
if(jewel > 0) jewels.push({ id: jewel, count: 1});
|
||||
for (let { jewel } of holes) {
|
||||
if (jewel > 0) jewels.push({ id: jewel, count: 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -476,8 +477,8 @@ export class EquipHandler {
|
||||
if (!goodInfo)
|
||||
return resResult(STATUS.EQUIP_NOT_FIND);
|
||||
|
||||
let holes = equip.holes||[];
|
||||
for(let { jewel } of holes) {
|
||||
let holes = equip.holes || [];
|
||||
for (let { jewel } of holes) {
|
||||
jewels.push({ id: jewel, count: 1 });
|
||||
}
|
||||
goods = goods.concat(goodInfo.decomposeItem);
|
||||
@@ -552,7 +553,7 @@ export class EquipHandler {
|
||||
let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
if(!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let dicJob = gameData.job.get(dicHero.jobid);
|
||||
|
||||
|
||||
@@ -570,29 +571,29 @@ export class EquipHandler {
|
||||
let { ePlace, lv } = hero;
|
||||
|
||||
let curEquips: Array<{ seqId: number, hid: number }> = [];
|
||||
for(let curEPlace of ePlace) {
|
||||
if(!curEPlace.equip) { // 未装备
|
||||
for (let curEPlace of ePlace) {
|
||||
if (!curEPlace.equip) { // 未装备
|
||||
let sortAttrId = equipTypeToSortAttr.get(curEPlace.id);
|
||||
let sortedAndSuitEquips = sortEquips.filter(equipInfos => { // 筛选可穿的
|
||||
let { lvLimited, classId, ePlaceId } = equipInfos;
|
||||
return lv >= lvLimited && classId.indexOf(dicJob.job_class) != -1 && curEPlace.id == ePlaceId;
|
||||
}).sort((a, b) => { // 排序按:战力 => 根据位置看个别属性 => 品质
|
||||
if(b.ce - a.ce != 0) return b.ce - a.ce;
|
||||
let abilityA = a.goodsAbility.get(sortAttrId)||0;
|
||||
let abilityB = b.goodsAbility.get(sortAttrId)||0;
|
||||
if( abilityA - abilityB != 0) return abilityB - abilityA;
|
||||
if (b.ce - a.ce != 0) return b.ce - a.ce;
|
||||
let abilityA = a.goodsAbility.get(sortAttrId) || 0;
|
||||
let abilityB = b.goodsAbility.get(sortAttrId) || 0;
|
||||
if (abilityA - abilityB != 0) return abilityB - abilityA;
|
||||
return b.quality - a.quality;
|
||||
});
|
||||
|
||||
if(sortedAndSuitEquips.length > 0) {
|
||||
if (sortedAndSuitEquips.length > 0) {
|
||||
let { equip } = sortedAndSuitEquips.shift();
|
||||
let curEquip = await dressEquip(serverId, roleId, sid, hero,equip, funcs);
|
||||
if(!!curEquip) curEquips.push(curEquip);
|
||||
let curEquip = await dressEquip(serverId, roleId, sid, hero, equip, funcs);
|
||||
if (!!curEquip) curEquips.push(curEquip);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(curEquips.length > 0) {
|
||||
if (curEquips.length > 0) {
|
||||
//任务
|
||||
//英雄满装备且都镶嵌相同阶数的宝石
|
||||
let { isTask, jewelLevel } = await checkTaskConditionEquipSuitJewelStage(hero)
|
||||
@@ -878,41 +879,41 @@ export class EquipHandler {
|
||||
* @returns
|
||||
* @memberof ComBattleHandler
|
||||
*/
|
||||
async composeBlueprt(msg: { target: number, original: Array<{id: number, count: number}>}, session: BackendSession) {
|
||||
async composeBlueprt(msg: { target: number, original: Array<{ id: number, count: number }> }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const sid = session.get('sid');
|
||||
const serverId = session.get('serverId');
|
||||
const funcs: number[] = session.get('funcs');
|
||||
|
||||
|
||||
const { target, original } = msg;
|
||||
|
||||
// 原材料检查
|
||||
let originalQuality: number, originalSum: number = 0;
|
||||
for(let {id, count} of original) {
|
||||
for (let { id, count } of original) {
|
||||
const goodInfo = gameData.goods.get(id);
|
||||
if(!originalQuality) originalQuality = goodInfo.quality;
|
||||
if(originalQuality != goodInfo.quality) {
|
||||
if (!originalQuality) originalQuality = goodInfo.quality;
|
||||
if (originalQuality != goodInfo.quality) {
|
||||
return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
}
|
||||
|
||||
if(goodInfo.itid == IT_TYPE.BLUEPRT) {
|
||||
if (goodInfo.itid == IT_TYPE.BLUEPRT) {
|
||||
originalSum += count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const dicCompose = gameData.blurprtCompose.get(originalQuality);
|
||||
if(!dicCompose) {
|
||||
if (!dicCompose) {
|
||||
return resResult(STATUS.COM_BLUEPRT_QUALITY_CANNOT_COMPOSE);
|
||||
}
|
||||
if(originalSum != dicCompose.blueprtNum) {
|
||||
}
|
||||
if (originalSum != dicCompose.blueprtNum) {
|
||||
return resResult(STATUS.COM_BLUEPRT_COUNT_ERROR);
|
||||
}
|
||||
|
||||
let dicTargetInfo = gameData.goods.get(target);
|
||||
if(!dicTargetInfo) return resResult(STATUS.WRONG_PARMS);
|
||||
if(dicTargetInfo.quality != dicCompose.targetQuality) return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
if (!dicTargetInfo) return resResult(STATUS.WRONG_PARMS);
|
||||
if (dicTargetInfo.quality != dicCompose.targetQuality) return resResult(STATUS.COM_BLUEPRT_QUALITY_ERROR);
|
||||
|
||||
// 添加寻宝币
|
||||
original.push({
|
||||
@@ -922,16 +923,16 @@ export class EquipHandler {
|
||||
// 消耗藏宝图和寻宝币
|
||||
|
||||
let costResult = await handleCost(roleId, sid, original);
|
||||
if(!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (!costResult) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
const reward = [{id: target, count: 1}];
|
||||
const reward = [{ id: target, count: 1 }];
|
||||
const goods = await addItems(roleId, roleName, sid, reward);
|
||||
if (dicCompose.targetQuality >= QUALITY_TYPE.ORANGE) {
|
||||
const { name } = gameData.goods.get(target);
|
||||
pushNormalItemMsg(roleId, roleName, serverId, MSG_SOURCE.ORANGE_BLUEPRT_COMPOSE, target, name);
|
||||
}
|
||||
await checkTask(roleId, sid, funcs, TASK_TYPE.COM_BATTLE_BLUEPRT, 1, true, { quality: dicCompose.targetQuality });
|
||||
|
||||
|
||||
return resResult(STATUS.SUCCESS, { goods, costGold: 0 });
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, ChannelService } from "pinus";
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from "pinus";
|
||||
import { resResult, getRandEelm, getResStr, shouldRefresh, sortArrRandom } from "../../../pubUtils/util";
|
||||
import { STATUS, ROLE_SELECT, FRIEND_DROP_TYPE, FRIEND_RELATION_TYPE, POPULATE_TYPE, BLOCK_OPEATE, CONSUME_TYPE, ITID, HERO_SELECT, EQUIP_SELECT, REDIS_KEY, MSG_SOURCE, MSG_TYPE, TASK_TYPE } from "../../../consts";
|
||||
import { RoleModel, RoleType } from "../../../db/Role";
|
||||
@@ -26,6 +26,7 @@ import { checkTaskWithRoles, checkTask, checkActivityTask } from "../../../servi
|
||||
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new FriendHandler(app);
|
||||
}
|
||||
|
||||
@@ -676,9 +677,9 @@ export class FriendHandler {
|
||||
list.push({
|
||||
roleId, roleName, hid, hName, ce, lv, star, colorStar, quality, job,
|
||||
skin: curSkin ? curSkin.id : 0, equips: equips.map(cur => {
|
||||
let curEplace = ePlace.find(ccur => cur.ePlaceId == ccur.id)||new EPlace();
|
||||
let { lv = 0, refineLv = 0} = curEplace;
|
||||
return {...cur, lv, refineLv}
|
||||
let curEplace = ePlace.find(ccur => cur.ePlaceId == ccur.id) || new EPlace();
|
||||
let { lv = 0, refineLv = 0 } = curEplace;
|
||||
return { ...cur, lv, refineLv }
|
||||
}), attributes
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, ChannelService } from 'pinus';
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from 'pinus';
|
||||
import { handleCost, addItems, unlockFigure, createHero } from '../../../services/rewardService';
|
||||
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
|
||||
import { resResult, deepCopy } from '../../../pubUtils/util';
|
||||
@@ -18,6 +18,7 @@ import { addSkin } from '../../../pubUtils/itemUtils';
|
||||
import Skin from '../../../db/Skin';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new HeroHandler(app);
|
||||
}
|
||||
|
||||
@@ -209,7 +210,7 @@ export class HeroHandler {
|
||||
if (!dicHero) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
let { pieceId, jobid } = dicHero;
|
||||
let dicJob = gameData.job.get(jobid);
|
||||
if(!dicJob) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
if (!dicJob) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if (!hero) return resResult(STATUS.ROLE_HERO_NOT_EXISTS);
|
||||
@@ -224,15 +225,15 @@ export class HeroHandler {
|
||||
// 根据dic_zyz_hero_star 计算需要花的碎片并检查碎片数量
|
||||
const curDicHeroStar = getHeroStarByQuality(dicJob.job_class, quality, oldStar);
|
||||
if (!curDicHeroStar) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
|
||||
let newStarStage = 0;
|
||||
let max = isOneClick? ABI_STAGE.END: oldStarStage + 1;
|
||||
for(let i = 0; i < max; i++ ) {
|
||||
let max = isOneClick ? ABI_STAGE.END : oldStarStage + 1;
|
||||
for (let i = 0; i < max; i++) {
|
||||
let costResult = await handleCost(roleId, sid, [{ id: pieceId, count: curDicHeroStar.advanceUpFragmentNum }]);
|
||||
if (!costResult) break;
|
||||
newStarStage++;
|
||||
}
|
||||
if(newStarStage == 0) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (newStarStage == 0) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let isUpStar = newStarStage == ABI_STAGE.END;
|
||||
|
||||
@@ -350,16 +351,16 @@ export class HeroHandler {
|
||||
if (!curDicHeroStar) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
let newColorStarStage = 0;
|
||||
let max = isOneClick? ABI_STAGE.END: oldColorStarStage + 1;
|
||||
for(let i = 0; i < max; i++) {
|
||||
let max = isOneClick ? ABI_STAGE.END : oldColorStarStage + 1;
|
||||
for (let i = 0; i < max; i++) {
|
||||
let { fragmentNum, consume } = curDicHeroStar;
|
||||
|
||||
|
||||
// console.log(JSON.stringify([{id: pieceId, count: fragmentNum}, ...consumeArr]))
|
||||
let costResult = await handleCost(roleId, sid, [{ id: pieceId, count: fragmentNum }, ...consume]);
|
||||
if (!costResult) break;
|
||||
newColorStarStage++;
|
||||
}
|
||||
if(newColorStarStage == 0) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
if (newColorStarStage == 0) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||
|
||||
let isWakeUp = oldColorStar == 0;
|
||||
let isUpStar = isWakeUp || newColorStarStage == ABI_STAGE.END;
|
||||
@@ -540,7 +541,7 @@ export class HeroHandler {
|
||||
|
||||
let { favourLv: oldLv, favour: oldExp, lv } = hero;
|
||||
|
||||
let maxLv = lv > gameData.maxFriendShipLv.max? gameData.maxFriendShipLv.max: lv; // 好感度最大等级
|
||||
let maxLv = lv > gameData.maxFriendShipLv.max ? gameData.maxFriendShipLv.max : lv; // 好感度最大等级
|
||||
if (maxLv <= oldLv)
|
||||
return resResult(STATUS.HERO_FAVOUR_LEVEL_REACH_MAXT);
|
||||
|
||||
@@ -614,14 +615,14 @@ export class HeroHandler {
|
||||
if (!!skin.enable) {
|
||||
return resResult(STATUS.HERO_SKIN_IS_EQUIPED);
|
||||
}
|
||||
newHeroSkins.push({...skin, enable: true});
|
||||
newHeroSkins.push({ ...skin, enable: true });
|
||||
result = true;
|
||||
} else {
|
||||
if (!!skin.enable) {
|
||||
lastSkinId = skin.id;
|
||||
}
|
||||
|
||||
newHeroSkins.push({...skin, enable: false});
|
||||
newHeroSkins.push({ ...skin, enable: false });
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { Application, BackendSession, HandlerService, } from "pinus";
|
||||
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, HERO_GROW_MAX, MSG_SOURCE, JEWEL_PUSH_LV, TASK_TYPE, DEBUG_MAGIC_WORD } from "../../../consts";
|
||||
import { ItemInter, RewardInter } from "../../../pubUtils/interface";
|
||||
|
||||
@@ -24,6 +24,7 @@ import { GiftCodeType, GiftCodeModel } from "../../../db/GiftCode";
|
||||
import UserGiftCode, { UserGiftCodeModel } from "../../../db/UserGiftCode";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ItemHandler(app);
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ export class ItemHandler {
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let { isOver } = await getAp(roleId, role.lv);
|
||||
if(isOver) return resResult(STATUS.AP_IS_FULL);
|
||||
if (isOver) return resResult(STATUS.AP_IS_FULL);
|
||||
|
||||
let consumeResult = await handleCost(roleId, sid, [{ id: id, count: count }]);
|
||||
if (!consumeResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
@@ -111,7 +112,7 @@ export class ItemHandler {
|
||||
const roleName: string = session.get('roleName');
|
||||
const sid: string = session.get('sid');
|
||||
|
||||
if(count <= 0) return resResult(STATUS.WRONG_PARMS);
|
||||
if (count <= 0) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let dicGoods = gameData.goods.get(id);
|
||||
if (!dicGoods) {
|
||||
@@ -125,18 +126,18 @@ export class ItemHandler {
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let { buyTimes = 0 } = await getAp(roleId, role.lv);
|
||||
if(buyTimes + count > gameData.apMaxBuyTimes.max) return resResult(STATUS.AP_BUY_TIMES_LACK);
|
||||
if (buyTimes + count > gameData.apMaxBuyTimes.max) return resResult(STATUS.AP_BUY_TIMES_LACK);
|
||||
|
||||
let cost: RewardInter[] = [];
|
||||
for(let i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
let curCost = gameData.apBuy.get(++buyTimes);
|
||||
if(curCost) cost = cost.concat(curCost);
|
||||
if (curCost) cost = cost.concat(curCost);
|
||||
}
|
||||
|
||||
let consumeResult = await handleCost(roleId, sid, cost);
|
||||
if (!consumeResult) return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, [{id, count}]);
|
||||
let goods = await addItems(roleId, roleName, sid, [{ id, count }]);
|
||||
let apJson = await setApBuyTimes(roleId, role.lv, sid, count);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
@@ -153,15 +154,15 @@ export class ItemHandler {
|
||||
|
||||
let giftCodeDetail = await GiftCodeDetailModel.findByCode(code);
|
||||
let giftCode = <GiftCodeType>giftCodeDetail.giftCode;
|
||||
|
||||
if(giftCode.isLimit && giftCodeDetail.usedNum >= giftCode.count) {
|
||||
|
||||
if (giftCode.isLimit && giftCodeDetail.usedNum >= giftCode.count) {
|
||||
return resResult(STATUS.GIFT_CODE_USED_NUM_MAX);
|
||||
}
|
||||
if(giftCode.beginTime > new Date()) return resResult(STATUS.GIFT_CODE_NOT_START);
|
||||
if(giftCode.endTime < new Date()) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED);
|
||||
if (giftCode.beginTime > new Date()) return resResult(STATUS.GIFT_CODE_NOT_START);
|
||||
if (giftCode.endTime < new Date()) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED);
|
||||
|
||||
let userGiftCode = await UserGiftCodeModel.findByCode(roleId, code);
|
||||
if(userGiftCode) {
|
||||
if (userGiftCode) {
|
||||
return resResult(STATUS.YOU_HAVE_USED_THIS_CODE);
|
||||
}
|
||||
|
||||
@@ -185,7 +186,7 @@ export class ItemHandler {
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'lv');
|
||||
let apJson = await setAp(roleId, role.lv, msg.ap, sid, funcs);
|
||||
if(!apJson) return resResult(STATUS.BATTLE_ACTION_POINT_LACK)
|
||||
if (!apJson) return resResult(STATUS.BATTLE_ACTION_POINT_LACK)
|
||||
return resResult(STATUS.SUCCESS, { apJson });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession } from "pinus";
|
||||
import { Application, BackendSession, HandlerService, } from "pinus";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { STATUS, RANK_TYPE_TO_KEY, ROLE_SELECT, RANK_TYPE, HERO_SELECT, GUILD_SELECT } from "../../../consts";
|
||||
import { RoleModel } from "../../../db/Role";
|
||||
@@ -12,6 +12,7 @@ import { HeroModel, HeroUpdate } from "../../../db/Hero";
|
||||
import { RewardInter } from "../../../pubUtils/interface";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new RoleHandler(app);
|
||||
}
|
||||
|
||||
@@ -25,7 +26,7 @@ export class RoleHandler {
|
||||
let serverId = session.get('serverId');
|
||||
|
||||
let role = await RoleModel.findByRoleId(roleId, 'rankReceived');
|
||||
if(!role) return resResult(STATUS.WRONG_PARMS);
|
||||
if (!role) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let res = await getGeneralRank(role, serverId);
|
||||
|
||||
@@ -38,13 +39,13 @@ export class RoleHandler {
|
||||
|
||||
let { type } = msg;
|
||||
let redisKey = RANK_TYPE_TO_KEY.get(type);
|
||||
if(!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
if (!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
let r = new Rank(redisKey, { serverId });
|
||||
|
||||
let { ranks, myRank } = await r.getRankListWithMyRank({roleId});
|
||||
if(!myRank) {
|
||||
let { ranks, myRank } = await r.getRankListWithMyRank({ roleId });
|
||||
if (!myRank) {
|
||||
let role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.RANK, true);
|
||||
if(type == RANK_TYPE.TOP_LINTUP) {
|
||||
if (type == RANK_TYPE.TOP_LINTUP) {
|
||||
myRank = await r.generMyRankWithRole(roleId, role.topLineupCe, 0, role);
|
||||
} else if (type == RANK_TYPE.TOP_HERO) {
|
||||
let hero = await HeroModel.getMyTopHero(roleId, HERO_SELECT.RANK_LINEUP);
|
||||
@@ -56,7 +57,7 @@ export class RoleHandler {
|
||||
} else if (type == RANK_TYPE.SUM_CE) {
|
||||
myRank = await r.generMyRankWithRole(roleId, role.ce, role.updatedAt.getTime(), role);
|
||||
} else if (type == RANK_TYPE.TOWER) {
|
||||
myRank = await r.generMyRankWithRole(roleId, role.towerLv, role.towerUpTime?.getTime()||0, role);
|
||||
myRank = await r.generMyRankWithRole(roleId, role.towerLv, role.towerUpTime?.getTime() || 0, role);
|
||||
} else if (type == RANK_TYPE.DUNGEON) {
|
||||
myRank = await r.generMyRankWithRole(roleId, role.dungeonWarId, role.dungeonUpdatedAt, role);
|
||||
} else if (type == RANK_TYPE.MAIN) {
|
||||
@@ -78,16 +79,16 @@ export class RoleHandler {
|
||||
let { type } = msg;
|
||||
|
||||
let redisKey = RANK_TYPE_TO_KEY.get(type);
|
||||
if(!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
if (!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let r = new Rank(redisKey, { serverId });
|
||||
const myUserGuild = await UserGuildModel.getMyGuild(roleId, 'auth guildCode');
|
||||
let { ranks, myRank } = await r.getRankListWithMyRank({guildCode: myUserGuild?.guildCode||''});
|
||||
let { ranks, myRank } = await r.getRankListWithMyRank({ guildCode: myUserGuild?.guildCode || '' });
|
||||
if (!myRank) {
|
||||
let guild = await GuildModel.findByCode(myUserGuild.guildCode, serverId, GUILD_SELECT.RANK);
|
||||
if(type == RANK_TYPE.GUILD_LV) {
|
||||
if (type == RANK_TYPE.GUILD_LV) {
|
||||
myRank = await r.generMyRankWithGuild(guild.code, guild.lv, guild.lvUpdateTime, guild);
|
||||
} else if(type == RANK_TYPE.GUILD_ACTIVE) {
|
||||
} else if (type == RANK_TYPE.GUILD_ACTIVE) {
|
||||
myRank = await r.generMyRankWithGuild(guild.code, guild.activeWeekly, guild.activeUpdateTime, guild);
|
||||
}
|
||||
}
|
||||
@@ -102,7 +103,7 @@ export class RoleHandler {
|
||||
|
||||
let { type, hid } = msg;
|
||||
let redisKey = RANK_TYPE_TO_KEY.get(type);
|
||||
if(!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
if (!redisKey) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
let r = new Rank(redisKey, { serverId, hid });
|
||||
let ranks = await r.getRankByRange();
|
||||
@@ -121,9 +122,9 @@ export class RoleHandler {
|
||||
let { type, id } = msg;
|
||||
|
||||
let ids: number[] = [];
|
||||
if(id == 0) {
|
||||
gameData.generalRankReward.forEach((dic, id)=> {
|
||||
if(dic.rankId == type) {
|
||||
if (id == 0) {
|
||||
gameData.generalRankReward.forEach((dic, id) => {
|
||||
if (dic.rankId == type) {
|
||||
ids.push(id);
|
||||
}
|
||||
});
|
||||
@@ -134,25 +135,25 @@ export class RoleHandler {
|
||||
let canReceiveId: number[] = [];
|
||||
let role = await RoleModel.findByRoleId(roleId, 'rankReceived');
|
||||
|
||||
for(let id of ids) {
|
||||
for (let id of ids) {
|
||||
let dicReward = gameData.generalRankReward.get(id);
|
||||
if(!dicReward || dicReward.rankId != type) continue;
|
||||
|
||||
if (!dicReward || dicReward.rankId != type) continue;
|
||||
|
||||
let redisKey = RANK_TYPE_TO_KEY.get(type);
|
||||
let r = new Rank(redisKey, { serverId }, false, 1);
|
||||
let ranks = await r.getRankByRange();
|
||||
let num = ranks.length > 0? ranks[0].num: 0;
|
||||
if(num < dicReward.condition) continue;
|
||||
|
||||
if(role.rankReceived.includes(id)) continue;
|
||||
|
||||
let num = ranks.length > 0 ? ranks[0].num : 0;
|
||||
if (num < dicReward.condition) continue;
|
||||
|
||||
if (role.rankReceived.includes(id)) continue;
|
||||
|
||||
let reward = dicReward.reward;
|
||||
rewards = rewards.concat(reward);
|
||||
canReceiveId.push(id);
|
||||
}
|
||||
|
||||
role = await RoleModel.receiveRankReward(roleId, canReceiveId);
|
||||
if(canReceiveId.length <= 0) return resResult(STATUS.REWARD_CONDITION_NOT_REACH);
|
||||
if (canReceiveId.length <= 0) return resResult(STATUS.REWARD_CONDITION_NOT_REACH);
|
||||
|
||||
let received = role.rankReceived.filter(rewardId => {
|
||||
let dic = gameData.generalRankReward.get(rewardId);
|
||||
@@ -168,12 +169,12 @@ export class RoleHandler {
|
||||
})
|
||||
}
|
||||
|
||||
async test(msg: { }, session: BackendSession) {
|
||||
async test(msg: {}, session: BackendSession) {
|
||||
let roles = await RoleModel.find({}).lean();
|
||||
for(let role of roles) {
|
||||
for (let role of roles) {
|
||||
let heroes = await HeroModel.find({ roleId: role.roleId }).lean();
|
||||
await RoleModel.updateRoleInfo(role.roleId, { heroNum: heroes.length, heroNumUpdatedAt: nowSeconds() });
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { STATUS } from '../../../consts/statusCode';
|
||||
import { RoleModel } from './../../../db/Role';
|
||||
import { HeroModel } from '../../../db/Hero';
|
||||
import { resResult, decodeIdCntArrayStr, parseGoodStr } from '../../../pubUtils/util';
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { Application, BackendSession, pinus, HandlerService, } from 'pinus';
|
||||
import { handleCost, addItems, createHeroes } from '../../../services/rewardService';
|
||||
import { getTitle, getTeraph, gameData, getScollByStar, getFriendLvByExp, getHeroExpByLv } from '../../../pubUtils/data';
|
||||
import { SCHOOL, SCROLL, EXTERIOR, SCRIPT } from '../../../pubUtils/dicParam';
|
||||
@@ -23,6 +23,7 @@ import { checkPvp } from '../../../services/pvpService';
|
||||
import { pushData } from '../../../services/connectorService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new RoleHandler(app);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Application, BackendSession, pinus } from "pinus";
|
||||
import { Application, BackendSession, pinus, HandlerService, } from "pinus";
|
||||
import { resResult, parseGoodStr, getRandSingleEelm } from "../../../pubUtils/util";
|
||||
import { STATUS, TASK_FUN_TYPE, SHOP_REFRESH_TYPE } from "../../../consts";
|
||||
import { gameData } from "../../../pubUtils/data";
|
||||
@@ -16,6 +16,7 @@ import { RoleModel } from "../../../db/Role";
|
||||
import { roleLevelup } from "../../../services/normalBattleService";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ShopHandler(app);
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ export class ShopHandler {
|
||||
}
|
||||
|
||||
let goods = await addItems(roleId, roleName, sid, taskReward);
|
||||
if(expItem && expItem.count > 0) {
|
||||
if (expItem && expItem.count > 0) {
|
||||
await roleLevelup(roleId, expItem.count, session);
|
||||
goods.push(expItem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user