use of mage.game.Game in project mage by magefree.
the class JourneyForTheElixirGraveyardTarget method possibleTargets.
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> possibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
Cards alreadyTargeted = new CardsImpl(this.getTargets());
alreadyTargeted.addAll(cards);
boolean hasBasic = alreadyTargeted.getCards(game).stream().filter(Objects::nonNull).filter(card1 -> card1.isLand(game)).anyMatch(MageObject::isBasic);
possibleTargets.removeIf(uuid -> {
Card card = game.getCard(uuid);
return card != null && hasBasic && card.isLand(game) && card.isBasic();
});
boolean hasYanggu = alreadyTargeted.getCards(game).stream().filter(Objects::nonNull).map(MageObject::getName).anyMatch(name::equals);
possibleTargets.removeIf(uuid -> {
Card card = game.getCard(uuid);
return card != null && hasYanggu && name.equals(card.getName());
});
return possibleTargets;
}
use of mage.game.Game in project mage by magefree.
the class PastInFlamesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
player.getGraveyard().stream().filter((cardId) -> (affectedObjectList.contains(new MageObjectReference(cardId, game)))).forEachOrdered((cardId) -> {
Card card = game.getCard(cardId);
if (card != null) {
FlashbackAbility ability = new FlashbackAbility(card, card.getManaCost());
ability.setSourceId(cardId);
ability.setControllerId(card.getOwnerId());
game.getState().addOtherAbility(card, ability);
}
});
return true;
}
use of mage.game.Game in project mage by magefree.
the class PrimalEmpathyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int highestPower = game.getBattlefield().getActivePermanents(source.getControllerId(), game).stream().filter(permanent1 -> permanent1.isCreature(game)).map(Permanent::getPower).mapToInt(MageInt::getValue).max().orElse(0);
boolean flag = game.getBattlefield().getAllActivePermanents(source.getControllerId()).stream().filter(permanent1 -> permanent1.isCreature(game)).map(Permanent::getPower).mapToInt(MageInt::getValue).anyMatch(i -> i >= highestPower);
if (flag) {
return player.drawCards(1, source, game) > 0;
}
Target target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
if (!player.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
Permanent permanent = game.getPermanent(target.getFirstTarget());
return permanent != null && permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
use of mage.game.Game in project mage by magefree.
the class SchemingSymmetryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
source.getTargets().get(0).getTargets().stream().map(playerId -> game.getPlayer(playerId)).filter(player -> player != null).forEach(player -> {
TargetCardInLibrary targetCard = new TargetCardInLibrary();
if (player.searchLibrary(targetCard, source, game)) {
Cards cards = new CardsImpl();
cards.add(targetCard.getFirstTarget());
player.shuffleLibrary(source, game);
player.putCardsOnTopOfLibrary(cards, game, source, false);
}
});
return true;
}
use of mage.game.Game in project mage by magefree.
the class ShowOfConfidenceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = (Spell) getValue("spellCast");
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
if (spell == null || watcher == null) {
return false;
}
int copies = watcher.getSpellsCastThisTurn(source.getControllerId()).stream().filter(Objects::nonNull).filter(spell1 -> spell1.isInstantOrSorcery(game)).filter(s -> !s.getSourceId().equals(source.getSourceId()) || s.getZoneChangeCounter(game) != source.getSourceObjectZoneChangeCounter()).mapToInt(x -> 1).sum();
if (copies > 0) {
spell.createCopyOnStack(game, source, source.getControllerId(), true, copies);
}
return true;
}
Aggregations