@Override protected boolean onCardSelected( final Card c0, final List<Card> otherCardsToSelect, final ITriggerEvent triggerEvent) { // the only place that would cause troubles - input is supposed only to // confirm, not to fire abilities final boolean fromHand = player.getZone(ZoneType.Hand).contains(c0); final boolean isSerumPowder = c0.getName().equals("Serum Powder"); final boolean isLegalChoice = fromHand && (isCommander || isSerumPowder); if (!isLegalChoice || cardSelectLocked) { return false; } final CardView cView = c0.getView(); if (isSerumPowder && getController().getGui().confirm(cView, "Use " + cView + "'s ability?")) { cardSelectLocked = true; ThreadUtil.invokeInGameThread( new Runnable() { @Override public void run() { final CardCollection hand = new CardCollection(c0.getController().getCardsIn(ZoneType.Hand)); for (final Card c : hand) { player.getGame().getAction().exile(c); } c0.getController().drawCards(hand.size()); cardSelectLocked = false; } }); return true; } if (isCommander) { // allow to choose cards for partial paris if (selected.contains(c0)) { getController().getGui().setUsedToPay(c0.getView(), false); selected.remove(c0); } else { getController().getGui().setUsedToPay(c0.getView(), true); selected.add(c0); } getController() .getGui() .updateButtons(getOwner(), "Keep", "Exile", true, !selected.isEmpty(), true); } return true; }
private void passPriority(final Runnable runnable) { if (FModel.getPreferences().getPrefBoolean(FPref.UI_MANA_LOST_PROMPT)) { // if gui player has mana floating that will be lost if phase ended right now, prompt before // passing priority final Game game = player.getGame(); if (game.getStack().isEmpty()) { // phase can't end right now if stack isn't empty Player player = game.getPhaseHandler().getPriorityPlayer(); if (player != null && player.getManaPool().willManaBeLostAtEndOfPhase() && player.getLobbyPlayer() == GamePlayerUtil.getGuiPlayer()) { ThreadUtil.invokeInGameThread( new Runnable() { // must invoke in game thread so dialog can be shown on mobile game @Override public void run() { String message = "You have mana floating in your mana pool that could be lost if you pass priority now."; if (FModel.getPreferences().getPrefBoolean(FPref.UI_MANABURN)) { message += " You will take mana burn damage equal to the amount of floating mana lost this way."; } if (SOptionPane.showOptionDialog( message, "Mana Floating", SOptionPane.WARNING_ICON, new String[] {"OK", "Cancel"}) == 0) { runnable.run(); } } }); return; } } } runnable.run(); // just pass priority immediately if no mana floating that would be lost }
@Override public void showMessageInitial() { final int ixCall = 1 + iCall.getAndIncrement(); ThreadUtil.delay(500, new InputUpdater(ixCall)); }
@Override public boolean isGuiThread() { return !ThreadUtil.isGameThread(); }