diff --git a/src/robot/Robot.ts b/src/robot/Robot.ts index a33f4ad..262b7be 100644 --- a/src/robot/Robot.ts +++ b/src/robot/Robot.ts @@ -223,7 +223,9 @@ export class Robot { @wait('playerActTime') private async selectPet() { let data = await assistantUtil.selectPet(this.player, this.room.state); - this.reply('select_pet_c2s', data); + if (data) { + this.reply('select_pet_c2s', data); + } } diff --git a/src/robot/RobotClient.ts b/src/robot/RobotClient.ts index 183931e..b268ab3 100644 --- a/src/robot/RobotClient.ts +++ b/src/robot/RobotClient.ts @@ -230,7 +230,9 @@ export class RobotClient implements Client { @wait('playerActTime') private async selectPet() { let data = await assistantUtil.selectPet(this.selfPlayer, this.svrstate); - this.reply('select_pet_c2s', data) + if (data) { + this.reply('select_pet_c2s', data); + } } } diff --git a/src/utils/assistant.util.ts b/src/utils/assistant.util.ts index cdb26d0..f7ebec9 100644 --- a/src/utils/assistant.util.ts +++ b/src/utils/assistant.util.ts @@ -9,6 +9,7 @@ import {Player} from "../rooms/schema/Player"; import {HeroCfg} from "../cfg/parsers/HeroCfg"; import {EffectType} from "../cfg/enums/EffectType"; import {CardType} from "../cfg/enums/CardType"; +import {GameEnv} from "../cfg/GameEnv"; let assistantUtil = { @@ -150,10 +151,15 @@ let assistantUtil = { let effectMap: Map = global.$cfg.get(BaseConst.EFFECTCARD); let spellCards: Card[] = []; // 优先取随从 + let petCount = 1; + for (let [,pet] of dstPlayer.pets) { + if (pet.state == 1) petCount ++; + } + let noMorePet = petCount >= new GameEnv().maxPlayerPetCount; for (let card of cards) { let effect = effectMap.get(card.effect); // if (effect.type_id == EffectType.unit && dstPlayer.unitCfgs.has(card.effect + '')) { - if (effect.type_id == EffectType.unit) { + if (effect.type_id == EffectType.unit && !noMorePet) { result = card; break; } else if (effect.type_id == EffectType.skill) { @@ -163,6 +169,9 @@ let assistantUtil = { if (!result) { result = spellCards.randomOne(); } + if (!result) { + return null; + } let targetType: SkillTargetType = CfgMan.getTargetByCard(result.effect); let targetPlayer; let targetPos;