* Fixed that mana auto-payment settings were not correctly set from previous settings on game start.

This commit is contained in:
LevelX2 2015-07-02 13:18:12 +02:00
parent 049f9aca7b
commit 0cbe590cac
9 changed files with 45 additions and 9 deletions

View file

@ -2429,7 +2429,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true").equals("true"), PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true").equals("true"),
getUserSkipPrioritySteps(), getUserSkipPrioritySteps(),
MageFrame.getPreferences().get(KEY_CONNECT_FLAG, "world"), MageFrame.getPreferences().get(KEY_CONNECT_FLAG, "world"),
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ASK_MOVE_TO_GRAVE_ORDER, "true").equals("true") PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_ASK_MOVE_TO_GRAVE_ORDER, "true").equals("true"),
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_MANA_AUTOPAYMENT_ONLY_ONE, "true").equals("true")
); );
} }

View file

@ -243,6 +243,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON : PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null); gamePanel.getSession().sendPlayerAction(manaPoolAutomatic ? PlayerAction.MANA_AUTO_PAYMENT_ON : PlayerAction.MANA_AUTO_PAYMENT_OFF, gameId, null);
} }
}); });
manaPoolMenuItem2 = new JCheckBoxMenuItem("No automatic usage for mana already in the pool", true); manaPoolMenuItem2 = new JCheckBoxMenuItem("No automatic usage for mana already in the pool", true);
manaPoolMenuItem2.setMnemonic(KeyEvent.VK_N); manaPoolMenuItem2.setMnemonic(KeyEvent.VK_N);
manaPoolMenuItem2.setToolTipText("<html>Mana that is already in the mana pool as you start casting a spell or activating an ability<br>" manaPoolMenuItem2.setToolTipText("<html>Mana that is already in the mana pool as you start casting a spell or activating an ability<br>"

View file

@ -2,7 +2,6 @@ package mage.view;
import java.io.Serializable; import java.io.Serializable;
import mage.players.net.UserData; import mage.players.net.UserData;
import mage.players.net.UserGroup;
import mage.players.net.UserSkipPrioritySteps; import mage.players.net.UserSkipPrioritySteps;
/** /**
@ -22,7 +21,7 @@ public class UserDataView implements Serializable {
protected boolean askMoveToGraveOrder; protected boolean askMoveToGraveOrder;
static UserData getDefaultUserDataView() { static UserData getDefaultUserDataView() {
return new UserData(UserGroup.DEFAULT, 0, false, false, true, null, "world.png", false); return UserData.getDefaultUserDataView();
} }
public UserDataView(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards, public UserDataView(int avatarId, boolean showAbilityPickerForced, boolean allowRequestShowHandCards,

View file

@ -175,7 +175,10 @@ public class ComputerPlayer extends PlayerImpl implements Player {
super(name, range); super(name, range);
flagName = "computer"; flagName = "computer";
human = false; human = false;
userData = new UserData(UserGroup.COMPUTER, 64, false, true, false, null, "Computer.png", false); userData = UserData.getDefaultUserDataView();
userData.setAvatarId(64);
userData.setGroupId(UserGroup.COMPUTER.getGroupId());
userData.setFlagName("Computer.png");
pickedCards = new ArrayList<>(); pickedCards = new ArrayList<>();
} }

View file

@ -140,7 +140,9 @@ public class Session {
if (user == null) { if (user == null) {
user = UserManager.getInstance().findUser("Admin"); user = UserManager.getInstance().findUser("Admin");
} }
user.setUserData(new UserData(UserGroup.ADMIN, 0, false, false, false, null, "world.png", false)); UserData adminUserData = UserData.getDefaultUserDataView();
adminUserData.setGroupId(UserGroup.ADMIN.getGroupId());
user.setUserData(adminUserData);
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) { if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
logger.info("Error connecting Admin!"); logger.info("Error connecting Admin!");
} }

View file

@ -43,7 +43,6 @@ import mage.game.Table;
import mage.game.tournament.TournamentPlayer; import mage.game.tournament.TournamentPlayer;
import mage.interfaces.callback.ClientCallback; import mage.interfaces.callback.ClientCallback;
import mage.players.net.UserData; import mage.players.net.UserData;
import mage.players.net.UserGroup;
import mage.server.draft.DraftSession; import mage.server.draft.DraftSession;
import mage.server.game.GameManager; import mage.server.game.GameManager;
import mage.server.game.GameSessionPlayer; import mage.server.game.GameSessionPlayer;
@ -400,7 +399,7 @@ public class User {
public UserData getUserData() { public UserData getUserData() {
if (userData == null) {// default these to avaiod NPE -> will be updated from client short after if (userData == null) {// default these to avaiod NPE -> will be updated from client short after
return new UserData(UserGroup.DEFAULT, 0, false, false, false, null, "world.png", false); return UserData.getDefaultUserDataView();
} }
return this.userData; return this.userData;
} }

View file

@ -1155,6 +1155,7 @@ public abstract class GameImpl implements Game, Serializable {
public synchronized void setManaPaymentMode(UUID playerId, boolean autoPayment) { public synchronized void setManaPaymentMode(UUID playerId, boolean autoPayment) {
Player player = state.getPlayer(playerId); Player player = state.getPlayer(playerId);
if (player != null) { if (player != null) {
player.getUserData().setManaPoolAutomatic(autoPayment);
player.getManaPool().setAutoPayment(autoPayment); player.getManaPool().setAutoPayment(autoPayment);
} }
} }
@ -1163,6 +1164,7 @@ public abstract class GameImpl implements Game, Serializable {
public synchronized void setManaPaymentModeRestricted(UUID playerId, boolean autoPaymentRestricted) { public synchronized void setManaPaymentModeRestricted(UUID playerId, boolean autoPaymentRestricted) {
Player player = state.getPlayer(playerId); Player player = state.getPlayer(playerId);
if (player != null) { if (player != null) {
player.getUserData().setManaPoolAutomaticRestricted(autoPaymentRestricted);
player.getManaPool().setAutoPaymentRestricted(autoPaymentRestricted); player.getManaPool().setAutoPaymentRestricted(autoPaymentRestricted);
} }
} }

View file

@ -2716,6 +2716,8 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public void setUserData(UserData userData) { public void setUserData(UserData userData) {
this.userData = userData; this.userData = userData;
getManaPool().setAutoPayment(userData.isManaPoolAutomatic());
getManaPool().setAutoPaymentRestricted(userData.isManaPoolAutomaticRestricted());
} }
@Override @Override

View file

@ -17,10 +17,12 @@ public class UserData implements Serializable {
protected UserSkipPrioritySteps userSkipPrioritySteps; protected UserSkipPrioritySteps userSkipPrioritySteps;
protected String flagName; protected String flagName;
protected boolean askMoveToGraveOrder; protected boolean askMoveToGraveOrder;
protected boolean manaPoolAutomatic;
protected boolean manaPoolAutomaticRestricted;
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced, public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced,
boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps, boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps,
String flagName, boolean askMoveToGraveOrder) { String flagName, boolean askMoveToGraveOrder, boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted) {
this.groupId = userGroup.getGroupId(); this.groupId = userGroup.getGroupId();
this.avatarId = avatarId; this.avatarId = avatarId;
this.showAbilityPickerForced = showAbilityPickerForced; this.showAbilityPickerForced = showAbilityPickerForced;
@ -29,6 +31,8 @@ public class UserData implements Serializable {
this.confirmEmptyManaPool = confirmEmptyManaPool; this.confirmEmptyManaPool = confirmEmptyManaPool;
this.flagName = flagName; this.flagName = flagName;
this.askMoveToGraveOrder = askMoveToGraveOrder; this.askMoveToGraveOrder = askMoveToGraveOrder;
this.manaPoolAutomatic = manaPoolAutomatic;
this.manaPoolAutomaticRestricted = manaPoolAutomaticRestricted;
} }
public void update(UserData userData) { public void update(UserData userData) {
@ -40,10 +44,12 @@ public class UserData implements Serializable {
this.confirmEmptyManaPool = userData.confirmEmptyManaPool; this.confirmEmptyManaPool = userData.confirmEmptyManaPool;
this.flagName = userData.flagName; this.flagName = userData.flagName;
this.askMoveToGraveOrder = userData.askMoveToGraveOrder; this.askMoveToGraveOrder = userData.askMoveToGraveOrder;
this.manaPoolAutomatic = userData.manaPoolAutomatic;
this.manaPoolAutomaticRestricted = userData.manaPoolAutomaticRestricted;
} }
public static UserData getDefaultUserDataView() { public static UserData getDefaultUserDataView() {
return new UserData(UserGroup.DEFAULT, 0, false, false, true, null, "world.png", false); return new UserData(UserGroup.DEFAULT, 0, false, false, true, null, "world.png", false, true, true);
} }
public void setGroupId(int groupId) { public void setGroupId(int groupId) {
@ -98,6 +104,10 @@ public class UserData implements Serializable {
return flagName; return flagName;
} }
public void setFlagName(String flagName) {
this.flagName = flagName;
}
public boolean askMoveToGraveOrder() { public boolean askMoveToGraveOrder() {
return askMoveToGraveOrder; return askMoveToGraveOrder;
} }
@ -106,4 +116,20 @@ public class UserData implements Serializable {
this.askMoveToGraveOrder = askMoveToGraveOrder; this.askMoveToGraveOrder = askMoveToGraveOrder;
} }
public boolean isManaPoolAutomatic() {
return manaPoolAutomatic;
}
public void setManaPoolAutomatic(boolean manaPoolAutomatic) {
this.manaPoolAutomatic = manaPoolAutomatic;
}
public boolean isManaPoolAutomaticRestricted() {
return manaPoolAutomaticRestricted;
}
public void setManaPoolAutomaticRestricted(boolean manaPoolAutomaticRestricted) {
this.manaPoolAutomaticRestricted = manaPoolAutomaticRestricted;
}
} }