[CHK] Vassal's Duty, Reverse the Sands, Sift Through Sands.

This commit is contained in:
LevelX2 2013-10-26 10:03:34 +02:00
parent 06a2b6e2f7
commit 2219929867
4 changed files with 420 additions and 1 deletions

View file

@ -0,0 +1,123 @@
/*
* 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.championsofkamigawa;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class ReverseTheSands extends CardImpl<ReverseTheSands> {
public ReverseTheSands(UUID ownerId) {
super(ownerId, 41, "Reverse the Sands", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{6}{W}{W}");
this.expansionSetCode = "CHK";
this.color.setWhite(true);
// Redistribute any number of players' life totals.
this.getSpellAbility().addEffect(new ReverseTheSandsEffect());
}
public ReverseTheSands(final ReverseTheSands card) {
super(card);
}
@Override
public ReverseTheSands copy() {
return new ReverseTheSands(this);
}
}
class ReverseTheSandsEffect extends OneShotEffect<ReverseTheSandsEffect> {
public ReverseTheSandsEffect() {
super(Outcome.Benefit);
this.staticText = "Redistribute any number of players' life totals";
}
public ReverseTheSandsEffect(final ReverseTheSandsEffect effect) {
super(effect);
}
@Override
public ReverseTheSandsEffect copy() {
return new ReverseTheSandsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice lifeChoice = new ChoiceImpl(true);
Set<String> choices = new HashSet<String>();
for (UUID playerId : controller.getInRange()) {
Player player = game.getPlayer(playerId);
if (player != null) {
choices.add(new StringBuilder(Integer.toString(player.getLife())).append(" life of ").append(player.getName()).toString());
}
}
lifeChoice.setChoices(choices);
for (UUID playersId : controller.getInRange()) {
Player player = game.getPlayer(playersId);
if (player != null) {
String selectedChoice;
if (choices.size() > 1) {
lifeChoice.setMessage("Which players life should get player " + player.getName());
controller.choose(Outcome.Detriment, lifeChoice, game);
selectedChoice = lifeChoice.getChoice();
} else {
selectedChoice = choices.iterator().next();
}
int index = selectedChoice.indexOf(" ");
if (index > 0) {
String lifeString = selectedChoice.substring(0, index);
int life = Integer.parseInt(lifeString);
player.setLife(life, game);
choices.remove(selectedChoice);
game.informPlayers(new StringBuilder("Player ").append(player.getName()).append(" life set to ").append(life).toString());
}
}
}
}
return false;
}
}

View file

@ -0,0 +1,145 @@
/*
* 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.championsofkamigawa;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DiscardControllerEffect;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.WatcherScope;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.stack.Spell;
import mage.target.common.TargetCardInLibrary;
import mage.watchers.WatcherImpl;
/**
*
* @author LevelX2
*/
public class SiftThroughSands extends CardImpl<SiftThroughSands> {
private static final String rule = "If you've cast a spell named Peer Through Depths and a spell named Reach Through Mists this turn, you may search your library for a card named The Unspeakable, put it onto the battlefield, then shuffle your library";
private static final FilterCreatureCard filter = new FilterCreatureCard("a card named The Unspeakable");
static {
filter.add(new NamePredicate("The Unspeakable"));
}
public SiftThroughSands(UUID ownerId) {
super(ownerId, 84, "Sift Through Sands", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}{U}");
this.expansionSetCode = "CHK";
this.subtype.add("Arcane");
this.color.setBlue(true);
// Draw two cards, then discard a card.
this.getSpellAbility().addEffect(new DrawCardControllerEffect(2));
Effect effect = new DiscardControllerEffect(1);
effect.setText(", then discard a card");
this.getSpellAbility().addEffect(effect);
// If you've cast a spell named Peer Through Depths and a spell named Reach Through Mists this turn, you may search your library for a card named The Unspeakable, put it onto the battlefield, then shuffle your library.
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), false, true), new SiftThroughSandsCondition(), rule));
this.addWatcher(new SiftThroughSandsWatcher());
}
public SiftThroughSands(final SiftThroughSands card) {
super(card);
}
@Override
public SiftThroughSands copy() {
return new SiftThroughSands(this);
}
}
class SiftThroughSandsCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
SiftThroughSandsWatcher watcher = (SiftThroughSandsWatcher) game.getState().getWatchers().get("SiftThroughSandsWatcher", source.getControllerId());
if (watcher != null) {
return watcher.conditionMet();
}
return false;
}
}
class SiftThroughSandsWatcher extends WatcherImpl<SiftThroughSandsWatcher> {
boolean castPeerThroughDepths = false;
boolean castReachThroughMists = false;
public SiftThroughSandsWatcher() {
super("SiftThroughSandsWatcher", WatcherScope.PLAYER);
}
public SiftThroughSandsWatcher(final SiftThroughSandsWatcher watcher) {
super(watcher);
this.castPeerThroughDepths = watcher.castPeerThroughDepths;
this.castReachThroughMists = watcher.castReachThroughMists;
}
@Override
public SiftThroughSandsWatcher copy() {
return new SiftThroughSandsWatcher(this);
}
@Override
public void watch(GameEvent event, Game game) {
if (condition == true) { //no need to check - condition has already occured
return;
}
if (event.getType() == EventType.SPELL_CAST
&& controllerId == event.getPlayerId()) {
Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell.getCard().getName().equals("Peer Through Depths")) {
castPeerThroughDepths = true;
} else if (spell.getCard().getName().equals("Reach Through Mists")) {
castReachThroughMists = true;
}
condition = castPeerThroughDepths && castReachThroughMists;
}
}
@Override
public void reset() {
super.reset();
this.castPeerThroughDepths = false;
this.castReachThroughMists = false;
}
}

View file

@ -0,0 +1,152 @@
/*
* 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.championsofkamigawa;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.PreventionEffectImpl;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.SupertypePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
/**
*
* @author LevelX2
*/
public class VassalsDuty extends CardImpl<VassalsDuty> {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("legendary creature you control");
static {
filter.add(new SupertypePredicate("Legendary"));
}
public VassalsDuty(UUID ownerId) {
super(ownerId, 48, "Vassal's Duty", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}");
this.expansionSetCode = "CHK";
this.color.setWhite(true);
// {1}: The next 1 damage that would be dealt to target legendary creature you control this turn is dealt to you instead.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new VassalsDutyPreventDamageTargetEffect(Duration.EndOfTurn, 1), new GenericManaCost(1));
ability.addTarget(new TargetControlledCreaturePermanent(1,1,filter, false, true));
this.addAbility(ability);
}
public VassalsDuty(final VassalsDuty card) {
super(card);
}
@Override
public VassalsDuty copy() {
return new VassalsDuty(this);
}
}
class VassalsDutyPreventDamageTargetEffect extends PreventionEffectImpl<VassalsDutyPreventDamageTargetEffect> {
private int amount;
public VassalsDutyPreventDamageTargetEffect(Duration duration, int amount) {
super(duration);
this.amount = amount;
staticText = "The next " + amount + " damage that would be dealt to target legendary creature you control this turn is dealt to you instead";
}
public VassalsDutyPreventDamageTargetEffect(final VassalsDutyPreventDamageTargetEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
public VassalsDutyPreventDamageTargetEffect copy() {
return new VassalsDutyPreventDamageTargetEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, event.getTargetId(), source.getSourceId(), source.getControllerId(), event.getAmount(), false);
if (!game.replaceEvent(preventEvent)) {
int prevented;
if (event.getAmount() >= this.amount) {
int damage = amount;
event.setAmount(event.getAmount() - amount);
this.used = true;
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, event.getTargetId(), source.getSourceId(), source.getControllerId(), damage));
prevented = damage;
} else {
int damage = event.getAmount();
event.setAmount(0);
amount -= damage;
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, event.getTargetId(), source.getSourceId(), source.getControllerId(), damage));
prevented = damage;
}
// deal damage now
if (prevented > 0) {
UUID redirectTo = source.getControllerId();
Player player = game.getPlayer(redirectTo);
if (player != null) {
game.informPlayers("Dealing " + prevented + " to " + player.getName() + " instead");
// keep the original source id as it is redirecting
player.damage(prevented, event.getSourceId(), game, true, false);
}
}
}
return false;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!this.used && super.applies(event, source, game)) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null) {
if (permanent.getId().equals(this.getTargetPointer().getFirst(game, source))) {
return true;
}
}
}
return false;
}
}

View file

@ -138,6 +138,5 @@ class DreamThiefWatcher extends WatcherImpl<DreamThiefWatcher> {
@Override
public void reset() {
super.reset();
condition = false;
}
}