Merge pull request #1748 from Styxo/master

Added Sylvan Echoes, edited Woodland Guidance and Entangling Trap
This commit is contained in:
LevelX2 2016-04-06 21:03:22 +02:00
commit ca7a083364
4 changed files with 136 additions and 56 deletions

View file

@ -27,6 +27,8 @@
*/
package mage.sets.lorwyn;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
@ -41,6 +43,7 @@ import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.abilities.effects.Effect;
import mage.game.events.GameEvent.EventType;
import mage.target.common.TargetCreaturePermanent;
@ -60,13 +63,10 @@ public class EntanglingTrap extends CardImpl {
super(ownerId, 13, "Entangling Trap", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");
this.expansionSetCode = "LRW";
// Whenever you clash, tap target creature an opponent controls. If you won, that creature doesn't untap during its controller's next untap step.
Ability ability = new EntanglingClashTriggeredAbility();
Ability ability = new EntanglingTrapTriggeredAbility();
ability.addTarget(new TargetCreaturePermanent(filter));
ability.addEffect(new TapTargetEffect());
this.addAbility(ability);
}
public EntanglingTrap(final EntanglingTrap card) {
@ -79,19 +79,19 @@ public class EntanglingTrap extends CardImpl {
}
}
class EntanglingClashTriggeredAbility extends TriggeredAbilityImpl {
class EntanglingTrapTriggeredAbility extends TriggeredAbilityImpl {
public EntanglingClashTriggeredAbility() {
super(Zone.BATTLEFIELD, null, false);
public EntanglingTrapTriggeredAbility() {
super(Zone.BATTLEFIELD, new TapTargetEffect());
}
public EntanglingClashTriggeredAbility(final EntanglingClashTriggeredAbility ability) {
public EntanglingTrapTriggeredAbility(final EntanglingTrapTriggeredAbility ability) {
super(ability);
}
@Override
public EntanglingClashTriggeredAbility copy() {
return new EntanglingClashTriggeredAbility(this);
public EntanglingTrapTriggeredAbility copy() {
return new EntanglingTrapTriggeredAbility(this);
}
@Override
@ -101,13 +101,24 @@ class EntanglingClashTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(getControllerId())) {
if (event.getFlag()) { // clash won
addEffect(new DontUntapInControllersNextUntapStepTargetEffect("that creature"));
//remove effects from previous triggers
List<Effect> effects = getEffects();
List<Effect> effectsToRemove = new ArrayList<>();
for (Effect effect : effects) {
if (effect instanceof DontUntapInControllersNextUntapStepTargetEffect) {
effectsToRemove.add(effect);
}
return true;
}
return false;
for (Effect effect : effectsToRemove) {
effects.remove(effect);
}
if (event.getData().equals("controller") && event.getPlayerId().equals(getControllerId())
|| event.getData().equals("opponent") && event.getTargetId().equals(getControllerId())) {
addEffect(new DontUntapInControllersNextUntapStepTargetEffect());
}
return true;
}
@Override

View file

@ -0,0 +1,94 @@
/*
* 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.lorwyn;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
*
* @author Styxo
*/
public class SylvanEchoes extends CardImpl {
public SylvanEchoes(UUID ownerId) {
super(ownerId, 237, "Sylvan Echoes", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{G}");
this.expansionSetCode = "LRW";
// Whenever you clahs and you win, you may draw a card
this.addAbility(new SylvanEchoesTriggeredAbility());
}
public SylvanEchoes(final SylvanEchoes card) {
super(card);
}
@Override
public SylvanEchoes copy() {
return new SylvanEchoes(this);
}
}
class SylvanEchoesTriggeredAbility extends TriggeredAbilityImpl {
public SylvanEchoesTriggeredAbility() {
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), true);
}
public SylvanEchoesTriggeredAbility(final SylvanEchoesTriggeredAbility ability) {
super(ability);
}
@Override
public SylvanEchoesTriggeredAbility copy() {
return new SylvanEchoesTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CLASHED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getData().equals("controller") && event.getPlayerId().equals(getControllerId())
|| event.getData().equals("opponent") && event.getTargetId().equals(getControllerId());
}
@Override
public String getRule() {
return "Whenever you clash and you win, " + super.getRule();
}
}

View file

@ -28,20 +28,14 @@
package mage.sets.lorwyn;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ClashEffect;
import mage.abilities.effects.common.DoIfClashWonEffect;
import mage.abilities.effects.common.ExileSpellEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
import mage.abilities.effects.common.UntapAllLandsControllerEffect;
import mage.constants.Outcome;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInYourGraveyard;
/**
@ -59,10 +53,10 @@ public class WoodlandGuidance extends CardImpl {
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard());
// Clash with an opponent. If you win, untap all Forest you control
this.getSpellAbility().addEffect(new WoodlandGuidanceEffect());
this.getSpellAbility().addEffect(new DoIfClashWonEffect(new UntapAllLandsControllerEffect(new FilterLandPermanent("Forest", "Forests"))));
// Remove WoodlandGuidance from the game
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
}
public WoodlandGuidance(final WoodlandGuidance card) {
@ -74,33 +68,3 @@ public class WoodlandGuidance extends CardImpl {
return new WoodlandGuidance(this);
}
}
class WoodlandGuidanceEffect extends OneShotEffect {
public WoodlandGuidanceEffect() {
super(Outcome.ReturnToHand);
this.staticText = "Clash with an opponent. If you win, untap all Forest you control";
}
public WoodlandGuidanceEffect(final WoodlandGuidanceEffect effect) {
super(effect);
}
@Override
public WoodlandGuidanceEffect copy() {
return new WoodlandGuidanceEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (ClashEffect.getInstance().apply(game, source)) {
Effect effect = new UntapAllLandsControllerEffect(new FilterLandPermanent("Forest", "Forests"));
effect.apply(game, source);
}
return true;
}
return false;
}
}

View file

@ -181,7 +181,18 @@ public class ClashEffect extends OneShotEffect implements MageSingleton {
if (cardOpponent != null) {
opponent.moveCardToLibraryWithInfo(cardOpponent, source.getSourceId(), game, Zone.LIBRARY, topOpponent, true);
}
game.fireEvent(new GameEvent(EventType.CLASHED, opponent.getId(), source.getSourceId(), controller.getId(), 0, cmcController > cmcOpponent));
// fire CLASHED event with info about who won
String winner = "draw";
if (cmcController > cmcOpponent) {
winner = "controller";
}
if (cmcOpponent > cmcController) {
winner = "opponent";
}
GameEvent gameEvent = new GameEvent(EventType.CLASHED, opponent.getId(), source.getSourceId(), controller.getId());
gameEvent.setData(winner);
game.fireEvent(gameEvent);
// set opponent to DoIfClashWonEffect
for (Effect effect : source.getEffects()) {
if (effect instanceof DoIfClashWonEffect) {