- Added Avenging Arrow, Lotleth Troll, and Permafrost Trap.

This commit is contained in:
jeffwadsworth 2012-10-03 14:05:07 -05:00
parent 665ea374ed
commit 8148c59aee
4 changed files with 492 additions and 0 deletions

View file

@ -0,0 +1,115 @@
/*
* 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.sets.returntoravnica;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
import mage.watchers.common.SourceDidDamageWatcher;
/**
*
* @author jeffwadsworth
*/
public class AvengingArrow extends CardImpl<AvengingArrow> {
public AvengingArrow(UUID ownerId) {
super(ownerId, 4, "Avenging Arrow", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{2}{W}");
this.expansionSetCode = "RTR";
this.color.setWhite(true);
// Destroy target creature that dealt damage this turn.
this.getSpellAbility().addEffect(new DestroyTargetEffect());
this.getSpellAbility().addTarget(new AvengingArrowTarget());
this.addWatcher(new SourceDidDamageWatcher());
}
public AvengingArrow(final AvengingArrow card) {
super(card);
}
@Override
public AvengingArrow copy() {
return new AvengingArrow(this);
}
}
class AvengingArrowTarget<T extends TargetCreaturePermanent<T>> extends TargetPermanent<TargetCreaturePermanent<T>> {
public AvengingArrowTarget() {
super(1, 1, new FilterCreaturePermanent(), false);
targetName = "creature that dealt damage this turn";
}
public AvengingArrowTarget(final AvengingArrowTarget target) {
super(target);
}
@Override
public boolean canTarget(UUID id, Ability source, Game game) {
SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher");
if (watcher != null) {
if (watcher.damageSources.contains(id)) {
return super.canTarget(id, source, game);
}
}
return false;
}
@Override
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> availablePossibleTargets = super.possibleTargets(sourceId, sourceControllerId, game);
Set<UUID> possibleTargets = new HashSet<UUID>();
SourceDidDamageWatcher watcher = (SourceDidDamageWatcher) game.getState().getWatchers().get("SourceDidDamageWatcher");
if (watcher != null) {
for (UUID targetId : availablePossibleTargets) {
Permanent permanent = game.getPermanent(targetId);
if (permanent != null && watcher.damageSources.contains(targetId)) {
possibleTargets.add(targetId);
}
}
}
return possibleTargets;
}
@Override
public AvengingArrowTarget copy() {
return new AvengingArrowTarget(this);
}
}

View file

@ -0,0 +1,83 @@
/*
* 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.sets.returntoravnica;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.DiscardTargetCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.RegenerateSourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.filter.common.FilterCreatureCard;
import mage.target.common.TargetCardInHand;
/**
*
* @author jeffwadsworth
*/
public class LotlethTroll extends CardImpl<LotlethTroll> {
final static private FilterCreatureCard filter = new FilterCreatureCard("creature card in your hand");
public LotlethTroll(UUID ownerId) {
super(ownerId, 177, "Lotleth Troll", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{B}{G}");
this.expansionSetCode = "RTR";
this.subtype.add("Zombie");
this.subtype.add("Troll");
this.color.setGreen(true);
this.color.setBlack(true);
this.power = new MageInt(2);
this.toughness = new MageInt(1);
// Trample
this.addAbility(TrampleAbility.getInstance());
// Discard a creature card: Put a +1/+1 counter on Lotleth Troll.
this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.P1P1.createInstance()), new DiscardTargetCost(new TargetCardInHand(filter))));
// {B}: Regenerate Lotleth Troll.
this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new RegenerateSourceEffect(), new ManaCostsImpl("{B}")));
}
public LotlethTroll(final LotlethTroll card) {
super(card);
}
@Override
public LotlethTroll copy() {
return new LotlethTroll(this);
}
}

View file

@ -0,0 +1,216 @@
/*
* 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.sets.worldwake;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.costs.AlternativeCostImpl;
import mage.abilities.costs.mana.ColoredManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
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.target.common.TargetCreaturePermanent;
import mage.watchers.WatcherImpl;
/**
*
* @author jeffwadsworth
*/
public class PermafrostTrap extends CardImpl<PermafrostTrap> {
public PermafrostTrap(UUID ownerId) {
super(ownerId, 34, "Permafrost Trap", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{2}{U}{U}");
this.expansionSetCode = "WWK";
this.subtype.add("Trap");
this.color.setBlue(true);
// If an opponent had a green creature enter the battlefield under his or her control this turn, you may pay {U} rather than pay Permafrost Trap's mana cost.
this.getSpellAbility().addAlternativeCost(new PermafrostTrapAlternativeCost());
// Tap up to two target creatures. Those creatures don't untap during their controller's next untap step.
TargetCreaturePermanent target = new TargetCreaturePermanent(0, 2);
this.getSpellAbility().addTarget(target);
this.getSpellAbility().addEffect(new PermafrostTrapEffect());
this.addWatcher(new PermafrostTrapWatcher());
}
public PermafrostTrap(final PermafrostTrap card) {
super(card);
}
@Override
public PermafrostTrap copy() {
return new PermafrostTrap(this);
}
}
class PermafrostTrapWatcher extends WatcherImpl<PermafrostTrapWatcher> {
public PermafrostTrapWatcher() {
super("PermafrostTrapWatcher", Constants.WatcherScope.GAME);
}
public PermafrostTrapWatcher(final PermafrostTrapWatcher watcher) {
super(watcher);
}
@Override
public PermafrostTrapWatcher copy() {
return new PermafrostTrapWatcher(this);
}
@Override
public void watch(GameEvent event, Game game) {
if (condition == true) { // no need to check - condition has already occured
return;
}
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && ((ZoneChangeEvent) event).getToZone() == Constants.Zone.BATTLEFIELD) {
Permanent perm = game.getPermanent(event.getTargetId());
if (perm.getCardType().contains(CardType.CREATURE) && perm.getColor().contains(ObjectColor.GREEN) && !perm.getControllerId().equals(controllerId)) {
condition = true;
}
}
}
@Override
public void reset() {
super.reset();
condition = false;
}
}
class PermafrostTrapAlternativeCost extends AlternativeCostImpl<PermafrostTrapAlternativeCost> {
public PermafrostTrapAlternativeCost() {
super("you may pay {U} rather than pay Permafrost Trap's mana cost");
this.add(new ColoredManaCost(Constants.ColoredManaSymbol.U));
}
public PermafrostTrapAlternativeCost(final PermafrostTrapAlternativeCost cost) {
super(cost);
}
@Override
public PermafrostTrapAlternativeCost copy() {
return new PermafrostTrapAlternativeCost(this);
}
@Override
public boolean isAvailable(Game game, Ability source) {
PermafrostTrapWatcher watcher = (PermafrostTrapWatcher) game.getState().getWatchers().get("PermafrostTrapWatcher");
if (watcher != null && watcher.conditionMet()) {
return true;
}
return false;
}
@Override
public String getText() {
return "If an opponent had a green creature enter the battlefield under his or her control this turn, you may pay {U} rather than pay Permafrost Trap's mana cost.";
}
}
class PermafrostTrapEffect extends OneShotEffect<PermafrostTrapEffect> {
public PermafrostTrapEffect() {
super(Constants.Outcome.Detriment);
staticText = "Tap up to two target creatures. Those creatures don't untap during their controller's next untap step";
}
public PermafrostTrapEffect(final PermafrostTrapEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
for (UUID target : this.targetPointer.getTargets(game, source)) {
Permanent creature = game.getPermanent(target);
if (creature != null) {
creature.tap(game);
game.addEffect(new PermafrostEffect2(creature.getId()), source);
}
}
return false;
}
@Override
public PermafrostTrapEffect copy() {
return new PermafrostTrapEffect(this);
}
}
class PermafrostEffect2 extends ReplacementEffectImpl<PermafrostEffect2> {
protected UUID creatureId;
public PermafrostEffect2(UUID creatureId) {
super(Constants.Duration.OneUse, Constants.Outcome.Detriment);
this.creatureId = creatureId;
}
public PermafrostEffect2(final PermafrostEffect2 effect) {
super(effect);
creatureId = effect.creatureId;
}
@Override
public PermafrostEffect2 copy() {
return new PermafrostEffect2(this);
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
used = true;
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getTurn().getStepType() == Constants.PhaseStep.UNTAP
&& event.getType() == GameEvent.EventType.UNTAP
&& event.getTargetId().equals(creatureId)) {
return true;
}
return false;
}
}

View file

@ -0,0 +1,78 @@
/*
* Copyright 2011 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.watchers.common;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.Constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.watchers.WatcherImpl;
/**
* Watcher stores which sources did damage to anything.
*
* @author jeffwadsworth
*/
public class SourceDidDamageWatcher extends WatcherImpl<SourceDidDamageWatcher> {
public List<UUID> damageSources = new ArrayList<UUID>();
public SourceDidDamageWatcher() {
super("SourceDidDamageWatcher", WatcherScope.GAME);
}
public SourceDidDamageWatcher(final SourceDidDamageWatcher watcher) {
super(watcher);
this.damageSources = watcher.damageSources;
}
@Override
public SourceDidDamageWatcher copy() {
return new SourceDidDamageWatcher(this);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == EventType.DAMAGED_CREATURE
|| event.getType() == EventType.DAMAGED_PLANESWALKER
|| event.getType() == EventType.DAMAGED_PLAYER) {
if (!damageSources.contains(event.getSourceId())) {
damageSources.add(event.getSourceId());
}
}
}
@Override
public void reset() {
super.reset();
damageSources.clear();
}
}