mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Adventure mode - Support to restrict cards from random pool
For now we just restrict the Power Nine. They can still be dropped explicitly.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package forge.adventure.data;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Data class that will be used to read Json configuration files
|
||||
* BiomeData
|
||||
@@ -17,4 +19,5 @@ public class ConfigData {
|
||||
public String[] starterDecks;
|
||||
public DifficultyData[] difficulties;
|
||||
public RewardData legalCards;
|
||||
public List<String> restrictedCards;
|
||||
}
|
||||
|
||||
@@ -41,11 +41,8 @@ public class RewardData {
|
||||
public String cardText;
|
||||
public boolean matchAllSubTypes;
|
||||
|
||||
public RewardData() { }
|
||||
|
||||
public RewardData()
|
||||
{
|
||||
|
||||
}
|
||||
public RewardData(RewardData rewardData) {
|
||||
type =rewardData.type;
|
||||
probability =rewardData.probability;
|
||||
@@ -68,23 +65,24 @@ public class RewardData {
|
||||
|
||||
private static Iterable<PaperCard> allCards;
|
||||
private static Iterable<PaperCard> allEnemyCards;
|
||||
public Array<Reward> generate(boolean isForEnemy)
|
||||
{
|
||||
|
||||
public Array<Reward> generate(boolean isForEnemy) {
|
||||
return generate(isForEnemy, null);
|
||||
}
|
||||
public Array<Reward> generate(boolean isForEnemy,Iterable<PaperCard> cards)
|
||||
{
|
||||
if(allCards==null)
|
||||
{
|
||||
RewardData legals=Config.instance().getConfigData().legalCards;
|
||||
if(legals==null)
|
||||
{
|
||||
allCards = FModel.getMagicDb().getCommonCards().getUniqueCardsNoAltNoOnline();
|
||||
}
|
||||
else
|
||||
{
|
||||
allCards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCardsNoAltNoOnline(), new CardUtil.CardPredicate(legals, true));
|
||||
}
|
||||
public Array<Reward> generate(boolean isForEnemy, Iterable<PaperCard> cards) {
|
||||
if(allCards==null) {
|
||||
RewardData legals = Config.instance().getConfigData().legalCards;
|
||||
if(legals==null) allCards = FModel.getMagicDb().getCommonCards().getUniqueCardsNoAltNoOnline();
|
||||
else allCards = Iterables.filter(FModel.getMagicDb().getCommonCards().getUniqueCardsNoAltNoOnline(), new CardUtil.CardPredicate(legals, true));
|
||||
//Filter out specific cards.
|
||||
allCards = Iterables.filter(allCards, new Predicate<PaperCard>() {
|
||||
@Override
|
||||
public boolean apply(PaperCard input){
|
||||
if(input == null) return false;
|
||||
return !Config.instance().getConfigData().restrictedCards.contains(input.getName());
|
||||
}
|
||||
});
|
||||
//Filter AI cards for enemies.
|
||||
allEnemyCards=Iterables.filter(allCards, new Predicate<PaperCard>() {
|
||||
@Override
|
||||
public boolean apply(PaperCard input) {
|
||||
@@ -94,11 +92,10 @@ public class RewardData {
|
||||
});
|
||||
}
|
||||
Array<Reward> ret=new Array<>();
|
||||
if(probability==0|| WorldSave.getCurrentSave().getWorld().getRandom().nextFloat()<=probability) {
|
||||
if(type==null||type.isEmpty())
|
||||
if(probability == 0 || WorldSave.getCurrentSave().getWorld().getRandom().nextFloat() <= probability) {
|
||||
if(type==null || type.isEmpty())
|
||||
type="randomCard";
|
||||
int addedCount=(int)((float)(addMaxCount)* WorldSave.getCurrentSave().getWorld().getRandom().nextFloat());
|
||||
|
||||
int addedCount = WorldSave.getCurrentSave().getWorld().getRandom().nextInt(addMaxCount);
|
||||
if( colors != null && colors.length > 0 ) { //Filter special "colorID" case.
|
||||
String C = Current.player().getColorIdentityLong();
|
||||
for(int i = 0; i < colors.length; i++){
|
||||
@@ -128,26 +125,23 @@ public class RewardData {
|
||||
}
|
||||
break;
|
||||
case "item":
|
||||
if(itemName!=null&&!itemName.isEmpty())
|
||||
{
|
||||
for(int i=0;i<count+addedCount;i++)
|
||||
{
|
||||
if(itemName!=null&&!itemName.isEmpty()) {
|
||||
for(int i=0;i<count+addedCount;i++) {
|
||||
ret.add(new Reward(ItemData.getItem(itemName)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "deckCard":
|
||||
if(cards==null)return ret;
|
||||
for(PaperCard card: CardUtil.generateCards(cards,this, count+addedCount))
|
||||
{
|
||||
if(cards == null) return ret;
|
||||
for(PaperCard card: CardUtil.generateCards(cards,this, count+addedCount)) {
|
||||
ret.add(new Reward(card));
|
||||
}
|
||||
break;
|
||||
case "gold":
|
||||
ret.add(new Reward(count+addedCount));
|
||||
ret.add(new Reward(count + addedCount));
|
||||
break;
|
||||
case "life":
|
||||
ret.add(new Reward(Reward.Type.Life, count+addedCount));
|
||||
ret.add(new Reward(Reward.Type.Life, count + addedCount));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,17 @@
|
||||
"decks/starter/red.json",
|
||||
"decks/starter/green.json"
|
||||
],
|
||||
"restrictedCards": [
|
||||
"Black Lotus",
|
||||
"Mox Emerald",
|
||||
"Mox Pearl",
|
||||
"Mox Ruby",
|
||||
"Mox Sapphire",
|
||||
"Mox Jet",
|
||||
"Ancestral Recall",
|
||||
"Timetwister",
|
||||
"Time Walk"
|
||||
],
|
||||
"difficulties": [
|
||||
{
|
||||
"name": "Easy",
|
||||
|
||||
Reference in New Issue
Block a user