mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 13:19:18 -08:00
[deck.generator] Added Set.findCard(name, random). Now decks contain random basic lands (against previous M11 only).
This commit is contained in:
parent
3123207b0d
commit
7bc6a97a44
3 changed files with 40 additions and 10 deletions
|
|
@ -31,11 +31,7 @@ package mage.sets;
|
|||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import mage.cards.Card;
|
||||
|
|
@ -51,6 +47,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
|
||||
private static final Sets fINSTANCE = new Sets();
|
||||
private static Set<String> names;
|
||||
protected static Random rnd = new Random();
|
||||
|
||||
public static Sets getInstance() {
|
||||
return fINSTANCE;
|
||||
|
|
@ -93,6 +90,24 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String findCard(String name, boolean random) {
|
||||
if (!random) {
|
||||
return findCard(name);
|
||||
} else {
|
||||
List<String> cards = new ArrayList<String>();
|
||||
for (ExpansionSet set: fINSTANCE.values()) {
|
||||
String cardName = set.findCard(name, true);
|
||||
if (cardName != null) {
|
||||
cards.add(cardName);
|
||||
}
|
||||
}
|
||||
if (cards.size() > 0) {
|
||||
return cards.get(rnd.nextInt(cards.size()));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ExpansionSet findSet(String code) {
|
||||
for (ExpansionSet set: fINSTANCE.values()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue