use of mage.players.Player in project mage by magefree.
the class HatefulEidolonTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
int auraCount = 0;
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (!zEvent.isDiesEvent()) {
return false;
}
Permanent deadCreature = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (deadCreature.getAttachments().isEmpty()) {
return false;
}
for (UUID auraId : deadCreature.getAttachments()) {
Permanent attachment = game.getPermanentOrLKIBattlefield(auraId);
if (attachment.getControllerId().equals(controllerId) && attachment.isEnchantment(game)) {
// Shadowspear or any other equipment does not count
auraCount += 1;
}
}
if (auraCount == 0) {
// just equipment not aura's
return false;
}
Player controller = game.getPlayer(controllerId);
if (controller != null && controller.canRespond()) {
this.getEffects().clear();
DrawCardTargetEffect drawCard = new DrawCardTargetEffect(auraCount);
drawCard.setTargetPointer(new FixedTarget(controllerId));
this.addEffect(drawCard);
return true;
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class HaukensInsightWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card card = controller.getLibrary().getFromTop(game);
if (card != null) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
MageObject sourceObject = source.getSourceObject(game);
String exileName = sourceObject == null ? null : sourceObject.getIdName();
controller.moveCardsToExile(card, source, game, true, exileId, exileName);
if (game.getState().getZone(card.getId()) == Zone.EXILED) {
card.setFaceDown(true, game);
HaukensInsightLookEffect effect = new HaukensInsightLookEffect(controller.getId());
effect.setTargetPointer(new FixedTarget(card, game));
game.addEffect(effect, source);
return true;
}
}
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class HaukensInsightWatcher method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (affectedControllerId.equals(source.getControllerId()) && game.isActivePlayer(source.getControllerId())) {
Player controller = game.getPlayer(source.getControllerId());
HaukensInsightWatcher watcher = game.getState().getWatcher(HaukensInsightWatcher.class);
Permanent sourceObject = game.getPermanent(source.getSourceId());
if (controller != null && watcher != null && sourceObject != null && !watcher.isAbilityUsed(new MageObjectReference(sourceObject, game))) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()));
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null && exileZone.contains(CardUtil.getMainCardId(game, objectId))) {
allowCardToPlayWithoutMana(objectId, source, affectedControllerId, game);
return true;
}
}
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class HarvestSeasonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int tappedCreatures = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
if (tappedCreatures > 0) {
TargetCardInLibrary target = new TargetCardInLibrary(0, tappedCreatures, StaticFilters.FILTER_CARD_BASIC_LAND);
if (controller.searchLibrary(target, source, game)) {
controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}
controller.shuffleLibrary(source, game);
return true;
}
return false;
}
use of mage.players.Player in project mage by magefree.
the class HeartPiercerManticoreSacrificeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Target target = new TargetControlledCreaturePermanent(1, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true);
if (!controller.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
Permanent toSacrifice = game.getPermanent(target.getFirstTarget());
if (toSacrifice == null) {
return false;
}
int power = toSacrifice.getPower().getValue();
if (!toSacrifice.sacrifice(source, game)) {
return false;
}
ReflexiveTriggeredAbility trigger = new ReflexiveTriggeredAbility(new DamageTargetEffect(power), false, "{this} deals damage equal to that creature's power to any target.");
trigger.addTarget(new TargetAnyTarget());
game.fireReflexiveTriggeredAbility(trigger, source);
return true;
}
Aggregations