grant haste to permanent cast with suspend as long as they are under control player who cast it, for #351
parent
08481ebc32
commit
86210e9c66
|
@ -83,6 +83,10 @@ public class MagicTuple implements MagicCopyable {
|
|||
return ((MagicInteger)tuple[i]).value;
|
||||
}
|
||||
|
||||
public final MagicPermanentAction getMod(int i) {
|
||||
return (MagicPermanentAction)tuple[i];
|
||||
}
|
||||
|
||||
public final List<MagicPermanentAction> getMods() {
|
||||
List<MagicPermanentAction> mods = new ArrayList<>(tuple.length);
|
||||
for (final MagicCopyable c : tuple) {
|
||||
|
|
|
@ -14,21 +14,27 @@ public class CastCardAction extends MagicAction {
|
|||
private final boolean withoutManaCost;
|
||||
private final MagicLocationType from;
|
||||
private final MagicLocationType to;
|
||||
private final MagicPermanentAction mod;
|
||||
|
||||
public CastCardAction(final MagicPlayer aPlayer, final MagicCard aCard, final MagicLocationType aFrom, final MagicLocationType aTo) {
|
||||
this(aPlayer, aCard, false, aFrom, aTo);
|
||||
this(aPlayer, aCard, false, aFrom, aTo, MagicPlayMod.NONE);
|
||||
}
|
||||
|
||||
public static CastCardAction WithoutManaCost(final MagicPlayer aPlayer, final MagicCard aCard, final MagicLocationType aFrom, final MagicLocationType aTo) {
|
||||
return new CastCardAction(aPlayer, aCard, true, aFrom, aTo);
|
||||
return new CastCardAction(aPlayer, aCard, true, aFrom, aTo, MagicPlayMod.NONE);
|
||||
}
|
||||
|
||||
private CastCardAction(final MagicPlayer aPlayer, final MagicCard aCard, final boolean aWithoutManaCost, final MagicLocationType aFrom, final MagicLocationType aTo) {
|
||||
public static CastCardAction WithoutManaCost(final MagicPlayer aPlayer, final MagicCard aCard, final MagicLocationType aFrom, final MagicLocationType aTo, final MagicPermanentAction mod) {
|
||||
return new CastCardAction(aPlayer, aCard, true, aFrom, aTo, mod);
|
||||
}
|
||||
|
||||
private CastCardAction(final MagicPlayer aPlayer, final MagicCard aCard, final boolean aWithoutManaCost, final MagicLocationType aFrom, final MagicLocationType aTo, final MagicPermanentAction aMod) {
|
||||
player = aPlayer;
|
||||
card = aCard;
|
||||
withoutManaCost = aWithoutManaCost;
|
||||
from = aFrom;
|
||||
to = aTo;
|
||||
mod = aMod;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +48,7 @@ public class CastCardAction extends MagicAction {
|
|||
for (final MagicEvent event : withoutManaCost ? card.getAdditionalCostEvent() : card.getCostEvent()) {
|
||||
game.addCostEvent(event);
|
||||
}
|
||||
game.addEvent(new MagicPutCardOnStackEvent(card, player, from, to));
|
||||
game.addEvent(new MagicPutCardOnStackEvent(card, player, from, to, mod));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import magic.model.MagicPermanent;
|
|||
import magic.model.MagicPermanentState;
|
||||
import magic.model.MagicPlayer;
|
||||
import magic.model.ARG;
|
||||
import magic.model.condition.MagicConditionFactory;
|
||||
import magic.model.event.MagicMorphActivation;
|
||||
import magic.model.mstatic.MagicStatic;
|
||||
import magic.model.trigger.AtEndOfCombatTrigger;
|
||||
|
@ -105,6 +106,16 @@ public enum MagicPlayMod implements MagicPermanentAction {
|
|||
game.doAction(new GainAbilityAction(perm, MagicAbility.Haste, MagicStatic.Forever));
|
||||
}
|
||||
},
|
||||
HASTE_SUSPEND() {
|
||||
@Override
|
||||
protected void doAction(final MagicGame game, final MagicPermanent perm) {
|
||||
game.doAction(new AddStaticAction(perm, MagicStatic.AsLongAsCond(
|
||||
perm,
|
||||
MagicAbility.Haste,
|
||||
MagicConditionFactory.PlayerControlsSource(perm.getController())
|
||||
)));
|
||||
}
|
||||
},
|
||||
PERSIST() {
|
||||
@Override
|
||||
protected void doAction(final MagicGame game, final MagicPermanent perm) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package magic.model.event;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import magic.model.MagicGame;
|
||||
import magic.model.MagicCard;
|
||||
import magic.model.MagicPlayer;
|
||||
|
@ -8,25 +10,27 @@ import magic.model.MagicTuple;
|
|||
import magic.model.stack.MagicCardOnStack;
|
||||
import magic.model.action.PutItemOnStackAction;
|
||||
import magic.model.action.RemoveCardAction;
|
||||
import magic.model.action.MagicPermanentAction;
|
||||
|
||||
public class MagicPutCardOnStackEvent extends MagicEvent {
|
||||
public MagicPutCardOnStackEvent(final MagicCard source, final MagicPlayer player, final MagicLocationType fromLocation, final MagicLocationType toLocation) {
|
||||
public MagicPutCardOnStackEvent(final MagicCard source, final MagicPlayer player, final MagicLocationType fromLocation, final MagicLocationType toLocation, final MagicPermanentAction mod) {
|
||||
super(
|
||||
source,
|
||||
player,
|
||||
new MagicTuple(fromLocation, toLocation),
|
||||
new MagicTuple(fromLocation, toLocation, mod),
|
||||
EVENT_ACTION,
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
private static final MagicEventAction EVENT_ACTION = (final MagicGame game, final MagicEvent event) -> {
|
||||
final MagicTuple tup = event.getRefTuple();
|
||||
final MagicCardOnStack cardOnStack = new MagicCardOnStack(
|
||||
event.getCard(),
|
||||
event.getPlayer(),
|
||||
game.getPayedCost()
|
||||
game.getPayedCost(),
|
||||
Collections.singletonList(tup.getMod(2))
|
||||
);
|
||||
final MagicTuple tup = event.getRefTuple();
|
||||
final MagicLocationType from = tup.getLocationType(0);
|
||||
final MagicLocationType to = tup.getLocationType(1);
|
||||
cardOnStack.setFromLocation(from);
|
||||
|
|
|
@ -8,6 +8,7 @@ import magic.model.MagicCard;
|
|||
import magic.model.MagicCounterType;
|
||||
import magic.model.MagicLocationType;
|
||||
import magic.model.MagicAbility;
|
||||
import magic.model.action.MagicPlayMod;
|
||||
import magic.model.action.DrawAction;
|
||||
import magic.model.action.RemoveTriggerAction;
|
||||
import magic.model.action.ChangeCountersAction;
|
||||
|
@ -92,7 +93,8 @@ public abstract class AtUpkeepTrigger extends MagicTrigger<MagicPlayer> {
|
|||
event.getPlayer(),
|
||||
card,
|
||||
MagicLocationType.Exile,
|
||||
MagicLocationType.Graveyard
|
||||
MagicLocationType.Graveyard,
|
||||
MagicPlayMod.HASTE_SUSPEND
|
||||
));
|
||||
//not implemented: If you cast a creature spell this way, it gains haste until you lose control of the spell or the permanent it becomes.
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue