forked from External/mage
refactor : removed all instances of new Random() and replaced with RandomUtil for a ThreadLocal randomizer
This commit is contained in:
parent
f2cc8d4571
commit
e2a479255a
51 changed files with 173 additions and 133 deletions
|
|
@ -61,10 +61,9 @@ public class TournamentUtil {
|
|||
if (landSetCodes.isEmpty()) {
|
||||
// if sets have no basic lands and also it has no parent or parent has no lands get last set with lands
|
||||
// select a set with basic lands by random
|
||||
Random generator = new Random();
|
||||
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||
if (basicLandSets.size() > 0) {
|
||||
landSetCodes.add(basicLandSets.get(generator.nextInt(basicLandSets.size())).getCode());
|
||||
landSetCodes.add(basicLandSets.get(RandomUtil.nextInt(basicLandSets.size())).getCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +74,6 @@ public class TournamentUtil {
|
|||
}
|
||||
|
||||
public static List<Card> getLands(String landName, int number, Set<String> landSets) {
|
||||
Random random = new Random();
|
||||
CardCriteria criteria = new CardCriteria();
|
||||
if (!landSets.isEmpty()) {
|
||||
criteria.setCodes(landSets.toArray(new String[landSets.size()]));
|
||||
|
|
@ -85,7 +83,7 @@ public class TournamentUtil {
|
|||
List<Card> cards = new ArrayList<>();
|
||||
if (!lands.isEmpty()) {
|
||||
for (int i = 0; i < number; i++) {
|
||||
Card land = lands.get(random.nextInt(lands.size())).getCard();
|
||||
Card land = lands.get(RandomUtil.nextInt(lands.size())).getCard();
|
||||
cards.add(land);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue