forked from External/mage
merge
This commit is contained in:
commit
185913fde3
5 changed files with 73 additions and 98 deletions
|
|
@ -30,23 +30,26 @@ package mage.sets.worldwake;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
import mage.Constants.Layer;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.SubLayer;
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.common.SearchLibraryRevealPutInHandEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.SpellStack;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
/**
|
||||
|
|
@ -70,7 +73,7 @@ public class EyeofUgin extends CardImpl<EyeofUgin> {
|
|||
this.supertype.add("Legendary");
|
||||
this.subtype.add("Land");
|
||||
|
||||
this.addAbility(new EyeofUginCostReductionAbility());
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new EyeofUginCostReductionEffect()));
|
||||
Ability searchAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SearchLibraryRevealPutInHandEffect(new TargetCardInLibrary(filter)), new TapSourceCost());
|
||||
searchAbility.addCost(new ManaCostsImpl("{7}"));
|
||||
this.addAbility(searchAbility);
|
||||
|
|
@ -86,112 +89,50 @@ public class EyeofUgin extends CardImpl<EyeofUgin> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented as a {@link TriggeredAbilityImpl} for now as there currently is
|
||||
* no other way of interacting with a cards casting cost from an external object.
|
||||
* This ability has no effect as of right now until a better way of implementing
|
||||
* this form of object interaction is designed and implemented.
|
||||
*
|
||||
* @author maurer.it_at_gmail.com
|
||||
*/
|
||||
class EyeofUginCostReductionAbility extends TriggeredAbilityImpl<EyeofUginCostReductionAbility> {
|
||||
class EyeofUginCostReductionEffect extends ContinuousEffectImpl<EyeofUginCostReductionEffect> {
|
||||
|
||||
private static final String abilityText = "Colorless Eldrazi spells you cast cost {2} less to cast.";
|
||||
private static final String effectText = "Colorless Eldrazi spells you cast cost {2} less to cast";
|
||||
|
||||
EyeofUginCostReductionAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
EyeofUginCostReductionEffect ( ) {
|
||||
super(Duration.WhileOnBattlefield, Layer.TextChangingEffects_3, SubLayer.NA, Outcome.Benefit);
|
||||
}
|
||||
|
||||
EyeofUginCostReductionAbility ( EyeofUginCostReductionAbility effect ) {
|
||||
EyeofUginCostReductionEffect(EyeofUginCostReductionEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if ( event.getType() == EventType.ZONE_CHANGE &&
|
||||
event.getPlayerId().equals(this.getControllerId()) &&
|
||||
((ZoneChangeEvent)event).getToZone() == Zone.STACK )
|
||||
{
|
||||
Card card = (Card)game.getObject(event.getTargetId());
|
||||
Spell spell = (Spell)game.getObject(event.getSourceId());
|
||||
if ( card.getSubtype().contains("Eldrazi") ) {
|
||||
ManaCosts costs = spell.getSpellAbility().getManaCosts();
|
||||
costs.load("{" + (card.getManaCost().convertedManaCost() - 2) + "}");
|
||||
public boolean apply(Game game, Ability source) {
|
||||
SpellStack stack = game.getStack();
|
||||
boolean applied = false;
|
||||
|
||||
for ( int idx = 0; idx < stack.size(); idx++ ) {
|
||||
StackObject stackObject = stack.get(idx);
|
||||
|
||||
if ( stackObject instanceof Spell &&
|
||||
((Spell)stackObject).getSubtype().contains("Eldrazi"))
|
||||
{
|
||||
SpellAbility spell = ((Spell)stackObject).getSpellAbility();
|
||||
int previousCost = spell.getManaCosts().convertedManaCost();
|
||||
int adjustedCost = 0;
|
||||
if ( (previousCost - 2) > 0 ) {
|
||||
adjustedCost = previousCost - 2;
|
||||
}
|
||||
spell.getManaCosts().load("{" + adjustedCost + "}");
|
||||
applied = true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
return applied;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EyeofUginCostReductionAbility copy() {
|
||||
return new EyeofUginCostReductionAbility(this);
|
||||
public EyeofUginCostReductionEffect copy() {
|
||||
return new EyeofUginCostReductionEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return abilityText;
|
||||
public String getText(Ability source) {
|
||||
return effectText;
|
||||
}
|
||||
}
|
||||
|
||||
//class EyeofUginCostReductionEffect extends ContinuousEffectImpl<EyeofUginCostReductionEffect> {
|
||||
//
|
||||
// private static final String effectText = "Colorless Eldrazi spells you cast cost {2} less to cast";
|
||||
//
|
||||
// EyeofUginCostReductionEffect ( ) {
|
||||
// super(Duration.WhileOnBattlefield, Layer.TextChangingEffects_3, SubLayer.NA, Outcome.Benefit);
|
||||
// }
|
||||
//
|
||||
// EyeofUginCostReductionEffect(EyeofUginCostReductionEffect effect) {
|
||||
// super(effect);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void init(Ability source, Game game) {
|
||||
// super.init(source, game);
|
||||
// if (this.affectedObjectsSet) {
|
||||
// SpellStack stack = game.getStack();
|
||||
// for ( int idx = 0; idx < stack.size(); idx++ ) {
|
||||
// StackObject stackObject = stack.get(idx);
|
||||
//
|
||||
// if ( stackObject instanceof Spell &&
|
||||
// !objects.contains(stackObject.getId()) &&
|
||||
// ((Spell)stackObject).getSubtype().contains("Eldrazi"))
|
||||
// {
|
||||
// objects.add(stackObject.getId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean apply(Game game, Ability source) {
|
||||
// SpellStack stack = game.getStack();
|
||||
// boolean applied = false;
|
||||
//
|
||||
// for ( int idx = 0; idx < stack.size(); idx++ ) {
|
||||
// StackObject stackObject = stack.get(idx);
|
||||
//
|
||||
// if ( stackObject instanceof Spell &&
|
||||
// !objects.contains(stackObject.getId()) &&
|
||||
// ((Spell)stackObject).getSubtype().contains("Eldrazi"))
|
||||
// {
|
||||
// SpellAbility spell = ((Spell)stackObject).getSpellAbility();
|
||||
// int previousCost = spell.getManaCosts().convertedManaCost();
|
||||
// spell.getManaCosts().load("{" + (previousCost - 2) + "}");
|
||||
// applied |= objects.add(stackObject.getId());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return applied;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public EyeofUginCostReductionEffect copy() {
|
||||
// return new EyeofUginCostReductionEffect(this);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getText(Ability source) {
|
||||
// return effectText;
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -240,6 +240,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
for (Player player: players.values()) {
|
||||
player.reset();
|
||||
}
|
||||
stack.reset(game);
|
||||
battlefield.reset(game);
|
||||
effects.apply(game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,12 +41,16 @@ import mage.MageObject;
|
|||
import mage.ObjectColor;
|
||||
import mage.abilities.Abilities;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.AlternativeCost;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.keyword.KickerAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.ManaPool;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.watchers.Watchers;
|
||||
|
|
@ -153,6 +157,28 @@ public class Spell<T extends Spell<T>> implements StackObject, Card {
|
|||
card.moveToZone(Zone.GRAVEYARD, sourceId, game, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset ( Game game ) {
|
||||
Mana oldPayment = ability.getManaCosts().getPayment();
|
||||
ManaPool tmpPool = new ManaPool();
|
||||
tmpPool.changeMana(oldPayment);
|
||||
List<AlternativeCost> oldAltCosts = ability.getAlternativeCosts();
|
||||
Costs<Cost> oldOptionalCosts = ability.getOptionalCosts();
|
||||
Costs<Cost> oldCosts = ability.getCosts();
|
||||
|
||||
//Get a fresh copy of the spell ability.
|
||||
ability = card.getSpellAbility().copy();
|
||||
|
||||
//Reload all the payments for all costs.
|
||||
ability.getManaCosts().assignPayment(tmpPool);
|
||||
ability.getAlternativeCosts().clear();
|
||||
ability.getAlternativeCosts().addAll(oldAltCosts);
|
||||
ability.getOptionalCosts().clear();
|
||||
ability.getOptionalCosts().addAll(oldOptionalCosts);
|
||||
ability.getCosts().clear();
|
||||
ability.getCosts().addAll(oldCosts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getSourceId() {
|
||||
return card.getId();
|
||||
|
|
|
|||
|
|
@ -134,6 +134,12 @@ public class SpellStack extends Stack<StackObject> {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void reset ( Game game ) {
|
||||
for ( StackObject stackObject : this ) {
|
||||
stackObject.reset(game);
|
||||
}
|
||||
}
|
||||
|
||||
public SpellStack copy() {
|
||||
return new SpellStack(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ public interface StackObject extends MageObject {
|
|||
public UUID getControllerId();
|
||||
public void checkTriggers(GameEvent event, Game game);
|
||||
public void counter(UUID sourceId, Game game);
|
||||
public void reset ( Game game );
|
||||
@Override
|
||||
public StackObject copy();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue