mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 12:22:10 -08:00
fix Obeka, Splitter of Seconds (#12085)
Now adding BeginningPhases with all but Upkeep skipped. Previously upkeep steps were added during combat phase, which was incorrect. fix #12085
This commit is contained in:
parent
add0fa4f58
commit
8a29dcc735
5 changed files with 46 additions and 7 deletions
|
|
@ -12,6 +12,7 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -258,4 +259,20 @@ public abstract class Phase implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* One card [[Okea, Splitter of Seconds]], adds extra beginning phases with
|
||||
* all but upkeep steps skipped.
|
||||
* To achieve that, this function is called right after creating the extra Phase,
|
||||
* before running it.
|
||||
*/
|
||||
public void keepOnlyStep(PhaseStep step) {
|
||||
if (count != 0) {
|
||||
throw new IllegalStateException("Wrong code usage: illegal Phase modification once it started running");
|
||||
}
|
||||
this.steps = this.steps.stream().filter(s -> s.getType().equals(step)).collect(Collectors.toList());
|
||||
if (this.steps.isEmpty()) {
|
||||
throw new IllegalStateException("Wrong code usage: keepOnlyStep should not remove all the steps in a phase - " + step);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -263,6 +263,10 @@ public class Turn implements Serializable {
|
|||
default:
|
||||
throw new IllegalArgumentException("Unknown phase type: " + extraPhase);
|
||||
}
|
||||
PhaseStep skipAllButExtraStep = extraPhaseMod.getSkipAllButExtraStep();
|
||||
if (skipAllButExtraStep != null) {
|
||||
phase.keepOnlyStep(skipAllButExtraStep);
|
||||
}
|
||||
currentPhase = phase;
|
||||
game.fireEvent(new PhaseChangedEvent(activePlayerId, extraPhaseMod));
|
||||
Player activePlayer = game.getPlayer(activePlayerId);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class TurnMod implements Serializable, Copyable<TurnMod> {
|
|||
|
||||
private Step extraStep;
|
||||
private PhaseStep skipStep;
|
||||
|
||||
private PhaseStep skipAllButExtraStep; // for extra phase skipping all but a specific step.
|
||||
private TurnPhase afterPhase;
|
||||
private PhaseStep afterStep;
|
||||
|
||||
|
|
@ -66,6 +66,7 @@ public class TurnMod implements Serializable, Copyable<TurnMod> {
|
|||
this.extraStep = mod.extraStep.copy();
|
||||
}
|
||||
this.skipStep = mod.skipStep;
|
||||
this.skipAllButExtraStep = mod.skipAllButExtraStep;
|
||||
this.afterPhase = mod.afterPhase;
|
||||
this.afterStep = mod.afterStep;
|
||||
if (mod.subsequentTurnMod != null) {
|
||||
|
|
@ -126,6 +127,18 @@ public class TurnMod implements Serializable, Copyable<TurnMod> {
|
|||
return withExtraPhase(extraPhase, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an extra step in a new extra phase after this one.
|
||||
* All steps that are not the right one are skipped in the extra phase.
|
||||
* e.g. [[Obeka, Splitter of Seconds]]
|
||||
*/
|
||||
public TurnMod withExtraStepInExtraPhase(PhaseStep extraStep, TurnPhase extraPhase) {
|
||||
this.extraPhase = extraPhase;
|
||||
this.skipAllButExtraStep = extraStep;
|
||||
lock();
|
||||
return this;
|
||||
}
|
||||
|
||||
public TurnMod withExtraPhase(TurnPhase extraPhase, TurnPhase addAfterPhase) {
|
||||
this.extraPhase = extraPhase;
|
||||
this.afterPhase = addAfterPhase;
|
||||
|
|
@ -192,6 +205,10 @@ public class TurnMod implements Serializable, Copyable<TurnMod> {
|
|||
return skipPhase;
|
||||
}
|
||||
|
||||
public PhaseStep getSkipAllButExtraStep() {
|
||||
return skipAllButExtraStep;
|
||||
}
|
||||
|
||||
public PhaseStep getSkipStep() {
|
||||
return skipStep;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue