use of mage.players.Player in project mage by magefree.
the class BontuTheGlorifiedRestrictionEffect method applies.
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (permanent.getId().equals(source.getSourceId())) {
Player controller = game.getPlayer(source.getControllerId());
CreaturesDiedWatcher watcher = game.getState().getWatcher(CreaturesDiedWatcher.class);
if (controller != null && watcher != null) {
return (watcher.getAmountOfCreaturesDiedThisTurnByController(controller.getId()) == 0);
}
return true;
}
// do not apply to other creatures.
return false;
}
use of mage.players.Player in project mage by magefree.
the class BoneMaskEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!this.used && super.applies(event, source, game)) {
if (event.getTargetId().equals(source.getControllerId()) && event.getSourceId().equals(source.getFirstTarget())) {
PreventionEffectData preventionData = preventDamageAction(event, source, game);
this.used = true;
this.discard();
if (preventionData.getPreventedDamage() > 0) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Set<Card> cardsToMoveToExileFromTopOfLibrary = controller.getLibrary().getTopCards(game, preventionData.getPreventedDamage());
controller.moveCards(cardsToMoveToExileFromTopOfLibrary, Zone.EXILED, source, game);
}
}
}
return true;
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class BondOfRevivalEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getFirstTarget());
if (player == null || card == null) {
return false;
}
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.UntilYourNextTurn);
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1));
if (player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
game.addEffect(effect, source);
}
return true;
}
use of mage.players.Player in project mage by magefree.
the class BondersOrnamentEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
if (game.getBattlefield().getAllActivePermanents(playerId).stream().map(MageObject::getName).noneMatch("Bonder's Ornament"::equals)) {
continue;
}
player.drawCards(1, source, game);
}
return true;
}
use of mage.players.Player in project mage by magefree.
the class CheckForTrapsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(targetPointer.getFirst(game, source));
if (controller == null || opponent == null) {
return false;
}
opponent.revealCards(source, opponent.getHand(), game);
TargetCard target = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD_NON_LAND);
target.setNotTarget(true);
boolean opponentLoseLife = false;
if (controller.choose(outcome, opponent.getHand(), target, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
controller.moveCards(card, Zone.EXILED, source, game);
if (card.isInstant(game) || card.hasAbility(FlashAbility.getInstance(), game)) {
opponentLoseLife = true;
}
}
}
if (opponentLoseLife) {
opponent.loseLife(1, game, source, false);
} else {
controller.loseLife(1, game, source, false);
}
return true;
}
Aggregations