mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 13:32:06 -08:00
Game: fixed rare bugs in some cards after rollback or cancel actions:
* Cumulative upkeep cost - fixed that it can lost payed state (cards: Aboroth, Karplusan Minotaur, Psychic Vortex, Sheltering Ancient); * Effects - fixed that it can lost selected targets or other settings (cards: Citadel of Pain, Crimson Honor Guard, Curfew, Leveler, Mana Cache, Monsoon, Paradigm Shift, Saprazzan Bailiff); * Exile all cards from graveyard ability - fixed that it can lost targets (example: Agent of Erebos); * Melee ability - fixed that it can lost targets (example: Adriana, Captain of the Guard).
This commit is contained in:
parent
82cc789534
commit
07ddad6e48
60 changed files with 163 additions and 224 deletions
|
|
@ -3,11 +3,12 @@ package mage.abilities.costs;
|
|||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
import mage.target.Targets;
|
||||
import mage.util.Copyable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Cost extends Serializable {
|
||||
public interface Cost extends Serializable, Copyable<Cost> {
|
||||
|
||||
UUID getId();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.costs;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -72,5 +71,4 @@ public abstract class CostImpl implements Cost {
|
|||
public UUID getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import mage.util.Copyable;
|
|||
/**
|
||||
* @author LevelX2
|
||||
*/
|
||||
public interface OptionalAdditionalCost extends Cost, Copyable<OptionalAdditionalCost> {
|
||||
public interface OptionalAdditionalCost extends Cost {
|
||||
|
||||
String getName();
|
||||
|
||||
|
|
@ -77,4 +77,6 @@ public interface OptionalAdditionalCost extends Cost, Copyable<OptionalAdditiona
|
|||
*/
|
||||
int getActivateCount();
|
||||
|
||||
@Override
|
||||
OptionalAdditionalCost copy();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,19 @@ package mage.abilities.dynamicvalue;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.util.Copyable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface DynamicValue extends Serializable {
|
||||
/**
|
||||
* Dynamic value can be called multiple times from different places, so don't use inner/changeable fields. If you
|
||||
* use it then think x100 times and override Copy method with copy constructor.
|
||||
*/
|
||||
public interface DynamicValue extends Serializable, Copyable<DynamicValue> {
|
||||
|
||||
int calculate(Game game, Ability sourceAbility, Effect effect);
|
||||
|
||||
DynamicValue copy();
|
||||
|
||||
String getMessage();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
|
||||
|
||||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class TargetPermanenToughnessValue implements DynamicValue {
|
||||
|
||||
private static final TargetPermanenToughnessValue instance = new TargetPermanenToughnessValue();
|
||||
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static TargetPermanenToughnessValue getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
Permanent sourcePermanent = game.getPermanent(sourceAbility.getFirstTarget());
|
||||
if (sourcePermanent == null) {
|
||||
sourcePermanent = (Permanent) game.getLastKnownInformation(sourceAbility.getFirstTarget(), Zone.BATTLEFIELD);
|
||||
}
|
||||
if (sourcePermanent != null) {
|
||||
return sourcePermanent.getToughness().getValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPermanenToughnessValue copy() {
|
||||
return new TargetPermanenToughnessValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "target creature's toughness";
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import mage.constants.EffectType;
|
|||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.target.targetpointer.TargetPointer;
|
||||
import mage.util.Copyable;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
|
@ -13,7 +14,7 @@ import java.util.UUID;
|
|||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public interface Effect extends Serializable {
|
||||
public interface Effect extends Serializable, Copyable<Effect> {
|
||||
|
||||
UUID getId();
|
||||
|
||||
|
|
|
|||
|
|
@ -19,5 +19,4 @@ public abstract class OneShotEffect extends EffectImpl {
|
|||
public OneShotEffect(final OneShotEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -21,9 +19,13 @@ public class ExileGraveyardAllTargetPlayerEffect extends OneShotEffect {
|
|||
staticText = "exile all cards from target player's graveyard";
|
||||
}
|
||||
|
||||
private ExileGraveyardAllTargetPlayerEffect(final ExileGraveyardAllTargetPlayerEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExileGraveyardAllTargetPlayerEffect copy() {
|
||||
return new ExileGraveyardAllTargetPlayerEffect();
|
||||
return new ExileGraveyardAllTargetPlayerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class ExileSpellEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public ExileSpellEffect copy() {
|
||||
return new ExileSpellEffect();
|
||||
return new ExileSpellEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TurnPhase;
|
||||
import mage.game.Game;
|
||||
import mage.game.turn.TurnMod;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author escplan9 (Derek Monturo - dmontur1 at gmail dot com)
|
||||
*/
|
||||
public class SkipNextCombatEffect extends OneShotEffect {
|
||||
|
||||
public SkipNextCombatEffect() {
|
||||
super(Outcome.Detriment);
|
||||
staticText = "target opponent skips their next combat phase";
|
||||
}
|
||||
|
||||
public SkipNextCombatEffect(SkipNextCombatEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (targetPointer != null) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
game.getState().getTurnMods().add(new TurnMod(player.getId(), TurnPhase.COMBAT, null, true));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkipNextCombatEffect copy() {
|
||||
return new SkipNextCombatEffect();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
package mage.abilities.effects.common.turn;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.turn.TurnMod;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
*/
|
||||
|
|
@ -35,6 +35,6 @@ public class ControlTargetPlayerNextTurnEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public ControlTargetPlayerNextTurnEffect copy() {
|
||||
return new ControlTargetPlayerNextTurnEffect();
|
||||
return new ControlTargetPlayerNextTurnEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -71,9 +70,19 @@ class MeleeWatcher extends Watcher {
|
|||
|
||||
class MeleeDynamicValue implements DynamicValue {
|
||||
|
||||
private boolean valueChecked = false;
|
||||
private boolean valueChecked;
|
||||
private int lockedInValue;
|
||||
|
||||
public MeleeDynamicValue() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected MeleeDynamicValue(final MeleeDynamicValue dynamicValue) {
|
||||
super();
|
||||
valueChecked = dynamicValue.valueChecked;
|
||||
lockedInValue = dynamicValue.lockedInValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
MeleeWatcher watcher = game.getState().getWatcher(MeleeWatcher.class);
|
||||
|
|
@ -89,7 +98,7 @@ class MeleeDynamicValue implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public MeleeDynamicValue copy() {
|
||||
return new MeleeDynamicValue();
|
||||
return new MeleeDynamicValue(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue