mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Fix treating Battle as PW
This commit is contained in:
@@ -722,6 +722,11 @@ public class AiAttackController {
|
||||
return pwNearUlti != null ? pwNearUlti : ComputerUtilCard.getBestPlaneswalkerAI(pwDefending);
|
||||
}
|
||||
|
||||
List<Card> battleDefending = c.getDefendingBattles();
|
||||
if (!battleDefending.isEmpty()) {
|
||||
// TODO filter for team ones
|
||||
}
|
||||
|
||||
return prefDefender;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.ai.AiAttackController;
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerCollection;
|
||||
import forge.game.player.PlayerPredicates;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
@@ -31,7 +35,10 @@ public class ChoosePlayerAi extends SpellAbilityAi {
|
||||
@Override
|
||||
public Player chooseSinglePlayer(Player ai, SpellAbility sa, Iterable<Player> choices, Map<String, Object> params) {
|
||||
Player chosen = null;
|
||||
if ("Curse".equals(sa.getParam("AILogic"))) {
|
||||
if (sa.hasParam("Protect")) {
|
||||
chosen = new PlayerCollection(choices).min(PlayerPredicates.compareByLife());
|
||||
}
|
||||
else if ("Curse".equals(sa.getParam("AILogic"))) {
|
||||
for (Player pc : choices) {
|
||||
if (pc.isOpponentOf(ai)) {
|
||||
chosen = pc;
|
||||
|
||||
@@ -3160,7 +3160,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
|
||||
|
||||
// no Ability for this type yet, make a new one
|
||||
if (sa == null) {
|
||||
sa = CardFactoryUtil.buildBasicLandAbility(state, c);
|
||||
sa = CardFactory.buildBasicLandAbility(state, c);
|
||||
basicLandAbilities[i] = sa;
|
||||
}
|
||||
|
||||
|
||||
@@ -380,6 +380,15 @@ public class CardFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public static SpellAbility buildBasicLandAbility(final CardState state, byte color) {
|
||||
String strcolor = MagicColor.toShortString(color);
|
||||
String abString = "AB$ Mana | Cost$ T | Produced$ " + strcolor +
|
||||
" | Secondary$ True | SpellDescription$ Add {" + strcolor + "}.";
|
||||
SpellAbility sa = AbilityFactory.getAbility(abString, state);
|
||||
sa.setIntrinsic(true); // always intrisic
|
||||
return sa;
|
||||
}
|
||||
|
||||
private static Card readCard(final CardRules rules, final IPaperCard paperCard, int cardId, Game game) {
|
||||
final Card card = new Card(cardId, paperCard, game);
|
||||
|
||||
|
||||
@@ -89,15 +89,6 @@ import io.sentry.Sentry;
|
||||
*/
|
||||
public class CardFactoryUtil {
|
||||
|
||||
public static SpellAbility buildBasicLandAbility(final CardState state, byte color) {
|
||||
String strcolor = MagicColor.toShortString(color);
|
||||
String abString = "AB$ Mana | Cost$ T | Produced$ " + strcolor +
|
||||
" | Secondary$ True | SpellDescription$ Add {" + strcolor + "}.";
|
||||
SpellAbility sa = AbilityFactory.getAbility(abString, state);
|
||||
sa.setIntrinsic(true); // always intrisic
|
||||
return sa;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* abilityMorphDown.
|
||||
@@ -3932,7 +3923,7 @@ public class CardFactoryUtil {
|
||||
StringBuilder chooseSB = new StringBuilder();
|
||||
chooseSB.append("Event$ Moved | ValidCard$ Card.Self | Destination$ Battlefield | ReplacementResult$ Updated");
|
||||
chooseSB.append(" | Description$ (As a Siege enters the battlefield, choose an opponent to protect it. You and others can attack it. When it's defeated, exile it, then cast it transformed.)");
|
||||
String chooseProtector = "DB$ ChoosePlayer | Defined$ You | Choices$ Opponent | Protect$ True | ChoiceTitle$ Choose an opponent to protect this battle | AILogic$ Curse";
|
||||
String chooseProtector = "DB$ ChoosePlayer | Defined$ You | Choices$ Opponent | Protect$ True | ChoiceTitle$ Choose an opponent to protect this battle";
|
||||
|
||||
ReplacementEffect re = ReplacementHandler.parseReplacement(chooseSB.toString(), card, true);
|
||||
re.setOverridingAbility(AbilityFactory.getAbility(chooseProtector, card));
|
||||
|
||||
@@ -47,6 +47,8 @@ import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardCollectionView;
|
||||
import forge.game.card.CardDamageMap;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.keyword.Keyword;
|
||||
import forge.game.player.Player;
|
||||
@@ -231,7 +233,11 @@ public class Combat {
|
||||
}
|
||||
|
||||
public final CardCollection getDefendingPlaneswalkers() {
|
||||
return new CardCollection(Iterables.filter(attackableEntries, Card.class));
|
||||
return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.isType("Planeswalker"));
|
||||
}
|
||||
|
||||
public final CardCollection getDefendingBattles() {
|
||||
return CardLists.filter(Iterables.filter(attackableEntries, Card.class), CardPredicates.isType("Battle"));
|
||||
}
|
||||
|
||||
public final Map<Card, GameEntity> getAttackersAndDefenders() {
|
||||
|
||||
Reference in New Issue
Block a user