Codechanges and lots of fixes related to playing other player's cards from exile.

- Cards now keep track of who's allowed to cast them, fixing possible issues in multiplayer.
- Face-down cards can now be properly looked at when allowed to by a static ability.
- Improve support for casting a face-down exiled card in general.
- Add Shared Fate (including AI support).
This commit is contained in:
elcnesh
2014-12-03 08:49:49 +00:00
parent 4ae2687478
commit ea23bb33b2
28 changed files with 251 additions and 93 deletions

View File

@@ -34,6 +34,7 @@ import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import forge.card.CardStateName;
import forge.card.CardType;
import forge.card.MagicColor;
import forge.card.CardType.Supertype;
@@ -335,7 +336,7 @@ public class AiController {
sa.setActivatingPlayer(player);
//add alternative costs as additional spell abilities
newAbilities.add(sa);
newAbilities.addAll(GameActionUtil.getAlternativeCosts(sa));
newAbilities.addAll(GameActionUtil.getAlternativeCosts(sa, player));
}
final ArrayList<SpellAbility> result = new ArrayList<SpellAbility>();
@@ -352,6 +353,11 @@ public class AiController {
for (final SpellAbility sa : c.getSpellAbilities()) {
spellAbilities.add(sa);
}
if (c.isFaceDown() && c.isInZone(ZoneType.Exile) && c.mayPlay(player) != null) {
for (final SpellAbility sa : c.getState(CardStateName.Original).getSpellAbilities()) {
spellAbilities.add(sa);
}
}
}
return spellAbilities;
}
@@ -392,11 +398,15 @@ public class AiController {
});
final CardCollection landsNotInHand = new CardCollection(player.getCardsIn(ZoneType.Graveyard));
landsNotInHand.addAll(game.getCardsIn(ZoneType.Exile));
if (!player.getCardsIn(ZoneType.Library).isEmpty()) {
landsNotInHand.add(player.getCardsIn(ZoneType.Library).get(0));
}
for (final Card crd : landsNotInHand) {
if (crd.isLand() && crd.hasKeyword("May be played")) {
if (!(crd.isLand() || (crd.isFaceDown() && crd.getState(CardStateName.Original).getType().isLand()))) {
continue;
}
if (crd.hasKeyword("May be played") || crd.mayPlay(player) != null) {
landList.add(crd);
}
}