Rework "second main phase" abilities (#12970)

* replace all instances of "postcombat main phase" with "second main phase" minus exceptions

* second main trigger now works correctly

* add survival test

* additional text fixes
This commit is contained in:
Evan Kranzler 2024-10-18 23:03:43 -04:00 committed by GitHub
parent 3131365abd
commit 1484e3b575
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 339 additions and 115 deletions

View file

@ -1,28 +1,26 @@
package mage.abilities.abilityword;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.BeginningOfSecondMainTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.constants.AbilityWord;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import java.util.Optional;
/**
* TODO: This should only trigger on the second main phase, this is part of a larger refactor that has to be done
*
* @author TheElk801
*/
public class SurvivalAbility extends TriggeredAbilityImpl {
public class SurvivalAbility extends BeginningOfSecondMainTriggeredAbility {
public SurvivalAbility(Effect effect) {
this(effect, false);
}
public SurvivalAbility(Effect effect, boolean optional) {
super(Zone.BATTLEFIELD, effect, optional);
super(Zone.BATTLEFIELD, effect, TargetController.YOU, optional, false);
setTriggerPhrase("At the beginning of your second main phase, if {this} is tapped, ");
setAbilityWord(AbilityWord.SURVIVAL);
}
@ -36,20 +34,10 @@ public class SurvivalAbility extends TriggeredAbilityImpl {
return new SurvivalAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.POSTCOMBAT_MAIN_PHASE_PRE;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return game.isActivePlayer(getControllerId());
}
@Override
public boolean checkInterveningIfClause(Game game) {
return Optional
.ofNullable(getSourcePermanentIfItStillExists(game))
.ofNullable(getSourcePermanentOrLKI(game))
.map(Permanent::isTapped)
.orElse(false);
}