mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
Clash - Fixed handling of Titan's Revenge.
This commit is contained in:
parent
b7a51adbc3
commit
7c0f93afcd
3 changed files with 40 additions and 26 deletions
|
@ -27,17 +27,21 @@
|
|||
*/
|
||||
package mage.sets.morningtide;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.PostResolveEffect;
|
||||
import mage.abilities.effects.common.ClashEffect;
|
||||
import mage.abilities.effects.common.DamageTargetEffect;
|
||||
import mage.abilities.effects.common.ReturnToHandSpellEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCreatureOrPlayer;
|
||||
|
@ -55,7 +59,9 @@ public class TitansRevenge extends CardImpl {
|
|||
this.color.setRed(true);
|
||||
|
||||
// Titan's Revenge deals X damage to target creature or player. Clash with an opponent. If you win, return Titan's Revenge to its owner's hand.
|
||||
this.getSpellAbility().addEffect(new TitansRevengeEffect());
|
||||
this.getSpellAbility().addEffect(new DamageTargetEffect(new ManacostVariableValue()));
|
||||
this.getSpellAbility().addEffect(TitansRevengeReturnToHandSpellEffect.getInstance());
|
||||
|
||||
this.getSpellAbility().addTarget(new TargetCreatureOrPlayer());
|
||||
}
|
||||
|
||||
|
@ -69,33 +75,41 @@ public class TitansRevenge extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class TitansRevengeReturnToHandSpellEffect extends PostResolveEffect implements MageSingleton {
|
||||
private static final TitansRevengeReturnToHandSpellEffect fINSTANCE = new TitansRevengeReturnToHandSpellEffect();
|
||||
|
||||
class TitansRevengeEffect extends OneShotEffect {
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
public TitansRevengeEffect() {
|
||||
super(Outcome.ReturnToHand);
|
||||
this.staticText = "{this} deals X damage to target creature or player. Clash with an opponent. If you win, return {this} to its owner's hand";
|
||||
}
|
||||
private TitansRevengeReturnToHandSpellEffect() {
|
||||
staticText = "Clash with an opponent. If you win, return {this} to its owner's hand";
|
||||
}
|
||||
|
||||
public TitansRevengeEffect(final TitansRevengeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
public static TitansRevengeReturnToHandSpellEffect getInstance() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TitansRevengeEffect copy() {
|
||||
return new TitansRevengeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
new DamageTargetEffect(new ManacostVariableValue(), true).apply(game, source);
|
||||
if (ClashEffect.getInstance().apply(game, source)) {
|
||||
source.addEffect(ReturnToHandSpellEffect.getInstance());
|
||||
}
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@Override
|
||||
public TitansRevengeReturnToHandSpellEffect copy() {
|
||||
return fINSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(Ability source, Game game) {
|
||||
return ClashEffect.getInstance().apply(game, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postResolve(Card card, Ability source, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
controller.moveCardToHandWithInfo(card, source.getSourceId(), game, Zone.STACK);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -52,7 +52,7 @@ public abstract class PostResolveEffect extends OneShotEffect {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
public boolean isActive(Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ public class Spell implements StackObject, Card {
|
|||
if (!copiedSpell) {
|
||||
for (Effect effect : ability.getEffects()) {
|
||||
if (effect instanceof PostResolveEffect) {
|
||||
if (((PostResolveEffect) effect).isActive()) {
|
||||
if (((PostResolveEffect) effect).isActive(ability, game)) {
|
||||
((PostResolveEffect) effect).postResolve(card, ability, controllerId, game);
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue