XMage Release 1.4.2v0

This commit is contained in:
LevelX2 2015-07-04 01:28:19 +02:00
parent b206beb9dc
commit cd0cba6ec7
35 changed files with 145 additions and 98 deletions

View file

@ -7,7 +7,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>1.4.1</version>
<version>1.4.2</version>
</parent>
<artifactId>mage</artifactId>
@ -24,7 +24,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.185</version>
<version>1.4.187</version>
<scope>runtime</scope>
</dependency>
<dependency>

View file

@ -60,7 +60,7 @@ public enum CardRepository {
// raise this if db structure was changed
private static final long CARD_DB_VERSION = 39;
// raise this if new cards were added to the server
private static final long CARD_CONTENT_VERSION = 20;
private static final long CARD_CONTENT_VERSION = 21;
private final Random random = new Random();
private Dao<CardInfo, Object> cardDao;
@ -135,7 +135,7 @@ public enum CardRepository {
int result = card.getName().indexOf(" // ");
if (result > 0) {
names.add(card.getName().substring(0, result));
names.add(card.getName().substring(result+4));
names.add(card.getName().substring(result + 4));
} else {
names.add(card.getName());
}
@ -156,7 +156,7 @@ public enum CardRepository {
int result = card.getName().indexOf(" // ");
if (result > 0) {
names.add(card.getName().substring(0, result));
names.add(card.getName().substring(result+4));
names.add(card.getName().substring(result + 4));
} else {
names.add(card.getName());
}
@ -165,7 +165,7 @@ public enum CardRepository {
}
return names;
}
public Set<String> getCreatureNames() {
Set<String> names = new TreeSet<>();
try {
@ -177,7 +177,7 @@ public enum CardRepository {
int result = card.getName().indexOf(" // ");
if (result > 0) {
names.add(card.getName().substring(0, result));
names.add(card.getName().substring(result+4));
names.add(card.getName().substring(result + 4));
} else {
names.add(card.getName());
}
@ -193,7 +193,7 @@ public enum CardRepository {
QueryBuilder<CardInfo, Object> qb = cardDao.queryBuilder();
qb.distinct().selectColumns("name");
Where where = qb.where();
where.and(where.not().like("types", '%' + CardType.CREATURE.name() +'%'),where.not().like("types", '%' + CardType.LAND.name() + '%'));
where.and(where.not().like("types", '%' + CardType.CREATURE.name() + '%'), where.not().like("types", '%' + CardType.LAND.name() + '%'));
List<CardInfo> results = cardDao.query(qb.prepare());
for (CardInfo card : results) {
int result = card.getName().indexOf(" // ");
@ -261,7 +261,6 @@ public enum CardRepository {
return null;
}
public List<String> getClassNames() {
List<String> names = new ArrayList<>();
try {
@ -313,7 +312,7 @@ public enum CardRepository {
try {
QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder();
criteria.buildQuery(queryBuilder);
return cardDao.query(queryBuilder.prepare());
} catch (SQLException ex) {
}
@ -333,7 +332,7 @@ public enum CardRepository {
public void setContentVersion(long version) {
try {
ConnectionSource connectionSource = new JdbcConnectionSource(JDBC_URL);
RepositoryUtil.updateVersion(connectionSource, VERSION_ENTITY_NAME + "Content", version);
RepositoryUtil.updateVersion(connectionSource, VERSION_ENTITY_NAME + "Content", version);
} catch (SQLException ex) {
ex.printStackTrace();
}

View file

@ -21,13 +21,13 @@ import org.apache.log4j.Logger;
public enum ExpansionRepository {
instance;
private static final Logger logger = Logger.getLogger(ExpansionRepository.class);
private static final Logger logger = Logger.getLogger(ExpansionRepository.class);
private static final String JDBC_URL = "jdbc:h2:file:./db/cards.h2;AUTO_SERVER=TRUE";
private static final String VERSION_ENTITY_NAME = "expansion";
private static final long EXPANSION_DB_VERSION = 5;
private static final long EXPANSION_CONTENT_VERSION = 8;
private static final long EXPANSION_CONTENT_VERSION = 9;
private Dao<ExpansionInfo, Object> expansionDao;
@ -73,7 +73,7 @@ public enum ExpansionRepository {
}
public ExpansionInfo[] getWithBoostersSortedByReleaseDate() {
ExpansionInfo[] sets = new ExpansionInfo[0];
ExpansionInfo[] sets = new ExpansionInfo[0];
try {
QueryBuilder<ExpansionInfo, Object> qb = expansionDao.queryBuilder();
qb.orderBy("releaseDate", false);
@ -96,9 +96,9 @@ public enum ExpansionRepository {
}
return sets;
}
public List<ExpansionInfo> getSetsFromBlock(String blockName) {
List<ExpansionInfo> sets = new LinkedList<>();
List<ExpansionInfo> sets = new LinkedList<>();
try {
QueryBuilder<ExpansionInfo, Object> qb = expansionDao.queryBuilder();
qb.where().eq("blockName", new SelectArg(blockName));
@ -119,9 +119,9 @@ public enum ExpansionRepository {
}
} catch (SQLException ex) {
}
return set;
return set;
}
public ExpansionInfo getSetByName(String setName) {
ExpansionInfo set = null;
try {
@ -133,7 +133,7 @@ public enum ExpansionRepository {
}
} catch (SQLException ex) {
}
return set;
return set;
}
public List<ExpansionInfo> getAll() {
@ -145,7 +145,7 @@ public enum ExpansionRepository {
}
return new ArrayList<>();
}
public List<String> getAllSetNames() {
try {
QueryBuilder<ExpansionInfo, Object> qb = expansionDao.queryBuilder();
@ -153,14 +153,14 @@ public enum ExpansionRepository {
List<ExpansionInfo> expansions = expansionDao.query(qb.prepare());
List<String> setNames = new LinkedList<>();
for (ExpansionInfo expansionInfo : expansions) {
setNames.add(expansionInfo.getName());
}
setNames.add(expansionInfo.getName());
}
return setNames;
} catch (SQLException ex) {
}
return new ArrayList<>();
}
public long getContentVersionFromDB() {
try {
ConnectionSource connectionSource = new JdbcConnectionSource(JDBC_URL);