Merge remote-tracking branch 'magefree/master'

This commit is contained in:
Samuel Sandeen 2016-09-07 23:31:38 -04:00
commit 80da09471d
139 changed files with 5092 additions and 252 deletions

View file

@ -138,6 +138,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
ownerId = card.ownerId;
cardNumber = card.cardNumber;
expansionSetCode = card.expansionSetCode;
tokenDescriptor = card.tokenDescriptor;
rarity = card.rarity;
canTransform = card.canTransform;

View file

@ -41,6 +41,7 @@ import java.util.Set;
import java.util.UUID;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.util.RandomUtil;
import mage.util.ThreadLocalStringBuilder;
/**
@ -51,7 +52,6 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
private static final ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(200);
private static Random rnd = new Random();
private UUID ownerId;
public CardsImpl() {
@ -114,7 +114,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
return null;
}
UUID[] cards = this.toArray(new UUID[this.size()]);
return game.getCard(cards[rnd.nextInt(cards.length)]);
return game.getCard(cards[RandomUtil.nextInt(cards.length)]);
}
@Override

View file

@ -38,13 +38,13 @@ import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.constants.Rarity;
import mage.constants.SetType;
import mage.util.RandomUtil;
/**
* @author BetaSteward_at_googlemail.com
*/
public abstract class ExpansionSet implements Serializable {
protected static Random rnd = new Random();
protected String name;
protected String code;
@ -136,7 +136,7 @@ public abstract class ExpansionSet implements Serializable {
protected void addToBooster(List<Card> booster, List<CardInfo> cards) {
if (!cards.isEmpty()) {
CardInfo cardInfo = cards.remove(rnd.nextInt(cards.size()));
CardInfo cardInfo = cards.remove(RandomUtil.nextInt(cards.size()));
if (cardInfo != null) {
Card card = cardInfo.getCard();
if (card != null) {
@ -156,7 +156,7 @@ public abstract class ExpansionSet implements Serializable {
List<CardInfo> specialLands = getSpecialLand();
List<CardInfo> basicLands = getCardsByRarity(Rarity.LAND);
for (int i = 0; i < numBoosterLands; i++) {
if (ratioBoosterSpecialLand > 0 && rnd.nextInt(ratioBoosterSpecialLand) == 0 && specialLands != null) {
if (ratioBoosterSpecialLand > 0 && RandomUtil.nextInt(ratioBoosterSpecialLand) == 0 && specialLands != null) {
addToBooster(booster, specialLands);
} else {
addToBooster(booster, basicLands);
@ -183,7 +183,7 @@ public abstract class ExpansionSet implements Serializable {
List<CardInfo> rares = getCardsByRarity(Rarity.RARE);
List<CardInfo> mythics = getCardsByRarity(Rarity.MYTHIC);
for (int i = 0; i < numBoosterRare; i++) {
if (ratioBoosterMythic > 0 && rnd.nextInt(ratioBoosterMythic) == 0) {
if (ratioBoosterMythic > 0 && RandomUtil.nextInt(ratioBoosterMythic) == 0) {
addToBooster(booster, mythics);
} else {
addToBooster(booster, rares);
@ -208,11 +208,11 @@ public abstract class ExpansionSet implements Serializable {
for (int i = 0; i < numBoosterDoubleFaced; i++) {
CardCriteria criteria = new CardCriteria();
criteria.setCodes(this.code).doubleFaced(true);
if (rnd.nextInt(15) < 10) {
if (RandomUtil.nextInt(15) < 10) {
criteria.rarities(Rarity.COMMON);
} else if (rnd.nextInt(5) < 4) {
} else if (RandomUtil.nextInt(5) < 4) {
criteria.rarities(Rarity.UNCOMMON);
} else if (rnd.nextInt(8) < 7) {
} else if (RandomUtil.nextInt(8) < 7) {
criteria.rarities(Rarity.RARE);
} else {
criteria.rarities(Rarity.MYTHIC);
@ -265,7 +265,7 @@ public abstract class ExpansionSet implements Serializable {
}
if (specialCards > 0) {
for (int i = 0; i < numBoosterSpecial; i++) {
if (rnd.nextInt(15) < 10) {
if (RandomUtil.nextInt(15) < 10) {
if (specialCommon != null && !specialCommon.isEmpty()) {
addToBooster(booster, specialCommon);
} else {
@ -273,7 +273,7 @@ public abstract class ExpansionSet implements Serializable {
}
continue;
}
if (rnd.nextInt(4) < 3) {
if (RandomUtil.nextInt(4) < 3) {
if (specialUncommon != null && !specialUncommon.isEmpty()) {
addToBooster(booster, specialUncommon);
} else {
@ -281,7 +281,7 @@ public abstract class ExpansionSet implements Serializable {
}
continue;
}
if (rnd.nextInt(8) < 7) {
if (RandomUtil.nextInt(8) < 7) {
if (specialRare != null && !specialRare.isEmpty()) {
addToBooster(booster, specialRare);
} else {
@ -291,7 +291,7 @@ public abstract class ExpansionSet implements Serializable {
}
if (specialMythic != null && !specialMythic.isEmpty()) {
if (specialBonus != null && !specialBonus.isEmpty()) {
if (rnd.nextInt(3) < 2) {
if (RandomUtil.nextInt(3) < 2) {
addToBooster(booster, specialMythic);
continue;
}

View file

@ -45,6 +45,7 @@ import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.util.ClassScanner;
import mage.util.RandomUtil;
import org.apache.log4j.Logger;
/**
@ -55,7 +56,6 @@ public class Sets extends HashMap<String, ExpansionSet> {
private static final Logger logger = Logger.getLogger(Sets.class);
private static final Sets fINSTANCE = new Sets();
protected static Random rnd = new Random();
public static Sets getInstance() {
return fINSTANCE;
@ -111,7 +111,7 @@ public class Sets extends HashMap<String, ExpansionSet> {
int tries = 0;
List<Card> cardPool = new ArrayList<>();
while (count < cardsCount) {
CardInfo cardInfo = cards.get(rnd.nextInt(cards.size()));
CardInfo cardInfo = cards.get(RandomUtil.nextInt(cards.size()));
Card card = cardInfo != null ? cardInfo.getCard() : null;
if (card != null) {
cardPool.add(card);

View file

@ -34,6 +34,7 @@ import mage.cards.decks.DeckCardLists;
import mage.cards.repository.CardCriteria;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
import mage.util.RandomUtil;
/**
*
@ -71,7 +72,7 @@ public class MWSDeckImporter extends DeckImporter {
List<CardInfo> cards = null;
cards = CardRepository.instance.findCards(criteria);
if (!cards.isEmpty()) {
cardInfo = cards.get(new Random().nextInt(cards.size()));
cardInfo = cards.get(RandomUtil.nextInt(cards.size()));
}
}
if (cardInfo == null) {

View file

@ -48,6 +48,7 @@ import java.util.TreeSet;
import java.util.concurrent.Callable;
import mage.constants.CardType;
import mage.constants.SetType;
import mage.util.RandomUtil;
import org.apache.log4j.Logger;
/**
@ -65,7 +66,6 @@ public enum CardRepository {
// raise this if new cards were added to the server
private static final long CARD_CONTENT_VERSION = 57;
private final Random random = new Random();
private Dao<CardInfo, Object> cardDao;
private Set<String> classNames;
@ -317,7 +317,7 @@ public enum CardRepository {
public CardInfo findCard(String name) {
List<CardInfo> cards = findCards(name);
if (!cards.isEmpty()) {
return cards.get(random.nextInt(cards.size()));
return cards.get(RandomUtil.nextInt(cards.size()));
}
return null;
}