mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 11:02:00 -08:00
Enhanced deck generator: monocolor decks, card pool 3 times bigger, bonus for multicolored cards, no duplicate cards.
This commit is contained in:
parent
1eb65e8d13
commit
935bf45c57
3 changed files with 33 additions and 19 deletions
|
|
@ -1,26 +1,11 @@
|
|||
package mage.client.deck.generator;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.ColoredManaSymbol;
|
||||
import mage.Mana;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.CardsStorage;
|
||||
import mage.client.util.gui.ColorsChooser;
|
||||
import mage.interfaces.rate.RateCallback;
|
||||
|
|
@ -28,6 +13,15 @@ import mage.sets.Sets;
|
|||
import mage.utils.CardUtil;
|
||||
import mage.utils.DeckBuilder;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Generates random card pool and builds a deck.
|
||||
*
|
||||
|
|
@ -38,7 +32,7 @@ public class DeckGenerator {
|
|||
private static JDialog dlg;
|
||||
private static String selectedColors;
|
||||
|
||||
private static final int SPELL_CARD_POOL_SIZE = 60;
|
||||
private static final int SPELL_CARD_POOL_SIZE = 180;
|
||||
|
||||
private static final int DECK_LANDS = 16;
|
||||
private static final int MAX_NON_BASIC_SOURCE = DECK_LANDS / 2;
|
||||
|
|
@ -61,7 +55,8 @@ public class DeckGenerator {
|
|||
JLabel text = new JLabel("Choose color for your deck: ");
|
||||
p0.add(text);
|
||||
p0.add(Box.createVerticalStrut(5));
|
||||
final ColorsChooser colorsChooser = new ColorsChooser("bu");
|
||||
String chosen = MageFrame.getPreferences().get("genDeckColor", "u");
|
||||
final ColorsChooser colorsChooser = new ColorsChooser(chosen);
|
||||
p0.add(colorsChooser);
|
||||
|
||||
final JButton btnGenerate = new JButton("Ok");
|
||||
|
|
@ -71,6 +66,7 @@ public class DeckGenerator {
|
|||
colorsChooser.setEnabled(false);
|
||||
selectedColors = (String) colorsChooser.getSelectedItem();
|
||||
dlg.setVisible(false);
|
||||
MageFrame.getPreferences().put("genDeckColor", selectedColors);
|
||||
}
|
||||
});
|
||||
final JButton btnCancel = new JButton("Cancel");
|
||||
|
|
|
|||
|
|
@ -27,6 +27,13 @@ public class ColorsChooser extends JComboBox implements ListCellRenderer {
|
|||
this.setRenderer(this);
|
||||
|
||||
final DefaultComboBoxModel model = new DefaultComboBoxModel();
|
||||
|
||||
model.addElement("u");
|
||||
model.addElement("r");
|
||||
model.addElement("b");
|
||||
model.addElement("g");
|
||||
model.addElement("w");
|
||||
|
||||
model.addElement("bu");
|
||||
model.addElement("bg");
|
||||
model.addElement("br");
|
||||
|
|
|
|||
|
|
@ -39,8 +39,13 @@ public class DeckBuilder {
|
|||
deck = new Deck();
|
||||
|
||||
final Collection<MageScoredCard> remainingCards = new ArrayList<MageScoredCard>();
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (final Card card : spellCardPool) {
|
||||
if (names.contains(card.getName())) {
|
||||
continue;
|
||||
}
|
||||
remainingCards.add(new MageScoredCard(card, allowedColors, callback));
|
||||
names.add(card.getName());
|
||||
}
|
||||
int min = 0;
|
||||
for (int index = 0; index < DECK_COUNT.length; index++) {
|
||||
|
|
@ -228,6 +233,8 @@ public class DeckBuilder {
|
|||
int converted = card.getManaCost().convertedManaCost();
|
||||
final Map<String, Integer> singleCount = new HashMap<String, Integer>();
|
||||
int maxSingleCount = 0;
|
||||
int multicolor = 0;
|
||||
Set<String> colors = new HashSet<String>();
|
||||
for (String symbol : card.getManaCost().getSymbols()) {
|
||||
int count = 0;
|
||||
symbol = symbol.replace("{", "").replace("}", "");
|
||||
|
|
@ -240,6 +247,9 @@ public class DeckBuilder {
|
|||
if (count == 0) {
|
||||
return -30;
|
||||
}
|
||||
if (!colors.contains(symbol)) {
|
||||
multicolor += 1;
|
||||
}
|
||||
Integer typeCount = singleCount.get(symbol);
|
||||
if (typeCount == null) {
|
||||
typeCount = new Integer(0);
|
||||
|
|
@ -249,8 +259,9 @@ public class DeckBuilder {
|
|||
maxSingleCount = Math.max(maxSingleCount, typeCount);
|
||||
}
|
||||
}
|
||||
int multicolorBonus = multicolor > 1 ? 30 : 0;
|
||||
maxSingleCount = Math.min(maxSingleCount, SINGLE_PENALTY.length - 1);
|
||||
return 2 * converted + 3 * (10 - SINGLE_PENALTY[maxSingleCount]/*-DOUBLE_PENALTY[doubleCount]*/);
|
||||
return 2 * converted + 3 * (10 - SINGLE_PENALTY[maxSingleCount]/*-DOUBLE_PENALTY[doubleCount]*/) + multicolorBonus;
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue