/** * Checks that chosen card can produce mana of specific color. * * @param card * @param allowedColors * @return */ private static boolean cardCardProduceChosenColors(Card card, List<ColoredManaSymbol> allowedColors) { int score = 0; for (Mana mana : card.getMana()) { for (ColoredManaSymbol color : allowedColors) { score = score + mana.getColor(color); } } if (score > 1) { return true; } return false; }
@Override public boolean apply(Game game, Ability source) { if (source.getAbilityType() == AbilityType.SPELL) { return (source.getManaCostsToPay().getPayment().getColor(coloredManaSymbol) > 0); } ManaSpentToCastWatcher watcher = game.getState().getWatcher(ManaSpentToCastWatcher.class, source.getSourceId()); if (watcher != null) { Mana payment = watcher.getAndResetLastPayment(); if (payment != null) { return payment.getColor(coloredManaSymbol) > 0; } } return false; }
@Override public boolean applies(GameEvent event, Ability source, Game game) { manaUsed = (Mana) game.getState().getValue("ProtectiveSphere" + source.getSourceId().toString()); if (super.applies(event, source, game)) { if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(target.getFirstTarget())) { colorsOfChosenSource = game.getObject(target.getFirstTarget()).getColor(game).getColors(); if (colorsOfChosenSource.stream().anyMatch((c) -> (manaUsed.getColor(c.getOneColoredManaSymbol()) > 0))) { return true; } } } return false; } }
for (Mana mana : landCard.getMana()) { for (ColoredManaSymbol color : allowedColors) { int amount = mana.getColor(color); if (amount > 0) { Integer count = colorSource.get(color.toString());