diff --git a/game.js b/game.js index 4c79f21..9f83fd7 100644 --- a/game.js +++ b/game.js @@ -1128,6 +1128,11 @@ class Game { this.addLog(`${player.character.name} 对 ${target.character.name} 使用了【火攻】`); this.showCardUseAnimation(); + if (target.hand.length === 0) { + this.addLog('目标没有手牌,火攻无效'); + return false; + } + const randomCardIndex = Math.floor(Math.random() * target.hand.length); const randomCard = target.hand[randomCardIndex]; this.addLog(`${target.character.name} 展示了一张 ${randomCard.name}`); @@ -1492,7 +1497,6 @@ class Game { } aiPlayCards(player) { - const targets = this.players.filter(p => p.isAlive && p.index !== player.index); const canUseMultipleAttacks = this.hasWeaponWithEffect('zhugeliannu') || player.character.name === '张飞'; const cardPriority = [ @@ -1513,6 +1517,11 @@ class Game { ]; const playNextCard = () => { + if (this.gameOver || this.getCurrentPlayer().index !== player.index) { + return; + } + + const targets = this.players.filter(p => p.isAlive && p.index !== player.index); let cardsUsed = false; if (player.character.name === '刘备' && player.hand.length >= 2) { @@ -1577,7 +1586,7 @@ class Game { targetIndex = this[priority.target](player, targets); } - if (targetIndex !== -1 || !priority.target) { + if (targetIndex !== -1 || !priority.target || priority.isEquip) { const result = this.playCard(cardIndex, targetIndex); if (result) { cardsUsed = true;