Fixed handling of Chisei, Heart of Oceans. Some more minor fixes/changes.

This commit is contained in:
LevelX2 2012-11-17 20:24:25 +01:00
parent 8684cf2962
commit f763985ce9
5 changed files with 151 additions and 52 deletions

View file

@ -28,17 +28,15 @@
package mage.sets.avacynrestored;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.common.ZoneChangeTriggeredAbility;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.CreatureEntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.target.common.TargetCreatureOrPlayer;
/**
@ -47,6 +45,12 @@ import mage.target.common.TargetCreatureOrPlayer;
*/
public class VigilanteJustice extends CardImpl<VigilanteJustice> {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Human");
static {
filter.add(new SubtypePredicate("Human"));
}
public VigilanteJustice(UUID ownerId) {
super(ownerId, 165, "Vigilante Justice", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}");
this.expansionSetCode = "AVR";
@ -54,7 +58,9 @@ public class VigilanteJustice extends CardImpl<VigilanteJustice> {
this.color.setRed(true);
// Whenever a Human enters the battlefield under your control, Vigilante Justice deals 1 damage to target creature or player.
this.addAbility(new VigilanteJusticeTriggeredAbility());
Ability ability = new CreatureEntersBattlefieldTriggeredAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), filter, false, false);
ability.addTarget(new TargetCreatureOrPlayer());
this.addAbility(ability);
}
public VigilanteJustice(final VigilanteJustice card) {
@ -66,36 +72,3 @@ public class VigilanteJustice extends CardImpl<VigilanteJustice> {
return new VigilanteJustice(this);
}
}
class VigilanteJusticeTriggeredAbility extends ZoneChangeTriggeredAbility<VigilanteJusticeTriggeredAbility> {
public VigilanteJusticeTriggeredAbility() {
super(Constants.Zone.BATTLEFIELD, new DamageTargetEffect(1), "Whenever a Human enters the battlefield under your control, ", false);
this.addTarget(new TargetCreatureOrPlayer());
}
public VigilanteJusticeTriggeredAbility(VigilanteJusticeTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getToZone() == Constants.Zone.BATTLEFIELD) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.getSubtype().contains("Human") && permanent.getControllerId().equals(this.getControllerId())) {
return true;
}
}
}
return false;
}
@Override
public VigilanteJusticeTriggeredAbility copy() {
return new VigilanteJusticeTriggeredAbility(this);
}
}

View file

@ -32,17 +32,17 @@ import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.TargetController;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.costs.common.RemoveCounterTargetCost;
import mage.abilities.costs.common.RemoveCounterCost;
import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.SoulshiftAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterPermanentOrPlayerWithCounter;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.target.common.TargetPermanentOrPlayerWithCounter;
import mage.filter.predicate.permanent.CounterAnyPredicate;
import mage.target.TargetPermanent;
/**
*
@ -50,10 +50,11 @@ import mage.target.common.TargetPermanentOrPlayerWithCounter;
*/
public class ChiseiHeartOfOceans extends CardImpl<ChiseiHeartOfOceans> {
private final static FilterPermanentOrPlayerWithCounter filter = new FilterPermanentOrPlayerWithCounter("remove a counter from a permanent you control");
private final static FilterPermanent filter = new FilterControlledPermanent("remove a counter from a permanent you control");
static {
filter.add(new ControllerPredicate(Constants.TargetController.YOU));
filter.add(new CounterAnyPredicate());
}
public ChiseiHeartOfOceans(UUID ownerId) {
@ -70,10 +71,9 @@ public class ChiseiHeartOfOceans extends CardImpl<ChiseiHeartOfOceans> {
this.addAbility(FlyingAbility.getInstance());
// At the beginning of your upkeep, sacrifice Chisei, Heart of Oceans unless you remove a counter from a permanent you control.
TargetPermanentOrPlayerWithCounter target = new TargetPermanentOrPlayerWithCounter(1);
target.setFilter(filter);
TargetPermanent target = new TargetPermanent(1,1,filter,true);
target.setTargetName("a permanent you control");
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceUnlessPaysEffect(new RemoveCounterTargetCost(target)),TargetController.YOU, false));
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SacrificeSourceUnlessPaysEffect(new RemoveCounterCost(target)),TargetController.YOU, false));
}

View file

@ -41,6 +41,7 @@ import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
import mage.cards.CardImpl;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ColorPredicate;
/**
@ -49,7 +50,7 @@ import mage.filter.predicate.mageobject.ColorPredicate;
*/
public class ResplendentMentor extends CardImpl<ResplendentMentor> {
private static final FilterPermanent filter = new FilterPermanent("White creatures");
private static final FilterPermanent filter = new FilterCreaturePermanent("White creatures");
static {
filter.add(new ColorPredicate(ObjectColor.WHITE));

View file

@ -28,7 +28,6 @@
package mage.sets.tenth;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
@ -53,11 +52,15 @@ public class RobeOfMirrors extends CardImpl<RobeOfMirrors> {
this.expansionSetCode = "10E";
this.subtype.add("Aura");
this.color.setBlue(true);
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Constants.Outcome.AddAbility));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// Enchanted creature has shroud.
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityAttachedEffect(ShroudAbility.getInstance(), Constants.AttachmentType.AURA)));
}

View file

@ -0,0 +1,122 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.costs.common;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.costs.CostImpl;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.counters.Counter;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
/**
*
* @author LevelX
*/
public class RemoveCounterCost extends CostImpl<RemoveCounterCost> {
private TargetPermanent target;
private int amount;
private String name;
public RemoveCounterCost(TargetPermanent target) {
this.target = target;
this.text = "Remove a counter from " + target.getTargetName();
}
public RemoveCounterCost(final RemoveCounterCost cost) {
super(cost);
this.target = cost.target.copy();
this.amount = cost.amount;
this.name = cost.name;
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
paid = false;
Player controller = game.getPlayer(controllerId);
if (target.choose(Outcome.UnboostCreature, controllerId, sourceId, game)) {
for (UUID targetId: (List<UUID>)target.getTargets()) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null) {
if (permanent.getCounters().size() > 0) {
String counterName = null;
if (permanent.getCounters().size() > 1) {
Choice choice = new ChoiceImpl(true);
Set<String> choices = new HashSet<String>();
for (Counter counter : permanent.getCounters().values()) {
if (permanent.getCounters().getCount(counter.getName()) > 0) {
choices.add(counter.getName());
}
}
choice.setChoices(choices);
choice.setMessage("Choose a counter to remove from " + permanent.getName());
controller.choose(Outcome.UnboostCreature, choice, game);
counterName = choice.getChoice();
} else {
for (Counter counter : permanent.getCounters().values()) {
if (counter.getCount() > 0) {
counterName = counter.getName();
}
}
}
if (counterName != null) {
permanent.removeCounters(counterName, 1, game);
if (permanent.getCounters().getCount(counterName) == 0 ){
permanent.getCounters().removeCounter(counterName);
}
this.paid = true;
game.informPlayers(controller.getName() + " removes a counter from " + permanent.getName());
}
}
}
}
}
target.clearChosen();
return paid;
}
@Override
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
return target.canChoose(controllerId, game);
}
@Override
public RemoveCounterCost copy() {
return new RemoveCounterCost(this);
}
}