- Added The Wretched.

This commit is contained in:
Jeff 2015-03-06 17:48:11 -06:00
parent 977645f88f
commit 57ba2861bc
5 changed files with 227 additions and 0 deletions

View file

@ -0,0 +1,156 @@
/*
* 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.fifthedition;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.condition.common.SourceOnBattlefieldControlUnchangedCondition;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.BlockedAttackerWatcher;
/**
*
* @author jeffwadsworth
*
5/1/2009 The ability grants you control of all creatures that are blocking it as the ability resolves. This will include any creatures that were put onto the battlefield blocking it.
5/1/2009 Any blocking creatures that regenerated during combat will have been removed from combat. Since such creatures are no longer in combat, they cannot be blocking The Wretched, which means you won't be able to gain control of them.
5/1/2009 If The Wretched itself regenerated during combat, then it will have been removed from combat. Since it is no longer in combat, there cannot be any creatures blocking it, which means you won't be able to gain control of any creatures.
10/1/2009 The Wretched's ability triggers only if it's still on the battlefield when the end of combat step begins (after the combat damage step). For example, if it's blocked by a 7/7 creature and is destroyed, its ability won't trigger at all.
10/1/2009 If The Wretched leaves the battlefield, you no longer control it, so the duration of its control-change effect ends.
10/1/2009 If you lose control of The Wretched before its ability resolves, you won't gain control of the creatures blocking it at all.
10/1/2009 Once the ability resolves, it doesn't care whether the permanents you gained control of remain creatures, only that they remain on the battlefield.
*/
public class TheWretched extends CardImpl {
public TheWretched(UUID ownerId) {
super(ownerId, 239, "The Wretched", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{3}{B}{B}");
this.expansionSetCode = "5ED";
this.subtype.add("Demon");
this.power = new MageInt(2);
this.toughness = new MageInt(5);
// At end of combat, gain control of all creatures blocking The Wretched for as long as you control The Wretched.
this.addAbility(new EndOfAnyCombatTriggeredAbility(), new BlockedAttackerWatcher());
}
public TheWretched(final TheWretched card) {
super(card);
}
@Override
public TheWretched copy() {
return new TheWretched(this);
}
}
class EndOfAnyCombatTriggeredAbility extends TriggeredAbilityImpl {
EndOfAnyCombatTriggeredAbility() {
super(Zone.BATTLEFIELD, new TheWretchedEffect(), false);
}
EndOfAnyCombatTriggeredAbility(final EndOfAnyCombatTriggeredAbility ability) {
super(ability);
}
@Override
public EndOfAnyCombatTriggeredAbility copy() {
return new EndOfAnyCombatTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return (event.getType() == GameEvent.EventType.END_COMBAT_STEP_PRE);
}
@Override
public String getRule() {
return "At the end of combat, gain control of all creatures blocking {this} for as long as you control {this}.";
}
}
class TheWretchedEffect extends OneShotEffect {
TheWretchedEffect() {
super(Outcome.Benefit);
}
TheWretchedEffect(final TheWretchedEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent theWretched = game.getPermanent(source.getSourceId());
if (theWretched == null) {
return false;
}
if (theWretched.isRemovedFromCombat()) {
return false;
}
if (!new SourceOnBattlefieldControlUnchangedCondition().apply(game, source)) {
return false;
}
BlockedAttackerWatcher watcher = (BlockedAttackerWatcher) game.getState().getWatchers().get("BlockedAttackerWatcher");
if (watcher != null) {
for (Permanent creature : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), game)) {
if (watcher.creatureHasBlockedAttacker(theWretched, creature)
&& !creature.isRemovedFromCombat()) {
ContinuousEffect effect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom, source.getControllerId()), new SourceOnBattlefieldControlUnchangedCondition(), "test");
effect.setTargetPointer(new FixedTarget(creature.getId()));
game.addEffect(effect, source);
}
}
return true;
}
return false;
}
@Override
public TheWretchedEffect copy() {
return new TheWretchedEffect(this);
}
}

View file

@ -0,0 +1,52 @@
/*
* 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.legends;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public class TheWretched extends mage.sets.fifthedition.TheWretched {
public TheWretched(UUID ownerId) {
super(ownerId);
this.cardNumber = 35;
this.expansionSetCode = "LEG";
}
public TheWretched(final TheWretched card) {
super(card);
}
@Override
public TheWretched copy() {
return new TheWretched(this);
}
}

View file

@ -50,6 +50,7 @@ import mage.util.trace.TraceUtil;
import java.io.Serializable; import java.io.Serializable;
import java.util.*; import java.util.*;
import mage.filter.common.FilterCreaturePermanent;
/** /**
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -881,6 +882,7 @@ public class Combat implements Serializable, Copyable<Combat> {
if (creature != null) { if (creature != null) {
creature.setAttacking(false); creature.setAttacking(false);
creature.setBlocking(0); creature.setBlocking(0);
creature.setRemovedFromCombat(true);
for (CombatGroup group : groups) { for (CombatGroup group : groups) {
result |= group.remove(creatureId); result |= group.remove(creatureId);
} }
@ -906,6 +908,10 @@ public class Combat implements Serializable, Copyable<Combat> {
} }
} }
} }
// reset the removeFromCombat flag on all creatures on the battlefield
for (Permanent creaturePermanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), game)) {
creaturePermanent.setRemovedFromCombat(false);
}
clear(); clear();
} }

View file

@ -154,6 +154,8 @@ public interface Permanent extends Card, Controllable {
int getMinBlockedBy(); int getMinBlockedBy();
void setMinBlockedBy(int minBlockedBy); void setMinBlockedBy(int minBlockedBy);
int getMaxBlockedBy(); int getMaxBlockedBy();
boolean isRemovedFromCombat();
void setRemovedFromCombat(boolean removedFromCombat);
/** /**
* Sets the maximum number of blockers the creature can be blocked by. * Sets the maximum number of blockers the creature can be blocked by.

View file

@ -99,6 +99,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
protected int minBlockedBy = 1; protected int minBlockedBy = 1;
// maximal number of creatures the creature can be blocked by 0 = no restriction // maximal number of creatures the creature can be blocked by 0 = no restriction
protected int maxBlockedBy = 0; protected int maxBlockedBy = 0;
protected boolean removedFromCombat;
protected boolean deathtouched; protected boolean deathtouched;
protected List<UUID> attachments = new ArrayList<>(); protected List<UUID> attachments = new ArrayList<>();
protected Map<String, List<UUID>> connectedCards = new HashMap<>(); protected Map<String, List<UUID>> connectedCards = new HashMap<>();
@ -507,6 +508,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
return maxBlockedBy; return maxBlockedBy;
} }
@Override
public boolean isRemovedFromCombat() {
return removedFromCombat;
}
@Override @Override
public UUID getControllerId() { public UUID getControllerId() {
return this.controllerId; return this.controllerId;
@ -1106,6 +1112,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
return true; return true;
} }
@Override
public void setRemovedFromCombat(boolean removedFromCombat) {
this.removedFromCombat = removedFromCombat;
}
@Override @Override
public boolean imprint(UUID imprintedCard, Game game) { public boolean imprint(UUID imprintedCard, Game game) {
if (connectedCards.containsKey("imprint")) { if (connectedCards.containsKey("imprint")) {