mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Mythic rare card generator now returns null for sets without mythic rare cards. This is used to fix win streak rewards.
This commit is contained in:
@@ -512,6 +512,7 @@ public class QuestWinLose extends ControlWinLose {
|
|||||||
int currentStreak = (qData.getAchievements().getWinStreakCurrent() + 1) % 50;
|
int currentStreak = (qData.getAchievements().getWinStreakCurrent() + 1) % 50;
|
||||||
|
|
||||||
final List<PaperCard> cardsWon = new ArrayList<>();
|
final List<PaperCard> cardsWon = new ArrayList<>();
|
||||||
|
List<PaperCard> cardsToAdd;
|
||||||
String typeWon = "";
|
String typeWon = "";
|
||||||
|
|
||||||
switch (currentStreak) {
|
switch (currentStreak) {
|
||||||
@@ -528,8 +529,9 @@ public class QuestWinLose extends ControlWinLose {
|
|||||||
typeWon = "rare";
|
typeWon = "rare";
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
cardsWon.addAll(qData.getCards().addRandomMythicRare(1));
|
cardsToAdd = qData.getCards().addRandomMythicRare(1);
|
||||||
if (cardsWon.size() > 0) {
|
if (cardsToAdd != null) {
|
||||||
|
cardsWon.addAll(cardsToAdd);
|
||||||
typeWon = "mythic rare";
|
typeWon = "mythic rare";
|
||||||
} else {
|
} else {
|
||||||
cardsWon.addAll(qData.getCards().addRandomRareNotMythic(5));
|
cardsWon.addAll(qData.getCards().addRandomRareNotMythic(5));
|
||||||
@@ -537,8 +539,9 @@ public class QuestWinLose extends ControlWinLose {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
cardsWon.addAll(qData.getCards().addRandomMythicRare(5));
|
cardsToAdd = qData.getCards().addRandomMythicRare(5);
|
||||||
if (cardsWon.size() > 0) {
|
if (cardsToAdd != null) {
|
||||||
|
cardsWon.addAll(cardsToAdd);
|
||||||
typeWon = "mythic rare";
|
typeWon = "mythic rare";
|
||||||
} else {
|
} else {
|
||||||
cardsWon.addAll(qData.getCards().addRandomRareNotMythic(15));
|
cardsWon.addAll(qData.getCards().addRandomRareNotMythic(15));
|
||||||
@@ -546,8 +549,9 @@ public class QuestWinLose extends ControlWinLose {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0: //The 50th win in the streak is 0, since (50 % 50 == 0)
|
case 0: //The 50th win in the streak is 0, since (50 % 50 == 0)
|
||||||
cardsWon.addAll(qData.getCards().addRandomMythicRare(10));
|
cardsToAdd = qData.getCards().addRandomMythicRare(10);
|
||||||
if (cardsWon.size() > 0) {
|
if (cardsToAdd != null) {
|
||||||
|
cardsWon.addAll(cardsToAdd);
|
||||||
typeWon = "mythic rare";
|
typeWon = "mythic rare";
|
||||||
} else {
|
} else {
|
||||||
cardsWon.addAll(qData.getCards().addRandomRareNotMythic(25));
|
cardsWon.addAll(qData.getCards().addRandomRareNotMythic(25));
|
||||||
|
|||||||
@@ -278,9 +278,16 @@ public final class QuestUtilCards {
|
|||||||
public List<PaperCard> addRandomMythicRare(final int n) {
|
public List<PaperCard> addRandomMythicRare(final int n) {
|
||||||
final Predicate<PaperCard> myFilter = applyFormatFilter(QuestUtilCards.MYTHIC_PREDICATE);
|
final Predicate<PaperCard> myFilter = applyFormatFilter(QuestUtilCards.MYTHIC_PREDICATE);
|
||||||
|
|
||||||
final List<PaperCard> newCards = Aggregates.random(Iterables.filter(FModel.getMagicDb().getCommonCards().getAllCards(), myFilter), n);
|
final Iterable<PaperCard> cardPool = Iterables.filter(FModel.getMagicDb().getCommonCards().getAllCards(), myFilter);
|
||||||
|
|
||||||
|
if (!cardPool.iterator().hasNext()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<PaperCard> newCards = Aggregates.random(cardPool, n);
|
||||||
this.addAllCards(newCards);
|
this.addAllCards(newCards);
|
||||||
return newCards;
|
return newCards;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user