From d217d332b6092b0ff80762e1efe3b548007078c9 Mon Sep 17 00:00:00 2001 From: BetaSteward Date: Fri, 11 Feb 2011 22:57:22 -0500 Subject: [PATCH] added sorting and counts to deck editor --- .../main/java/mage/client/cards/CardGrid.java | 51 +++- .../java/mage/client/cards/CardsList.form | 84 ++++++- .../java/mage/client/cards/CardsList.java | 156 +++++++++++-- .../java/mage/client/constants/Constants.java | 19 ++ .../mage/client/deckeditor/CardSelector.form | 26 ++- .../mage/client/deckeditor/CardSelector.java | 48 ++-- .../java/mage/client/deckeditor/DeckArea.java | 5 +- .../java/mage/client/draft/DraftPanel.java | 5 +- Mage.Common/src/mage/view/CardView.java | 6 + .../Mage.Draft.8PlayerBooster/pom.xml | 49 ---- .../plugins/mage-draft-8playerbooster.jar | Bin 2635 -> 0 bytes Mage/src/mage/ObjectColor.java | 38 ++- src/mage/game/tournament/TournamentImpl.java | 219 ------------------ .../game/tournament/TournamentPlayer.java | 115 --------- .../TournamentSingleElimination.java | 58 ----- 15 files changed, 372 insertions(+), 507 deletions(-) delete mode 100644 Mage.Server.Plugins/Mage.Draft.8PlayerBooster/pom.xml delete mode 100644 Mage.Server/plugins/mage-draft-8playerbooster.jar delete mode 100644 src/mage/game/tournament/TournamentImpl.java delete mode 100644 src/mage/game/tournament/TournamentPlayer.java delete mode 100644 src/mage/game/tournament/TournamentSingleElimination.java diff --git a/Mage.Client/src/main/java/mage/client/cards/CardGrid.java b/Mage.Client/src/main/java/mage/client/cards/CardGrid.java index 619160c565..7a7547e5fb 100644 --- a/Mage.Client/src/main/java/mage/client/cards/CardGrid.java +++ b/Mage.Client/src/main/java/mage/client/cards/CardGrid.java @@ -50,6 +50,7 @@ import java.util.UUID; import java.util.Map.Entry; import mage.cards.MageCard; +import mage.client.constants.Constants.SortBy; import mage.client.plugins.impl.Plugins; import mage.client.util.Config; import mage.client.util.Event; @@ -74,7 +75,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener setOpaque(false); } - public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) { + public void loadCards(CardsView showCards, SortBy sortBy, BigCard bigCard, UUID gameId) { this.bigCard = bigCard; this.gameId = gameId; for (CardView card: showCards.values()) { @@ -89,7 +90,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener i.remove(); } } - drawCards(); + drawCards(sortBy); this.setVisible(true); } @@ -105,7 +106,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener cards.put(card.getId(), cardImg); } - public void drawCards() { + public void drawCards(SortBy sortBy) { int maxWidth = this.getParent().getWidth(); int numColumns = maxWidth / Config.dimensions.frameWidth; int curColumn = 0; @@ -113,7 +114,20 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener if (cards.size() > 0) { Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight); List sortedCards = new ArrayList(cards.values()); - Collections.sort(sortedCards, new CardComparator()); + switch (sortBy) { + case NAME: + Collections.sort(sortedCards, new CardNameComparator()); + break; + case RARITY: + Collections.sort(sortedCards, new CardRarityComparator()); + break; + case COLOR: + Collections.sort(sortedCards, new CardColorComparator()); + break; + case CASTING_COST: + Collections.sort(sortedCards, new CardCostComparator()); + break; + } for (MageCard cardImg: sortedCards) { rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20); cardImg.setBounds(rectangle); @@ -229,11 +243,38 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener } } -class CardComparator implements Comparator { +class CardNameComparator implements Comparator { @Override public int compare(MageCard o1, MageCard o2) { return o1.getOriginal().getName().compareTo(o2.getOriginal().getName()); } +} + +class CardRarityComparator implements Comparator { + + @Override + public int compare(MageCard o1, MageCard o2) { + return o1.getOriginal().getRarity().compareTo(o2.getOriginal().getRarity()); + } + +} + +class CardCostComparator implements Comparator { + + @Override + public int compare(MageCard o1, MageCard o2) { + return Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost())); + } + +} + +class CardColorComparator implements Comparator { + + @Override + public int compare(MageCard o1, MageCard o2) { + return o1.getOriginal().getColor().compareTo(o2.getOriginal().getColor()); + } + } \ No newline at end of file diff --git a/Mage.Client/src/main/java/mage/client/cards/CardsList.form b/Mage.Client/src/main/java/mage/client/cards/CardsList.form index dd8e29b3cd..773addc57e 100644 --- a/Mage.Client/src/main/java/mage/client/cards/CardsList.form +++ b/Mage.Client/src/main/java/mage/client/cards/CardsList.form @@ -21,17 +21,27 @@ - - + + + + + + + + + + + + + + + + + - - - - - @@ -41,5 +51,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mage.Client/src/main/java/mage/client/cards/CardsList.java b/Mage.Client/src/main/java/mage/client/cards/CardsList.java index 69510a2252..3b9ca08f00 100644 --- a/Mage.Client/src/main/java/mage/client/cards/CardsList.java +++ b/Mage.Client/src/main/java/mage/client/cards/CardsList.java @@ -44,8 +44,11 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.UUID; +import javax.swing.DefaultComboBoxModel; +import mage.Constants.CardType; import mage.cards.MageCard; +import mage.client.constants.Constants.SortBy; import mage.client.plugins.impl.Plugins; import mage.client.util.Config; import mage.client.util.Event; @@ -61,6 +64,9 @@ public class CardsList extends javax.swing.JPanel implements MouseListener { protected CardEventSource cardEventSource = new CardEventSource(); private Dimension cardDimension; + private CardsView cards; + protected BigCard bigCard; + protected UUID gameId; /** Creates new form Cards */ public CardsList() { @@ -68,32 +74,64 @@ public class CardsList extends javax.swing.JPanel implements MouseListener { jScrollPane1.setOpaque(false); cardArea.setOpaque(false); jScrollPane1.getViewport().setOpaque(false); + cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values())); } public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) { - loadCards(showCards, bigCard, gameId, false); + loadCards(showCards, bigCard, gameId, SortBy.UNSORTED); } - public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId, boolean sorted) { + public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId, SortBy sortBy) { //FIXME: why we remove all cards? for performance it's better to merge changes + cards = showCards; + this.bigCard = bigCard; + this.gameId = gameId; + drawCards(sortBy); + } + + private void drawCards(SortBy sortBy) { + int maxWidth = this.getParent().getWidth(); + int numColumns = maxWidth / Config.dimensions.frameWidth; + int curColumn = 0; + int curRow = 0; + int landCount = 0; + int creatureCount = 0; cardArea.removeAll(); - if (showCards != null && showCards.size() > 0) { + if (cards != null && cards.size() > 0) { Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight); int count = 0; - List sortedCards = new ArrayList(showCards.values()); - if (sorted) - Collections.sort(sortedCards, new CardViewComparator()); + List sortedCards = new ArrayList(cards.values()); + switch (sortBy) { + case NAME: + Collections.sort(sortedCards, new CardViewNameComparator()); + break; + case RARITY: + Collections.sort(sortedCards, new CardViewRarityComparator()); + break; + case COLOR: + Collections.sort(sortedCards, new CardViewColorComparator()); + break; + case CASTING_COST: + Collections.sort(sortedCards, new CardViewCostComparator()); + break; + } for (CardView card: sortedCards) { + rectangle.setLocation(curColumn * Config.dimensions.frameWidth, curRow * 20); addCard(card, bigCard, gameId, rectangle); - if (count >= 10) { - rectangle.translate(Config.dimensions.frameWidth, -200); - count = 0; - } else { - rectangle.translate(0, 20); - count++; + if (card.getCardTypes().contains(CardType.LAND)) + landCount++; + if (card.getCardTypes().contains(CardType.CREATURE)) + creatureCount++; + curColumn++; + if (curColumn == numColumns) { + curColumn = 0; + curRow++; } } } + this.lblCount.setText("Count: " + Integer.toString(cards.size())); + this.lblCreatureCount.setText("Creatures: " + Integer.toString(creatureCount)); + this.lblLandCount.setText("Lands: " + Integer.toString(landCount)); cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 200)); cardArea.revalidate(); this.revalidate(); @@ -133,20 +171,81 @@ public class CardsList extends javax.swing.JPanel implements MouseListener { jScrollPane1 = new javax.swing.JScrollPane(); cardArea = new javax.swing.JLayeredPane(); + jPanel1 = new javax.swing.JPanel(); + cbSortBy = new javax.swing.JComboBox(); + lblCount = new javax.swing.JLabel(); + lblCreatureCount = new javax.swing.JLabel(); + lblLandCount = new javax.swing.JLabel(); setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); setPreferredSize((!Beans.isDesignTime())?(new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight)):(new Dimension(100, 100))); - setLayout(new java.awt.BorderLayout()); jScrollPane1.setViewportView(cardArea); - add(jScrollPane1, java.awt.BorderLayout.CENTER); + cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + cbSortBy.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cbSortByActionPerformed(evt); + } + }); + + lblCount.setText("Card Count"); + + lblCreatureCount.setText("Creature Count"); + + lblLandCount.setText("Land Count"); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() + .addComponent(lblCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(lblCreatureCount, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(lblLandCount) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(cbSortBy, javax.swing.GroupLayout.PREFERRED_SIZE, 338, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(cbSortBy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblCount) + .addComponent(lblCreatureCount) + .addComponent(lblLandCount)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 553, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)) + ); }// //GEN-END:initComponents + private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed + drawCards((SortBy) cbSortBy.getSelectedItem()); + }//GEN-LAST:event_cbSortByActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLayeredPane cardArea; + private javax.swing.JComboBox cbSortBy; + private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel lblCount; + private javax.swing.JLabel lblCreatureCount; + private javax.swing.JLabel lblLandCount; // End of variables declaration//GEN-END:variables @Override @@ -180,11 +279,38 @@ public class CardsList extends javax.swing.JPanel implements MouseListener { } -class CardViewComparator implements Comparator { +class CardViewNameComparator implements Comparator { @Override public int compare(CardView o1, CardView o2) { return o1.getName().compareTo(o2.getName()); } +} + +class CardViewRarityComparator implements Comparator { + + @Override + public int compare(CardView o1, CardView o2) { + return o1.getRarity().compareTo(o2.getRarity()); + } + +} + +class CardViewCostComparator implements Comparator { + + @Override + public int compare(CardView o1, CardView o2) { + return Integer.valueOf(o1.getConvertedManaCost()).compareTo(Integer.valueOf(o2.getConvertedManaCost())); + } + +} + +class CardViewColorComparator implements Comparator { + + @Override + public int compare(CardView o1, CardView o2) { + return o1.getColor().compareTo(o2.getColor()); + } + } \ No newline at end of file diff --git a/Mage.Client/src/main/java/mage/client/constants/Constants.java b/Mage.Client/src/main/java/mage/client/constants/Constants.java index 6915df6985..0eac53f690 100644 --- a/Mage.Client/src/main/java/mage/client/constants/Constants.java +++ b/Mage.Client/src/main/java/mage/client/constants/Constants.java @@ -92,4 +92,23 @@ public final class Constants { Sideboard } + public enum SortBy { + CASTING_COST ("Casting Cost"), + RARITY ("Rarity"), + COLOR ("Color"), + NAME ("Name"), + UNSORTED ("Unsorted"); + + private String text; + + SortBy(String text) { + this.text = text; + } + + @Override + public String toString() { + return text; + } + } + } diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.form b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.form index 0ab0eb66fe..a317ec55e0 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.form +++ b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.form @@ -151,17 +151,6 @@ - - - - - - - - - - - @@ -266,6 +255,21 @@ + + + + + + + + + + + + + + + diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java index 69499db2bc..7ad58865f3 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java @@ -45,6 +45,7 @@ import mage.cards.ExpansionSet; import mage.client.cards.BigCard; import mage.client.cards.CardGrid; import mage.client.cards.CardsStorage; +import mage.client.constants.Constants.SortBy; import mage.filter.Filter.ComparisonScope; import mage.filter.FilterCard; import mage.sets.Sets; @@ -68,13 +69,13 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene cardGrid.setOpaque(false); jScrollPane1.setOpaque(false); jScrollPane1.getViewport().setOpaque(false); + cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values())); } public void loadCards(List sideboard, BigCard bigCard, boolean construct) { this.bigCard = bigCard; this.btnBooster.setVisible(false); this.btnClear.setVisible(false); - this.btnAddLand.setVisible(construct); this.cbExpansionSet.setVisible(false); this.cards.clear(); for (Card card: sideboard) { @@ -88,7 +89,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene this.bigCard = bigCard; this.btnBooster.setVisible(true); this.btnClear.setVisible(true); - this.btnAddLand.setVisible(false); this.cbExpansionSet.setVisible(true); Object[] l = Sets.getInstance().values().toArray(); Arrays.sort(l, new Comparator() { @@ -142,7 +142,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene filteredCards.add(card); } } - this.cardGrid.loadCards(new CardsView(filteredCards), bigCard, null); + this.cardGrid.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), bigCard, null); } finally { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); @@ -188,7 +188,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene cbExpansionSet = new javax.swing.JComboBox(); btnBooster = new javax.swing.JButton(); btnClear = new javax.swing.JButton(); - btnAddLand = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); cardGrid = new mage.client.cards.CardGrid(); tbTypes = new javax.swing.JToolBar(); @@ -199,6 +198,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene rdoInstants = new javax.swing.JRadioButton(); rdoSorceries = new javax.swing.JRadioButton(); rdoPlaneswalkers = new javax.swing.JRadioButton(); + cbSortBy = new javax.swing.JComboBox(); tbColor.setFloatable(false); tbColor.setRollover(true); @@ -305,17 +305,6 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene }); tbColor.add(btnClear); - btnAddLand.setText("Add Land"); - btnAddLand.setFocusable(false); - btnAddLand.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - btnAddLand.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - btnAddLand.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnAddLandActionPerformed(evt); - } - }); - tbColor.add(btnAddLand); - jScrollPane1.setViewportView(cardGrid); tbTypes.setFloatable(false); @@ -405,6 +394,14 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene }); tbTypes.add(rdoPlaneswalkers); + cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + cbSortBy.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cbSortByActionPerformed(evt); + } + }); + tbTypes.add(cbSortBy); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -531,17 +528,18 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene filterCards(); }//GEN-LAST:event_btnBoosterActionPerformed - private void btnAddLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddLandActionPerformed - - }//GEN-LAST:event_btnAddLandActionPerformed + private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed + if (cbSortBy.getSelectedItem() instanceof SortBy) + this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem()); + }//GEN-LAST:event_cbSortByActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton btnAddLand; private javax.swing.JButton btnBooster; private javax.swing.JButton btnClear; private mage.client.cards.CardGrid cardGrid; private javax.swing.JComboBox cbExpansionSet; + private javax.swing.JComboBox cbSortBy; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JRadioButton rdoArtifacts; private javax.swing.JRadioButton rdoBlack; @@ -562,22 +560,26 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene @Override public void componentResized(ComponentEvent e) { - this.cardGrid.drawCards(); + if (cbSortBy.getSelectedItem() instanceof SortBy) + this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem()); } @Override public void componentMoved(ComponentEvent e) { - this.cardGrid.drawCards(); + if (cbSortBy.getSelectedItem() instanceof SortBy) + this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem()); } @Override public void componentShown(ComponentEvent e) { - this.cardGrid.drawCards(); + if (cbSortBy.getSelectedItem() instanceof SortBy) + this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem()); } @Override public void componentHidden(ComponentEvent e) { - this.cardGrid.drawCards(); + if (cbSortBy.getSelectedItem() instanceof SortBy) + this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem()); } } diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/DeckArea.java b/Mage.Client/src/main/java/mage/client/deckeditor/DeckArea.java index 5a8eebced7..7be22adb2e 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/DeckArea.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/DeckArea.java @@ -38,6 +38,7 @@ package mage.client.deckeditor; import mage.cards.decks.Deck; import mage.client.cards.BigCard; import mage.client.cards.CardsList; +import mage.client.constants.Constants.SortBy; import mage.client.util.Event; import mage.client.util.Listener; import mage.view.CardsView; @@ -61,9 +62,9 @@ public class DeckArea extends javax.swing.JPanel { } public void loadDeck(Deck deck, BigCard bigCard) { - deckList.loadCards(new CardsView(deck.getCards()), bigCard, null, true); + deckList.loadCards(new CardsView(deck.getCards()), bigCard, null, SortBy.NAME); if (sideboardList.isVisible()) - sideboardList.loadCards(new CardsView(deck.getSideboard()), bigCard, null, true); + sideboardList.loadCards(new CardsView(deck.getSideboard()), bigCard, null, SortBy.NAME); } public void addDeckEventListener(Listener listener) { diff --git a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java index cdb949e5b4..9bd5c9d9df 100644 --- a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java +++ b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java @@ -40,6 +40,7 @@ import java.awt.event.ActionListener; import java.util.UUID; import javax.swing.Timer; import mage.client.MageFrame; +import mage.client.constants.Constants.SortBy; import mage.client.remote.Session; import mage.client.util.Event; import mage.client.util.Listener; @@ -97,7 +98,7 @@ public class DraftPanel extends javax.swing.JPanel { public void loadBooster(DraftPickView draftPickView) { draftBooster.loadBooster(draftPickView.getBooster(), bigCard); - draftPicks.loadCards(draftPickView.getPicks(), bigCard, null); + draftPicks.loadCards(draftPickView.getPicks(), SortBy.NAME, bigCard, null); this.draftBooster.clearCardEventListeners(); this.draftBooster.addCardEventListener( new Listener () { @@ -107,7 +108,7 @@ public class DraftPanel extends javax.swing.JPanel { DraftPickView view = session.sendCardPick(draftId, (UUID)event.getSource()); if (view != null) { draftBooster.loadBooster(view.getBooster(), bigCard); - draftPicks.loadCards(view.getPicks(), bigCard, null); + draftPicks.loadCards(view.getPicks(), SortBy.NAME, bigCard, null); setMessage("Waiting for other players"); } } diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java index 3d16d7c820..1474749aa6 100644 --- a/Mage.Common/src/mage/view/CardView.java +++ b/Mage.Common/src/mage/view/CardView.java @@ -64,6 +64,7 @@ public class CardView implements Serializable { protected List superTypes; protected ObjectColor color; protected List manaCost; + protected int convertedManaCost; protected String art; protected Rarity rarity; protected String expansionSetCode; @@ -91,6 +92,7 @@ public class CardView implements Serializable { this.superTypes = card.getSupertype(); this.color = card.getColor(); this.manaCost = card.getManaCost().getSymbols(); + this.convertedManaCost = card.getManaCost().convertedManaCost(); if (card instanceof PermanentToken) { this.art = ""; this.rarity = Rarity.NA; @@ -209,6 +211,10 @@ public class CardView implements Serializable { return manaCost; } + public int getConvertedManaCost() { + return convertedManaCost; + } + public String getArt() { return art; } diff --git a/Mage.Server.Plugins/Mage.Draft.8PlayerBooster/pom.xml b/Mage.Server.Plugins/Mage.Draft.8PlayerBooster/pom.xml deleted file mode 100644 index 3a3d408d82..0000000000 --- a/Mage.Server.Plugins/Mage.Draft.8PlayerBooster/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - 4.0.0 - - - org.mage - mage-root - 0.6 - - - Mage-Draft-8PlayerBooster - jar - Mage Draft 8 Player Booster - - - - ${project.groupId} - Mage - ${project.version} - - - - - src - - - org.apache.maven.plugins - maven-compiler-plugin - 2.0.2 - - 1.6 - 1.6 - - - - maven-resources-plugin - - UTF-8 - - - - - - mage-draft-8playerbooster - - - - diff --git a/Mage.Server/plugins/mage-draft-8playerbooster.jar b/Mage.Server/plugins/mage-draft-8playerbooster.jar deleted file mode 100644 index 918f6dc92dc8ecd597402f87a3bd0cac5760b9d7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2635 zcmWIWW@h1H00Gurns#6Yl;8x?zOEsTx}JV+`T|F{J{ftASVqS(&e+ zpQoE^aEP9-+h^Z1r+vJ2^)B*y>uQ}lbAEG>!4=~NPm6TC&YjTl)^*}wf3hTOikS8R zm5QBnx`TwhgMv%uYONKK;TD=~93)yJd^+eeP{zx+*z3R}znPYn0(D*M!oAE+6d2n! zS13Ej>BZ?Wz?{Xv;J*#k^{hZ=by^lMO zKmYZ6{rdY1caDVdndzlWJie)|yE4W})BR#9Z@5X!)eVahLl2vBr*ez7`2<%5ZI$p! zEkE)5(96#Y3#t_Fho7tM?Ppf4)z1p~CJ}VI&fnn7u1muGZio9g=6^ibVDx$2{in^g za$dD^>cOuZ+<3eV^L;AMe^*v@I(#Q#!=D**6Mz1{D|u<+qlHNx)3#1}x$V*2!|gT_ z-%o8zz5h5%Bxuja{8e`o4Kn<$Tv{ZybDKTa?njMRdRpyIZ=L?9rzNp#7{(@d`2A9c?pAKZ{qz_q-yIb?ywv#R7BjcH$%g|Jv z(iWq9|GHN}Rvvqu`-H9;>fBnEk=pNHcVXIPu1RhOwKlbwcFDd9J#IPcAy;p~T(yYh zjCo1iymw4rz1i_T;;v+rm}b0&nz2ge$(k#XN*8|rypKq-=oyY5IVa^NmZj#w(*W_ej+V@%hs zUz3))F-}!!XW8y?UNLC1?7~|OysDF&Ua-txXj}T8HTjF2uJE4sU(c%LU2RUhnH&5q zY|`AmYu{Nd8~>=ZTv9l0w2bxF>?b|XUvf|MJzMs2o2BN#Yuvee3uJdSC5B%#YBKMe z=g4Zq>?gTmvz^tCE6w6{d;dNzZn61f_3%!}?90buXI#Jj?ZoQ?p3k3s=u7X&Jy!lB zWb>mx`az4PiR8^RVRD)mq?*~(p5VW}>(-9dY~iIZR4qc?@jbf#t2`FYl15uSWmltsqaa}|1(QVI_^sW%gXIkIT#xdn||5!?re_EH8WSX%g1btv{P_%UrFv z-!V1)`%2ln^PULbZ@s;rHz*`w7JKXE10FjKy_)yKG6Dy<>`qiMW+(-wCQy~)Kz6Ds zD9SHLEh@=OE#^IOkgM5%hv7o?!v6vva#pe?a>X4xcEdqphx~~&ou+KJo~HW!a`(0K zrg#KowtQ!_eK%!|W}EIoX5k-fP8r$v+t}6}=5AWAm0dQe^x2il@ZD!L_WXU9d|c?R zxN>CkqR%bzXKy~&&~KVNZTa&i_LDO!Lxr;c1$Z+ui7?}?PJ#Xc0s)4%jvyMTa)oKb zUcG`8gTRtTbs!1XhE&-iTa2wH1ZxLdybs8P77{Q^vDb_UEe~N@VD%(SBlemSq7md; zE?_AEwhN*Wv))8@HhNJ7Dh(k(fZ_lDLSQuv_c*L4?xg4^uNzS&7>eP-%%U zq5$;Od=0nR;L`Y)KP6%tN*vPd8k+}lAS%Ic7FmM6k M3t%J3mmS0d0Aq5C5dZ)H diff --git a/Mage/src/mage/ObjectColor.java b/Mage/src/mage/ObjectColor.java index 054dfa6c60..652e4b4be7 100644 --- a/Mage/src/mage/ObjectColor.java +++ b/Mage/src/mage/ObjectColor.java @@ -31,7 +31,7 @@ package mage; import java.io.Serializable; import mage.util.Copyable; -public class ObjectColor implements Serializable, Copyable { +public class ObjectColor implements Serializable, Copyable, Comparable { public static final ObjectColor WHITE = new ObjectColor("W"); public static final ObjectColor BLUE = new ObjectColor("U"); @@ -244,5 +244,41 @@ public class ObjectColor implements Serializable, Copyable { System.out.println(new ObjectColor("W").shares(new ObjectColor("1"))); } + + @Override + public int compareTo(ObjectColor o) { + int o1 = 0; + int o2 = 0; + + if (this.isMulticolored()) + o1 = 6; + else if(this.isColorless()) + o1 = 0; + else if(this.isBlack()) + o1 = 1; + else if(this.isBlue()) + o1 = 2; + else if(this.isGreen()) + o1 = 3; + else if(this.isRed()) + o1 = 4; + else if(this.isWhite()) + o1 = 5; + if (o.isMulticolored()) + o2 = 6; + else if(o.isColorless()) + o2 = 0; + else if(o.isBlack()) + o2 = 1; + else if(o.isBlue()) + o2 = 2; + else if(o.isGreen()) + o2 = 3; + else if(o.isRed()) + o2 = 4; + else if(o.isWhite()) + o2 = 5; + return o1 - o2; + } } diff --git a/src/mage/game/tournament/TournamentImpl.java b/src/mage/game/tournament/TournamentImpl.java deleted file mode 100644 index 8c5769ff8c..0000000000 --- a/src/mage/game/tournament/TournamentImpl.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * 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.game.tournament; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; -import mage.cards.decks.Deck; -import mage.game.events.Listener; -import mage.game.events.TableEvent; -import mage.game.events.TableEvent.EventType; -import mage.game.events.TableEventSource; -import mage.game.match.Match; -import mage.players.Player; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public abstract class TournamentImpl implements Tournament { - - protected UUID id = UUID.randomUUID(); - protected List rounds = new CopyOnWriteArrayList(); - protected Map players = new HashMap(); - protected static Random rnd = new Random(); - protected String matchName; - protected TournamentOptions options; - - protected transient TableEventSource tableEventSource = new TableEventSource(); - - public TournamentImpl(TournamentOptions options) { - this.options = options; - } - - @Override - public UUID getId() { - return id; - } - - @Override - public void addPlayer(Player player, String playerType) { - players.put(player.getId(), new TournamentPlayer(player, playerType)); - } - - @Override - public TournamentPlayer getPlayer(UUID playerId) { - return players.get(playerId); - } - - @Override - public Collection getPlayers() { - return players.values(); - } - - @Override - public Collection getRounds() { - return rounds; - } - - @Override - public void leave(UUID playerId) { - //TODO: implement this - } - - @Override - public void submitDeck(UUID playerId, Deck deck) { - if (players.containsKey(playerId)) { - players.get(playerId).submitDeck(deck); - } - synchronized (this) { - this.notifyAll(); - } - } - - protected Round createRoundRandom() { - Round round = new Round(rounds.size() + 1); - rounds.add(round); - List roundPlayers = getActivePlayers(); - while (roundPlayers.size() > 1) { - int i = rnd.nextInt(roundPlayers.size()); - TournamentPlayer player1 = roundPlayers.get(i); - roundPlayers.remove(i); - i = rnd.nextInt(roundPlayers.size()); - TournamentPlayer player2 = roundPlayers.get(i); - roundPlayers.remove(i); - round.addPairing(new TournamentPairing(player1, player2)); - } - return round; - } - - protected void playRound(Round round) { - for (TournamentPairing pair: round.getPairs()) { - playMatch(pair); - } - - while (!round.isRoundOver()) { - try { - //TODO: improve this - Thread.sleep(1000); - } catch (InterruptedException ex) { - Logger.getLogger(TournamentImpl.class.getName()).log(Level.SEVERE, null, ex); - break; - } - } - updateResults(); - } - - protected List getActivePlayers() { - List activePlayers = new ArrayList(); - for (TournamentPlayer player: players.values()) { - if (!player.getEliminated()) { - activePlayers.add(player); - } - } - return activePlayers; - } - - protected void updateResults() { - for (TournamentPlayer player: players.values()) { - player.setResults(""); - } - for (Round round: rounds) { - for (TournamentPairing pair: round.getPairs()) { - UUID player1Id = pair.getPlayer1().getPlayer().getId(); - UUID player2Id = pair.getPlayer2().getPlayer().getId(); - Match match = pair.getMatch(); - StringBuilder sb1 = new StringBuilder(players.get(player1Id).getResults()); - StringBuilder sb2 = new StringBuilder(players.get(player2Id).getResults()); - sb1.append(pair.getPlayer2().getPlayer().getName()); - sb1.append(" (").append(match.getPlayer(player1Id).getWins()); - sb1.append("-").append(match.getPlayer(player2Id).getWins()).append(")"); - sb2.append(pair.getPlayer1().getPlayer().getName()); - sb2.append(" (").append(match.getPlayer(player2Id).getWins()); - sb2.append("-").append(match.getPlayer(player1Id).getWins()).append(") "); - players.get(player1Id).setResults(sb1.toString()); - players.get(player2Id).setResults(sb2.toString()); - } - } - - } - - @Override - public boolean isDoneConstructing() { - for (TournamentPlayer player: this.players.values()) { - if (!player.isDoneConstructing()) - return false; - } - return true; - } - - @Override - public boolean allJoined() { - for (TournamentPlayer player: this.players.values()) { - if (!player.isJoined()) - return false; - } - return true; - } - - @Override - public void addTableEventListener(Listener listener) { - tableEventSource.addListener(listener); - } - - public void construct() { - tableEventSource.fireTableEvent(EventType.CONSTRUCT); - synchronized(this) { - while (!isDoneConstructing()) { - try { - this.wait(); - } catch (InterruptedException ex) { } - } - } - nextStep(); - } - - public void playMatch(TournamentPairing pair) { - options.getMatchOptions().getPlayerTypes().clear(); - options.getMatchOptions().getPlayerTypes().add(pair.getPlayer1().getPlayerType()); - options.getMatchOptions().getPlayerTypes().add(pair.getPlayer2().getPlayerType()); - tableEventSource.fireTableEvent(EventType.START_MATCH, pair, options.getMatchOptions()); - } - - protected abstract void runTournament(); - -} diff --git a/src/mage/game/tournament/TournamentPlayer.java b/src/mage/game/tournament/TournamentPlayer.java deleted file mode 100644 index 778fed3d38..0000000000 --- a/src/mage/game/tournament/TournamentPlayer.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * 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.game.tournament; - -import mage.cards.decks.Deck; -import mage.players.Player; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public class TournamentPlayer { - - protected int points; - protected String name; - protected String playerType; - protected Player player; - protected Deck deck; - protected String results = ""; - protected boolean eliminated = false; - protected boolean doneConstructing; - protected boolean joined = false; - - public TournamentPlayer(Player player, String playerType) { - this.player = player; - this.playerType = playerType; - } - - public Player getPlayer() { - return player; - } - - public String getPlayerType() { - return playerType; - } - - public Deck getDeck() { - return deck; - } - - public int getPoints() { - return points; - } - - public void setPoints(int points) { - this.points = points; - } - - public boolean getEliminated() { - return eliminated; - } - - public void setEliminated() { - this.eliminated = true; - } - - public boolean isJoined() { - return joined; - } - - public void setJoined() { - this.joined = true; - } - - public void setConstructing() { - this.doneConstructing = false; - } - - public void submitDeck(Deck deck) { - this.deck = deck; - this.doneConstructing = true; - } - - public boolean isDoneConstructing() { - return this.doneConstructing; - } - - public void setDeck(Deck deck) { - this.deck = deck; - } - - public String getResults() { - return this.results; - } - - public void setResults(String results) { - this.results = results; - } -} diff --git a/src/mage/game/tournament/TournamentSingleElimination.java b/src/mage/game/tournament/TournamentSingleElimination.java deleted file mode 100644 index ed018b7b5f..0000000000 --- a/src/mage/game/tournament/TournamentSingleElimination.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * 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.game.tournament; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public abstract class TournamentSingleElimination extends TournamentImpl { - - public TournamentSingleElimination(TournamentOptions options) { - super(options); - } - - @Override - protected void runTournament() { - while (this.getActivePlayers().size() > 1) { - Round round = createRoundRandom(); - playRound(round); - eliminatePlayers(round); - } - nextStep(); - } - - private void eliminatePlayers(Round round) { - for (TournamentPairing pair: round.getPairs()) { - pair.eliminatePlayers(); - } - } - - -}