forked from External/mage
Merge remote-tracking branch 'magefree/master'
This commit is contained in:
commit
80da09471d
139 changed files with 5092 additions and 252 deletions
|
|
@ -40,7 +40,6 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.UUID;
|
||||
|
|
@ -124,6 +123,7 @@ import mage.target.TargetPermanent;
|
|||
import mage.target.TargetPlayer;
|
||||
import mage.util.GameLog;
|
||||
import mage.util.MessageToClient;
|
||||
import mage.util.RandomUtil;
|
||||
import mage.util.functions.ApplyToPermanent;
|
||||
import mage.watchers.Watchers;
|
||||
import mage.watchers.common.BlockedAttackerWatcher;
|
||||
|
|
@ -159,7 +159,6 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
FILTER_LEGENDARY.add(new SupertypePredicate("Legendary"));
|
||||
}
|
||||
|
||||
private static Random rnd = new Random();
|
||||
|
||||
private transient Object customData;
|
||||
protected boolean simulation = false;
|
||||
|
|
@ -1010,9 +1009,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
for (UUID playerId : state.getPlayerList(startingPlayerId)) {
|
||||
Player player = getPlayer(playerId);
|
||||
if (player != null && player.getHand().size() < startingHandSize) {
|
||||
if (player.chooseUse(Outcome.Benefit, new MessageToClient("Scry 1?", "Look at the top card of your library. You may put that card on the bottom of your library."), null, this)) {
|
||||
player.scry(1, null, this);
|
||||
}
|
||||
player.scry(1, null, this);
|
||||
}
|
||||
}
|
||||
getState().setChoosingPlayerId(null);
|
||||
|
|
@ -1098,7 +1095,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
UUID[] players = getPlayers().keySet().toArray(new UUID[0]);
|
||||
UUID playerId;
|
||||
while (!hasEnded()) {
|
||||
playerId = players[rnd.nextInt(players.length)];
|
||||
playerId = players[RandomUtil.nextInt(players.length)];
|
||||
Player player = getPlayer(playerId);
|
||||
if (player != null && player.isInGame()) {
|
||||
fireInformEvent(state.getPlayer(playerId).getLogName() + " won the toss");
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import mage.cards.Card;
|
|||
import mage.cards.repository.CardCriteria;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.util.RandomUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -71,7 +72,6 @@ public abstract class DraftCube {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(DraftCube.class);
|
||||
|
||||
private static final Random rnd = new Random();
|
||||
private final String name;
|
||||
private final int boosterSize = 15;
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ public abstract class DraftCube {
|
|||
boolean done = false;
|
||||
int notValid = 0;
|
||||
while (!done) {
|
||||
int index = rnd.nextInt(leftCubeCards.size());
|
||||
int index = RandomUtil.nextInt(leftCubeCards.size());
|
||||
CardIdentity cardId = leftCubeCards.get(index);
|
||||
leftCubeCards.remove(index);
|
||||
if (!cardId.getName().isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ public abstract class DraftImpl implements Draft {
|
|||
for(UUID playerId : players.keySet()) {
|
||||
table.add(playerId);
|
||||
}
|
||||
|
||||
table.setCurrent(currentId);
|
||||
}
|
||||
if (oldDraftPlayer.isPicking()) {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import mage.game.result.ResultProtos.MatchProto;
|
|||
import mage.game.result.ResultProtos.MatchQuitStatus;
|
||||
import mage.players.Player;
|
||||
import mage.util.DateFormat;
|
||||
import mage.util.RandomUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -243,7 +244,7 @@ public abstract class MatchImpl implements Match {
|
|||
}
|
||||
|
||||
protected void shufflePlayers() {
|
||||
Collections.shuffle(this.players, new Random());
|
||||
Collections.shuffle(this.players, RandomUtil.getRandom());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ package mage.game.permanent.token;
|
|||
import java.util.Random;
|
||||
import mage.constants.CardType;
|
||||
import mage.MageInt;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -41,7 +42,7 @@ public class CentaurToken extends Token {
|
|||
public CentaurToken() {
|
||||
super("Centaur", "3/3 green Centaur creature token");
|
||||
cardType.add(CardType.CREATURE);
|
||||
setTokenType(new Random().nextInt(2) +1); // randomly take image 1 or 2
|
||||
setTokenType(RandomUtil.nextInt(2) +1); // randomly take image 1 or 2
|
||||
color.setGreen(true);
|
||||
subtype.add("Centaur");
|
||||
power = new MageInt(3);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import mage.abilities.costs.mana.GenericManaCost;
|
|||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Zone;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -69,10 +70,10 @@ public class ClueArtifactToken extends Token {
|
|||
public void setExpansionSetCodeForImage(String code) {
|
||||
super.setExpansionSetCodeForImage(code);
|
||||
if (getOriginalExpansionSetCode().equals("SOI")) {
|
||||
this.setTokenType(new Random().nextInt(6) + 1); // 6 different images
|
||||
this.setTokenType(RandomUtil.nextInt(6) + 1); // 6 different images
|
||||
}
|
||||
if (getOriginalExpansionSetCode().equals("EDM")) {
|
||||
this.setTokenType(new Random().nextInt(6) + 1); // 6 different images
|
||||
this.setTokenType(RandomUtil.nextInt(6) + 1); // 6 different images
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import mage.abilities.costs.common.SacrificeSourceCost;
|
|||
import mage.abilities.mana.SimpleManaAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Zone;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -65,10 +66,10 @@ public class EldraziScionToken extends Token {
|
|||
public void setExpansionSetCodeForImage(String code) {
|
||||
super.setExpansionSetCodeForImage(code);
|
||||
if (getOriginalExpansionSetCode().equals("BFZ")) {
|
||||
this.setTokenType(new Random().nextInt(3) + 1); // 3 different images
|
||||
this.setTokenType(RandomUtil.nextInt(3) + 1); // 3 different images
|
||||
}
|
||||
if (getOriginalExpansionSetCode().equals("OGW")) {
|
||||
this.setTokenType(new Random().nextInt(6) + 1); // 6 different images
|
||||
this.setTokenType(RandomUtil.nextInt(6) + 1); // 6 different images
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import mage.abilities.costs.common.SacrificeSourceCost;
|
|||
import mage.abilities.mana.SimpleManaAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Zone;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -61,6 +62,6 @@ public class EldraziSpawnToken extends Token {
|
|||
|
||||
availableImageSetCodes = tokenImageSets;
|
||||
// Get one of the three possible token images
|
||||
this.setTokenType(new Random().nextInt(3) + 1);
|
||||
this.setTokenType(RandomUtil.nextInt(3) + 1);
|
||||
}
|
||||
}
|
||||
72
Mage/src/main/java/mage/game/permanent/token/ServoToken.java
Normal file
72
Mage/src/main/java/mage/game/permanent/token/ServoToken.java
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fireshoes
|
||||
*/
|
||||
public class ServoToken extends Token {
|
||||
|
||||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("KLD"));
|
||||
}
|
||||
|
||||
public ServoToken() {
|
||||
super("Servo", "1/1 colorless Servo artifact creature token");
|
||||
availableImageSetCodes = tokenImageSets;
|
||||
cardType.add(CardType.ARTIFACT);
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add("Servo");
|
||||
power = new MageInt(1);
|
||||
toughness = new MageInt(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpansionSetCodeForImage(String code) {
|
||||
super.setExpansionSetCodeForImage(code);
|
||||
}
|
||||
|
||||
public ServoToken(final ServoToken token) {
|
||||
super(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServoToken copy() {
|
||||
return new ServoToken(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -33,6 +33,7 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -62,7 +63,7 @@ public class SoldierToken extends Token {
|
|||
public void setExpansionSetCodeForImage(String code) {
|
||||
super.setExpansionSetCodeForImage(code);
|
||||
if (getOriginalExpansionSetCode().equals("THS")) {
|
||||
this.setTokenType(new Random().nextInt(2) + 1);
|
||||
this.setTokenType(RandomUtil.nextInt(2) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import java.util.Random;
|
|||
import mage.MageInt;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -63,7 +64,7 @@ public class ThopterColorlessToken extends Token {
|
|||
public void setExpansionSetCodeForImage(String code) {
|
||||
super.setExpansionSetCodeForImage(code);
|
||||
if (getOriginalExpansionSetCode().equals("ORI")) {
|
||||
this.setTokenType(new Random().nextInt(2) + 1);
|
||||
this.setTokenType(RandomUtil.nextInt(2) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import mage.game.events.ZoneChangeEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
import mage.players.Player;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
public class Token extends MageObjectImpl {
|
||||
|
||||
|
|
@ -290,7 +291,7 @@ public class Token extends MageObjectImpl {
|
|||
// we should not set random set if appropriate set is already used
|
||||
if (getOriginalExpansionSetCode() == null || getOriginalExpansionSetCode().isEmpty()
|
||||
|| !availableImageSetCodes.contains(getOriginalExpansionSetCode())) {
|
||||
setOriginalExpansionSetCode(availableImageSetCodes.get(new Random().nextInt(availableImageSetCodes.size())));
|
||||
setOriginalExpansionSetCode(availableImageSetCodes.get(RandomUtil.nextInt(availableImageSetCodes.size())));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import java.util.Arrays;
|
|||
import java.util.Random;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -62,7 +63,7 @@ public class WarriorToken extends Token {
|
|||
public void setExpansionSetCodeForImage(String code) {
|
||||
super.setExpansionSetCodeForImage(code);
|
||||
if (getOriginalExpansionSetCode().equals("KTK")) {
|
||||
this.setTokenType(new Random().nextInt(2) + 1);
|
||||
this.setTokenType(RandomUtil.nextInt(2) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -61,13 +62,13 @@ public class ZombieToken extends Token {
|
|||
public void setExpansionSetCodeForImage(String code) {
|
||||
super.setExpansionSetCodeForImage(code);
|
||||
if (getOriginalExpansionSetCode().equals("ISD")) {
|
||||
this.setTokenType(new Random().nextInt(3) + 1);
|
||||
this.setTokenType(RandomUtil.nextInt(3) + 1);
|
||||
}
|
||||
if (getOriginalExpansionSetCode().equals("C14")) {
|
||||
this.setTokenType(2);
|
||||
}
|
||||
if (getOriginalExpansionSetCode().equals("EMN")) {
|
||||
this.setTokenType(new Random().nextInt(4) + 1);
|
||||
this.setTokenType(RandomUtil.nextInt(4) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import mage.game.result.ResultProtos.MatchQuitStatus;
|
|||
import mage.game.result.ResultProtos.TourneyProto;
|
||||
import mage.game.result.ResultProtos.TourneyRoundProto;
|
||||
import mage.players.Player;
|
||||
import mage.util.RandomUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -68,7 +69,6 @@ public abstract class TournamentImpl implements Tournament {
|
|||
protected UUID id = UUID.randomUUID();
|
||||
protected List<Round> rounds = new CopyOnWriteArrayList<>();
|
||||
protected Map<UUID, TournamentPlayer> players = new HashMap<>();
|
||||
protected static Random rnd = new Random();
|
||||
protected String matchName;
|
||||
protected TournamentOptions options;
|
||||
protected TournamentType tournamentType;
|
||||
|
|
@ -217,7 +217,7 @@ public abstract class TournamentImpl implements Tournament {
|
|||
private TournamentPlayer getNextAvailablePlayer(List<TournamentPlayer> roundPlayers, List<TournamentPlayer> playerWithByes) {
|
||||
TournamentPlayer nextPlayer;
|
||||
if (playerWithByes.isEmpty()) {
|
||||
int i = rnd.nextInt(roundPlayers.size());
|
||||
int i = RandomUtil.nextInt(roundPlayers.size());
|
||||
nextPlayer = roundPlayers.get(i);
|
||||
roundPlayers.remove(i);
|
||||
} else { // prefer players with byes to pair
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue