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