use of mage.MageObject in project mage by magefree.
the class SageEyeAvengersEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && controller != null) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null && targetCreature.getPower().getValue() < sourceObject.getPower().getValue()) {
controller.moveCards(targetCreature, Zone.HAND, source, game);
}
return true;
}
return false;
}
use of mage.MageObject in project mage by magefree.
the class SenTripletsPlayFromOpponentsHandEffect method getInfoMessage.
@Override
public String getInfoMessage(Ability source, GameEvent event, Game game) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
MageObject mageObject = game.getObject(source.getSourceId());
if (targetPlayer != null && mageObject != null) {
return "This turn you can't cast spells or activate abilities" + " (" + mageObject.getLogName() + ')';
}
return null;
}
use of mage.MageObject in project mage by magefree.
the class SecretSalvageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
if (targetCard != null) {
controller.moveCards(targetCard, Zone.EXILED, source, game);
String nameToSearch = CardUtil.getCardNameForSameNameSearch(targetCard);
FilterCard nameFilter = new FilterCard();
nameFilter.add(new NamePredicate(nameToSearch));
TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, nameFilter);
if (controller.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
Cards cards = new CardsImpl();
for (UUID cardId : target.getTargets()) {
Card card = controller.getLibrary().remove(cardId, game);
if (card != null) {
cards.add(card);
}
}
controller.revealCards(sourceObject.getIdName(), cards, game);
controller.moveCards(cards, Zone.HAND, source, game);
}
controller.shuffleLibrary(source, game);
return true;
}
}
}
return false;
}
use of mage.MageObject in project mage by magefree.
the class SehtsTigerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
ChoiceColor choice = new ChoiceColor();
if (controller != null && mageObject != null && controller.choose(Outcome.Protect, choice, game)) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(choice.getColor()));
filter.setMessage(choice.getChoice());
Ability ability = new ProtectionAbility(filter);
game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
return true;
}
return false;
}
use of mage.MageObject in project mage by magefree.
the class SifterWurmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
controller.scry(3, source, game);
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
Cards cards = new CardsImpl();
cards.add(card);
controller.revealCards(sourceObject.getIdName(), cards, game);
controller.gainLife(card.getManaValue(), game, source);
}
return true;
}
return false;
}
Aggregations