use of mage.target.TargetPlayer in project mage by magefree.
the class ScrabblingClawsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer == null) {
return false;
}
FilterCard filter = new FilterCard("card from your graveyard");
filter.add(new OwnerIdPredicate(targetPlayer.getId()));
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
if (!targetPlayer.chooseTarget(Outcome.Exile, target, source, game)) {
return false;
}
Card card = game.getCard(target.getFirstTarget());
return card != null && targetPlayer.moveCards(card, Zone.EXILED, source, game);
}
use of mage.target.TargetPlayer in project mage by magefree.
the class SludgeStriderEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
Player you = game.getPlayer(source.getControllerId());
if (targetPlayer != null) {
targetPlayer.loseLife(1, game, source, false);
}
if (you != null) {
you.gainLife(1, game, source);
}
return true;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class AegisOfHonorEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getControllerId())) {
// Checks to see the damage is to Aegis of Honor's controller
Spell spell = null;
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
if (stackObject == null) {
stackObject = (StackObject) game.getLastKnownInformation(event.getSourceId(), Zone.STACK);
}
if (stackObject instanceof Spell) {
spell = (Spell) stackObject;
}
// Checks if damage is from a sorcery or instants
if (spell != null && instantOrSorceryfilter.match(spell.getCard(), game)) {
TargetPlayer target = new TargetPlayer();
target.add(spell.getControllerId(), game);
redirectTarget = target;
return true;
}
}
return false;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class BitterFeudEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller != null && permanent != null) {
TargetPlayer target = new TargetPlayer(2, 2, true);
controller.chooseTarget(outcome, target, source, game);
Player player1 = game.getPlayer(target.getFirstTarget());
if (target.getTargets().size() > 1) {
Player player2 = game.getPlayer(target.getTargets().get(1));
if (player1 != null && player2 != null) {
game.getState().setValue(source.getSourceId() + "_player1", player1);
game.getState().setValue(source.getSourceId() + "_player2", player2);
game.informPlayers(permanent.getLogName() + ": " + controller.getLogName() + " has chosen " + player1.getLogName() + " and " + player2.getLogName());
permanent.addInfo("chosen players", "<font color = 'blue'>Chosen players: " + player1.getName() + ", " + player2.getName() + "</font>", game);
return true;
}
}
}
return false;
}
use of mage.target.TargetPlayer in project mage by magefree.
the class BitterOrdealEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && targetPlayer != null) {
TargetCardInLibrary target = new TargetCardInLibrary();
if (controller.searchLibrary(target, source, game, targetPlayer.getId())) {
Card card = targetPlayer.getLibrary().getCard(target.getFirstTarget(), game);
if (card != null) {
controller.moveCardToExileWithInfo(card, null, null, source, game, Zone.LIBRARY, true);
}
}
targetPlayer.shuffleLibrary(source, game);
return true;
}
return false;
}
Aggregations