mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Continuing implementation of Planechase.
This commit is contained in:
parent
dbbc5f255c
commit
c8b741f0bf
13 changed files with 77 additions and 25 deletions
|
@ -44,6 +44,8 @@
|
|||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkSpectatorsAllowed" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
|
||||
<Component id="chkPlaneChase" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="txtName" min="-2" pref="178" max="-2" attributes="0"/>
|
||||
|
@ -156,6 +158,7 @@
|
|||
<Component id="lblFreeMulligans" 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"/>
|
||||
<Component id="chkPlaneChase" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
|
@ -284,6 +287,12 @@
|
|||
<Property name="toolTipText" type="java.lang.String" value="Allow spectators to view your game."/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="chkPlaneChase">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Use PlaneChase"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Use the PlaneChase variant for your game."/>
|
||||
</Properties>
|
||||
</Component>
|
||||
|
||||
<Component class="javax.swing.JSpinner" name="spnFreeMulligans">
|
||||
</Component>
|
||||
|
|
|
@ -102,6 +102,7 @@ public class NewTableDialog extends MageDialog {
|
|||
cbGameType = new javax.swing.JComboBox();
|
||||
chkRollbackTurnsAllowed = new javax.swing.JCheckBox();
|
||||
chkSpectatorsAllowed = new javax.swing.JCheckBox();
|
||||
chkPlaneChase = new javax.swing.JCheckBox();
|
||||
chkRated = new javax.swing.JCheckBox();
|
||||
lblFreeMulligans = new javax.swing.JLabel();
|
||||
spnFreeMulligans = new javax.swing.JSpinner();
|
||||
|
@ -154,6 +155,9 @@ public class NewTableDialog extends MageDialog {
|
|||
chkSpectatorsAllowed.setText("Allow Spectators");
|
||||
chkSpectatorsAllowed.setToolTipText("<HTML>Allow spectators to watch.\n");
|
||||
|
||||
chkPlaneChase.setText("Use PlaneChase");
|
||||
chkPlaneChase.setToolTipText("<HTML>Use planechase variant (suitable for all game types).\n");
|
||||
|
||||
chkRated.setText("Rated");
|
||||
chkRated.setToolTipText("Indicates if matches will be rated.");
|
||||
|
||||
|
@ -236,7 +240,9 @@ public class NewTableDialog extends MageDialog {
|
|||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(13, 13, 13)
|
||||
.addComponent(chkSpectatorsAllowed))
|
||||
.addComponent(chkSpectatorsAllowed)
|
||||
.addGap(13, 13, 13)
|
||||
.addComponent(chkPlaneChase))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
|
@ -331,7 +337,8 @@ public class NewTableDialog extends MageDialog {
|
|||
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblFreeMulligans)
|
||||
.addComponent(chkRollbackTurnsAllowed)
|
||||
.addComponent(chkSpectatorsAllowed))
|
||||
.addComponent(chkSpectatorsAllowed)
|
||||
.addComponent(chkPlaneChase))
|
||||
.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(lblGameType)))
|
||||
|
@ -408,6 +415,7 @@ public class NewTableDialog extends MageDialog {
|
|||
options.setWinsNeeded((Integer) this.spnNumWins.getValue());
|
||||
options.setRollbackTurnsAllowed(chkRollbackTurnsAllowed.isSelected());
|
||||
options.setSpectatorsAllowed(chkSpectatorsAllowed.isSelected());
|
||||
options.setPlaneChase(chkPlaneChase.isSelected());
|
||||
options.setRated(chkRated.isSelected());
|
||||
options.setFreeMulligans((Integer) this.spnFreeMulligans.getValue());
|
||||
options.setPassword(this.txtPassword.getText());
|
||||
|
@ -671,6 +679,7 @@ public class NewTableDialog extends MageDialog {
|
|||
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.chkSpectatorsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, "Yes").equals("Yes"));
|
||||
this.chkPlaneChase.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PLANECHASE + 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")));
|
||||
|
||||
|
@ -729,6 +738,7 @@ public class NewTableDialog extends MageDialog {
|
|||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ATTACK_OPTION + versionStr, options.getAttackOption().toString());
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL + versionStr, options.getSkillLevel().toString());
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, options.isSpectatorsAllowed() ? "Yes" : "No");
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PLANECHASE + versionStr, options.isPlaneChase() ? "Yes" : "No");
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, Integer.toString(options.getQuitRatio()));
|
||||
StringBuilder playerTypesString = new StringBuilder();
|
||||
for (Object player : players) {
|
||||
|
@ -754,6 +764,7 @@ public class NewTableDialog extends MageDialog {
|
|||
private javax.swing.JComboBox cbTimeLimit;
|
||||
private javax.swing.JCheckBox chkRollbackTurnsAllowed;
|
||||
private javax.swing.JCheckBox chkSpectatorsAllowed;
|
||||
private javax.swing.JCheckBox chkPlaneChase;
|
||||
private javax.swing.JCheckBox chkRated;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
|
|
|
@ -238,6 +238,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
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_SPECTATORS_ALLOWED = "newTableSpectatorsAllowed";
|
||||
public static final String KEY_NEW_TABLE_PLANECHASE = "newTablePlaneChase";
|
||||
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_RANGE = "newTableRange";
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
*/
|
||||
package mage.client.util;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -44,7 +43,7 @@ public final class CardsViewUtil {
|
|||
public static CardsView convertSimple(SimpleCardsView view) {
|
||||
CardsView cards = new CardsView();
|
||||
|
||||
for (SimpleCardView simple: view.values()) {
|
||||
for (SimpleCardView simple : view.values()) {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
|
||||
Card card = cardInfo != null ? cardInfo.getMockCard() : null;
|
||||
if (card != null) {
|
||||
|
@ -54,15 +53,14 @@ public final class CardsViewUtil {
|
|||
|
||||
return cards;
|
||||
}
|
||||
|
||||
|
||||
public static CardsView convertSimple(SimpleCardsView view, Map<String, Card> loadedCards) {
|
||||
CardsView cards = new CardsView();
|
||||
|
||||
for (SimpleCardView simple: view.values()) {
|
||||
for (SimpleCardView simple : view.values()) {
|
||||
String key = simple.getExpansionSetCode() + '_' + simple.getCardNumber();
|
||||
Card card = loadedCards.get(key);
|
||||
if(card == null)
|
||||
{
|
||||
if (card == null) {
|
||||
CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
|
||||
card = cardInfo != null ? cardInfo.getMockCard() : null;
|
||||
loadedCards.put(key, card);
|
||||
|
@ -79,12 +77,15 @@ public final class CardsViewUtil {
|
|||
CardsView cards = new CardsView();
|
||||
|
||||
for (CommandObjectView commandObject : view) {
|
||||
if(commandObject instanceof EmblemView ){
|
||||
CardView cardView = new CardView((EmblemView)commandObject);
|
||||
if (commandObject instanceof EmblemView) {
|
||||
CardView cardView = new CardView((EmblemView) commandObject);
|
||||
cards.put(commandObject.getId(), cardView);
|
||||
}
|
||||
else if(commandObject instanceof CommanderView ){
|
||||
cards.put(commandObject.getId(),(CommanderView)commandObject);
|
||||
} else if (commandObject instanceof PlaneView) {
|
||||
CardView cardView = null;
|
||||
cardView = new CardView((PlaneView) commandObject);
|
||||
cards.put(commandObject.getId(), cardView);
|
||||
} else if (commandObject instanceof CommanderView) {
|
||||
cards.put(commandObject.getId(), (CommanderView) commandObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -768,6 +768,9 @@ public class CardView extends SimpleCardView {
|
|||
|
||||
@Override
|
||||
public String getExpansionSetCode() {
|
||||
if (expansionSetCode == null) {
|
||||
expansionSetCode = "";
|
||||
}
|
||||
return expansionSetCode;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,8 @@ public class TableController {
|
|||
} else {
|
||||
controllerName = "System";
|
||||
}
|
||||
table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getDeckType()), options.getPlayerTypes(), TableRecorderImpl.instance, match, options.getBannedUsers());
|
||||
table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getDeckType()),
|
||||
options.getPlayerTypes(), TableRecorderImpl.instance, match, options.getBannedUsers(), options.isPlaneChase());
|
||||
chatId = ChatManager.instance.createChatSession("Match Table " + table.getId());
|
||||
init();
|
||||
}
|
||||
|
@ -119,7 +120,8 @@ public class TableController {
|
|||
} else {
|
||||
controllerName = "System";
|
||||
}
|
||||
table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), TableRecorderImpl.instance, tournament, options.getMatchOptions().getBannedUsers());
|
||||
table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.instance.createDeckValidator(options.getMatchOptions().getDeckType()),
|
||||
options.getPlayerTypes(), TableRecorderImpl.instance, tournament, options.getMatchOptions().getBannedUsers(), options.isPlaneChase());
|
||||
chatId = ChatManager.instance.createChatSession("Tourn. table " + table.getId());
|
||||
}
|
||||
|
||||
|
@ -615,6 +617,7 @@ public class TableController {
|
|||
GameOptions gameOptions = new GameOptions();
|
||||
gameOptions.rollbackTurnsAllowed = match.getOptions().isRollbackTurnsAllowed();
|
||||
gameOptions.bannedUsers = match.getOptions().getBannedUsers();
|
||||
gameOptions.planeChase = match.getOptions().isPlaneChase();
|
||||
match.getGame().setGameOptions(gameOptions);
|
||||
GameManager.instance.createGameSession(match.getGame(), userPlayerMap, table.getId(), choosingPlayerId, gameOptions);
|
||||
String creator = null;
|
||||
|
|
|
@ -51,6 +51,6 @@ public enum MainPhaseStackEmptyCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "during the main phase and the stack is empty";
|
||||
return "during the main phase when the stack is empty";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1074,7 +1074,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
|
||||
// 20180408 - 901.5
|
||||
if (state.isPlaneChase()) {
|
||||
if (gameOptions.planeChase) {
|
||||
addPlane(Plane.getRandomPlane(), null, getActivePlayerId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,5 +50,10 @@ public class GameOptions implements Serializable {
|
|||
* Names of users banned from participating in the game
|
||||
*/
|
||||
public Set<String> bannedUsers = Collections.emptySet();
|
||||
|
||||
/**
|
||||
* Use planechase variant
|
||||
*/
|
||||
public boolean planeChase = false;
|
||||
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public class Table implements Serializable {
|
|||
private Tournament tournament;
|
||||
private TableRecorder recorder;
|
||||
private Set<String> bannedUsernames;
|
||||
private boolean isPlaneChase;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface TableRecorder {
|
||||
|
@ -70,21 +71,21 @@ public class Table implements Serializable {
|
|||
|
||||
protected TableEventSource tableEventSource = new TableEventSource();
|
||||
|
||||
public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<PlayerType> playerTypes, TableRecorder recorder, Tournament tournament, Set<String> bannedUsernames) {
|
||||
this(roomId, gameType, name, controllerName, validator, playerTypes, recorder, bannedUsernames);
|
||||
public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<PlayerType> playerTypes, TableRecorder recorder, Tournament tournament, Set<String> bannedUsernames, boolean isPlaneChase) {
|
||||
this(roomId, gameType, name, controllerName, validator, playerTypes, recorder, bannedUsernames, isPlaneChase);
|
||||
this.tournament = tournament;
|
||||
this.isTournament = true;
|
||||
setState(TableState.WAITING);
|
||||
}
|
||||
|
||||
public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<PlayerType> playerTypes, TableRecorder recorder, Match match, Set<String> bannedUsernames) {
|
||||
this(roomId, gameType, name, controllerName, validator, playerTypes, recorder, bannedUsernames);
|
||||
public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<PlayerType> playerTypes, TableRecorder recorder, Match match, Set<String> bannedUsernames, boolean isPlaneChase) {
|
||||
this(roomId, gameType, name, controllerName, validator, playerTypes, recorder, bannedUsernames, isPlaneChase);
|
||||
this.match = match;
|
||||
this.isTournament = false;
|
||||
setState(TableState.WAITING);
|
||||
}
|
||||
|
||||
protected Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<PlayerType> playerTypes, TableRecorder recorder, Set<String> bannedUsernames) {
|
||||
protected Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<PlayerType> playerTypes, TableRecorder recorder, Set<String> bannedUsernames, boolean isPlaneChase) {
|
||||
tableId = UUID.randomUUID();
|
||||
this.roomId = roomId;
|
||||
this.numSeats = playerTypes.size();
|
||||
|
@ -96,6 +97,7 @@ public class Table implements Serializable {
|
|||
this.validator = validator;
|
||||
this.recorder = recorder;
|
||||
this.bannedUsernames = new HashSet<>(bannedUsernames);
|
||||
this.isPlaneChase = isPlaneChase;
|
||||
}
|
||||
|
||||
private void createSeats(List<PlayerType> playerTypes) {
|
||||
|
|
|
@ -59,13 +59,12 @@ import mage.watchers.common.PlanarRollWatcher;
|
|||
public class FeedingGroundsPlane extends Plane {
|
||||
|
||||
private static final FilterCard filter = new FilterCard("Red spells or Green spells");
|
||||
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("Red or Green creature");
|
||||
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent("a creature");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.or(
|
||||
new ColorPredicate(ObjectColor.RED),
|
||||
new ColorPredicate(ObjectColor.GREEN)));
|
||||
filter2.add(Predicates.or(new ColorPredicate(ObjectColor.RED), new ColorPredicate(ObjectColor.GREEN)));
|
||||
}
|
||||
|
||||
private static final String rule = "put X +1/+1 counters on target creature, where X is that creature's converted mana cost";
|
||||
|
|
|
@ -61,6 +61,7 @@ public class MatchOptions implements Serializable {
|
|||
protected SkillLevel skillLevel;
|
||||
protected boolean rollbackTurnsAllowed;
|
||||
protected boolean spectatorsAllowed;
|
||||
protected boolean planeChase;
|
||||
protected int quitRatio;
|
||||
protected int edhPowerLevel;
|
||||
protected boolean rated;
|
||||
|
@ -213,6 +214,14 @@ public class MatchOptions implements Serializable {
|
|||
public void setSpectatorsAllowed(boolean spectatorsAllowed) {
|
||||
this.spectatorsAllowed = spectatorsAllowed;
|
||||
}
|
||||
|
||||
public boolean isPlaneChase() {
|
||||
return planeChase;
|
||||
}
|
||||
|
||||
public void setPlaneChase(boolean planeChase) {
|
||||
this.planeChase = planeChase;
|
||||
}
|
||||
|
||||
public int getQuitRatio() {
|
||||
return quitRatio;
|
||||
|
|
|
@ -46,6 +46,7 @@ public class TournamentOptions implements Serializable {
|
|||
protected MatchOptions matchOptions;
|
||||
protected LimitedOptions limitedOptions;
|
||||
protected boolean watchingAllowed = true;
|
||||
protected boolean planeChase = false;
|
||||
protected int numberRounds;
|
||||
protected String password;
|
||||
protected int quitRatio;
|
||||
|
@ -91,6 +92,14 @@ public class TournamentOptions implements Serializable {
|
|||
this.watchingAllowed = watchingAllowed;
|
||||
}
|
||||
|
||||
public boolean isPlaneChase() {
|
||||
return planeChase;
|
||||
}
|
||||
|
||||
public void setPlaneChase(boolean planeChase) {
|
||||
this.planeChase = planeChase;
|
||||
}
|
||||
|
||||
public int getNumberRounds() {
|
||||
return numberRounds;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue