add methods to MagicSourceActivation to simplify usage in MagicPriorityEvent

master
melvin 2013-07-07 21:21:50 +08:00
parent 9cfdfbcd2d
commit c7f0af266a
3 changed files with 15 additions and 10 deletions

View File

@ -53,10 +53,13 @@ public abstract class MagicActivation<T extends MagicSource> implements MagicEve
return id >= actpri.getActivationId();
}
void changeActivationPriority(final MagicGame game,final MagicPlayer player) {
void changeActivationPriority(final MagicPlayer player) {
final MagicActivationPriority actpri = player.getActivationPriority();
actpri.setPriority(priority);
actpri.setActivationId(id);
// reset activation/priority of opponent
player.getOpponent().getActivationPriority().clear();
}
public final boolean canPlay(

View File

@ -40,19 +40,13 @@ public class MagicPriorityEvent extends MagicEvent {
}
} else {
// Clear priority passed only when stack is used.
final MagicSourceActivation sourceActivation=playChoiceResult.sourceActivation;
if (sourceActivation.activation.usesStack()) {
final MagicSourceActivation<? extends MagicSource> sourceActivation = playChoiceResult.sourceActivation;
if (sourceActivation.usesStack()) {
game.setPriorityPassed(false);
}
final MagicSource source = sourceActivation.source;
final MagicPlayer player = source.getController();
// set activation/priority of controller
sourceActivation.activation.changeActivationPriority(game,player);
// reset activation/priority of opponent
player.getOpponent().getActivationPriority().clear();
sourceActivation.changeActivationPriority();
// reset payed costs
game.resetPayedCost();

View File

@ -34,6 +34,14 @@ public class MagicSourceActivation<T extends MagicSource> implements Comparable<
return activation.getEvent(source);
}
public boolean usesStack() {
return activation.usesStack();
}
public void changeActivationPriority() {
activation.changeActivationPriority(source.getController());
}
@Override
public int compareTo(final MagicSourceActivation other) {
return activation.compareTo(other.activation);