mirror of
https://github.com/correl/mage.git
synced 2024-11-14 11:09:31 +00:00
* Fixed that mana auto-payment settings were not correctly set from previous settings on game start.
This commit is contained in:
parent
049f9aca7b
commit
0cbe590cac
9 changed files with 45 additions and 9 deletions
|
@ -2429,7 +2429,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GAME_CONFIRM_EMPTY_MANA_POOL, "true").equals("true"),
|
||||
getUserSkipPrioritySteps(),
|
||||
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")
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
manaPoolMenuItem2 = new JCheckBoxMenuItem("No automatic usage for mana already in the pool", true);
|
||||
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>"
|
||||
|
|
|
@ -2,7 +2,6 @@ package mage.view;
|
|||
|
||||
import java.io.Serializable;
|
||||
import mage.players.net.UserData;
|
||||
import mage.players.net.UserGroup;
|
||||
import mage.players.net.UserSkipPrioritySteps;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +21,7 @@ public class UserDataView implements Serializable {
|
|||
protected boolean askMoveToGraveOrder;
|
||||
|
||||
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,
|
||||
|
|
|
@ -175,7 +175,10 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
super(name, range);
|
||||
flagName = "computer";
|
||||
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<>();
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,9 @@ public class Session {
|
|||
if (user == null) {
|
||||
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())) {
|
||||
logger.info("Error connecting Admin!");
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ import mage.game.Table;
|
|||
import mage.game.tournament.TournamentPlayer;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.players.net.UserData;
|
||||
import mage.players.net.UserGroup;
|
||||
import mage.server.draft.DraftSession;
|
||||
import mage.server.game.GameManager;
|
||||
import mage.server.game.GameSessionPlayer;
|
||||
|
@ -400,7 +399,7 @@ public class User {
|
|||
|
||||
public UserData getUserData() {
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -1155,6 +1155,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
public synchronized void setManaPaymentMode(UUID playerId, boolean autoPayment) {
|
||||
Player player = state.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.getUserData().setManaPoolAutomatic(autoPayment);
|
||||
player.getManaPool().setAutoPayment(autoPayment);
|
||||
}
|
||||
}
|
||||
|
@ -1163,6 +1164,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
public synchronized void setManaPaymentModeRestricted(UUID playerId, boolean autoPaymentRestricted) {
|
||||
Player player = state.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.getUserData().setManaPoolAutomaticRestricted(autoPaymentRestricted);
|
||||
player.getManaPool().setAutoPaymentRestricted(autoPaymentRestricted);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2716,6 +2716,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
@Override
|
||||
public void setUserData(UserData userData) {
|
||||
this.userData = userData;
|
||||
getManaPool().setAutoPayment(userData.isManaPoolAutomatic());
|
||||
getManaPool().setAutoPaymentRestricted(userData.isManaPoolAutomaticRestricted());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,10 +17,12 @@ public class UserData implements Serializable {
|
|||
protected UserSkipPrioritySteps userSkipPrioritySteps;
|
||||
protected String flagName;
|
||||
protected boolean askMoveToGraveOrder;
|
||||
protected boolean manaPoolAutomatic;
|
||||
protected boolean manaPoolAutomaticRestricted;
|
||||
|
||||
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced,
|
||||
boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps,
|
||||
String flagName, boolean askMoveToGraveOrder) {
|
||||
String flagName, boolean askMoveToGraveOrder, boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted) {
|
||||
this.groupId = userGroup.getGroupId();
|
||||
this.avatarId = avatarId;
|
||||
this.showAbilityPickerForced = showAbilityPickerForced;
|
||||
|
@ -29,6 +31,8 @@ public class UserData implements Serializable {
|
|||
this.confirmEmptyManaPool = confirmEmptyManaPool;
|
||||
this.flagName = flagName;
|
||||
this.askMoveToGraveOrder = askMoveToGraveOrder;
|
||||
this.manaPoolAutomatic = manaPoolAutomatic;
|
||||
this.manaPoolAutomaticRestricted = manaPoolAutomaticRestricted;
|
||||
}
|
||||
|
||||
public void update(UserData userData) {
|
||||
|
@ -40,10 +44,12 @@ public class UserData implements Serializable {
|
|||
this.confirmEmptyManaPool = userData.confirmEmptyManaPool;
|
||||
this.flagName = userData.flagName;
|
||||
this.askMoveToGraveOrder = userData.askMoveToGraveOrder;
|
||||
this.manaPoolAutomatic = userData.manaPoolAutomatic;
|
||||
this.manaPoolAutomaticRestricted = userData.manaPoolAutomaticRestricted;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -98,6 +104,10 @@ public class UserData implements Serializable {
|
|||
return flagName;
|
||||
}
|
||||
|
||||
public void setFlagName(String flagName) {
|
||||
this.flagName = flagName;
|
||||
}
|
||||
|
||||
public boolean askMoveToGraveOrder() {
|
||||
return askMoveToGraveOrder;
|
||||
}
|
||||
|
@ -106,4 +116,20 @@ public class UserData implements Serializable {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue