mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
GUI play ability on behalf of AI no longer freezes game
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user