* Can't cast prevention effects - fixed that UI marked affected cards as playable, but they're not;

This commit is contained in:
Oleg Agafonov 2020-02-01 12:17:04 +04:00
parent 4ad29abdd7
commit f0ff8154f3

View file

@ -3286,12 +3286,25 @@ public abstract class PlayerImpl implements Player, Serializable {
boolean isPlayLand = (ability instanceof PlayLandAbility);
// as original controller
// land restrictions
// play land restrictions
if (isPlayLand && game.getContinuousEffects().preventedByRuleModification(
GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(),
ability.getSourceId(), this.getId()), ability, game, true)) {
continue;
}
// cast spell restrictions 1
if (isPlaySpell && game.getContinuousEffects().preventedByRuleModification(
GameEvent.getEvent(EventType.CAST_SPELL, ability.getSourceId(),
ability.getSourceId(), this.getId()), ability, game, true)) {
continue;
}
// cast spell restrictions 2
if (isPlaySpell && game.getContinuousEffects().preventedByRuleModification(
GameEvent.getEvent(EventType.CAST_SPELL_LATE, ability.getSourceId(),
ability.getSourceId(), this.getId()), ability, game, true)) {
continue;
}
MageObjectReference permittingObject;
if (isPlaySpell || isPlayLand) {
@ -3307,6 +3320,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|| (fromZone == Zone.GRAVEYARD && canPlayCardsFromGraveyard());
// as affected controller
UUID savedControllerId = ability.getControllerId();
ability.setControllerId(this.getId());
try {
@ -3351,20 +3365,38 @@ public abstract class PlayerImpl implements Player, Serializable {
}
boolean fromAll = fromZone.equals(Zone.ALL);
if (hidden && (fromAll || fromZone == Zone.HAND)) {
for (Card card : hand.getCards(game)) {
for (Ability ability : card.getAbilities(game)) { // gets this activated ability from hand? (Morph?)
if (ability.getZone().match(Zone.HAND)) {
if (ability instanceof ActivatedAbility) {
if (!(ability instanceof PlayLandAbility)
|| !game.getContinuousEffects().preventedByRuleModification(
boolean isPlaySpell = (ability instanceof SpellAbility);
boolean isPlayLand = (ability instanceof PlayLandAbility);
// play land restrictions
if (isPlayLand && game.getContinuousEffects().preventedByRuleModification(
GameEvent.getEvent(GameEvent.EventType.PLAY_LAND, ability.getSourceId(),
ability.getSourceId(), playerId), ability, game, true)) {
ability.getSourceId(), this.getId()), ability, game, true)) {
continue;
}
// cast spell restrictions 1
if (isPlaySpell && game.getContinuousEffects().preventedByRuleModification(
GameEvent.getEvent(EventType.CAST_SPELL, ability.getSourceId(),
ability.getSourceId(), this.getId()), ability, game, true)) {
continue;
}
// cast spell restrictions 2
if (isPlaySpell && game.getContinuousEffects().preventedByRuleModification(
GameEvent.getEvent(EventType.CAST_SPELL_LATE, ability.getSourceId(),
ability.getSourceId(), this.getId()), ability, game, true)) {
continue;
}
// if have alternative cost
if (ability instanceof ActivatedAbility) {
// normal ability
if (canPlay((ActivatedAbility) ability, availableMana, card, game)) {
playable.add(ability);
}
}
} else if (ability instanceof AlternativeSourceCosts) {
if (card.isLand()) {
if (canLandPlayAlternateSourceCostsAbility(card, availableMana, ability, game)) { // e.g. Land with Morph
@ -3377,6 +3409,8 @@ public abstract class PlayerImpl implements Player, Serializable {
}
}
}
} else {
// unknown type
}
}
}