- Basic code to reinforce an attack with Banding creatures.

- Enable AI support for Defensive Formation.
This commit is contained in:
Agetian
2023-07-02 22:16:53 +03:00
parent bf0a816bf8
commit 8fca839549
2 changed files with 38 additions and 1 deletions

View File

@@ -1304,6 +1304,44 @@ public class AiController {
AiAttackController aiAtk = new AiAttackController(attacker); AiAttackController aiAtk = new AiAttackController(attacker);
lastAttackAggression = aiAtk.declareAttackers(combat); lastAttackAggression = aiAtk.declareAttackers(combat);
// Check if we can reinforce with Banding creatures
if (!combat.getAttackers().isEmpty()) {
List<String> bandsWithString = Arrays.asList("Bands with Other Legendary Creatures",
"Bands with Other Creatures named Wolves of the Hunt",
"Bands with Other Dinosaurs");
List<Card> bandingCreatures = new CardCollection(aiAtk.notNeededAsBlockers(attacker.getCreaturesInPlay()));
bandingCreatures = CardLists.filter(bandingCreatures, new Predicate<Card>() {
@Override
public boolean apply(Card card) {
return card.hasKeyword(Keyword.BANDING) || card.hasAnyKeyword(bandsWithString);
}
});
if (!bandingCreatures.isEmpty()) {
List<String> evasionKeywords = Arrays.asList("Flying", "Horsemanship", "Shadow");
String[] validString = {"Legendary.Creature", "Creature.namedWolves of the Hunt", "Dinosaur"};
// TODO: Assign to band with the best attacker for now, but needs better logic.
CardCollection attackers = combat.getAttackers();
Card bestAttacker = ComputerUtilCard.getBestCreatureAI(attackers);
Card bestAttackerNoEvasion = ComputerUtilCard.getBestCreatureAI(CardLists.filter(attackers, new Predicate<Card>() {
@Override
public boolean apply(Card card) {
return !card.hasAnyKeyword(evasionKeywords);
}
}));
for (Card c : bandingCreatures) {
// TODO: check for legality in Bands with Other X
if (!c.hasAnyKeyword(evasionKeywords) && bestAttacker.hasAnyKeyword(evasionKeywords)) {
if (bestAttackerNoEvasion != null) {
combat.addAttacker(c, combat.getDefenderByAttacker(bestAttackerNoEvasion), combat.getBandOfAttacker(bestAttackerNoEvasion));
}
} else {
combat.addAttacker(c, combat.getDefenderByAttacker(bestAttacker), combat.getBandOfAttacker(bestAttacker));
}
}
}
}
// if invalid: just try an attack declaration that we know to be legal // if invalid: just try an attack declaration that we know to be legal
if (!CombatUtil.validateAttackers(combat)) { if (!CombatUtil.validateAttackers(combat)) {
combat.clearAttackers(); combat.clearAttackers();

View File

@@ -3,5 +3,4 @@ ManaCost:W
Types:Enchantment Types:Enchantment
S:Mode$ Continuous | Affected$ You | AddKeyword$ You assign combat damage of each creature attacking you. | Description$ Rather than the attacking player, you assign the combat damage of each creature attacking you. You can divide that creature's combat damage as you choose among any of the creatures blocking it. S:Mode$ Continuous | Affected$ You | AddKeyword$ You assign combat damage of each creature attacking you. | Description$ Rather than the attacking player, you assign the combat damage of each creature attacking you. You can divide that creature's combat damage as you choose among any of the creatures blocking it.
SVar:NonStackingEffect:True SVar:NonStackingEffect:True
AI:RemoveDeck:All
Oracle:Rather than the attacking player, you assign the combat damage of each creature attacking you. You can divide that creature's combat damage as you choose among any of the creatures blocking it. Oracle:Rather than the attacking player, you assign the combat damage of each creature attacking you. You can divide that creature's combat damage as you choose among any of the creatures blocking it.