MTG Forge 06-12

Download 06-12
Hi this version is just a minor update of the 06-06 version. I made two minor changes.
1. The "Generate Deck" option for Constructed or Sealed ensures that all of your creatures will have at least an attacking power of 2. (I got tired of puny 1/1s and this code does eleminate */* creatures like Nightmare and Serra Avatar.)
2. In the quest deck editor "AI Menu" there is a new option called "Add Card" which lets you add a card to your current cardpool, aka. this lets you cheat. You can see the "AI Menu" by creating a file named "edit" in the MTG Forge directory.
Maybe I should add a cheat menu and add this option, what do you think?
I used Chris's all rarities for common.txt, uncommon.txt, rare.txt and quest-common.txt, quest-uncommon.txt, quest-rare.txt
////////////////////////////////
Dennis,
Here are my small changes. When I tried to compile QuestData_BoosterPack the compiler said that it add some error message with the method addAll(), because it didn't know which addAll() method to use, so I changed the code so that it would compile. I just changed ArrayList<?> to ArrayList<String>.
QuestData_BoosterPack.java
Hi this version is just a minor update of the 06-06 version. I made two minor changes.
1. The "Generate Deck" option for Constructed or Sealed ensures that all of your creatures will have at least an attacking power of 2. (I got tired of puny 1/1s and this code does eleminate */* creatures like Nightmare and Serra Avatar.)
2. In the quest deck editor "AI Menu" there is a new option called "Add Card" which lets you add a card to your current cardpool, aka. this lets you cheat. You can see the "AI Menu" by creating a file named "edit" in the MTG Forge directory.
Maybe I should add a cheat menu and add this option, what do you think?
I used Chris's all rarities for common.txt, uncommon.txt, rare.txt and quest-common.txt, quest-uncommon.txt, quest-rare.txt
////////////////////////////////
Dennis,
Here are my small changes. When I tried to compile QuestData_BoosterPack the compiler said that it add some error message with the method addAll(), because it didn't know which addAll() method to use, so I changed the code so that it would compile. I just changed ArrayList<?> to ArrayList<String>.
QuestData_BoosterPack.java
- Code: Select all
//nCommon is the number of common cards
@SuppressWarnings("unchecked")
private ArrayList<String> getNewCards(int nCommon, int nUncommon, int nRare)
{
ArrayList<String> out = new ArrayList<String>();
out.addAll(getCommon(nCommon));
out.addAll(getCommon(nUncommon));
out.addAll(getCommon(nRare));
return out;
}//getNewCards()
1. changed GenerateSealedDeck.filterBadCards() - removes creatures with power less than 2
private CardList filterBadCards(CardList list)
{
//remove "bad" and multi-colored cards
final ArrayList<String> remove = new ArrayList<String>();
remove.add("Force of Savagery");
remove.add("Darksteel Colossus");
remove.add("Jokulhaups");
remove.add("Steel Wall");
remove.add("Ornithopter");
remove.add("Sarcomite Myr");
CardList out = list.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
if(c.isCreature() && c.getBaseAttack() < 2)
return false;
return CardUtil.getColors(c).size() == 1 && !remove.contains(c.getName());
}
});
return out;
}//filterBadCards()
////////////////////////////////////////////////////////////////////////////////
2. changed GenerateConstructedDeck.filterBadCards() - removes creatures with power less than 2
private CardList filterBadCards(CardList list)
{
//remove "bad" and multi-colored cards
final ArrayList<String> remove = new ArrayList<String>();
remove.add("Sarcomite Myr");
remove.add("Force of Savagery");
remove.add("Darksteel Colossus");
remove.add("Jokulhaups");
remove.add("Steel Wall");
remove.add("Ornithopter");
remove.add("Amnesia");
remove.add("Battle of Wits");
remove.add("Ashes to Ashes");
remove.add("Haunted Angel");
remove.add("Sky Swallower");
remove.add("Magus of the Library");
remove.add("The Unspeakable");
remove.add("Wall of Kelp");
remove.add("Incendiary Command");
remove.add("Memnarch");
remove.add("Plague Wind");
remove.add("Klaas, Elf Friend");
remove.add("Delirium Skeins");
remove.add("Undying Beast");
remove.add("Wit's End");
remove.add("Blinding Light");
remove.add("Hymn to Tourach");
//useless, or combo cards:
remove.add("Aluren");
remove.add("Conspiracy");
remove.add("Crucible of Fire");
remove.add("Verduran Enchantress");
remove.add("Enchantress's Presence");
remove.add("Mesa Enchantress");
remove.add("Moat");
remove.add("Magus of the Moat");
remove.add("Relentless Rats");
remove.add("Vedalken Archmage");
remove.add("Hatching Plans");
remove.add("Sensation Gorger");
//cards the AI cannot play:
remove.add("Sensei's Divining Top");
remove.add("Standstill");
remove.add("Counterspell");
remove.add("Exclude");
remove.add("Remove Soul");
remove.add("Punish Ignorance");
remove.add("Remand");
remove.add("Mystic Snake");
remove.add("Absorb");
remove.add("Undermine");
remove.add("Overwhelming Intellect");
final ArrayList<Card> goodLand = new ArrayList<Card>();
//goodLand.add("Faerie Conclave");
//goodLand.add("Forbidding Watchtower");
//goodLand.add("Treetop Village");
CardList out = list.filter(new CardListFilter()
{
public boolean addCard(Card c)
{
if(c.isCreature() && c.getBaseAttack() < 2)
return false;
return CardUtil.getColors(c).size() == 1 && //no gold colored cards
!c.isLand() && //no land
!remove.contains(c.getName()) || //OR very important
goodLand.contains(c.getName());
}
});
return out;
}//filterBadCards()
////////////////////////////////////////////////////////////////////////////////
2. changed Gui_Quest_DeckEditor_Menu.setupComputerMenu() - adds "Add Card" to quest deck editor "AI Deck" menu
import javax.swing.event.*; //add this import statement
//edit the AI decks
private void setupComputerMenu()
{
JMenuItem open = new JMenuItem("Open");
JMenuItem new2 = new JMenuItem("New");
JMenuItem rename = new JMenuItem("Rename");
JMenuItem save = new JMenuItem("Save");
JMenuItem copy = new JMenuItem("Copy");
JMenuItem delete = new JMenuItem("Delete");
JMenuItem exit = new JMenuItem("Exit");
//adds a card to human player's cardpool
JMenuItem addCard = new JMenuItem("Add Card");
JMenuItem viewAllDecks = new JMenuItem("View All Decks");
//add card
addCard.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a)
{
CardList cardList = AllZone.CardFactory.getAllCards();
TableSorter sorter = new TableSorter(cardList, 1, true);
cardList.sort(sorter);
final Card[] card = cardList.toArray();
final JList list = new JList(card);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addListSelectionListener(new ListSelectionListener()
{
public void valueChanged(ListSelectionEvent e)
{
CardDetail cd = (CardDetail)deckDisplay;
cd.updateCardDetail((Card)list.getSelectedValue());
}
});
Object[] o = {"Add Card to Your Cardpool", "The number next to the card name doesn't mean anything", new JScrollPane(list)};
JOptionPane pane = new JOptionPane(o, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
JDialog dialog = pane.createDialog(null, "Add Card");
dialog.setModal(true);
dialog.setVisible(true);
Object choice = pane.getValue();
boolean cancel = false;
//there are a ton of ways to cancel
if(
choice == null ||
choice.equals(JOptionPane.UNINITIALIZED_VALUE)
)
cancel = true;
else
{
int n = ((Integer)choice).intValue();
if(n == JOptionPane.CANCEL_OPTION)
cancel = true;
}
if(cancel || list.getSelectedValue() == null)
System.out.println("cancelled");
else
{
System.out.println(list.getSelectedValue());
Card c = (Card) list.getSelectedValue();
Gui_Quest_DeckEditor g = (Gui_Quest_DeckEditor)deckDisplay;
TableModel table = g.getTopTableModel();
table.addCard(c);
table.resort();
}
}//actionPerformed()
});//add card
//AI
viewAllDecks.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a)
{
ArrayList nameList = questData.ai_getDeckNames();
Collections.sort(nameList);
Deck deck;
String allText = "";
for(int i = 0; i < nameList.size(); i++)
{
deck = questData.ai_getDeck(nameList.get(i).toString());
allText += deck.getName() +"\r\n";
allText += getExportDeckText(deck);
allText += "++++++++++++++++++++++++++++++++++++++++++++++++++++++ \r\n \r\n";
}
JTextArea area = new JTextArea(allText, 30, 30);
JOptionPane.showMessageDialog(null, new JScrollPane(area));
}//actionPerformed()
});//viewAllDecks
//AI
open.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a)
{
String deckName = getUserInput_OpenDeck(questData.ai_getDeckNames());
//check if user selected "cancel"
if(deckName.equals(""))
return;
setComputerPlayer(deckName);
Deck d = questData.ai_getDeck(deckName);
CardList deck = new CardList();
for(int i = 0; i < d.countMain(); i++)
deck.add(AllZone.CardFactory.getCard(d.getMain(i), ""));
CardList cardpool = AllZone.CardFactory.getAllCards();
deckDisplay.updateDisplay(cardpool, deck);
}
});//open
//AI
new2.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a)
{
deckDisplay.updateDisplay(AllZone.CardFactory.getAllCards(), new CardList());
setComputerPlayer("");
}
});//new
//AI
rename.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a)
{
String name = getUserInput_GetDeckName(questData.ai_getDeckNames());
//check if user cancels
if(name.equals(""))
return;
//is the current deck already saved and in QuestData?
if(questData.ai_getDeckNames().contains(currentDeck.getName()))
questData.ai_removeDeck(currentDeck.getName());//remove old deck
currentDeck.setName(name);
Deck deck = convertCardListToDeck(deckDisplay.getBottom());
deck.setName(name);
questData.ai_addDeck(deck);
setComputerPlayer(name);
}
});//rename
//AI
save.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a)
{
String name = currentDeck.getName();
//check to see if name is set
if(name.equals(""))
{
name = getUserInput_GetDeckName(questData.ai_getDeckNames());
//check if user cancels
if(name.equals(""))
return;
}
setComputerPlayer(name);
Deck deck = convertCardListToDeck(deckDisplay.getBottom());
deck.setName(name);
questData.ai_addDeck(deck);
}
});//save
//AI
copy.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a)
{
String name = getUserInput_GetDeckName(questData.ai_getDeckNames());
//check if user cancels
if(name.equals(""))
return;
setComputerPlayer(name);
Deck deck = convertCardListToDeck(deckDisplay.getBottom());
deck.setName(name);
questData.ai_addDeck(deck);
}
});//copy
//AI
delete.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a)
{
if(currentDeck == null || currentDeck.getName().equals(""))
return;
int check = JOptionPane.showConfirmDialog(null, "Do you really want to delete this deck?", "Delete", JOptionPane.YES_NO_OPTION);
if(check == JOptionPane.NO_OPTION)
return;//stop here
questData.ai_removeDeck(currentDeck.getName());
//show card pool
CardList cardpool = AllZone.CardFactory.getAllCards();
deckDisplay.updateDisplay(cardpool, new CardList());
setComputerPlayer("");
}
});//delete
//AI
exit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent a)
{
Gui_Quest_DeckEditor_Menu.this.close();
}
});
JMenu deckMenu = new JMenu("AI Deck");
deckMenu.add(addCard);//not sure where to put this
deckMenu.addSeparator();
deckMenu.add(open);
deckMenu.add(rename);
deckMenu.add(new2);
deckMenu.add(save);
deckMenu.add(copy);
deckMenu.addSeparator();
addImportExport(deckMenu, false);
deckMenu.add(viewAllDecks);
deckMenu.addSeparator();
deckMenu.add(delete);
deckMenu.addSeparator();
deckMenu.add(exit);
this.add(deckMenu);
}//setupComputerMenu()