Added an option that player has to confirm if he passes priority with empty stack and has mana in his pool. Implements #707.

This commit is contained in:
LevelX2 2015-06-07 22:37:12 +02:00
parent 907ec7abb0
commit 9da44a547d
16 changed files with 187 additions and 61 deletions

View file

@ -335,6 +335,7 @@ public class ConnectDialog extends MageDialog {
connection.setAllowRequestShowHandCards(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"));
connection.setShowAbilityPickerForced(showAbilityPickerForced);
connection.setUserSkipPrioritySteps(PreferencesDialog.getUserSkipPrioritySteps());
connection.setConfirmEmptyManaPool(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true").equals("true"));
logger.debug("connecting: " + connection.getProxyType() + " " + connection.getProxyHost() + " " + connection.getProxyPort());
task = new ConnectTask();
task.execute();

View file

@ -31,7 +31,7 @@
<Component id="exitButton" min="-2" pref="55" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="tabsPanel" alignment="0" max="32767" attributes="0"/>
<Component id="tabsPanel" alignment="0" pref="595" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -85,7 +85,7 @@
<Component id="main_game" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="main_gamelog" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="63" max="32767" attributes="0"/>
<EmptySpace pref="40" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -203,16 +203,17 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="cbAllowRequestToShowHandCards" min="-2" pref="546" max="-2" attributes="0"/>
<EmptySpace pref="14" max="32767" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="showPlayerNamesPermanently" alignment="0" max="32767" attributes="0"/>
<Component id="nonLandPermanentsInOnePile" alignment="0" max="32767" attributes="0"/>
<Component id="showAbilityPickerForced" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="cbShowStormCounter" alignment="0" min="-2" pref="546" max="-2" attributes="0"/>
<Component id="cbConfirmEmptyManaPool" alignment="0" min="-2" pref="546" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
@ -232,6 +233,8 @@
<Component id="cbAllowRequestToShowHandCards" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbShowStormCounter" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbConfirmEmptyManaPool" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -293,6 +296,17 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbShowStormCounterActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="cbConfirmEmptyManaPool">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Confirm if you want to pass a phase/step but there is still mana in your mana pool"/>
<Property name="toolTipText" type="java.lang.String" value="&lt;html&gt;If activated you get a confirm message if you pass priority while stack is empty&lt;br&gt;&#xa; and you still have mana in your mana pool."/>
<Property name="horizontalAlignment" type="int" value="2"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbConfirmEmptyManaPoolActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="main_gamelog">
@ -1128,7 +1142,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="598" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="590" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">

View file

@ -85,6 +85,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_SHOW_ABILITY_PICKER_FORCED = "showAbilityPicker";
public static final String KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS = "gameAllowRequestShowHandCards";
public static final String KEY_GAME_SHOW_STORM_COUNTER = "gameShowStormCounter";
public static final String KEY_GAME_CONFIRM_EMPTY_MANA_POOL = "gameConfirmEmptyManaPool";
public static final String KEY_GAME_LOG_AUTO_SAVE = "gameLogAutoSave";
@ -335,6 +336,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
showAbilityPickerForced = new javax.swing.JCheckBox();
cbAllowRequestToShowHandCards = new javax.swing.JCheckBox();
cbShowStormCounter = new javax.swing.JCheckBox();
cbConfirmEmptyManaPool = new javax.swing.JCheckBox();
main_gamelog = new javax.swing.JPanel();
cbGameLogAutoSave = new javax.swing.JCheckBox();
tabPhases = new javax.swing.JPanel();
@ -549,6 +551,16 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
});
cbConfirmEmptyManaPool.setSelected(true);
cbConfirmEmptyManaPool.setText("Confirm if you want to pass a phase/step but there is still mana in your mana pool");
cbConfirmEmptyManaPool.setToolTipText("<html>If activated you get a confirm message if you pass priority while stack is empty<br>\n and you still have mana in your mana pool.");
cbConfirmEmptyManaPool.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
cbConfirmEmptyManaPool.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbConfirmEmptyManaPoolActionPerformed(evt);
}
});
javax.swing.GroupLayout main_gameLayout = new javax.swing.GroupLayout(main_game);
main_game.setLayout(main_gameLayout);
main_gameLayout.setHorizontalGroup(
@ -558,14 +570,15 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addGroup(main_gameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(main_gameLayout.createSequentialGroup()
.addComponent(cbAllowRequestToShowHandCards, javax.swing.GroupLayout.PREFERRED_SIZE, 546, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(14, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(main_gameLayout.createSequentialGroup()
.addGroup(main_gameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(main_gameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(showPlayerNamesPermanently, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(nonLandPermanentsInOnePile, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(showAbilityPickerForced, javax.swing.GroupLayout.Alignment.LEADING))
.addComponent(cbShowStormCounter, javax.swing.GroupLayout.PREFERRED_SIZE, 546, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(cbShowStormCounter, javax.swing.GroupLayout.PREFERRED_SIZE, 546, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbConfirmEmptyManaPool, javax.swing.GroupLayout.PREFERRED_SIZE, 546, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, Short.MAX_VALUE))))
);
main_gameLayout.setVerticalGroup(
@ -579,7 +592,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbAllowRequestToShowHandCards)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbShowStormCounter))
.addComponent(cbShowStormCounter)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbConfirmEmptyManaPool))
);
nonLandPermanentsInOnePile.getAccessibleContext().setAccessibleName("nonLandPermanentsInOnePile");
@ -630,7 +645,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addComponent(main_game, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(main_gamelog, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(63, Short.MAX_VALUE))
.addContainerGap(40, Short.MAX_VALUE))
);
main_card.getAccessibleContext().setAccessibleName("Game panel");
@ -1383,7 +1398,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
tabAvatars.setLayout(tabAvatarsLayout);
tabAvatarsLayout.setHorizontalGroup(
tabAvatarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE)
);
tabAvatarsLayout.setVerticalGroup(
tabAvatarsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -1602,7 +1617,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addComponent(tabsPanel)
.addComponent(tabsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 595, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -1630,6 +1645,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.showAbilityPickerForced, KEY_SHOW_ABILITY_PICKER_FORCED, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbShowStormCounter, KEY_GAME_SHOW_STORM_COUNTER, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbConfirmEmptyManaPool, KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true", "false", UPDATE_CACHE_POLICY);
// Phases
@ -1696,6 +1712,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
getSelectedAvatar(),
dialog.showAbilityPickerForced.isSelected(),
dialog.cbAllowRequestToShowHandCards.isSelected(),
dialog.cbConfirmEmptyManaPool.isSelected(),
getUserSkipPrioritySteps());
prefs.flush();
@ -1947,6 +1964,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
// TODO add your handling code here:
}//GEN-LAST:event_cbShowStormCounterActionPerformed
private void cbConfirmEmptyManaPoolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbConfirmEmptyManaPoolActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_cbConfirmEmptyManaPoolActionPerformed
private void showProxySettings() {
if (cbProxyType.getSelectedItem() == Connection.ProxyType.SOCKS) {
this.pnlProxy.setVisible(true);
@ -2023,6 +2044,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.showAbilityPickerForced, KEY_SHOW_ABILITY_PICKER_FORCED, "true");
load(prefs, dialog.cbAllowRequestToShowHandCards, KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true");
load(prefs, dialog.cbShowStormCounter, KEY_GAME_SHOW_STORM_COUNTER, "true");
load(prefs, dialog.cbConfirmEmptyManaPool, KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true");
load(prefs, dialog.cbGameLogAutoSave, KEY_GAME_LOG_AUTO_SAVE, "true");
@ -2367,6 +2389,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
id,
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_ANY_ZONE, "true").equals("true"),
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ALLOW_REQUEST_SHOW_HAND_CARDS, "true").equals("true"),
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true").equals("true"),
getUserSkipPrioritySteps());
}
}
@ -2381,6 +2404,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JButton btnBrowseImageLocation;
private javax.swing.JCheckBox cbAllowRequestToShowHandCards;
private javax.swing.JCheckBox cbCheckForNewImages;
private javax.swing.JCheckBox cbConfirmEmptyManaPool;
private javax.swing.JCheckBox cbEnableBattlefieldBGM;
private javax.swing.JCheckBox cbEnableDraftSounds;
private javax.swing.JCheckBox cbEnableGameSounds;

View file

@ -221,12 +221,18 @@ public class HelperPanel extends JPanel {
public void setMessage(String message) {
if (message.startsWith("Use alternative cost")) {
textArea.setText("Use alternative cost?");
} else if (message.length() > 40 && message.contains("Use ")) {
textArea.setText("Use ability?");
message = "Use alternative cost?";
} else if (message.contains("Use ")) {
if (message.length() < this.getWidth() / 10) {
message = getSmallText(message);
} else {
message = "Use ability?" + getSmallText(message.substring(this.getWidth() / 10));
}
}
textArea.setText(message);
}
protected String getSmallText(String text) {
return "<div style='font-size:11pt'>" + text + "</div>";
}
@Override

View file

@ -378,11 +378,13 @@ public class PlayAreaPanel extends javax.swing.JPanel {
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the game?", "Confirm concede game", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
MageFrame.getSession().sendPlayerAction(PlayerAction.CONCEDE, gameId, null);
}
break;
}
case "Match": {
if (JOptionPane.showConfirmDialog(PlayAreaPanel.this, "Are you sure you want to concede the complete match?", "Confirm concede match", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
MageFrame.getSession().quitMatch(gameId);
}
break;
}
}
}

View file

@ -57,6 +57,7 @@ public class Connection {
private int avatarId;
private boolean showAbilityPickerForced;
private boolean allowRequestShowHandCards;
private boolean confirmEmptyManaPool;
private UserSkipPrioritySteps userSkipPrioritySteps;
private static final String serialization = "?serializationtype=jboss";
@ -242,6 +243,16 @@ public class Connection {
public void setAllowRequestShowHandCards(boolean allowRequestShowHandCards) {
this.allowRequestShowHandCards = allowRequestShowHandCards;
}
public boolean confirmEmptyManaPool() {
return confirmEmptyManaPool;
}
public void setConfirmEmptyManaPool(boolean confirmEmptyManaPool) {
this.confirmEmptyManaPool = confirmEmptyManaPool;
}
public UserSkipPrioritySteps getUserSkipPrioritySteps() {
return userSkipPrioritySteps;
}

View file

@ -278,6 +278,7 @@ public class SessionImpl implements Session {
UserDataView userDataView = new UserDataView(connection.getAvatarId(),
connection.isShowAbilityPickerForced(),
connection.allowRequestShowHandCards(),
connection.confirmEmptyManaPool(),
connection.getUserSkipPrioritySteps());
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
registerResult = server.registerClient(connection.getUsername(), sessionId, client.getVersion());
@ -1395,10 +1396,10 @@ public class SessionImpl implements Session {
}
@Override
public boolean updatePreferencesForServer(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards, UserSkipPrioritySteps userSkipPrioritySteps) {
public boolean updatePreferencesForServer(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps) {
try {
if (isConnected()) {
UserDataView userDataView = new UserDataView(avatarId, showAbilityPickerForced, allowRequestShowHandCards, userSkipPrioritySteps);
UserDataView userDataView = new UserDataView(avatarId, showAbilityPickerForced, allowRequestShowHandCards, confirmEmptyManaPool, userSkipPrioritySteps);
server.setUserData(connection.getUsername(), sessionId, userDataView);
}
return true;

View file

@ -36,5 +36,5 @@ public interface ClientData {
String getUserName();
boolean updatePreferencesForServer(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards, UserSkipPrioritySteps userSkipPrioritySteps);
boolean updatePreferencesForServer(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps);
}

View file

@ -115,7 +115,7 @@ public class PlayerView implements Serializable {
if (player.getUserData() != null) {
this.userDataView = new UserDataView(player.getUserData());
} else {
this.userDataView = new UserDataView(0, false, false, null);
this.userDataView = new UserDataView(0, false, false, true, null);
}
for (CommandObject commandObject : game.getState().getCommand()) {

View file

@ -15,13 +15,16 @@ public class UserDataView implements Serializable {
protected int userGroup;
protected boolean showAbilityPickerForced;
protected boolean allowRequestShowHandCards;
protected boolean confirmEmptyManaPool;
protected UserSkipPrioritySteps userSkipPrioritySteps;
public UserDataView(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards, UserSkipPrioritySteps userSkipPrioritySteps) {
public UserDataView(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards,
boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps) {
this.avatarId = avatarId;
this.showAbilityPickerForced = showAbilityPickerForced;
this.allowRequestShowHandCards = allowRequestShowHandCards;
this.userSkipPrioritySteps = userSkipPrioritySteps;
this.confirmEmptyManaPool = confirmEmptyManaPool;
}
public UserDataView(UserData userData) {
@ -30,6 +33,7 @@ public class UserDataView implements Serializable {
this.allowRequestShowHandCards = userData.isAllowRequestShowHandCards();
this.showAbilityPickerForced = userData.isShowAbilityPickerForced();
this.userSkipPrioritySteps = userData.getUserSkipPrioritySteps();
this.confirmEmptyManaPool = userData.confirmEmptyManaPool();
}
public int getAvatarId() {
@ -48,4 +52,8 @@ public class UserDataView implements Serializable {
return userSkipPrioritySteps;
}
public boolean confirmEmptyManaPool() {
return confirmEmptyManaPool;
}
}

View file

@ -175,7 +175,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
public ComputerPlayer(String name, RangeOfInfluence range) {
super(name, range);
human = false;
userData = new UserData(UserGroup.COMPUTER, 64, false, true, null);
userData = new UserData(UserGroup.COMPUTER, 64, false, true, false, null);
pickedCards = new ArrayList<>();
}

View file

@ -68,6 +68,7 @@ import org.apache.log4j.Logger;
import java.io.Serializable;
import java.util.*;
import mage.util.GameLog;
/**
*
@ -494,80 +495,89 @@ public class HumanPlayer extends PlayerImpl {
passed = false;
if (!abort) {
if (passedAllTurns) {
pass(game);
if(passWithManaPoolCheck(game)) {
return false;
}
}
if (game.getStack().isEmpty()) {
passedUntilStackResolved = false;
boolean dontCheckPassStep = false;
if (passedTurn) {
pass(game);
if(passWithManaPoolCheck(game)) {
return false;
}
}
if (passedUntilNextMain) {
if (game.getTurn().getStepType().equals(PhaseStep.POSTCOMBAT_MAIN) || game.getTurn().getStepType().equals(PhaseStep.PRECOMBAT_MAIN)) {
// it's a main phase
if (!skippedAtLeastOnce || (!playerId.equals(game.getActivePlayerId()) && !this.getUserData().getUserSkipPrioritySteps().isStopOnAllMainPhases())) {
skippedAtLeastOnce = true;
pass(game);
if(passWithManaPoolCheck(game)) {
return false;
}
} else {
dontCheckPassStep = true;
passedUntilNextMain = false; // reset skip action
}
} else {
skippedAtLeastOnce = true;
pass(game);
if(passWithManaPoolCheck(game)) {
return false;
}
}
}
if (passedUntilEndOfTurn) {
if (game.getTurn().getStepType().equals(PhaseStep.END_TURN)) {
// It's end of turn phase
if (!skippedAtLeastOnce || (playerId.equals(game.getActivePlayerId()) && !this.getUserData().getUserSkipPrioritySteps().isStopOnAllEndPhases())) {
skippedAtLeastOnce = true;
pass(game);
if(passWithManaPoolCheck(game)) {
return false;
}
} else {
dontCheckPassStep = true;
passedUntilEndOfTurn = false;
}
} else {
skippedAtLeastOnce = true;
pass(game);
if(passWithManaPoolCheck(game)) {
return false;
}
}
}
if (!dontCheckPassStep && checkPassStep(game)) {
pass(game);
if(passWithManaPoolCheck(game)) {
return false;
}
}
} else if (passedUntilStackResolved) {
if (dateLastAddedToStack == game.getStack().getDateLastAdded()) {
dateLastAddedToStack = game.getStack().getDateLastAdded();
pass(game);
if(passWithManaPoolCheck(game)) {
return false;
}
} else {
passedUntilStackResolved = false;
}
}
while (isInGame()) {
updateGameStatePriority("priority", game);
game.firePriorityEvent(playerId);
waitForResponse(game);
if(game.executingRollback()) {
return true;
}
if (response.getBoolean() != null) {
pass(game);
if (response.getBoolean() != null || response.getInteger() != null) {
if (passWithManaPoolCheck(game)) {
return false;
} else if (response.getInteger() != null) {
/*if (response.getInteger() == -9999) {
passedAllTurns = true;
}*/
pass(game);
//passedTurn = true;
return false;
} else if (response.getString() != null && response.getString().equals("special")) {
} else {
continue;
}
}
break;
}
if (response.getString() != null && response.getString().equals("special")) {
specialAction(game);
} else if (response.getUUID() != null) {
boolean result = false;
@ -1216,4 +1226,27 @@ public class HumanPlayer extends PlayerImpl {
super.sendPlayerAction(playerAction, game);
}
}
protected boolean passWithManaPoolCheck(Game game) {
if (userData.confirmEmptyManaPool() &&
game.getStack().isEmpty() && getManaPool().count() > 0) {
String activePlayerText;
if (game.getActivePlayerId().equals(playerId)) {
activePlayerText = "Your turn";
} else {
activePlayerText = game.getPlayer(game.getActivePlayerId()).getName() + "'s turn";
}
String priorityPlayerText = "";
if (!isGameUnderControl()) {
priorityPlayerText = " / priority " + game.getPlayer(game.getPriorityPlayerId()).getName();
}
if (!chooseUse(Outcome.Detriment, GameLog.getPlayerConfirmColoredText("You have still mana in your mana pool. Pass regardless?")
+ GameLog.getSmallSecondLineText(activePlayerText + " / " + game.getStep().getType().toString() + priorityPlayerText), game)) {
sendPlayerAction(PlayerAction.PASS_PRIORITY_CANCEL_ALL_ACTIONS, game);
return false;
}
}
pass(game);
return true;
}
}

View file

@ -142,7 +142,7 @@ public class Session {
if (user == null) {
user = UserManager.getInstance().findUser("Admin");
}
user.setUserData(new UserData(UserGroup.ADMIN, 0, false, false, null));
user.setUserData(new UserData(UserGroup.ADMIN, 0, false, false, false, null));
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
logger.info("Error connecting Admin!");
}
@ -154,7 +154,9 @@ public class Session {
if (user != null) {
UserData userData = user.getUserData();
if (userData == null) {
userData = new UserData(UserGroup.PLAYER, userDataView.getAvatarId(), userDataView.isShowAbilityPickerForced(), userDataView.allowRequestShowHandCards(), userDataView.getUserSkipPrioritySteps());
userData = new UserData(UserGroup.PLAYER, userDataView.getAvatarId(),
userDataView.isShowAbilityPickerForced(), userDataView.allowRequestShowHandCards(),
userDataView.confirmEmptyManaPool(), userDataView.getUserSkipPrioritySteps());
user.setUserData(userData);
} else {
if (userDataView.getAvatarId() == 51) { // Update special avatar if first avatar is selected
@ -164,6 +166,7 @@ public class Session {
userData.setShowAbilityPickerForced(userDataView.isShowAbilityPickerForced());
userData.setAllowRequestShowHandCards(userDataView.allowRequestShowHandCards());
userData.setUserSkipPrioritySteps(userDataView.getUserSkipPrioritySteps());
userData.setConfirmEmptyManaPool(userDataView.confirmEmptyManaPool());
}
return true;
}

View file

@ -573,6 +573,10 @@ public abstract class PlayerImpl implements Player, Serializable {
playersUnderYourControl.clear();
}
/**
* returns true if the player has the control itself - false if the player is controlled by another player
* @return
*/
@Override
public boolean isGameUnderControl() {
return isGameUnderControl;
@ -3132,5 +3136,4 @@ public abstract class PlayerImpl implements Player, Serializable {
public void abortReset() {
abort = false;
}
}

View file

@ -13,14 +13,17 @@ public class UserData implements Serializable {
protected int avatarId;
protected boolean showAbilityPickerForced;
protected boolean allowRequestShowHandCards;
protected boolean confirmEmptyManaPool;
protected UserSkipPrioritySteps userSkipPrioritySteps;
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards, UserSkipPrioritySteps userSkipPrioritySteps) {
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced,
boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps) {
this.groupId = userGroup.getGroupId();
this.avatarId = avatarId;
this.showAbilityPickerForced = showAbilityPickerForced;
this.allowRequestShowHandCards = allowRequestShowHandCards;
this.userSkipPrioritySteps = userSkipPrioritySteps;
this.confirmEmptyManaPool = confirmEmptyManaPool;
}
public void setGroupId(int groupId) {
@ -67,4 +70,12 @@ public class UserData implements Serializable {
this.userSkipPrioritySteps = userSkipPrioritySteps;
}
public boolean confirmEmptyManaPool() {
return confirmEmptyManaPool;
}
public void setConfirmEmptyManaPool(boolean confirmEmptyManaPool) {
this.confirmEmptyManaPool = confirmEmptyManaPool;
}
}

View file

@ -39,6 +39,7 @@ public class GameLog {
static final String LOG_COLOR_PLAYER = "#20B2AA"; // LightSeaGreen
static final String LOG_COLOR_PLAYER_REQUEST = "#D2691E"; // Chocolate
static final String LOG_COLOR_PLAYER_CONFIRM = "#D2691E"; // Chocolate
static final String LOG_COLOR_GREEN = "#90EE90"; // LightGreen
static final String LOG_COLOR_RED = "#FF6347"; // Tomato
static final String LOG_COLOR_BLUE = "#87CEFA"; // LightSkyBlue
@ -70,6 +71,14 @@ public class GameLog {
return "<font color=\'" + LOG_COLOR_PLAYER_REQUEST + "\'>" + name + "</font>";
}
public static String getPlayerConfirmColoredText(String name) {
return "<font color=\'" + LOG_COLOR_PLAYER_CONFIRM + "\'>" + name + "</font>";
}
public static String getSmallSecondLineText(String text) {
return "<div style='font-size:11pt'>" + text + "</div>";
}
private static String getColorName(ObjectColor objectColor) {
if (objectColor.isMulticolored()) {
return LOG_COLOR_MULTI;