forked from External/mage
Merge pull request #2861 from kubikrubikvkube/master
Bugfix - after 12820b54d4 refactoring
This commit is contained in:
commit
c2191227cd
21 changed files with 103 additions and 105 deletions
|
|
@ -1,7 +1,5 @@
|
|||
package mage.client.util.gui;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
|
@ -14,31 +12,37 @@ import java.util.List;
|
|||
*/
|
||||
public class ArrowBuilder {
|
||||
|
||||
private static final ArrowBuilder instance;
|
||||
private static ArrowBuilder instance;
|
||||
|
||||
static {
|
||||
instance = new ArrowBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores arrow panels per game
|
||||
*/
|
||||
private final Map<UUID, JPanel> arrowPanels = new HashMap<>();
|
||||
private final Map<UUID, Map<Type, List<Arrow>>> map = new MapMaker().weakKeys().weakValues().makeMap();
|
||||
/**
|
||||
* The top panel where arrow panels are added to.
|
||||
*/
|
||||
private JPanel arrowsManagerPanel;
|
||||
private int currentWidth;
|
||||
private int currentHeight;
|
||||
|
||||
public static ArrowBuilder getBuilder() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* The top panel where arrow panels are added to.
|
||||
*/
|
||||
private JPanel arrowsManagerPanel;
|
||||
|
||||
/**
|
||||
* Stores arrow panels per game
|
||||
*/
|
||||
private final Map<UUID, JPanel> arrowPanels = new HashMap<UUID, JPanel>();
|
||||
|
||||
private final Map<UUID, Map<Type, List<Arrow>>> map = new HashMap<UUID, Map<Type, java.util.List<Arrow>>>();
|
||||
|
||||
private int currentWidth;
|
||||
private int currentHeight;
|
||||
|
||||
public enum Type {
|
||||
PAIRED, SOURCE, TARGET, COMBAT, ENCHANT_PLAYERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the panel where all arrows are being drawn.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public JPanel getArrowsManagerPanel() {
|
||||
|
|
@ -69,6 +73,17 @@ public class ArrowBuilder {
|
|||
return arrowPanels.get(gameId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not synchronized method for arrows panel.
|
||||
* Doesn't create JPanel in case the panel doesn't exist.
|
||||
* Works faster.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/*public JPanel getPanelRef() {
|
||||
return arrowsManagerPanel;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Adds new arrow.
|
||||
*
|
||||
|
|
@ -85,25 +100,26 @@ public class ArrowBuilder {
|
|||
arrow.setColor(color);
|
||||
arrow.setArrowLocation(startX, startY, endX, endY);
|
||||
arrow.setBounds(0, 0, Math.max(startX, endX) + 40, Math.max(startY, endY) + 30); // 30 is offset for arrow heads (being cut otherwise)
|
||||
p.add(arrow);
|
||||
Map<Type, List<Arrow>> innerMap = map.computeIfAbsent(gameId, k -> new HashMap<>());
|
||||
List<Arrow> arrows = innerMap.computeIfAbsent(type, k -> new ArrayList<>());
|
||||
arrows.add(arrow);
|
||||
|
||||
synchronized (map) {
|
||||
p.add(arrow);
|
||||
Map<Type, java.util.List<Arrow>> innerMap = map.get(gameId);
|
||||
if (innerMap == null) {
|
||||
innerMap = new HashMap<Type, List<Arrow>>();
|
||||
map.put(gameId, innerMap);
|
||||
}
|
||||
java.util.List<Arrow> arrows = innerMap.get(type);
|
||||
if (arrows == null) {
|
||||
arrows = new ArrayList<Arrow>();
|
||||
innerMap.put(type, arrows);
|
||||
}
|
||||
arrows.add(arrow);
|
||||
}
|
||||
|
||||
p.revalidate();
|
||||
p.repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Not synchronized method for arrows panel.
|
||||
* Doesn't create JPanel in case the panel doesn't exist.
|
||||
* Works faster.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
/*public JPanel getPanelRef() {
|
||||
return arrowsManagerPanel;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Removes all arrows from the screen.
|
||||
*/
|
||||
|
|
@ -111,13 +127,15 @@ public class ArrowBuilder {
|
|||
if (map.containsKey(gameId)) {
|
||||
Map<Type, List<Arrow>> innerMap = map.get(gameId);
|
||||
JPanel p = getArrowsPanel(gameId);
|
||||
if (p != null && p.getComponentCount() > 0) {
|
||||
p.removeAll();
|
||||
p.revalidate();
|
||||
p.repaint();
|
||||
synchronized (map) {
|
||||
if (p != null && p.getComponentCount() > 0) {
|
||||
p.removeAll();
|
||||
p.revalidate();
|
||||
p.repaint();
|
||||
}
|
||||
innerMap.clear();
|
||||
map.remove(gameId);
|
||||
}
|
||||
innerMap.clear();
|
||||
map.remove(gameId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -125,12 +143,14 @@ public class ArrowBuilder {
|
|||
if (map.containsKey(gameId)) {
|
||||
Map<Type, List<Arrow>> innerMap = map.get(gameId);
|
||||
java.util.List<Arrow> arrows = innerMap.get(type);
|
||||
if (arrows != null && !arrows.isEmpty()) {
|
||||
if (arrows != null && arrows.size() > 0) {
|
||||
JPanel p = getArrowsPanel(gameId);
|
||||
for (Arrow arrow : arrows) {
|
||||
p.remove(arrow);
|
||||
synchronized (map) {
|
||||
for (Arrow arrow : arrows) {
|
||||
p.remove(arrow);
|
||||
}
|
||||
innerMap.put(type, new ArrayList<Arrow>());
|
||||
}
|
||||
innerMap.put(type, new ArrayList<>());
|
||||
p.revalidate();
|
||||
p.repaint();
|
||||
}
|
||||
|
|
@ -161,8 +181,4 @@ public class ArrowBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
PAIRED, SOURCE, TARGET, COMBAT, ENCHANT_PLAYERS
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,12 +240,9 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
private static List<CardDownloadData> getNeededCards(List<CardInfo> allCards) {
|
||||
|
||||
List<CardDownloadData> cardsToDownload = Collections.synchronizedList(new ArrayList<>());
|
||||
|
||||
/**
|
||||
* read all card names and urls
|
||||
*/
|
||||
List<CardDownloadData> allCardsUrls = Collections.synchronizedList(new ArrayList<>());
|
||||
HashSet<String> ignoreUrls = SettingsManager.getIntance().getIgnoreUrls();
|
||||
|
||||
/**
|
||||
|
|
@ -261,6 +258,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
int numberCardImages = allCards.size();
|
||||
int numberWithoutTokens = 0;
|
||||
List<CardDownloadData> allCardsUrls = Collections.synchronizedList(new ArrayList<>());
|
||||
try {
|
||||
offlineMode = true;
|
||||
allCards.parallelStream().forEach(card -> {
|
||||
|
|
@ -290,11 +288,11 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
if (card.getFlipCardName() == null || card.getFlipCardName().trim().isEmpty()) {
|
||||
throw new IllegalStateException("Flipped card can't have empty name.");
|
||||
}
|
||||
url = new CardDownloadData(card.getFlipCardName(), card.getSetCode(), card.getCardNumber(), card.usesVariousArt(), 0, "", "", false, card.isDoubleFaced(), card.isNightCard());
|
||||
url.setFlipCard(true);
|
||||
url.setFlippedSide(true);
|
||||
url.setType2(isType2);
|
||||
allCardsUrls.add(url);
|
||||
CardDownloadData cardDownloadData = new CardDownloadData(card.getFlipCardName(), card.getSetCode(), card.getCardNumber(), card.usesVariousArt(), 0, "", "", false, card.isDoubleFaced(), card.isNightCard());
|
||||
cardDownloadData.setFlipCard(true);
|
||||
cardDownloadData.setFlippedSide(true);
|
||||
cardDownloadData.setType2(isType2);
|
||||
allCardsUrls.add(cardDownloadData);
|
||||
}
|
||||
} else if (card.getCardNumber().isEmpty() || "0".equals(card.getCardNumber())) {
|
||||
System.err.println("There was a critical error!");
|
||||
|
|
@ -315,6 +313,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
/**
|
||||
* check to see which cards we already have
|
||||
*/
|
||||
List<CardDownloadData> cardsToDownload = Collections.synchronizedList(new ArrayList<>());
|
||||
allCardsUrls.parallelStream().forEach(card -> {
|
||||
TFile file = new TFile(CardImageUtils.generateImagePath(card));
|
||||
if (!file.exists()) {
|
||||
|
|
@ -348,19 +347,18 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
try(InputStreamReader input = new InputStreamReader(in);
|
||||
BufferedReader reader = new BufferedReader(input)) {
|
||||
String line;
|
||||
|
||||
line = reader.readLine();
|
||||
String line = reader.readLine();
|
||||
while (line != null) {
|
||||
line = line.trim();
|
||||
if (line.startsWith("|")) { // new format
|
||||
String[] params = line.split("\\|", -1);
|
||||
if (params.length >= 5) {
|
||||
int type = 0;
|
||||
String fileName = "";
|
||||
if (params[4] != null && !params[4].isEmpty()) {
|
||||
type = Integer.parseInt(params[4].trim());
|
||||
}
|
||||
String fileName = "";
|
||||
if (params.length > 5 && params[5] != null && !params[5].isEmpty()) {
|
||||
fileName = params[5].trim();
|
||||
}
|
||||
|
|
@ -516,7 +514,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
private final String actualFilename;
|
||||
private final boolean useSpecifiedPaths;
|
||||
|
||||
public DownloadTask(CardDownloadData card, URL url, int count) {
|
||||
DownloadTask(CardDownloadData card, URL url, int count) {
|
||||
this.card = card;
|
||||
this.url = url;
|
||||
this.count = count;
|
||||
|
|
@ -524,7 +522,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
useSpecifiedPaths = false;
|
||||
}
|
||||
|
||||
public DownloadTask(CardDownloadData card, URL url, String actualFilename, int count) {
|
||||
DownloadTask(CardDownloadData card, URL url, String actualFilename, int count) {
|
||||
this.card = card;
|
||||
this.url = url;
|
||||
this.count = count;
|
||||
|
|
@ -583,7 +581,6 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
}
|
||||
return;
|
||||
}
|
||||
BufferedOutputStream out;
|
||||
|
||||
// Logger.getLogger(this.getClass()).info(url.toString());
|
||||
boolean useTempFile = false;
|
||||
|
|
@ -602,6 +599,7 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
|
|||
|
||||
if (responseCode == 200 || useTempFile) {
|
||||
if (!useTempFile) {
|
||||
BufferedOutputStream out;
|
||||
try (BufferedInputStream in = new BufferedInputStream(httpConn.getInputStream())) {
|
||||
//try (BufferedInputStream in = new BufferedInputStream(url.openConnection(p).getInputStream())) {
|
||||
out = new BufferedOutputStream(new TFileOutputStream(temporaryFile));
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import org.mage.plugins.card.utils.CardImageUtils;
|
|||
* look</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class ImageCache {
|
||||
public final class ImageCache {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ImageCache.class);
|
||||
|
||||
|
|
@ -157,6 +157,9 @@ public class ImageCache {
|
|||
});
|
||||
}
|
||||
|
||||
private ImageCache() {
|
||||
}
|
||||
|
||||
public static BufferedImage getMorphImage() {
|
||||
CardDownloadData info = new CardDownloadData("Morph", "KTK", "0", false, 0, "KTK", "");
|
||||
info.setToken(true);
|
||||
|
|
@ -222,8 +225,7 @@ public class ImageCache {
|
|||
*/
|
||||
private static BufferedImage getImage(String key) {
|
||||
try {
|
||||
BufferedImage image = IMAGE_CACHE.get(key);
|
||||
return image;
|
||||
return IMAGE_CACHE.get(key);
|
||||
} catch (NullPointerException ex) {
|
||||
// unfortunately NullOutputException, thrown when apply() returns
|
||||
// null, is not public
|
||||
|
|
@ -244,11 +246,7 @@ public class ImageCache {
|
|||
* the cache.
|
||||
*/
|
||||
private static BufferedImage tryGetImage(String key) {
|
||||
if (IMAGE_CACHE.containsKey(key)) {
|
||||
return IMAGE_CACHE.get(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return IMAGE_CACHE.containsKey(key) ? IMAGE_CACHE.get(key) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -279,11 +277,11 @@ public class ImageCache {
|
|||
if (file == null) {
|
||||
return null;
|
||||
}
|
||||
BufferedImage image = null;
|
||||
if (!file.exists()) {
|
||||
LOGGER.debug("File does not exist: " + file.toString());
|
||||
return null;
|
||||
}
|
||||
BufferedImage image = null;
|
||||
try {
|
||||
try (TFileInputStream inputStream = new TFileInputStream(file)) {
|
||||
image = ImageIO.read(inputStream);
|
||||
|
|
@ -395,8 +393,7 @@ public class ImageCache {
|
|||
|
||||
public static TFile getTFile(String path) {
|
||||
try {
|
||||
TFile file = new TFile(path);
|
||||
return file;
|
||||
return new TFile(path);
|
||||
} catch (NullPointerException ex) {
|
||||
LOGGER.warn("Imagefile does not exist: " + path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -271,8 +271,7 @@ public class ChatManager {
|
|||
}
|
||||
|
||||
public ArrayList<ChatSession> getChatSessions() {
|
||||
ArrayList<ChatSession> chatSessionList = new ArrayList<>(chatSessions.values());
|
||||
return chatSessionList;
|
||||
return new ArrayList<>(chatSessions.values());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
package mage.server;
|
||||
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.server.exceptions.UserNotFoundException;
|
||||
import mage.view.ChatMessage;
|
||||
import mage.view.ChatMessage.MessageColor;
|
||||
import mage.view.ChatMessage.MessageType;
|
||||
|
|
@ -36,7 +35,6 @@ import mage.view.ChatMessage.SoundToPlay;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
|
|
|
|||
|
|
@ -227,13 +227,13 @@ public class MageServerImpl implements MageServer {
|
|||
// check AI players max
|
||||
String maxAiOpponents = ConfigSettings.getInstance().getMaxAiOpponents();
|
||||
if (maxAiOpponents != null) {
|
||||
int max = Integer.parseInt(maxAiOpponents);
|
||||
int aiPlayers = 0;
|
||||
for (String playerType : options.getPlayerTypes()) {
|
||||
if (!playerType.equals("Human")) {
|
||||
aiPlayers++;
|
||||
}
|
||||
}
|
||||
int max = Integer.parseInt(maxAiOpponents);
|
||||
if (aiPlayers > max) {
|
||||
user.showUserMessage("Create tournament", "It's only allowed to use a maximum of " + max + " AI players.");
|
||||
throw new MageException("No message");
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ public class MailClient {
|
|||
message.setSubject(subject);
|
||||
message.setText(text);
|
||||
|
||||
Transport trnsport;
|
||||
trnsport = session.getTransport("smtps");
|
||||
Transport trnsport = session.getTransport("smtps");
|
||||
trnsport.connect(null, properties.getProperty("mail.password"));
|
||||
message.saveChanges();
|
||||
trnsport.sendMessage(message, message.getAllRecipients());
|
||||
|
|
|
|||
|
|
@ -116,13 +116,13 @@ public class Main {
|
|||
}
|
||||
|
||||
logger.info("Loading extension packages...");
|
||||
List<ExtensionPackage> extensions = new ArrayList<>();
|
||||
if (!extensionFolder.exists()) {
|
||||
if (!extensionFolder.mkdirs()) {
|
||||
logger.error("Could not create extensions directory.");
|
||||
}
|
||||
}
|
||||
File[] extensionDirectories = extensionFolder.listFiles();
|
||||
List<ExtensionPackage> extensions = new ArrayList<>();
|
||||
if (extensionDirectories != null) {
|
||||
for (File f : extensionDirectories) {
|
||||
if (f.isDirectory()) {
|
||||
|
|
|
|||
|
|
@ -101,11 +101,11 @@ public class Session {
|
|||
return returnMessage;
|
||||
}
|
||||
AuthorizedUserRepository.instance.add(userName, password, email);
|
||||
String subject = "XMage Registration Completed";
|
||||
String text = "You are successfully registered as " + userName + '.';
|
||||
text += " Your initial, generated password is: " + password;
|
||||
|
||||
boolean success;
|
||||
String subject = "XMage Registration Completed";
|
||||
if (!ConfigSettings.getInstance().getMailUser().isEmpty()) {
|
||||
success = MailClient.sendMessage(email, subject, text);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -173,8 +173,9 @@ public class SessionManager {
|
|||
*/
|
||||
public void disconnectUser(String sessionId, String userSessionId) {
|
||||
if (isAdmin(sessionId)) {
|
||||
User userAdmin, user;
|
||||
User userAdmin;
|
||||
if ((userAdmin = getUserFromSession(sessionId)) != null) {
|
||||
User user;
|
||||
if ((user = getUserFromSession(userSessionId)) != null) {
|
||||
user.showUserMessage("Admin operation", "Your session was disconnected by Admin.");
|
||||
userAdmin.showUserMessage("Admin action", "User" + user.getName() + " was disconnected.");
|
||||
|
|
|
|||
|
|
@ -911,9 +911,6 @@ public class TableController {
|
|||
public boolean isMatchTableStillValid() {
|
||||
// check only normal match table with state != Finished
|
||||
if (!table.isTournament()) {
|
||||
int humanPlayers = 0;
|
||||
int aiPlayers = 0;
|
||||
int validHumanPlayers = 0;
|
||||
if (!(table.getState() == TableState.WAITING || table.getState() == TableState.STARTING || table.getState() == TableState.READY_TO_START)) {
|
||||
if (match == null) {
|
||||
logger.debug("- Match table with no match:");
|
||||
|
|
@ -927,6 +924,9 @@ public class TableController {
|
|||
}
|
||||
}
|
||||
// check for active players
|
||||
int validHumanPlayers = 0;
|
||||
int aiPlayers = 0;
|
||||
int humanPlayers = 0;
|
||||
for (Map.Entry<UUID, UUID> userPlayerEntry : userPlayerMap.entrySet()) {
|
||||
MatchPlayer matchPlayer = match.getPlayer(userPlayerEntry.getValue());
|
||||
if (matchPlayer == null) {
|
||||
|
|
|
|||
|
|
@ -55,9 +55,8 @@ public class CubeFactory {
|
|||
public DraftCube createDraftCube(String draftCubeName) {
|
||||
|
||||
DraftCube draftCube;
|
||||
Constructor<?> con;
|
||||
try {
|
||||
con = draftCubes.get(draftCubeName).getConstructor();
|
||||
Constructor<?> con = draftCubes.get(draftCubeName).getConstructor();
|
||||
draftCube = (DraftCube)con.newInstance();
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("CubeFactory error", ex);
|
||||
|
|
@ -71,9 +70,8 @@ public class CubeFactory {
|
|||
public DraftCube createDeckDraftCube(String draftCubeName, Deck cubeFromDeck) {
|
||||
|
||||
DraftCube draftCube;
|
||||
Constructor<?> con;
|
||||
try {
|
||||
con = draftCubes.get(draftCubeName).getConstructor(Deck.class);
|
||||
Constructor<?> con = draftCubes.get(draftCubeName).getConstructor(Deck.class);
|
||||
draftCube = (DraftCube)con.newInstance(cubeFromDeck);
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("CubeFactory error", ex);
|
||||
|
|
|
|||
|
|
@ -55,9 +55,8 @@ public class DeckValidatorFactory {
|
|||
public DeckValidator createDeckValidator(String deckType) {
|
||||
|
||||
DeckValidator validator;
|
||||
Constructor<?> con;
|
||||
try {
|
||||
con = deckTypes.get(deckType).getConstructor();
|
||||
Constructor<?> con = deckTypes.get(deckType).getConstructor();
|
||||
validator = (DeckValidator)con.newInstance();
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("DeckValidatorFactory error", ex);
|
||||
|
|
|
|||
|
|
@ -621,9 +621,8 @@ public class GameController implements GameCallback {
|
|||
}
|
||||
|
||||
public void cheat(UUID userId, UUID playerId, DeckCardLists deckList) {
|
||||
Deck deck;
|
||||
try {
|
||||
deck = Deck.load(deckList, false, false);
|
||||
Deck deck = Deck.load(deckList, false, false);
|
||||
game.loadCards(deck.getCards(), playerId);
|
||||
for (Card card : deck.getCards()) {
|
||||
card.putOntoBattlefield(game, Zone.OUTSIDE, null, playerId);
|
||||
|
|
|
|||
|
|
@ -62,9 +62,8 @@ public class GameFactory {
|
|||
public Match createMatch(String gameType, MatchOptions options) {
|
||||
|
||||
Match match;
|
||||
Constructor<Match> con;
|
||||
try {
|
||||
con = games.get(gameType).getConstructor(MatchOptions.class);
|
||||
Constructor<Match> con = games.get(gameType).getConstructor(MatchOptions.class);
|
||||
match = con.newInstance(options);
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Error creating match - " + gameType, ex);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ package mage.server.game;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
|
@ -89,10 +88,10 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
}
|
||||
|
||||
private void update() {
|
||||
ArrayList<TableView> tableList = new ArrayList<>();
|
||||
ArrayList<MatchView> matchList = new ArrayList<>();
|
||||
List<Table> allTables = new ArrayList<>(tables.values());
|
||||
allTables.sort(new TableListSorter());
|
||||
ArrayList<MatchView> matchList = new ArrayList<>();
|
||||
ArrayList<TableView> tableList = new ArrayList<>();
|
||||
for (Table table : allTables) {
|
||||
if (table.getState() != TableState.FINISHED) {
|
||||
tableList.add(new TableView(table));
|
||||
|
|
|
|||
|
|
@ -54,13 +54,11 @@ public class PlayerFactory {
|
|||
private PlayerFactory() {}
|
||||
|
||||
public Player createPlayer(String playerType, String name, RangeOfInfluence range, int skill) {
|
||||
Player player;
|
||||
Constructor<?> con;
|
||||
try {
|
||||
Class playerTypeClass = playerTypes.get(playerType);
|
||||
if (playerTypeClass != null) {
|
||||
con = playerTypeClass.getConstructor(String.class, RangeOfInfluence.class, int.class);
|
||||
player = (Player)con.newInstance(name, range, skill);
|
||||
Constructor<?> con = playerTypeClass.getConstructor(String.class, RangeOfInfluence.class, int.class);
|
||||
Player player = (Player) con.newInstance(name, range, skill);
|
||||
logger.trace("Player created: " + name + " - " + player.getId());
|
||||
return player;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import java.util.UUID;
|
|||
import mage.game.Game;
|
||||
import mage.game.GameState;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.server.User;
|
||||
import mage.server.UserManager;
|
||||
import mage.view.GameView;
|
||||
|
||||
|
|
|
|||
|
|
@ -418,10 +418,10 @@ public class TournamentController {
|
|||
}
|
||||
// replace player that quits with draft bot
|
||||
if (humans > 1) {
|
||||
String replacePlayerName = "Draftbot";
|
||||
Optional<User> user = UserManager.getInstance().getUser(userId);
|
||||
TableController tableController = TableManager.getInstance().getController(tableId);
|
||||
if (tableController != null) {
|
||||
String replacePlayerName = "Draftbot";
|
||||
if (user.isPresent()) {
|
||||
replacePlayerName = "Draftbot (" + user.get().getName() + ')';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,9 +64,8 @@ public class TournamentFactory {
|
|||
public Tournament createTournament(String tournamentType, TournamentOptions options) {
|
||||
|
||||
Tournament tournament;
|
||||
Constructor<Tournament> con;
|
||||
try {
|
||||
con = tournaments.get(tournamentType).getConstructor(TournamentOptions.class);
|
||||
Constructor<Tournament> con = tournaments.get(tournamentType).getConstructor(TournamentOptions.class);
|
||||
tournament = con.newInstance(options);
|
||||
// transfer set information, create short info string for included sets
|
||||
tournament.setTournamentType(tournamentTypes.get(tournamentType));
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ public class SystemUtil {
|
|||
public static void addCardsForTesting(Game game) {
|
||||
try {
|
||||
File f = new File(INIT_FILE_PATH);
|
||||
Pattern pattern = Pattern.compile("([a-zA-Z]+):([\\w]+):([a-zA-Z ,\\/\\-.!'\\d:]+?):(\\d+)");
|
||||
if (!f.exists()) {
|
||||
logger.warn("Couldn't find init file: " + INIT_FILE_PATH);
|
||||
return;
|
||||
|
|
@ -54,6 +53,7 @@ public class SystemUtil {
|
|||
logger.info("Parsing init.txt... ");
|
||||
|
||||
try (Scanner scanner = new Scanner(f)) {
|
||||
Pattern pattern = Pattern.compile("([a-zA-Z]+):([\\w]+):([a-zA-Z ,\\/\\-.!'\\d:]+?):(\\d+)");
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine().trim();
|
||||
if (line.isEmpty() || line.startsWith("#")) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue