GUI play ability on behalf of AI no longer freezes game

This commit is contained in:
Maxmtg
2013-05-27 14:34:16 +00:00
parent f99e0b3b4b
commit 4c76527c3d
5 changed files with 9 additions and 7 deletions

View File

@@ -25,7 +25,6 @@ import com.google.common.base.Predicate;
import forge.Card;
import forge.CardLists;
import forge.CardPredicates.Presets;
import forge.card.cost.Cost;
import forge.card.mana.ManaCost;
import forge.card.spellability.Ability;

View File

@@ -185,7 +185,7 @@ public class HumanPlay {
if (sa != null) {
sa.setActivatingPlayer(player);
playSaWithoutPayingManaCost(player, sa);
playSaWithoutPayingManaCost(player.getGame(), sa);
}
}
@@ -197,7 +197,7 @@ public class HumanPlay {
* @param sa
* a {@link forge.card.spellability.SpellAbility} object.
*/
public static final void playSaWithoutPayingManaCost(final Player player, final SpellAbility sa) {
public static final void playSaWithoutPayingManaCost(final GameState game, final SpellAbility sa) {
FThreads.assertExecutedByEdt(false);
final Card source = sa.getSourceCard();
@@ -215,12 +215,12 @@ public class HumanPlay {
if (sa.isSpell()) {
final Card c = sa.getSourceCard();
if (!c.isCopiedSpell()) {
sa.setSourceCard(player.getGame().getAction().moveToStack(c));
sa.setSourceCard(game.getAction().moveToStack(c));
}
}
boolean x = sa.getSourceCard().getManaCost().getShardCount(ManaCostShard.X) > 0;
player.getGame().getStack().add(sa, x);
game.getStack().add(sa, x);
}
}

View File

@@ -78,6 +78,8 @@ public abstract class PlayerController {
if ( handler.getPriorityPlayer() == player )
game.getPhaseHandler().passPriority();
/* else // it is not our priority! - have to check if this works fine
game.getInputQueue().updateObservers(); */
}
// Triggers preliminary choice: ask, decline or play

View File

@@ -130,7 +130,7 @@ public class PlayerControllerHuman extends PlayerController {
*/
@Override
public void playSpellAbilityForFree(SpellAbility copySA) {
HumanPlay.playSaWithoutPayingManaCost(player, copySA);
HumanPlay.playSaWithoutPayingManaCost(player.getGame(), copySA);
}
/* (non-Javadoc)

View File

@@ -418,7 +418,8 @@ public final class GuiDisplayUtil {
game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least)
// Human player is choosing targets for an ability controlled by chosen player.
sa.setActivatingPlayer(p);
HumanPlay.playSaWithoutPayingManaCost(game.getPhaseHandler().getPriorityPlayer(), sa);
HumanPlay.playSaWithoutPayingManaCost(game, sa);
game.getInputQueue().updateObservers();
}
});
}