(final boolean fromUntapStep)
| 5666 | } |
| 5667 | |
| 5668 | private boolean switchPhaseState(final boolean fromUntapStep) { |
| 5669 | if (isPhasedOut() && fromUntapStep && wontPhaseInNormal) { |
| 5670 | return false; |
| 5671 | } |
| 5672 | |
| 5673 | final Map<AbilityKey, Object> runParams = AbilityKey.mapFromCard(this); |
| 5674 | |
| 5675 | if (!isPhasedOut()) { |
| 5676 | // If this is currently PhasedIn, it's about to phase out. |
| 5677 | // Run trigger before it does because triggers don't work with phased out objects |
| 5678 | getGame().getTriggerHandler().runTrigger(TriggerType.PhaseOut, runParams, true); |
| 5679 | // CR 702.26f |
| 5680 | runPhaseOutCommands(); |
| 5681 | |
| 5682 | // these links also break |
| 5683 | clearEncodedCards(); |
| 5684 | if (isPaired()) { |
| 5685 | getPairedWith().setPairedWith(null); |
| 5686 | setPairedWith(null); |
| 5687 | } |
| 5688 | } |
| 5689 | |
| 5690 | setPhasedOut(isPhasedOut() ? null : getController()); |
| 5691 | final Combat combat = getGame().getCombat(); |
| 5692 | if (combat != null && isPhasedOut()) { |
| 5693 | combat.saveLKI(this); |
| 5694 | combat.removeFromCombat(this); |
| 5695 | } |
| 5696 | |
| 5697 | if (!isPhasedOut()) { |
| 5698 | // CR 702.26g phases in unattached if that object is still in the same zone or that player is still in the game |
| 5699 | if (isAttachedToEntity()) { |
| 5700 | final GameEntity ge = getEntityAttachedTo(); |
| 5701 | boolean unattach = false; |
| 5702 | if (ge instanceof Player) { |
| 5703 | unattach = !((Player) ge).isInGame(); |
| 5704 | } else { |
| 5705 | unattach = !((Card) ge).isInPlay(); |
| 5706 | } |
| 5707 | if (unattach) { |
| 5708 | unattachFromEntity(ge); |
| 5709 | } |
| 5710 | } |
| 5711 | |
| 5712 | // Just phased in, time to run the phased in trigger |
| 5713 | getGame().getTriggerHandler().registerActiveTrigger(this, false); |
| 5714 | getGame().getTriggerHandler().runTrigger(TriggerType.PhaseIn, runParams, true); |
| 5715 | } |
| 5716 | |
| 5717 | game.updateLastStateForCard(this); |
| 5718 | |
| 5719 | return true; |
| 5720 | } |
| 5721 | |
| 5722 | public final boolean isDirectlyPhasedOut() { |
| 5723 | return directlyPhasedOut; |
no test coverage detected