mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
* Mana pool handling - Fixed bug where wrong playerId was used. Fixed that menu check state is the same for all GamePanles of client.
This commit is contained in:
parent
610c7d7462
commit
c13f7a2115
7 changed files with 32 additions and 14 deletions
|
@ -581,6 +581,16 @@ public final class GamePanel extends javax.swing.JPanel {
|
|||
this.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the same state for menu selections to all player areas.
|
||||
* @param manaPoolAutomatic
|
||||
*/
|
||||
public void setMenuStates(boolean manaPoolAutomatic) {
|
||||
for(PlayAreaPanel playAreaPanel: players.values()) {
|
||||
playAreaPanel.setMenuStates(manaPoolAutomatic);
|
||||
}
|
||||
}
|
||||
|
||||
private void displayStack(GameView game, BigCard bigCard, FeedbackPanel feedbackPanel, UUID gameId) {
|
||||
this.stack.loadCards(game.getStack(), bigCard, gameId, null);
|
||||
}
|
||||
|
|
|
@ -65,6 +65,8 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
private boolean playingMode = true;
|
||||
private GamePanel gamePanel;
|
||||
|
||||
private JCheckBoxMenuItem manaPoolMenuItem;
|
||||
|
||||
public static final int PANEL_HEIGHT = 242;
|
||||
public static final int PANEL_HEIGHT_SMALL = 190;
|
||||
|
||||
|
@ -177,16 +179,18 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
|
||||
popupMenu.addSeparator();
|
||||
|
||||
menuItem = new JCheckBoxMenuItem("Use mana from pool automatically", true);
|
||||
menuItem.setMnemonic(KeyEvent.VK_M);
|
||||
menuItem.setToolTipText("If not active, you have to click the type of mana you want to pay in the player panel.");
|
||||
popupMenu.add(menuItem);
|
||||
manaPoolMenuItem = new JCheckBoxMenuItem("Use mana from pool automatically", true);
|
||||
manaPoolMenuItem.setMnemonic(KeyEvent.VK_M);
|
||||
manaPoolMenuItem.setToolTipText("If not active, you have to click the type of mana you want to pay in the player panel.");
|
||||
popupMenu.add(manaPoolMenuItem);
|
||||
|
||||
// Auto pay mana from mana pool
|
||||
menuItem.addActionListener(new ActionListener() {
|
||||
manaPoolMenuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gamePanel.getSession().setManaPoolMode(((JCheckBoxMenuItem)e.getSource()).getState(), gameId);
|
||||
boolean manaPoolAutomatic = ((JCheckBoxMenuItem)e.getSource()).getState();
|
||||
gamePanel.setMenuStates(manaPoolAutomatic);
|
||||
gamePanel.getSession().setManaPoolMode(manaPoolAutomatic, gameId);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -367,6 +371,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
this.playingMode = playingMode;
|
||||
}
|
||||
|
||||
public void setMenuStates(boolean manaPoolAutomatic) {
|
||||
manaPoolMenuItem.setSelected(manaPoolAutomatic);
|
||||
}
|
||||
|
||||
private mage.client.game.BattlefieldPanel battlefieldPanel;
|
||||
private javax.swing.JButton btnCheat;
|
||||
//private javax.swing.JScrollPane jScrollPane1;
|
||||
|
|
|
@ -968,10 +968,10 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setResponseManaType(UUID playerId, ManaType manaType) {
|
||||
public void setResponseManaType(UUID manaTypePlayerId, ManaType manaType) {
|
||||
synchronized(response) {
|
||||
response.setManaType(manaType);
|
||||
response.setResponseManaTypePlayerId(playerId);
|
||||
response.setResponseManaTypePlayerId(manaTypePlayerId);
|
||||
response.notify();
|
||||
log.debug("Got response mana type from player: " + getId());
|
||||
}
|
||||
|
|
|
@ -475,11 +475,11 @@ public class GameController implements GameCallback {
|
|||
});
|
||||
}
|
||||
|
||||
public void sendPlayerManaType(UUID userId, UUID playerId, final ManaType data) {
|
||||
public void sendPlayerManaType(UUID userId, final UUID manaTypePlayerId, final ManaType data) {
|
||||
sendMessage(userId, new Command() {
|
||||
@Override
|
||||
public void execute(UUID playerId) {
|
||||
getGameSession(playerId).sendPlayerManaType(data, playerId);
|
||||
getGameSession(playerId).sendPlayerManaType(data, manaTypePlayerId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -221,9 +221,9 @@ public class GameSession extends GameWatcher {
|
|||
game.getPlayer(playerId).setResponseString(data);
|
||||
}
|
||||
|
||||
public void sendPlayerManaType(ManaType manaType, UUID playerId) {
|
||||
public void sendPlayerManaType(ManaType manaType, UUID manaTypePlayerId) {
|
||||
cancelTimeout();
|
||||
game.getPlayer(playerId).setResponseManaType(playerId, manaType);
|
||||
game.getPlayer(playerId).setResponseManaType(manaTypePlayerId, manaType);
|
||||
}
|
||||
|
||||
public void sendPlayerBoolean(Boolean data) {
|
||||
|
|
|
@ -278,7 +278,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
void setResponseUUID(UUID responseUUID);
|
||||
void setResponseBoolean(Boolean responseBoolean);
|
||||
void setResponseInteger(Integer data);
|
||||
void setResponseManaType(UUID playerId, ManaType responseManaType);
|
||||
void setResponseManaType(UUID manaTypePlayerId, ManaType responseManaType);
|
||||
|
||||
boolean priority(Game game);
|
||||
boolean choose(Outcome outcome, Target target, UUID sourceId, Game game);
|
||||
|
|
|
@ -1473,7 +1473,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
public void setResponseString(String responseString) {}
|
||||
|
||||
@Override
|
||||
public void setResponseManaType(UUID playerId, ManaType responseManaType) {}
|
||||
public void setResponseManaType(UUID manaTypePlayerId, ManaType responseManaType) {}
|
||||
|
||||
@Override
|
||||
public void setResponseUUID(UUID responseUUID) {}
|
||||
|
|
Loading…
Reference in a new issue