mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
[UI] Displaying creatures that can attack
This commit is contained in:
parent
a8476d3613
commit
65a0c9fc79
15 changed files with 132 additions and 120 deletions
|
|
@ -46,6 +46,7 @@ import mage.client.util.Config;
|
|||
import mage.client.util.GameManager;
|
||||
import mage.client.util.PhaseManager;
|
||||
import mage.client.util.gui.ArrowBuilder;
|
||||
import mage.constants.Constants;
|
||||
import mage.constants.EnlargeMode;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.remote.Session;
|
||||
|
|
@ -62,6 +63,7 @@ import java.awt.*;
|
|||
import java.awt.event.*;
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
|
@ -448,6 +450,10 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
public synchronized void updateGame(GameView game) {
|
||||
updateGame(game, null);
|
||||
}
|
||||
|
||||
public synchronized void updateGame(GameView game, Map<String, Serializable> options) {
|
||||
if (playerId == null || game.getHand() == null) {
|
||||
this.handContainer.setVisible(false);
|
||||
} else {
|
||||
|
|
@ -506,8 +512,23 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.txtActivePlayer.setText(game.getActivePlayerName());
|
||||
this.txtPriority.setText(game.getPriorityPlayerName());
|
||||
this.txtTurn.setText(Integer.toString(game.getTurn()));
|
||||
|
||||
List<UUID> possibleAttackers = new ArrayList<>();
|
||||
if (options != null && options.containsKey(Constants.Option.POSSIBLE_ATTACKERS)) {
|
||||
if (options.get(Constants.Option.POSSIBLE_ATTACKERS) instanceof List) {
|
||||
possibleAttackers.addAll((List) options.get(Constants.Option.POSSIBLE_ATTACKERS));
|
||||
}
|
||||
}
|
||||
|
||||
for (PlayerView player: game.getPlayers()) {
|
||||
if (players.containsKey(player.getPlayerId())) {
|
||||
if (!possibleAttackers.isEmpty()) {
|
||||
for (UUID permanentId : possibleAttackers) {
|
||||
if (player.getBattlefield().containsKey(permanentId)) {
|
||||
player.getBattlefield().get(permanentId).setCanAttack(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
players.get(player.getPlayerId()).update(player);
|
||||
} else {
|
||||
logger.warn("Couldn't find player.");
|
||||
|
|
@ -693,15 +714,15 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
return JOptionPane.showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION);
|
||||
}
|
||||
|
||||
public void select(String message, GameView gameView, int messageId) {
|
||||
updateGame(gameView);
|
||||
public void select(String message, GameView gameView, int messageId, Map<String, Serializable> options) {
|
||||
updateGame(gameView, options);
|
||||
String messageToDisplay = message;
|
||||
Map<String, Serializable> options = null;
|
||||
Map<String, Serializable> panelOptions = null;
|
||||
for (PlayerView playerView : gameView.getPlayers()) {
|
||||
if (playerView.getPlayerId().equals(playerId)) {
|
||||
if (playerView.isActive()) {
|
||||
options = new HashMap<>();
|
||||
options.put("your_turn", true);
|
||||
panelOptions = new HashMap<>();
|
||||
panelOptions.put("your_turn", true);
|
||||
messageToDisplay = message + " <div style='font-size:11pt'>Your turn</div>";
|
||||
}
|
||||
// magenoxx: because of uncaught bug with saving state, rolling back and stack
|
||||
|
|
@ -712,7 +733,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
break;
|
||||
}
|
||||
}
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), options, messageId);
|
||||
this.feedbackPanel.getFeedback(FeedbackMode.SELECT, messageToDisplay, gameView.getSpecial(), panelOptions, messageId);
|
||||
if (PhaseManager.getInstance().isSkip(gameView, message)) {
|
||||
this.feedbackPanel.doClick();
|
||||
logger.debug(new StringBuilder("Phase skipped: ").append(message).append(" id: ").append(messageId));
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@
|
|||
*/
|
||||
package mage.client.remote;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.chat.ChatPanel;
|
||||
|
|
@ -38,25 +34,21 @@ import mage.client.constants.Constants.DeckEditorMode;
|
|||
import mage.client.draft.DraftPanel;
|
||||
import mage.client.game.GamePanel;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.client.util.DeckUtil;
|
||||
import mage.client.util.GameManager;
|
||||
import mage.client.util.audio.AudioManager;
|
||||
import mage.client.util.object.SaveObjectUtil;
|
||||
import mage.interfaces.callback.CallbackClient;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.utils.CompressUtil;
|
||||
import mage.view.AbilityPickerView;
|
||||
import mage.view.ChatMessage;
|
||||
import mage.view.*;
|
||||
import mage.view.ChatMessage.MessageType;
|
||||
import mage.view.DeckView;
|
||||
import mage.view.DraftClientMessage;
|
||||
import mage.view.DraftView;
|
||||
import mage.view.GameClientMessage;
|
||||
import mage.view.GameEndView;
|
||||
import mage.view.GameView;
|
||||
import mage.view.TableClientMessage;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -218,7 +210,7 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||
GamePanel panel = MageFrame.getGame(callback.getObjectId());
|
||||
if (panel != null) {
|
||||
panel.select(message.getMessage(), message.getGameView(), callback.getMessageId());
|
||||
panel.select(message.getMessage(), message.getGameView(), callback.getMessageId(), message.getOptions());
|
||||
} break;
|
||||
}
|
||||
case "gameChooseAbility":
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
private boolean isSelected;
|
||||
private boolean isPlayable;
|
||||
private boolean isChoosable;
|
||||
private boolean canAttack;
|
||||
private boolean showCastingCost;
|
||||
private boolean hasImage = false;
|
||||
private float alpha = 1.0f;
|
||||
|
|
@ -434,6 +435,11 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize);
|
||||
}
|
||||
|
||||
if (canAttack) {
|
||||
g2d.setColor(new Color(250, 250, 0, 200));
|
||||
g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize);
|
||||
}
|
||||
|
||||
|
||||
//TODO:uncomment
|
||||
/*
|
||||
|
|
@ -702,6 +708,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
|
||||
this.isPlayable = card.isPlayable();
|
||||
this.isChoosable = card.isChoosable();
|
||||
this.canAttack = card.isCanAttack();
|
||||
|
||||
boolean updateImage = !gameCard.getName().equals(card.getName()) || gameCard.isFaceDown() != card.isFaceDown(); // update after e.g. turning a night/day card
|
||||
this.gameCard = card;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue