* Torment of Scarabs - Some fixes to try to solve a problem in games beyond the first in a match.

This commit is contained in:
LevelX2 2017-07-08 23:33:26 +02:00
parent c42841196f
commit 1911b91a82

View file

@ -47,7 +47,6 @@ import mage.players.Player;
import mage.target.Target;
import mage.target.TargetPermanent;
import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -104,11 +103,9 @@ class TormentOfScarabsAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanent(this.sourceId);
Permanent enchantment = game.getPermanent(this.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
Player player = game.getPlayer(enchantment.getAttachedTo());
if (player != null && game.getActivePlayerId().equals(player.getId())) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(player.getId()));
if (game.getActivePlayerId().equals(enchantment.getAttachedTo())) {
return true;
}
}
@ -140,10 +137,14 @@ class TormentOfScarabsEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player enchantedPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment == null || enchantment.getAttachedTo() == null) {
return false;
}
Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
if (enchantedPlayer != null) {
int permanents = game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_NON_LAND, enchantedPlayer.getId(), game);
if (permanents > 0 && enchantedPlayer.chooseUse(outcome, "Sacrifices a nonland permanent?",
if (permanents > 0 && enchantedPlayer.chooseUse(outcome, "Sacrifice a nonland permanent?",
"Otherwise you have to discard a card or lose 3 life.", "Sacrifice", "Discard or life loss", source, game)) {
Target target = new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_NON_LAND);
if (enchantedPlayer.choose(outcome, target, source.getSourceId(), game)) {