mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -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
|
|
@ -8,13 +8,9 @@ import mage.abilities.effects.OneShotEffect;
|
|||
import mage.abilities.keyword.MenaceAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.turn.TurnMod;
|
||||
import mage.game.turn.UpkeepStep;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -76,7 +72,10 @@ class ObekaSplitterOfSecondsEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
for (int i = 0; i < extraSteps; ++i) {
|
||||
game.getState().getTurnMods().add(new TurnMod(source.getControllerId()).withExtraStep(new UpkeepStep()));
|
||||
game.getState().getTurnMods().add(
|
||||
new TurnMod(source.getControllerId())
|
||||
.withExtraStepInExtraPhase(PhaseStep.UPKEEP, TurnPhase.BEGINNING)
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ public class ObekaSplitterOfSecondsTest extends CardTestPlayerBase {
|
|||
addCard(Zone.BATTLEFIELD, playerA, "Fountain of Renewal");
|
||||
|
||||
attack(1, playerA, obeka, playerB);
|
||||
checkLife("Extra upkeeps are in extra phases after combat", 1, PhaseStep.END_COMBAT, playerA, 20 + 1);
|
||||
|
||||
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
|
|
|
|||
|
|
@ -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