mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10:00
Fixed random set for basic land definition. (Fixed issue #274)
This commit is contained in:
parent
a80fff7a8c
commit
178b4cb158
4 changed files with 13 additions and 13 deletions
|
@ -382,9 +382,9 @@ public class DeckGenerator {
|
|||
// 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();
|
||||
ExpansionInfo [] randomLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||
if (randomLandSets.length > 0) {
|
||||
landSets.add(randomLandSets[generator.nextInt(randomLandSets.length)-1].getCode());
|
||||
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||
if (basicLandSets.size() > 0) {
|
||||
landSets.add(basicLandSets.get(generator.nextInt(basicLandSets.size())).getCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,9 +88,9 @@ public class AddLandDialog extends MageDialog {
|
|||
// 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();
|
||||
ExpansionInfo [] landSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||
if (landSets.length > 0) {
|
||||
this.setCodesland.add(landSets[generator.nextInt(landSets.length)-1].getCode());
|
||||
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||
if (basicLandSets.size() > 0) {
|
||||
this.setCodesland.add(basicLandSets.get(generator.nextInt(basicLandSets.size())).getCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1332,9 +1332,9 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
|
|||
// 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();
|
||||
ExpansionInfo [] basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||
if (basicLandSets.length > 0) {
|
||||
landSets.add(basicLandSets[generator.nextInt(basicLandSets.length)-1].getCode());
|
||||
List<ExpansionInfo> basicLandSets = ExpansionRepository.instance.getSetsWithBasicLandsByReleaseDate();
|
||||
if (basicLandSets.size() > 0) {
|
||||
landSets.add(basicLandSets.get(generator.nextInt(basicLandSets.size())).getCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.j256.ormlite.table.TableUtils;
|
|||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -77,14 +78,13 @@ public enum ExpansionRepository {
|
|||
return sets;
|
||||
}
|
||||
|
||||
public ExpansionInfo[] getSetsWithBasicLandsByReleaseDate() {
|
||||
ExpansionInfo[] sets = new ExpansionInfo[0];
|
||||
public List<ExpansionInfo> getSetsWithBasicLandsByReleaseDate() {
|
||||
List<ExpansionInfo> sets = new LinkedList<ExpansionInfo>();
|
||||
try {
|
||||
QueryBuilder<ExpansionInfo, Object> qb = expansionDao.queryBuilder();
|
||||
qb.orderBy("releaseDate", false);
|
||||
qb.where().eq("basicLands", new SelectArg(true));
|
||||
List<ExpansionInfo> expansions = expansionDao.query(qb.prepare());
|
||||
sets = expansions.toArray(new ExpansionInfo[0]);
|
||||
sets = expansionDao.query(qb.prepare());
|
||||
} catch (SQLException ex) {
|
||||
}
|
||||
return sets;
|
||||
|
|
Loading…
Add table
Reference in a new issue