Fixed test

This commit is contained in:
Oleg Agafonov 2021-02-23 03:27:19 +04:00
parent 5e43c79f11
commit 51c9121f5e
2 changed files with 16 additions and 4 deletions

View file

@ -14,7 +14,9 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
/**
@ -65,9 +67,19 @@ public class SpellAbility extends ActivatedAbilityImpl {
if (object == null) {
return false;
}
if (game.getState().getValue("PlayFromNotOwnHandZone" + object.getId()) != null) {
return (Boolean) game.getState().getValue("PlayFromNotOwnHandZone" + object.getId()); // card like Chandra, Torch of Defiance +1 loyal ability)
// forced to cast (can be part id or main id)
Set<UUID> idsToCheck = new HashSet<>();
idsToCheck.add(object.getId());
if (object instanceof Card) {
idsToCheck.add(((Card) object).getMainCard().getId());
}
for (UUID idToCheck : idsToCheck) {
if (game.getState().getValue("PlayFromNotOwnHandZone" + idToCheck) != null) {
return (Boolean) game.getState().getValue("PlayFromNotOwnHandZone" + idToCheck); // card like Chandra, Torch of Defiance +1 loyal ability)
}
}
return null != game.getContinuousEffects().asThough(sourceId, AsThoughEffectType.CAST_AS_INSTANT, this, playerId, game) // check this first to allow Offering in main phase
|| timing == TimingRule.INSTANT
|| object.hasAbility(FlashAbility.getInstance(), game)

View file

@ -367,9 +367,9 @@ public interface Player extends MageItem, Copyable<Player> {
/**
* Force player to choose spell ability to cast. Use it in effects while casting cards.
*
* <p>
* Commands order in all use cases:
* - PlayFromNotOwnHandZone - true
* - PlayFromNotOwnHandZone - true (if you put main id then all parts allows, if you put part id then only part allows)
* - chooseAbilityForCast
* - cast
* - PlayFromNotOwnHandZone - false