mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- The AI will now be aware of opponents Royal Assassin and similar cards.
This commit is contained in:
@@ -973,10 +973,18 @@ public class AiAttackController {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ComputerUtilCard.canBeBlockedProfitably(defendingOpponent, attacker)) {
|
||||
|
||||
if (!attacker.hasKeyword("vigilance") && ComputerUtilCard.canBeKilledByRoyalAssassin(ai, attacker)) {
|
||||
canKillAllDangerous = false;
|
||||
canBeKilled = true;
|
||||
canBeKilledByOne = true;
|
||||
isWorthLessThanAllKillers = false;
|
||||
hasCombatEffect = false;
|
||||
}
|
||||
else if (ComputerUtilCard.canBeBlockedProfitably(defendingOpponent, attacker)) {
|
||||
canKillAllDangerous = false;
|
||||
canBeKilled = true;
|
||||
}
|
||||
|
||||
// if the creature cannot block and can kill all opponents they might as
|
||||
// well attack, they do nothing staying back
|
||||
|
||||
@@ -14,6 +14,7 @@ import forge.deck.Deck;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.game.Game;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.*;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
@@ -592,6 +593,35 @@ public class ComputerUtilCard {
|
||||
aiAtk.declareAttackers(combat);
|
||||
return combat.isAttacking(card);
|
||||
}
|
||||
|
||||
public static boolean canBeKilledByRoyalAssassin(final Player ai, final Card card) {
|
||||
boolean wasTapped = card.isTapped();
|
||||
for (Player opp : ai.getOpponents()) {
|
||||
for (Card c : opp.getCardsIn(ZoneType.Battlefield)) {
|
||||
for (SpellAbility sa : c.getSpellAbilities()) {
|
||||
if (sa.getApi() != ApiType.Destroy) {
|
||||
continue;
|
||||
}
|
||||
if (!ComputerUtilCost.canPayCost(sa, opp)) {
|
||||
continue;
|
||||
}
|
||||
sa.setActivatingPlayer(opp);
|
||||
if (sa.canTarget(card)) {
|
||||
continue;
|
||||
}
|
||||
// check whether the ability can only target tapped creatures
|
||||
card.setTapped(true);
|
||||
if (!sa.canTarget(card)) {
|
||||
card.setTapped(wasTapped);
|
||||
continue;
|
||||
}
|
||||
card.setTapped(wasTapped);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a mock combat and returns the list of likely blockers.
|
||||
|
||||
Reference in New Issue
Block a user