mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
- Added Abandoned Sarcophagus. [HOU]
This commit is contained in:
parent
5e9ebcaa51
commit
4d87821497
3 changed files with 600 additions and 278 deletions
274
Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java
Normal file
274
Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java
Normal file
|
@ -0,0 +1,274 @@
|
|||
/*
|
||||
* 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.cards.a;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.keyword.CyclingAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.AbilityPredicate;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class AbandonedSarcophagus extends CardImpl {
|
||||
|
||||
public AbandonedSarcophagus(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
|
||||
|
||||
// You may cast nonland cards with cycling from your graveyard.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AbandonedSarcophagusEffect()));
|
||||
|
||||
// If a card with cycling would be put into your graveyard from anywhere and it wasn't cycled, exile it instead.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AbandonedSarcophagusReplacementEffect()), new AbandonedSarcophagusWatcher());
|
||||
|
||||
}
|
||||
|
||||
public AbandonedSarcophagus(final AbandonedSarcophagus card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbandonedSarcophagus copy() {
|
||||
return new AbandonedSarcophagus(this);
|
||||
}
|
||||
}
|
||||
|
||||
class AbandonedSarcophagusEffect extends ContinuousEffectImpl {
|
||||
|
||||
private static final FilterCard filter = new FilterCard("nonland cards with cycling");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(new CardTypePredicate(CardType.LAND)));
|
||||
filter.add(new AbilityPredicate(CyclingAbility.class));
|
||||
}
|
||||
|
||||
AbandonedSarcophagusEffect() {
|
||||
super(Duration.WhileOnBattlefield, Layer.PlayerEffects, SubLayer.NA, Outcome.Benefit);
|
||||
staticText = "You may cast nonland cards with cycling from your graveyard";
|
||||
}
|
||||
|
||||
AbandonedSarcophagusEffect(final AbandonedSarcophagusEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbandonedSarcophagusEffect copy() {
|
||||
return new AbandonedSarcophagusEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (Card card : controller.getGraveyard().getCards(filter, game)) {
|
||||
ContinuousEffect effect = new AbandonedSarcophagusCastFromGraveyardEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class AbandonedSarcophagusCastFromGraveyardEffect extends AsThoughEffectImpl {
|
||||
|
||||
AbandonedSarcophagusCastFromGraveyardEffect() {
|
||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "You may cast nonland cards with cycling from your graveyard";
|
||||
}
|
||||
|
||||
AbandonedSarcophagusCastFromGraveyardEffect(final AbandonedSarcophagusCastFromGraveyardEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbandonedSarcophagusCastFromGraveyardEffect copy() {
|
||||
return new AbandonedSarcophagusCastFromGraveyardEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
|
||||
if (objectId.equals(getTargetPointer().getFirst(game, source))) {
|
||||
if (affectedControllerId.equals(source.getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class AbandonedSarcophagusReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
boolean cardHasCycling;
|
||||
boolean cardWasCycledThisTurn;
|
||||
|
||||
public AbandonedSarcophagusReplacementEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Exile);
|
||||
staticText = "If a card with cycling would be put into your graveyard from anywhere and it wasn't cycled, exile it instead";
|
||||
}
|
||||
|
||||
public AbandonedSarcophagusReplacementEffect(final AbandonedSarcophagusReplacementEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbandonedSarcophagusReplacementEffect copy() {
|
||||
return new AbandonedSarcophagusReplacementEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null) {
|
||||
return controller.moveCards(card, Zone.EXILED, source, game);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
cardWasCycledThisTurn = false;
|
||||
cardHasCycling = false;
|
||||
if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
AbandonedSarcophagusWatcher watcher = (AbandonedSarcophagusWatcher) game.getState().getWatchers().get(AbandonedSarcophagusWatcher.class.getSimpleName());
|
||||
Card card = game.getCard(event.getTargetId());
|
||||
if (card != null
|
||||
&& watcher != null) {
|
||||
for (Ability ability : card.getAbilities()) {
|
||||
if (ability instanceof CyclingAbility) {
|
||||
cardHasCycling = true;
|
||||
}
|
||||
}
|
||||
Cards cards = watcher.getCardsCycledThisTurn(controller.getId());
|
||||
for (Card c : cards.getCards(game)) {
|
||||
if (c == card) {
|
||||
cardWasCycledThisTurn = true;
|
||||
watcher.getCardsCycledThisTurn(controller.getId()).remove(card); //remove reference to the card as it is no longer needed
|
||||
}
|
||||
}
|
||||
return (!cardWasCycledThisTurn
|
||||
&& cardHasCycling);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class AbandonedSarcophagusWatcher extends Watcher {
|
||||
|
||||
private final Map<UUID, Cards> cycledCardsThisTurn = new HashMap<>();
|
||||
|
||||
public AbandonedSarcophagusWatcher() {
|
||||
super(AbandonedSarcophagusWatcher.class.getSimpleName(), WatcherScope.GAME);
|
||||
}
|
||||
|
||||
public AbandonedSarcophagusWatcher(final AbandonedSarcophagusWatcher watcher) {
|
||||
super(watcher);
|
||||
for (Entry<UUID, Cards> entry : watcher.cycledCardsThisTurn.entrySet()) {
|
||||
cycledCardsThisTurn.put(entry.getKey(), entry.getValue().copy());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.CYCLE_CARD) {
|
||||
Card card = game.getCard(event.getSourceId());
|
||||
if (card != null) {
|
||||
Cards c = getCardsCycledThisTurn(event.getPlayerId());
|
||||
c.add(card);
|
||||
cycledCardsThisTurn.put(event.getPlayerId(), c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Cards getCardsCycledThisTurn(UUID playerId) {
|
||||
return cycledCardsThisTurn.getOrDefault(playerId, new CardsImpl());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
cycledCardsThisTurn.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbandonedSarcophagusWatcher copy() {
|
||||
return new AbandonedSarcophagusWatcher(this);
|
||||
}
|
||||
}
|
|
@ -66,6 +66,7 @@ public class HourOfDevastation extends ExpansionSet {
|
|||
this.ratioBoosterSpecialLand = 144;
|
||||
this.maxCardNumberInBooster = 199;
|
||||
|
||||
cards.add(new SetCardInfo("Abandoned Sarcophagus", 158, Rarity.RARE, mage.cards.a.AbandonedSarcophagus.class));
|
||||
cards.add(new SetCardInfo("Abrade", 83, Rarity.UNCOMMON, mage.cards.a.Abrade.class));
|
||||
cards.add(new SetCardInfo("Accursed Horde", 56, Rarity.UNCOMMON, mage.cards.a.AccursedHorde.class));
|
||||
cards.add(new SetCardInfo("Act of Heroism", 1, Rarity.COMMON, mage.cards.a.ActOfHeroism.class));
|
||||
|
|
|
@ -27,14 +27,20 @@
|
|||
*/
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.DiscardSourceCost;
|
||||
import mage.abilities.costs.CostImpl;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
/**
|
||||
|
@ -48,14 +54,14 @@ public class CyclingAbility extends ActivatedAbilityImpl {
|
|||
|
||||
public CyclingAbility(Cost cost) {
|
||||
super(Zone.HAND, new DrawCardSourceControllerEffect(1), cost);
|
||||
this.addCost(new DiscardSourceCost(false));
|
||||
this.addCost(new CyclingDiscardCost());
|
||||
this.cost = cost;
|
||||
this.text = "Cycling";
|
||||
}
|
||||
|
||||
public CyclingAbility(Cost cost, FilterCard filter, String text) {
|
||||
super(Zone.HAND, new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true, true), cost);
|
||||
this.addCost(new DiscardSourceCost(false));
|
||||
this.addCost(new CyclingDiscardCost());
|
||||
this.cost = cost;
|
||||
this.text = text;
|
||||
}
|
||||
|
@ -84,3 +90,44 @@ public class CyclingAbility extends ActivatedAbilityImpl {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class CyclingDiscardCost extends CostImpl {
|
||||
|
||||
public CyclingDiscardCost() {
|
||||
}
|
||||
|
||||
public CyclingDiscardCost(CyclingDiscardCost cost) {
|
||||
super(cost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
return game.getPlayer(controllerId).getHand().contains(sourceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
if (player != null) {
|
||||
Card card = player.getHand().get(sourceId, game);
|
||||
if (card != null) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CYCLE_CARD, card.getId(), card.getId(), card.getOwnerId()));
|
||||
paid = player.discard(card, null, game);
|
||||
if (paid) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CYCLED_CARD, card.getId(), card.getId(), card.getOwnerId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Discard this card";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CyclingDiscardCost copy() {
|
||||
return new CyclingDiscardCost(this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue