forked from External/mage
[BRO] Implemented Gix, Yawgmoth Praetor (#9765)
* [BRO] Implemented Gix, Yawgmoth Praetor * Add missing TestPlayer, PlayerStub implementations
This commit is contained in:
parent
89687b305a
commit
92b6d7a531
8 changed files with 280 additions and 15 deletions
|
|
@ -4,10 +4,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import mage.ApprovingObject;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
|
|
@ -1235,7 +1232,8 @@ public final class CardUtil {
|
|||
void addCard(Card card, Ability source, Game game);
|
||||
}
|
||||
|
||||
private static List<Card> getCastableComponents(Card cardToCast, FilterCard filter, Ability source, UUID playerId, Game game, SpellCastTracker spellCastTracker) {
|
||||
private static List<Card> getCastableComponents(Card cardToCast, FilterCard filter, Ability source, Player player, Game game, SpellCastTracker spellCastTracker, boolean playLand) {
|
||||
UUID playerId = player.getId();
|
||||
List<Card> cards = new ArrayList<>();
|
||||
if (cardToCast instanceof CardWithHalves) {
|
||||
cards.add(((CardWithHalves) cardToCast).getLeftHalfCard());
|
||||
|
|
@ -1247,7 +1245,9 @@ public final class CardUtil {
|
|||
cards.add(cardToCast);
|
||||
}
|
||||
cards.removeIf(Objects::isNull);
|
||||
cards.removeIf(card -> card.isLand(game));
|
||||
if (!playLand || !player.canPlayLand() || !game.isActivePlayer(playerId)) {
|
||||
cards.removeIf(card -> card.isLand(game));
|
||||
}
|
||||
cards.removeIf(card -> !filter.match(card, playerId, source, game));
|
||||
if (spellCastTracker != null) {
|
||||
cards.removeIf(card -> !spellCastTracker.checkCard(card, game));
|
||||
|
|
@ -1266,9 +1266,13 @@ public final class CardUtil {
|
|||
}
|
||||
|
||||
public static boolean castSpellWithAttributesForFree(Player player, Ability source, Game game, Cards cards, FilterCard filter, SpellCastTracker spellCastTracker) {
|
||||
return castSpellWithAttributesForFree(player, source, game, cards, filter, spellCastTracker, false);
|
||||
}
|
||||
|
||||
public static boolean castSpellWithAttributesForFree(Player player, Ability source, Game game, Cards cards, FilterCard filter, SpellCastTracker spellCastTracker, boolean playLand) {
|
||||
Map<UUID, List<Card>> cardMap = new HashMap<>();
|
||||
for (Card card : cards.getCards(game)) {
|
||||
List<Card> castableComponents = getCastableComponents(card, filter, source, player.getId(), game, spellCastTracker);
|
||||
List<Card> castableComponents = getCastableComponents(card, filter, source, player, game, spellCastTracker, playLand);
|
||||
if (!castableComponents.isEmpty()) {
|
||||
cardMap.put(card.getId(), castableComponents);
|
||||
}
|
||||
|
|
@ -1303,10 +1307,22 @@ public final class CardUtil {
|
|||
return false;
|
||||
}
|
||||
partsToCast.forEach(card -> game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE));
|
||||
boolean result = player.cast(
|
||||
player.chooseAbilityForCast(cardToCast, game, true),
|
||||
game, true, new ApprovingObject(source, game)
|
||||
);
|
||||
ActivatedAbility chosenAbility;
|
||||
if (playLand) {
|
||||
chosenAbility = player.chooseLandOrSpellAbility(cardToCast, game, true);
|
||||
} else {
|
||||
chosenAbility = player.chooseAbilityForCast(cardToCast, game, true);
|
||||
}
|
||||
boolean result = false;
|
||||
if (chosenAbility instanceof SpellAbility) {
|
||||
result = player.cast(
|
||||
(SpellAbility) chosenAbility,
|
||||
game, true, new ApprovingObject(source, game)
|
||||
);
|
||||
} else if (playLand && chosenAbility instanceof PlayLandAbility) {
|
||||
Card land = game.getCard(chosenAbility.getSourceId());
|
||||
result = player.playLand(land, game, true);
|
||||
}
|
||||
partsToCast.forEach(card -> game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null));
|
||||
if (result && spellCastTracker != null) {
|
||||
spellCastTracker.addCard(cardToCast, source, game);
|
||||
|
|
@ -1317,11 +1333,11 @@ public final class CardUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static boolean checkForPlayable(Cards cards, FilterCard filter, Ability source, UUID playerId, Game game, SpellCastTracker spellCastTracker) {
|
||||
private static boolean checkForPlayable(Cards cards, FilterCard filter, Ability source, Player player, Game game, SpellCastTracker spellCastTracker, boolean playLand) {
|
||||
return cards
|
||||
.getCards(game)
|
||||
.stream()
|
||||
.anyMatch(card -> !getCastableComponents(card, filter, source, playerId, game, spellCastTracker).isEmpty());
|
||||
.anyMatch(card -> !getCastableComponents(card, filter, source, player, game, spellCastTracker, playLand).isEmpty());
|
||||
}
|
||||
|
||||
public static void castMultipleWithAttributeForFree(Player player, Ability source, Game game, Cards cards, FilterCard filter) {
|
||||
|
|
@ -1333,6 +1349,10 @@ public final class CardUtil {
|
|||
}
|
||||
|
||||
public static void castMultipleWithAttributeForFree(Player player, Ability source, Game game, Cards cards, FilterCard filter, int maxSpells, SpellCastTracker spellCastTracker) {
|
||||
castMultipleWithAttributeForFree(player, source, game, cards, filter, maxSpells, spellCastTracker, false);
|
||||
}
|
||||
|
||||
public static void castMultipleWithAttributeForFree(Player player, Ability source, Game game, Cards cards, FilterCard filter, int maxSpells, SpellCastTracker spellCastTracker, boolean playLand) {
|
||||
if (maxSpells == 1) {
|
||||
CardUtil.castSpellWithAttributesForFree(player, source, game, cards, filter);
|
||||
return;
|
||||
|
|
@ -1340,11 +1360,11 @@ public final class CardUtil {
|
|||
int spellsCast = 0;
|
||||
cards.removeZone(Zone.STACK, game);
|
||||
while (player.canRespond() && spellsCast < maxSpells && !cards.isEmpty()) {
|
||||
if (CardUtil.castSpellWithAttributesForFree(player, source, game, cards, filter, spellCastTracker)) {
|
||||
if (CardUtil.castSpellWithAttributesForFree(player, source, game, cards, filter, spellCastTracker, playLand)) {
|
||||
spellsCast++;
|
||||
cards.removeZone(Zone.STACK, game);
|
||||
} else if (!checkForPlayable(
|
||||
cards, filter, source, player.getId(), game, spellCastTracker
|
||||
cards, filter, source, player, game, spellCastTracker, playLand
|
||||
) || !player.chooseUse(
|
||||
Outcome.PlayForFree, "Continue casting spells?", source, game
|
||||
)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue