1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-13 09:11:06 -09:00

Add a 'spectators allowed' option for regular tables (aka non tournaments).

This commit is contained in:
spjspj 2018-03-08 23:31:51 +11:00
parent be70ecd7f3
commit 4c7b0d50d2
6 changed files with 49 additions and 9 deletions
Mage.Client/src/main/java/mage/client
Mage.Common/src/main/java/mage/view
Mage/src/main/java/mage/game/match

View file

@ -41,6 +41,9 @@
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/> <Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="spnFreeMulligans" min="-2" pref="50" max="-2" attributes="0"/> <Component id="spnFreeMulligans" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="chkSpectatorsAllowed" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="txtName" min="-2" pref="178" max="-2" attributes="0"/> <Component id="txtName" min="-2" pref="178" max="-2" attributes="0"/>
@ -152,6 +155,7 @@
<Component id="spnFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="spnFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkRollbackTurnsAllowed" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="chkRollbackTurnsAllowed" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="chkSpectatorsAllowed" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/>
@ -274,6 +278,13 @@
<Property name="toolTipText" type="java.lang.String" value="The number of mulligans a player can use without decreasing the number of drawn cards."/> <Property name="toolTipText" type="java.lang.String" value="The number of mulligans a player can use without decreasing the number of drawn cards."/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JCheckBox" name="chkSpectatorsAllowed">
<Properties>
<Property name="text" type="java.lang.String" value="Spectators allowed"/>
<Property name="toolTipText" type="java.lang.String" value="&lt;HTML&gt;Allow to rollback to the start of previous turns&lt;br&gt;&#xa;if all players agree.&#xa;"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnFreeMulligans"> <Component class="javax.swing.JSpinner" name="spnFreeMulligans">
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblNumPlayers"> <Component class="javax.swing.JLabel" name="lblNumPlayers">

View file

@ -102,6 +102,7 @@ public class NewTableDialog extends MageDialog {
lblGameType = new javax.swing.JLabel(); lblGameType = new javax.swing.JLabel();
cbGameType = new javax.swing.JComboBox(); cbGameType = new javax.swing.JComboBox();
chkRollbackTurnsAllowed = new javax.swing.JCheckBox(); chkRollbackTurnsAllowed = new javax.swing.JCheckBox();
chkSpectatorsAllowed = new javax.swing.JCheckBox();
chkRated = new javax.swing.JCheckBox(); chkRated = new javax.swing.JCheckBox();
lblFreeMulligans = new javax.swing.JLabel(); lblFreeMulligans = new javax.swing.JLabel();
spnFreeMulligans = new javax.swing.JSpinner(); spnFreeMulligans = new javax.swing.JSpinner();
@ -151,6 +152,9 @@ public class NewTableDialog extends MageDialog {
chkRollbackTurnsAllowed.setText("Allow rollbacks"); chkRollbackTurnsAllowed.setText("Allow rollbacks");
chkRollbackTurnsAllowed.setToolTipText("<HTML>Allow to rollback to the start of previous turns<br>\nif all players agree.\n"); chkRollbackTurnsAllowed.setToolTipText("<HTML>Allow to rollback to the start of previous turns<br>\nif all players agree.\n");
chkSpectatorsAllowed.setText("Allow Spectators");
chkSpectatorsAllowed.setToolTipText("<HTML>Allow spectators to watch.\n");
chkRated.setText("Rated"); chkRated.setText("Rated");
chkRated.setToolTipText("Indicates if matches will be rated."); chkRated.setToolTipText("Indicates if matches will be rated.");
@ -231,7 +235,9 @@ public class NewTableDialog extends MageDialog {
.addGap(13, 13, 13) .addGap(13, 13, 13)
.addComponent(lblFreeMulligans) .addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(13, 13, 13)
.addComponent(chkSpectatorsAllowed))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -325,7 +331,8 @@ public class NewTableDialog extends MageDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblFreeMulligans) .addComponent(lblFreeMulligans)
.addComponent(chkRollbackTurnsAllowed)) .addComponent(chkRollbackTurnsAllowed)
.addComponent(chkSpectatorsAllowed))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblGameType))) .addComponent(lblGameType)))
@ -401,6 +408,7 @@ public class NewTableDialog extends MageDialog {
options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem()); options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem());
options.setWinsNeeded((Integer) this.spnNumWins.getValue()); options.setWinsNeeded((Integer) this.spnNumWins.getValue());
options.setRollbackTurnsAllowed(chkRollbackTurnsAllowed.isSelected()); options.setRollbackTurnsAllowed(chkRollbackTurnsAllowed.isSelected());
options.setSpectatorsAllowed(chkSpectatorsAllowed.isSelected());
options.setRated(chkRated.isSelected()); options.setRated(chkRated.isSelected());
options.setFreeMulligans((Integer) this.spnFreeMulligans.getValue()); options.setFreeMulligans((Integer) this.spnFreeMulligans.getValue());
options.setPassword(this.txtPassword.getText()); options.setPassword(this.txtPassword.getText());
@ -658,6 +666,7 @@ public class NewTableDialog extends MageDialog {
} }
this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS + versionStr, "2"))); this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS + versionStr, "2")));
this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED + versionStr, "Yes").equals("Yes")); this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED + versionStr, "Yes").equals("Yes"));
this.chkSpectatorsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, "Yes").equals("Yes"));
this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RATED + versionStr, "No").equals("Yes")); this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RATED + versionStr, "No").equals("Yes"));
this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS + versionStr, "0"))); this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS + versionStr, "0")));
@ -739,6 +748,7 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JComboBox cbSkillLevel; private javax.swing.JComboBox cbSkillLevel;
private javax.swing.JComboBox cbTimeLimit; private javax.swing.JComboBox cbTimeLimit;
private javax.swing.JCheckBox chkRollbackTurnsAllowed; private javax.swing.JCheckBox chkRollbackTurnsAllowed;
private javax.swing.JCheckBox chkSpectatorsAllowed;
private javax.swing.JCheckBox chkRated; private javax.swing.JCheckBox chkRated;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;

View file

@ -229,6 +229,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_NEW_TABLE_GAME_TYPE = "newTableGameType"; public static final String KEY_NEW_TABLE_GAME_TYPE = "newTableGameType";
public static final String KEY_NEW_TABLE_NUMBER_OF_WINS = "newTableNumberOfWins"; public static final String KEY_NEW_TABLE_NUMBER_OF_WINS = "newTableNumberOfWins";
public static final String KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED = "newTableRollbackTurnsAllowed"; public static final String KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED = "newTableRollbackTurnsAllowed";
public static final String KEY_NEW_TABLE_SPECTATORS_ALLOWED = "newTableSpectatorsAllowed";
public static final String KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS = "newTableNumberOfFreeMulligans"; public static final String KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS = "newTableNumberOfFreeMulligans";
public static final String KEY_NEW_TABLE_DECK_FILE = "newTableDeckFile"; public static final String KEY_NEW_TABLE_DECK_FILE = "newTableDeckFile";
public static final String KEY_NEW_TABLE_RANGE = "newTableRange"; public static final String KEY_NEW_TABLE_RANGE = "newTableRange";

View file

@ -1444,11 +1444,14 @@ class TableTableModel extends AbstractTableModel {
if (tables[arg0].isTournament()) { if (tables[arg0].isTournament()) {
return "Show"; return "Show";
} else { } else {
owner = tables[arg0].getControllerName(); owner = tables[arg0].getControllerName();
if (SessionHandler.getSession() != null && owner.equals(SessionHandler.getUserName())) { if (SessionHandler.getSession() != null && owner.equals(SessionHandler.getUserName())) {
return ""; return "";
} }
return "Watch"; if (tables[arg0].getSpectatorsAllowed()) {
return "Watch";
}
return "";
} }
default: default:
return ""; return "";

View file

@ -65,6 +65,7 @@ public class TableView implements Serializable {
private final boolean limited; private final boolean limited;
private final boolean rated; private final boolean rated;
private final boolean passworded; private final boolean passworded;
private final boolean spectatorsAllowed;
public TableView(Table table) { public TableView(Table table) {
this.tableId = table.getId(); this.tableId = table.getId();
@ -139,6 +140,7 @@ public class TableView implements Serializable {
this.limited = table.getMatch().getOptions().isLimited(); this.limited = table.getMatch().getOptions().isLimited();
this.rated = table.getMatch().getOptions().isRated(); this.rated = table.getMatch().getOptions().isRated();
this.passworded = !table.getMatch().getOptions().getPassword().isEmpty(); this.passworded = !table.getMatch().getOptions().getPassword().isEmpty();
this.spectatorsAllowed = table.getMatch().getOptions().isSpectatorsAllowed();
} else { } else {
// TOURNAMENT // TOURNAMENT
if (table.getTournament().getOptions().getNumberRounds() > 0) { if (table.getTournament().getOptions().getNumberRounds() > 0) {
@ -186,6 +188,7 @@ public class TableView implements Serializable {
this.limited = table.getTournament().getOptions().getMatchOptions().isLimited(); this.limited = table.getTournament().getOptions().getMatchOptions().isLimited();
this.rated = table.getTournament().getOptions().getMatchOptions().isRated(); this.rated = table.getTournament().getOptions().getMatchOptions().isRated();
this.passworded = !table.getTournament().getOptions().getPassword().isEmpty(); this.passworded = !table.getTournament().getOptions().getPassword().isEmpty();
this.spectatorsAllowed = table.getTournament().getOptions().isWatchingAllowed();
} }
} }
@ -200,6 +203,11 @@ public class TableView implements Serializable {
public String getControllerName() { public String getControllerName() {
return controllerName; return controllerName;
} }
public boolean getSpectatorsAllowed() {
return spectatorsAllowed;
}
public String getGameType() { public String getGameType() {
return gameType; return gameType;

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.game.match; package mage.game.match;
import mage.constants.MatchTimeLimit; import mage.constants.MatchTimeLimit;
@ -61,6 +60,7 @@ public class MatchOptions implements Serializable {
protected String password; protected String password;
protected SkillLevel skillLevel; protected SkillLevel skillLevel;
protected boolean rollbackTurnsAllowed; protected boolean rollbackTurnsAllowed;
protected boolean spectatorsAllowed;
protected int quitRatio; protected int quitRatio;
protected int edhPowerLevel; protected int edhPowerLevel;
protected boolean rated; protected boolean rated;
@ -79,8 +79,7 @@ public class MatchOptions implements Serializable {
this.multiPlayer = false; this.multiPlayer = false;
this.numSeats = 2; this.numSeats = 2;
}*/ }*/
public MatchOptions(String name, String gameType, boolean multiPlayer, int numSeats) {
public MatchOptions(String name, String gameType, boolean multiPlayer, int numSeats ) {
this.name = name; this.name = name;
this.gameType = gameType; this.gameType = gameType;
this.password = ""; this.password = "";
@ -178,7 +177,7 @@ public class MatchOptions implements Serializable {
public MatchTimeLimit getMatchTimeLimit() { public MatchTimeLimit getMatchTimeLimit() {
return this.matchTimeLimit; return this.matchTimeLimit;
} }
public void setMatchTimeLimit(MatchTimeLimit matchTimeLimit) { public void setMatchTimeLimit(MatchTimeLimit matchTimeLimit) {
this.matchTimeLimit = matchTimeLimit; this.matchTimeLimit = matchTimeLimit;
} }
@ -207,6 +206,14 @@ public class MatchOptions implements Serializable {
this.rollbackTurnsAllowed = rollbackTurnsAllowed; this.rollbackTurnsAllowed = rollbackTurnsAllowed;
} }
public boolean isSpectatorsAllowed() {
return spectatorsAllowed;
}
public void setSpectatorsAllowed(boolean spectatorsAllowed) {
this.spectatorsAllowed = spectatorsAllowed;
}
public int getQuitRatio() { public int getQuitRatio() {
return quitRatio; return quitRatio;
} }
@ -214,7 +221,7 @@ public class MatchOptions implements Serializable {
public void setQuitRatio(int quitRatio) { public void setQuitRatio(int quitRatio) {
this.quitRatio = quitRatio; this.quitRatio = quitRatio;
} }
public int getEdhPowerLevel() { public int getEdhPowerLevel() {
return edhPowerLevel; return edhPowerLevel;
} }