mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Implemented Desperate Research
This commit is contained in:
parent
78c288358b
commit
d2e8016a10
4 changed files with 109 additions and 2 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
|
|
@ -24,6 +23,7 @@ public class NameACardEffect extends OneShotEffect {
|
|||
public enum TypeOfName {
|
||||
|
||||
ALL,
|
||||
NOT_BASIC_LAND_NAME,
|
||||
NON_ARTIFACT_AND_NON_LAND_NAME,
|
||||
NON_LAND_NAME,
|
||||
NON_LAND_AND_NON_CREATURE_NAME,
|
||||
|
|
@ -58,6 +58,10 @@ public class NameACardEffect extends OneShotEffect {
|
|||
cardChoice.setChoices(CardRepository.instance.getNames());
|
||||
cardChoice.setMessage("Choose a card name");
|
||||
break;
|
||||
case NOT_BASIC_LAND_NAME:
|
||||
cardChoice.setChoices(CardRepository.instance.getNotBasicLandNames());
|
||||
cardChoice.setMessage("Choose a card name other than a basic land card name");
|
||||
break;
|
||||
case NON_ARTIFACT_AND_NON_LAND_NAME:
|
||||
cardChoice.setChoices(CardRepository.instance.getNonArtifactAndNonLandNames());
|
||||
cardChoice.setMessage("Choose a nonartifact, nonland card name");
|
||||
|
|
@ -106,6 +110,9 @@ public class NameACardEffect extends OneShotEffect {
|
|||
case ALL:
|
||||
sb.append("card");
|
||||
break;
|
||||
case NOT_BASIC_LAND_NAME:
|
||||
sb.append("card name other than a basic land card");
|
||||
break;
|
||||
case NON_ARTIFACT_AND_NON_LAND_NAME:
|
||||
sb.append("nonartifact, nonland card");
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.repository;
|
||||
|
||||
import com.j256.ormlite.dao.Dao;
|
||||
|
|
@ -17,6 +16,7 @@ import java.util.*;
|
|||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SetType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.util.RandomUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -153,6 +153,29 @@ public enum CardRepository {
|
|||
return names;
|
||||
}
|
||||
|
||||
public Set<String> getNotBasicLandNames() {
|
||||
Set<String> names = new TreeSet<>();
|
||||
try {
|
||||
QueryBuilder<CardInfo, Object> qb = cardDao.queryBuilder();
|
||||
qb.distinct().selectColumns("name");
|
||||
qb.where().not().like("supertypes", new SelectArg('%' + SuperType.BASIC.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> getCreatureNames() {
|
||||
Set<String> names = new TreeSet<>();
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue