use of mage.game.Game in project mage by magefree.
the class UginTheIneffableLookAtFaceDownEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = ((ZoneChangeEvent) event);
if (zEvent.getToZone() == Zone.BATTLEFIELD || tokenRefs.stream().noneMatch(tokenRef -> tokenRef.refersTo(zEvent.getTarget(), game))) {
return false;
}
this.getEffects().clear();
Effect effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(cardRef));
this.addEffect(effect);
return true;
}
use of mage.game.Game in project mage by magefree.
the class TymaretChosenFromDeathEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl(source.getTargets().stream().map(Target::getTargets).flatMap(Collection::stream).collect(Collectors.toSet()));
player.moveCards(cards, Zone.EXILED, source, game);
int lifeGain = cards.getCards(game).stream().filter(card -> card.isCreature(game)).map(Card::getId).map(game.getState()::getZone).filter(Zone.EXILED::equals).mapToInt(x -> 1).sum();
player.gainLife(lifeGain, game, source);
return true;
}
use of mage.game.Game in project mage by magefree.
the class FloodOfTearsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
List<Permanent> nonlands = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_NON_LAND, source.getControllerId(), source.getSourceId(), game);
Cards cards = new CardsImpl();
if (!nonlands.isEmpty()) {
nonlands.forEach(cards::add);
boolean putIntoPlay = nonlands.stream().filter(permanent -> permanent.isControlledBy(player.getId())).filter(permanent -> !(permanent instanceof PermanentToken)).count() > 3;
player.moveCards(cards, Zone.HAND, source, game);
if (putIntoPlay) {
new PutCardFromHandOntoBattlefieldEffect().apply(game, source);
}
return true;
}
return false;
}
use of mage.game.Game in project mage by magefree.
the class GideonChampionOfJusticeToken method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
MageObjectReference mor = new MageObjectReference(source.getSourceObject(game), game);
Cards cards = new CardsImpl();
game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, source.getControllerId(), game).stream().filter(Objects::nonNull).filter(permanent -> !mor.refersTo(permanent, game)).forEach(cards::add);
return player.moveCards(cards, Zone.EXILED, source, game);
}
use of mage.game.Game in project mage by magefree.
the class IdolOfEnduranceWatcher method addPlayable.
static void addPlayable(Ability source, Game game) {
MageObjectReference mor = new MageObjectReference(source);
game.getState().getWatcher(IdolOfEnduranceWatcher.class).morMap.computeIfAbsent(mor, m -> new HashMap<>()).compute(source.getControllerId(), CardUtil::setOrIncrementValue);
}
Aggregations