add custom canPlay method for MagicPermanentActivation to perform more complex checking such as permanent that needs to tap but already tapped to pay for mana cost
parent
c07e0a62a9
commit
d4c3095d12
|
@ -6,6 +6,7 @@ import magic.model.MagicChangeCardDefinition;
|
||||||
import magic.model.MagicGame;
|
import magic.model.MagicGame;
|
||||||
import magic.model.MagicPayedCost;
|
import magic.model.MagicPayedCost;
|
||||||
import magic.model.MagicPermanent;
|
import magic.model.MagicPermanent;
|
||||||
|
import magic.model.MagicPlayer;
|
||||||
import magic.model.MagicSource;
|
import magic.model.MagicSource;
|
||||||
import magic.model.MagicCopyable;
|
import magic.model.MagicCopyable;
|
||||||
import magic.model.MagicCopyMap;
|
import magic.model.MagicCopyMap;
|
||||||
|
@ -58,6 +59,34 @@ public abstract class MagicPermanentActivation extends MagicActivation<MagicPerm
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean canPlay(final MagicGame game, final MagicPlayer player, final MagicPermanent source, final boolean useHints) {
|
||||||
|
final boolean superCanPlay = super.canPlay(game, player, source, useHints);
|
||||||
|
|
||||||
|
// More complex check that first executes events without choice, then check conditions of the others
|
||||||
|
if (superCanPlay && source.producesMana()) {
|
||||||
|
game.record();
|
||||||
|
for (final MagicEvent event : getCostEvent(source)) {
|
||||||
|
if (event.hasChoice() == false) {
|
||||||
|
game.executeEvent(event, MagicEvent.NO_CHOICE_RESULTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (final MagicEvent event : getCostEvent(source)) {
|
||||||
|
if (event.hasChoice() == true) {
|
||||||
|
for (final MagicCondition condition : event.getConditions()) {
|
||||||
|
if (!condition.accept(source)) {
|
||||||
|
game.restore();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
game.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
return superCanPlay;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MagicCopyable copy(final MagicCopyMap copyMap) {
|
public MagicCopyable copy(final MagicCopyMap copyMap) {
|
||||||
return this;
|
return this;
|
||||||
|
|
Loading…
Reference in New Issue