mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
[rate.plugin] take into account that some cards were printed several times and need to be displayed with the same probability.
This commit is contained in:
parent
e45a8ad1e0
commit
50702a026d
2 changed files with 16 additions and 1 deletions
|
@ -67,7 +67,7 @@ public class RateThread extends Thread {
|
|||
}
|
||||
|
||||
protected Card getRandomUniqueNonLandCard(Card previousCard) {
|
||||
int count = CardsStorage.getAllCards().size();
|
||||
int count = CardsStorage.getUniqueCards().size();
|
||||
Card card1 = CardsStorage.getAllCards().get((int)(Math.random()*count));
|
||||
while (card1.getCardType().contains(CardType.LAND) || card1.getName().equals(previousCard)) {
|
||||
card1 = CardsStorage.getAllCards().get((int)(Math.random()*count));
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.mage.plugins.rating.cards;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.ExpansionSet;
|
||||
|
@ -9,14 +11,27 @@ import mage.sets.Sets;
|
|||
|
||||
public class CardsStorage {
|
||||
private static List<Card> allCards = new ArrayList<Card>();
|
||||
private static List<Card> uniqueCards = new ArrayList<Card>();
|
||||
|
||||
static {
|
||||
for (ExpansionSet set: Sets.getInstance().values()) {
|
||||
allCards.addAll(set.createCards());
|
||||
}
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (Card card : allCards) {
|
||||
if (!names.contains(card.getName())) {
|
||||
uniqueCards.add(card);
|
||||
names.add(card.getName());
|
||||
}
|
||||
}
|
||||
System.out.println("cards=" + allCards.size() + ", unique cards=" + uniqueCards.size());
|
||||
}
|
||||
|
||||
public static List<Card> getAllCards() {
|
||||
return allCards;
|
||||
}
|
||||
|
||||
public static List<Card> getUniqueCards() {
|
||||
return uniqueCards;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue