Skip to content

Commit

Permalink
fix Obeka, Splitter of Seconds' extra phase calling beginning of turn…
Browse files Browse the repository at this point in the history
… method
  • Loading branch information
Susucre committed Apr 25, 2024
1 parent 110e990 commit ff4bd9b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,31 @@ public void test_ExtraUpkeep() {
assertTapped(obeka, true); // checks that no extra untap happened
assertHandCount(playerA, 0); // checks that no draw step happened
}

// Bug: Extra upkeep is wrongly changing summoning sickness status
@Test
public void test_ExtraUpkeep_TapAbility() {
setStrictChooseMode(true);

addCard(Zone.BATTLEFIELD, playerA, obeka);
// At the beginning of your upkeep, you gain 1 life.
addCard(Zone.BATTLEFIELD, playerA, "Fountain of Renewal");
addCard(Zone.HAND, playerA, "Soulmender"); // "{T}: You gain 1 life
addCard(Zone.BATTLEFIELD, playerA, "Plains");

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Soulmender", true);
checkPlayableAbility("Soulmender summoning sick pre-combat", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: You gain 1 life", false);

attack(1, playerA, obeka, playerB);
checkLife("Extra upkeeps are in extra phases after combat", 1, PhaseStep.END_COMBAT, playerA, 20 + 1);
checkPlayableAbility("Soulmender summoning sick after extra upkeep", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{T}: You gain 1 life", false);

checkPlayableAbility("Soulmender no longer summoning sick turn 3", 3, PhaseStep.UPKEEP, playerA, "{T}: You gain 1 life", true);
activateAbility(3, PhaseStep.UPKEEP, playerA, "{T}: You gain 1 life");

setStopAt(3, PhaseStep.PRECOMBAT_MAIN);
execute();

assertLife(playerA, 20 + 2 + 2 + 1); // 2 regular upkeep + 2 obeka ones + 1 Soulmender activation
}
}
17 changes: 13 additions & 4 deletions Mage/src/main/java/mage/game/turn/BeginningPhase.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,45 @@

package mage.game.turn;

import java.util.UUID;

import mage.constants.TurnPhase;
import mage.game.Game;
import mage.game.events.GameEvent.EventType;

import java.util.UUID;

/**
* @author BetaSteward_at_googlemail.com
*/
public class BeginningPhase extends Phase {

private final boolean isExtra;

public BeginningPhase() {
this(false);
}

public BeginningPhase(boolean isExtra) {
this.type = TurnPhase.BEGINNING;
this.event = EventType.BEGINNING_PHASE;
this.preEvent = EventType.BEGINNING_PHASE_PRE;
this.postEvent = EventType.BEGINNING_PHASE_POST;
this.steps.add(new UntapStep());
this.steps.add(new UpkeepStep());
this.steps.add(new DrawStep());
this.isExtra = isExtra;

This comment has been minimized.

Copy link
@JayDi85

JayDi85 Apr 25, 2024

Member

Must skip draw and untap steps due rules:

IMG_0253

This comment has been minimized.

Copy link
@Susucre

Susucre Apr 25, 2024

Author Contributor

That is already enforced, and unit tested.

Basically Obeka is adding new Beginning Phases (now with the extra flag), and skips every step that is not Upkeep in them.

}

@Override
public boolean beginPhase(Game game, UUID activePlayerId) {
game.getBattlefield().beginningOfTurn(game);
if (!isExtra) {
game.getBattlefield().beginningOfTurn(game);

This comment has been minimized.

Copy link
@JayDi85

JayDi85 Apr 25, 2024

Member

Check all related events like BEGINNING_PHASE_PRE -- cards like [[Power Surge]] -- it uses it to find beginning turn and can be broken too.

This comment has been minimized.

Copy link
@Susucre

Susucre Apr 25, 2024

Author Contributor

Oh right, checked them, all were either 'turn begun' watcher resets, or 'game begun' watcher resets (for Karn Liberated I think). None should be altered by Obeka new extra phases, so just made new events for the extra phase.

}
return super.beginPhase(game, activePlayerId);
}


protected BeginningPhase(final BeginningPhase phase) {
super(phase);
this.isExtra = phase.isExtra;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion Mage/src/main/java/mage/game/turn/Turn.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private boolean playExtraPhases(Game game, TurnPhase afterPhase) {
Phase phase;
switch (extraPhase) {
case BEGINNING:
phase = new BeginningPhase();
phase = new BeginningPhase(true);
break;
case PRECOMBAT_MAIN:
phase = new PreCombatMainPhase();
Expand Down

0 comments on commit ff4bd9b

Please sign in to comment.