public ManaType asThoughMana(ManaType manaType, ManaPoolItem mana, UUID objectId, Ability affectedAbility, UUID controllerId, Game game) { // First check existing only effects List<AsThoughEffect> asThoughEffectsList = getApplicableAsThoughEffects(AsThoughEffectType.SPEND_ONLY_MANA, game); for (AsThoughEffect effect : asThoughEffectsList) { Set<Ability> abilities = asThoughEffectsMap.get(AsThoughEffectType.SPEND_ONLY_MANA).getAbility(effect.getId()); for (Ability ability : abilities) { if ((affectedAbility == null && effect.applies(objectId, ability, controllerId, game)) || effect.applies(objectId, affectedAbility, ability, game, controllerId)) { if (((AsThoughManaEffect) effect).getAsThoughManaType(manaType, mana, controllerId, ability, game) == null) { return null; } } } } // then check effects that allow to use other mana types to pay the current mana type to pay asThoughEffectsList = getApplicableAsThoughEffects(AsThoughEffectType.SPEND_OTHER_MANA, game); for (AsThoughEffect effect : asThoughEffectsList) { Set<Ability> abilities = asThoughEffectsMap.get(AsThoughEffectType.SPEND_OTHER_MANA).getAbility(effect.getId()); for (Ability ability : abilities) { if ((affectedAbility == null && effect.applies(objectId, ability, controllerId, game)) || effect.applies(objectId, affectedAbility, ability, game, controllerId)) { ManaType usableManaType = ((AsThoughManaEffect) effect).getAsThoughManaType(manaType, mana, controllerId, ability, game); if (usableManaType != null) { return usableManaType; } } } } return manaType; }
private boolean checkPlayability(Card card, Player targetPlayer, Game game, Ability source) { // check for card playability boolean canPlay = false; if (card.isLand()) { // we can't use getPlayableInHand(game) in here because it disallows playing lands outside the main step if (targetPlayer.canPlayLand() && game.getActivePlayerId().equals(targetPlayer.getId())) { canPlay = true; for (Ability ability : card.getAbilities(game)) { if (!game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(), ability.getSourceId(), targetPlayer.getId()), ability, game, true)) { canPlay &= true; } } } } else { // Word of Command allows the chosen card to be played "as if it had flash" so we need to invoke such effect to bypass the check AsThoughEffectImpl effect2 = new WordOfCommandTestFlashEffect(); game.addEffect(effect2, source); if (targetPlayer.getPlayableInHand(game).contains(card.getId())) { canPlay = true; } for (AsThoughEffect eff : game.getContinuousEffects().getApplicableAsThoughEffects(AsThoughEffectType.CAST_AS_INSTANT, game)) { if (eff instanceof WordOfCommandTestFlashEffect) { eff.discard(); break; } } } return canPlay; } }
List<AsThoughEffect> asThoughEffectsList = getApplicableAsThoughEffects(type, game); if (!asThoughEffectsList.isEmpty()) { UUID idToCheck;