Implemented Alpine Moon

This commit is contained in:
Evan Kranzler 2018-06-19 13:32:15 -04:00
parent 880534c4df
commit 8116f1365e
4 changed files with 147 additions and 0 deletions

View file

@ -24,6 +24,7 @@ public class ChooseACardNameEffect extends OneShotEffect {
ALL,
NOT_BASIC_LAND_NAME,
NONBASIC_LAND_NAME,
NON_ARTIFACT_AND_NON_LAND_NAME,
NON_LAND_NAME,
NON_LAND_AND_NON_CREATURE_NAME,
@ -62,6 +63,10 @@ public class ChooseACardNameEffect extends OneShotEffect {
cardChoice.setChoices(CardRepository.instance.getNotBasicLandNames());
cardChoice.setMessage("Choose a card name other than a basic land card name");
break;
case NONBASIC_LAND_NAME:
cardChoice.setChoices(CardRepository.instance.getNonbasicLandNames());
cardChoice.setMessage("Choose a nonbasic land card name");
break;
case NON_ARTIFACT_AND_NON_LAND_NAME:
cardChoice.setChoices(CardRepository.instance.getNonArtifactAndNonLandNames());
cardChoice.setMessage("Choose a nonartifact, nonland card name");
@ -113,6 +118,9 @@ public class ChooseACardNameEffect extends OneShotEffect {
case NOT_BASIC_LAND_NAME:
sb.append("card name other than a basic land card");
break;
case NONBASIC_LAND_NAME:
sb.append("nonbasic land card name");
break;
case NON_ARTIFACT_AND_NON_LAND_NAME:
sb.append("nonartifact, nonland card");
break;

View file

@ -153,6 +153,30 @@ public enum CardRepository {
return names;
}
public Set<String> getNonbasicLandNames() {
Set<String> names = new TreeSet<>();
try {
QueryBuilder<CardInfo, Object> qb = cardDao.queryBuilder();
qb.distinct().selectColumns("name");
Where where = qb.where();
where.and(where.not().not().like("supertypes", '%' + SuperType.BASIC.name() + '%'), where.like("types", '%' + CardType.LAND.name() + '%'));
List<CardInfo> results = cardDao.query(qb.prepare());
for (CardInfo card : results) {
int result = card.getName().indexOf(" // ");
if (result > 0) {
names.add(card.getName().substring(0, result));
names.add(card.getName().substring(result + 4));
} else {
names.add(card.getName());
}
}
} catch (SQLException ex) {
Logger.getLogger(CardRepository.class).error("Error getting non-land names from DB : " + ex);
}
return names;
}
public Set<String> getNotBasicLandNames() {
Set<String> names = new TreeSet<>();
try {