mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Merge branch 'master' into migrate-google-collections-to-guava
This commit is contained in:
commit
f76efb2b65
483 changed files with 2270 additions and 1997 deletions
|
@ -9,7 +9,6 @@
|
|||
<version>1.4.33</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-client</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Mage Client</name>
|
||||
|
@ -52,7 +51,7 @@
|
|||
<dependency>
|
||||
<groupId>com.mortennobel</groupId>
|
||||
<artifactId>java-image-scaling</artifactId>
|
||||
<version>0.8.5</version>
|
||||
<version>0.8.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
|
@ -67,12 +66,12 @@
|
|||
<dependency>
|
||||
<groupId>org.jetlang</groupId>
|
||||
<artifactId>jetlang</artifactId>
|
||||
<version>0.2.9</version>
|
||||
<version>0.2.23</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
<version>1.11.286</version>
|
||||
<version>1.11.498</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jgoodies</groupId>
|
||||
|
@ -109,13 +108,13 @@
|
|||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.5.2</version>
|
||||
<version>1.11.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>truevfs-profile-base</artifactId>
|
||||
<groupId>net.java.truevfs</groupId>
|
||||
<type>jar</type>
|
||||
<version>0.10.8</version>
|
||||
<version>0.11.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>truevfs-access-swing</artifactId>
|
||||
|
@ -130,7 +129,7 @@
|
|||
<dependency>
|
||||
<groupId>com.googlecode.soundlibs</groupId>
|
||||
<artifactId>mp3spi</artifactId>
|
||||
<version>1.9.5-1</version>
|
||||
<version>1.9.5.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javazoom</groupId>
|
||||
|
@ -155,13 +154,13 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.xmlgraphics</groupId>
|
||||
<artifactId>batik-transcoder</artifactId>
|
||||
<version>1.7</version>
|
||||
<version>1.11</version>
|
||||
</dependency>
|
||||
<!-- svg support end -->
|
||||
<dependency>
|
||||
<groupId>org.ocpsoft.prettytime</groupId>
|
||||
<artifactId>prettytime</artifactId>
|
||||
<version>3.2.7.Final</version>
|
||||
<version>4.0.2.Final</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.awt.event.KeyEvent;
|
|||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -35,18 +36,12 @@ import org.mage.card.arcane.CardRenderer;
|
|||
*/
|
||||
public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarget {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(DragCardGrid.class);
|
||||
private static final Logger LOGGER = Logger.getLogger(DragCardGrid.class);
|
||||
private Constants.DeckEditorMode mode;
|
||||
|
||||
@Override
|
||||
public Collection<CardView> dragCardList() {
|
||||
ArrayList<CardView> selectedCards = new ArrayList<>();
|
||||
for (CardView card : allCards) {
|
||||
if (card.isSelected()) {
|
||||
selectedCards.add(card);
|
||||
}
|
||||
}
|
||||
return selectedCards;
|
||||
return allCards.stream().filter(CardView::isSelected).collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,8 +57,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
// Don't remove the cards, no target
|
||||
} else {
|
||||
// Remove dragged cards
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
for (int i = 0; i < stack.size(); ++i) {
|
||||
CardView card = stack.get(i);
|
||||
if (card.isSelected()) {
|
||||
|
@ -160,7 +155,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
}
|
||||
|
||||
// Get the appropirate stack
|
||||
ArrayList<CardView> stack;
|
||||
List<CardView> stack;
|
||||
if (rowIndex < cardGrid.size() && col < cardGrid.get(0).size()) {
|
||||
stack = cardGrid.get(rowIndex).get(col);
|
||||
} else {
|
||||
|
@ -200,8 +195,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
// If we're dragging onto ourself, erase the old cards (just null them out, we will
|
||||
// compact the grid removing the null gaps / empty rows & cols later)
|
||||
if (source == this) {
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
for (int i = 0; i < stack.size(); ++i) {
|
||||
if (cards.contains(stack.get(i))) {
|
||||
stack.set(i, null);
|
||||
|
@ -241,7 +236,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
|
||||
// Add a new row if needed
|
||||
if (rowIndex >= cardGrid.size()) {
|
||||
ArrayList<ArrayList<CardView>> newRow = new ArrayList<>();
|
||||
List<List<CardView>> newRow = new ArrayList<>();
|
||||
if (!cardGrid.isEmpty()) {
|
||||
for (int colIndex = 0; colIndex < cardGrid.get(0).size(); ++colIndex) {
|
||||
newRow.add(new ArrayList<>());
|
||||
|
@ -286,7 +281,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
|
||||
// Add a new row if needed
|
||||
if (rowIndex >= cardGrid.size()) {
|
||||
ArrayList<ArrayList<CardView>> newRow = new ArrayList<>();
|
||||
List<List<CardView>> newRow = new ArrayList<>();
|
||||
if (!cardGrid.isEmpty()) {
|
||||
for (int colIndex = 0; colIndex < cardGrid.get(0).size(); ++colIndex) {
|
||||
newRow.add(new ArrayList<>());
|
||||
|
@ -304,7 +299,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
}
|
||||
|
||||
// Get the appropirate stack
|
||||
ArrayList<CardView> stack = cardGrid.get(rowIndex).get(col);
|
||||
List<CardView> stack = cardGrid.get(rowIndex).get(col);
|
||||
|
||||
// Figure out position in the stack based on the offsetIntoRow
|
||||
int stackInsertIndex = (offsetIntoStack + cardTopHeight / 2) / cardTopHeight;
|
||||
|
@ -375,8 +370,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
}
|
||||
|
||||
public void removeSelection() {
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
for (int i = 0; i < stack.size(); ++i) {
|
||||
CardView card = stack.get(i);
|
||||
if (card.isSelected()) {
|
||||
|
@ -394,11 +389,11 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
|
||||
public DeckCardLayout getCardLayout() {
|
||||
// 2D Array to put entries into
|
||||
java.util.List<java.util.List<java.util.List<DeckCardInfo>>> info = new ArrayList<>();
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
java.util.List<java.util.List<DeckCardInfo>> row = new ArrayList<>();
|
||||
List<List<List<DeckCardInfo>>> info = new ArrayList<>();
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
List<List<DeckCardInfo>> row = new ArrayList<>();
|
||||
info.add(row);
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
row.add(stack.stream()
|
||||
.map(card -> new DeckCardInfo(card.getName(), card.getCardNumber(), card.getExpansionSetCode()))
|
||||
.collect(Collectors.toList()));
|
||||
|
@ -544,12 +539,12 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
public static final int COUNT_LABEL_HEIGHT = 20;
|
||||
public static final int GRID_PADDING = 10;
|
||||
|
||||
private final static ImageIcon INSERT_ROW_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_row.png"));
|
||||
private final static ImageIcon INSERT_COL_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_col.png"));
|
||||
private static final ImageIcon INSERT_ROW_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_row.png"));
|
||||
private static final ImageIcon INSERT_COL_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_col.png"));
|
||||
|
||||
// All of the current card views
|
||||
private final Map<UUID, MageCard> cardViews = new LinkedHashMap<>();
|
||||
private final ArrayList<CardView> allCards = new ArrayList<>();
|
||||
private final List<CardView> allCards = new ArrayList<>();
|
||||
|
||||
// Card listeners
|
||||
private final CardEventSource eventSource = new CardEventSource();
|
||||
|
@ -578,8 +573,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
final JSlider cardSizeSlider;
|
||||
final JLabel cardSizeSliderLabel;
|
||||
|
||||
final Map<Sort, AbstractButton> sortButtons = new HashMap<>();
|
||||
final HashMap<CardType, AbstractButton> selectByTypeButtons = new HashMap<>();
|
||||
final Map<Sort, AbstractButton> sortButtons = new EnumMap<>(Sort.class);
|
||||
final Map<CardType, AbstractButton> selectByTypeButtons = new EnumMap<>(CardType.class);
|
||||
|
||||
final JLabel deckNameAndCountLabel;
|
||||
final JLabel landCountLabel;
|
||||
|
@ -611,11 +606,11 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
// The outermost array contains multiple rows of stacks of cards
|
||||
// The next inner array represents a row of stacks of cards
|
||||
// The innermost array represents a single vertical stack of cards
|
||||
private ArrayList<ArrayList<ArrayList<CardView>>> cardGrid;
|
||||
private ArrayList<Integer> maxStackSize = new ArrayList<>();
|
||||
private final ArrayList<ArrayList<JLabel>> stackCountLabels = new ArrayList<>();
|
||||
private List<List<List<CardView>>> cardGrid;
|
||||
private List<Integer> maxStackSize = new ArrayList<>();
|
||||
private final List<List<JLabel>> stackCountLabels = new ArrayList<>();
|
||||
private Sort cardSort = Sort.CMC;
|
||||
private final ArrayList<CardType> selectByTypeSelected = new ArrayList<>();
|
||||
private final List<CardType> selectByTypeSelected = new ArrayList<>();
|
||||
private boolean separateCreatures = true;
|
||||
|
||||
public enum Role {
|
||||
|
@ -639,7 +634,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
public boolean separateCreatures;
|
||||
public int cardSize;
|
||||
|
||||
private final static Pattern parser = Pattern.compile("\\(([^,]*),([^,]*),([^)]*)\\)");
|
||||
private static final Pattern parser = Pattern.compile("\\(([^,]*),([^,]*),([^)]*)\\)");
|
||||
|
||||
public static Settings parse(String str) {
|
||||
Matcher m = parser.matcher(str);
|
||||
|
@ -810,7 +805,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
insertArrow = new JLabel();
|
||||
insertArrow.setSize(20, 20);
|
||||
insertArrow.setVisible(false);
|
||||
cardContent.add(insertArrow, new Integer(1000));
|
||||
cardContent.add(insertArrow, 1000);
|
||||
|
||||
// Selection panel
|
||||
selectionPanel = new SelectionBox();
|
||||
|
@ -917,7 +912,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
ButtonGroup selectByTypeModeGroup = new ButtonGroup();
|
||||
for (final CardType cardType : CardType.values()) {
|
||||
|
||||
if (cardType == cardType.CONSPIRACY) {
|
||||
if (cardType == CardType.CONSPIRACY) {
|
||||
multiplesButton = new JToggleButton("Multiples");
|
||||
selectByTypeButtons.put(cardType, multiplesButton);
|
||||
selectByTypeMode.add(multiplesButton);
|
||||
|
@ -1045,8 +1040,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
* Deselect all cards in this DragCardGrid
|
||||
*/
|
||||
public void deselectAll() {
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
for (CardView card : stack) {
|
||||
if (card.isSelected()) {
|
||||
card.setSelected(false);
|
||||
|
@ -1166,9 +1161,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
} else {
|
||||
stackEndIndex = (y2 - curY) / cardTopHeight;
|
||||
}
|
||||
ArrayList<ArrayList<CardView>> gridRow = cardGrid.get(rowIndex);
|
||||
List<List<CardView>> gridRow = cardGrid.get(rowIndex);
|
||||
for (int col = 0; col < gridRow.size(); ++col) {
|
||||
ArrayList<CardView> stack = gridRow.get(col);
|
||||
List<CardView> stack = gridRow.get(col);
|
||||
int stackBottomBegin = curY + cardTopHeight * (stack.size());
|
||||
int stackBottomEnd = curY + cardTopHeight * (stack.size() - 1) + cardHeight;
|
||||
for (int i = 0; i < stack.size(); ++i) {
|
||||
|
@ -1201,8 +1196,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
// Resort the existing cards based on the current sort
|
||||
public void resort() {
|
||||
// First null out the grid and trim it down
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
stack.clear();
|
||||
}
|
||||
}
|
||||
|
@ -1243,8 +1238,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
if (cardType == CardType.CONSPIRACY) {
|
||||
HashMap<String, CardView> cardNames = new HashMap<>();
|
||||
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
for (CardView card : stack) {
|
||||
if (cardNames.get(card.getName()) == null) {
|
||||
cardNames.put(card.getName(), card);
|
||||
|
@ -1262,10 +1257,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
continue;
|
||||
}
|
||||
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
for (CardView card : stack) {
|
||||
boolean s = card.isSelected() | card.getCardTypes().contains(cardType);
|
||||
boolean s = card.isSelected() || card.getCardTypes().contains(cardType);
|
||||
card.setSelected(s);
|
||||
cardViews.get(card.getId()).update(card);
|
||||
}
|
||||
|
@ -1276,13 +1271,13 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
}
|
||||
|
||||
if (useText) {
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
for (CardView card : stack) {
|
||||
boolean s = card.isSelected();
|
||||
// Name
|
||||
if (!s) {
|
||||
s |= card.getName().toLowerCase(Locale.ENGLISH).contains(searchStr);
|
||||
s = card.getName().toLowerCase(Locale.ENGLISH).contains(searchStr);
|
||||
}
|
||||
// Sub & Super Types
|
||||
if (!s) {
|
||||
|
@ -1354,21 +1349,13 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
qtys.put("wastes", 0);
|
||||
manaCounts = new HashMap<>();
|
||||
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
for (CardView card : stack) {
|
||||
// Type line
|
||||
String t = "";
|
||||
for (CardType type : card.getCardTypes()) {
|
||||
t += ' ' + type.toString();
|
||||
}
|
||||
// Sub & Super Types
|
||||
for (SuperType type : card.getSuperTypes()) {
|
||||
t += ' ' + type.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
for (SubType str : card.getSubTypes()) {
|
||||
t += " " + str.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
String t = card.getCardTypes().stream().map(CardType::toString).collect(Collectors.joining(" "));
|
||||
t += card.getSuperTypes().stream().map(st -> st.toString().toLowerCase(Locale.ENGLISH)).collect(Collectors.joining(" "));
|
||||
t += card.getSubTypes().stream().map(st -> st.toString().toLowerCase(Locale.ENGLISH)).collect(Collectors.joining(" "));
|
||||
|
||||
for (String qty : qtys.keySet()) {
|
||||
int value = qtys.get(qty);
|
||||
|
@ -1494,7 +1481,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
}
|
||||
|
||||
public void blingDeck() {
|
||||
if (!(this.mode == Constants.DeckEditorMode.FREE_BUILDING)) {
|
||||
if (this.mode != Constants.DeckEditorMode.FREE_BUILDING) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1503,8 +1490,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
return;
|
||||
}
|
||||
|
||||
HashMap<String, Integer> pimpedSets = new HashMap<>();
|
||||
HashMap<CardView, Integer> pimpedCards = new HashMap<>();
|
||||
Map<String, Integer> pimpedSets = new HashMap<>();
|
||||
Map<CardView, Integer> pimpedCards = new HashMap<>();
|
||||
pimpedSets.put("CP", 1);
|
||||
pimpedSets.put("JR", 1);
|
||||
pimpedSets.put("MPS", 1);
|
||||
|
@ -1529,8 +1516,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
String[] sets = pimpedSets.keySet().toArray(new String[pimpedSets.keySet().size()]);
|
||||
Boolean didModify = false;
|
||||
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
for (CardView card : stack) {
|
||||
if (card.getSuperTypes().contains(SuperType.BASIC)) {
|
||||
continue;
|
||||
|
@ -1580,9 +1567,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
// Remove all of the cards not in the cardsView
|
||||
boolean didModify = false; // Until contested
|
||||
for (int i = 0; i < cardGrid.size(); ++i) {
|
||||
ArrayList<ArrayList<CardView>> gridRow = cardGrid.get(i);
|
||||
List<List<CardView>> gridRow = cardGrid.get(i);
|
||||
for (int j = 0; j < gridRow.size(); ++j) {
|
||||
ArrayList<CardView> stack = gridRow.get(j);
|
||||
List<CardView> stack = gridRow.get(j);
|
||||
for (int k = 0; k < stack.size(); ++k) {
|
||||
CardView card = stack.get(k);
|
||||
if (!cardsView.containsKey(card.getId())) {
|
||||
|
@ -1626,21 +1613,21 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
loadSettings(Settings.parse(layout.getSettings()));
|
||||
|
||||
// Traverse the cards once and track them so we can pick ones to insert into the grid
|
||||
Map<String, Map<String, ArrayList<CardView>>> trackedCards = new HashMap<>();
|
||||
Map<String, Map<String, List<CardView>>> trackedCards = new HashMap<>();
|
||||
for (CardView newCard : cardsView.values()) {
|
||||
if (!cardViews.containsKey(newCard.getId())) {
|
||||
// Add the new card
|
||||
addCardView(newCard, false);
|
||||
|
||||
// Add the new card to tracking
|
||||
Map<String, ArrayList<CardView>> forSetCode;
|
||||
Map<String, List<CardView>> forSetCode;
|
||||
if (trackedCards.containsKey(newCard.getExpansionSetCode())) {
|
||||
forSetCode = trackedCards.get(newCard.getExpansionSetCode());
|
||||
} else {
|
||||
forSetCode = new HashMap<>();
|
||||
trackedCards.put(newCard.getExpansionSetCode(), forSetCode);
|
||||
}
|
||||
ArrayList<CardView> list;
|
||||
List<CardView> list;
|
||||
if (forSetCode.containsKey(newCard.getCardNumber())) {
|
||||
list = forSetCode.get(newCard.getCardNumber());
|
||||
} else {
|
||||
|
@ -1654,16 +1641,16 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
// Now go through the layout and use it to build the cardGrid
|
||||
cardGrid = new ArrayList<>();
|
||||
maxStackSize = new ArrayList<>();
|
||||
for (java.util.List<java.util.List<DeckCardInfo>> row : layout.getCards()) {
|
||||
ArrayList<ArrayList<CardView>> gridRow = new ArrayList<>();
|
||||
for (List<List<DeckCardInfo>> row : layout.getCards()) {
|
||||
List<List<CardView>> gridRow = new ArrayList<>();
|
||||
int thisMaxStackSize = 0;
|
||||
cardGrid.add(gridRow);
|
||||
for (java.util.List<DeckCardInfo> stack : row) {
|
||||
for (List<DeckCardInfo> stack : row) {
|
||||
ArrayList<CardView> gridStack = new ArrayList<>();
|
||||
gridRow.add(gridStack);
|
||||
for (DeckCardInfo info : stack) {
|
||||
if (trackedCards.containsKey(info.getSetCode()) && trackedCards.get(info.getSetCode()).containsKey(info.getCardNum())) {
|
||||
ArrayList<CardView> candidates
|
||||
List<CardView> candidates
|
||||
= trackedCards.get(info.getSetCode()).get(info.getCardNum());
|
||||
if (!candidates.isEmpty()) {
|
||||
gridStack.add(candidates.remove(0));
|
||||
|
@ -1678,8 +1665,8 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
// Check that there aren't any "orphans" not referenced in the layout. There should
|
||||
// never be any under normal operation, but as a failsafe in case the user screwed with
|
||||
// the file in an invalid way, sort them into the grid so that they aren't just left hanging.
|
||||
for (Map<String, ArrayList<CardView>> tracked : trackedCards.values()) {
|
||||
for (ArrayList<CardView> orphans : tracked.values()) {
|
||||
for (Map<String, List<CardView>> tracked : trackedCards.values()) {
|
||||
for (List<CardView> orphans : tracked.values()) {
|
||||
for (CardView orphan : orphans) {
|
||||
LOGGER.info("Orphan when setting with layout: ");
|
||||
sortIntoGrid(orphan);
|
||||
|
@ -1733,7 +1720,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
AbstractButton button = selectByTypeButtons.get(cardType);
|
||||
String text = cardType.toString();
|
||||
int numCards = getCount(cardType);
|
||||
if (cardType == cardType.CONSPIRACY) {
|
||||
if (cardType == CardType.CONSPIRACY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1908,7 +1895,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
maxStackSize.add(0, 0);
|
||||
}
|
||||
// What row to add it to?
|
||||
ArrayList<ArrayList<CardView>> targetRow;
|
||||
List<List<CardView>> targetRow;
|
||||
if (separateCreatures && !newCard.isCreature()) {
|
||||
// Ensure row 2 exists
|
||||
if (cardGrid.size() < 2) {
|
||||
|
@ -1929,7 +1916,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
for (int currentColumn = 0; currentColumn < cardGrid.get(0).size(); ++currentColumn) {
|
||||
// Find an item from this column
|
||||
CardView cardInColumn = null;
|
||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
for (CardView card : gridRow.get(currentColumn)) {
|
||||
cardInColumn = card;
|
||||
break;
|
||||
|
@ -1974,9 +1961,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
private void trimGrid() {
|
||||
// Compact stacks and rows
|
||||
for (int rowIndex = 0; rowIndex < cardGrid.size(); ++rowIndex) {
|
||||
ArrayList<ArrayList<CardView>> gridRow = cardGrid.get(rowIndex);
|
||||
List<List<CardView>> gridRow = cardGrid.get(rowIndex);
|
||||
int rowMaxStackSize = 0;
|
||||
for (ArrayList<CardView> stack : gridRow) {
|
||||
for (List<CardView> stack : gridRow) {
|
||||
// Clear out nulls in the stack
|
||||
for (int i = 0; i < stack.size(); ++i) {
|
||||
if (stack.get(i) == null) {
|
||||
|
@ -2000,15 +1987,15 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
if (!cardGrid.isEmpty()) {
|
||||
for (int colIndex = 0; colIndex < cardGrid.get(0).size(); ++colIndex) {
|
||||
boolean hasContent = false; // Until contested
|
||||
for (int rowIndex = 0; rowIndex < cardGrid.size(); ++rowIndex) {
|
||||
if (!cardGrid.get(rowIndex).get(colIndex).isEmpty()) {
|
||||
for (List<List<CardView>> aCardGrid : cardGrid) {
|
||||
if (!aCardGrid.get(colIndex).isEmpty()) {
|
||||
hasContent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasContent) {
|
||||
for (int rowIndex = 0; rowIndex < cardGrid.size(); ++rowIndex) {
|
||||
cardGrid.get(rowIndex).remove(colIndex);
|
||||
for (List<List<CardView>> aCardGrid : cardGrid) {
|
||||
aCardGrid.remove(colIndex);
|
||||
}
|
||||
--colIndex;
|
||||
}
|
||||
|
@ -2017,13 +2004,13 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
|
||||
// Clean up extra column header count labels
|
||||
while (stackCountLabels.size() > cardGrid.size()) {
|
||||
ArrayList<JLabel> labels = stackCountLabels.remove(cardGrid.size());
|
||||
List<JLabel> labels = stackCountLabels.remove(cardGrid.size());
|
||||
for (JLabel label : labels) {
|
||||
cardContent.remove(label);
|
||||
}
|
||||
}
|
||||
int colCount = cardGrid.isEmpty() ? 0 : cardGrid.get(0).size();
|
||||
for (ArrayList<JLabel> labels : stackCountLabels) {
|
||||
for (List<JLabel> labels : stackCountLabels) {
|
||||
while (labels.size() > colCount) {
|
||||
cardContent.remove(labels.remove(colCount));
|
||||
}
|
||||
|
@ -2056,9 +2043,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
int maxWidth = 0;
|
||||
for (int rowIndex = 0; rowIndex < cardGrid.size(); ++rowIndex) {
|
||||
int rowMaxStackSize = 0;
|
||||
ArrayList<ArrayList<CardView>> gridRow = cardGrid.get(rowIndex);
|
||||
List<List<CardView>> gridRow = cardGrid.get(rowIndex);
|
||||
for (int colIndex = 0; colIndex < gridRow.size(); ++colIndex) {
|
||||
ArrayList<CardView> stack = gridRow.get(colIndex);
|
||||
List<CardView> stack = gridRow.get(colIndex);
|
||||
|
||||
// Stack count label
|
||||
if (stackCountLabels.size() <= rowIndex) {
|
||||
|
|
|
@ -14,6 +14,9 @@ import java.util.UUID;
|
|||
|
||||
public final class LocalCommands {
|
||||
|
||||
|
||||
private LocalCommands(){}
|
||||
|
||||
/**
|
||||
* Handler for commands that do not require server interaction, i.e settings etc
|
||||
* @param chatId
|
||||
|
|
|
@ -27,7 +27,6 @@ public class MageRoundPane extends JPanel {
|
|||
private int Y_OFFSET = 30;
|
||||
private final Color defaultBackgroundColor = new Color(141, 130, 112, 200); // color of the frame of the popup window
|
||||
private Color backgroundColor = defaultBackgroundColor;
|
||||
private static final int alpha = 0;
|
||||
private static final SoftValuesLoadingCache<ShadowKey, BufferedImage> SHADOW_IMAGE_CACHE;
|
||||
private static final SoftValuesLoadingCache<Key, BufferedImage> IMAGE_CACHE;
|
||||
|
||||
|
@ -36,7 +35,7 @@ public class MageRoundPane extends JPanel {
|
|||
IMAGE_CACHE = ImageCaches.register(SoftValuesLoadingCache.from(MageRoundPane::createImage));
|
||||
}
|
||||
|
||||
private final static class ShadowKey {
|
||||
private static final class ShadowKey {
|
||||
|
||||
final int width;
|
||||
final int height;
|
||||
|
@ -76,7 +75,7 @@ public class MageRoundPane extends JPanel {
|
|||
}
|
||||
}
|
||||
|
||||
private final static class Key {
|
||||
private static final class Key {
|
||||
|
||||
final int width;
|
||||
final int height;
|
||||
|
@ -163,8 +162,8 @@ public class MageRoundPane extends JPanel {
|
|||
/**
|
||||
* Add white translucent substrate
|
||||
*/
|
||||
/*if (alpha != 0) {
|
||||
g2.setColor(new Color(255, 255, 255, alpha));
|
||||
/*if (ALPHA != 0) {
|
||||
g2.setColor(new Color(255, 255, 255, ALPHA));
|
||||
g2.fillRoundRect(x, y, w, h, arc, arc);
|
||||
}*/
|
||||
g2.setColor(key.backgroundColor);
|
||||
|
|
|
@ -16,7 +16,7 @@ public class BackgroundPainter extends AbstractPainter {
|
|||
|
||||
private final Color bgColor = Color.black;
|
||||
|
||||
static final float bgalpha = 0.6f;
|
||||
static final float BACKGROUND_ALPHA = 0.6f;
|
||||
|
||||
public BackgroundPainter() {
|
||||
super();
|
||||
|
@ -25,7 +25,7 @@ public class BackgroundPainter extends AbstractPainter {
|
|||
|
||||
@Override
|
||||
protected void doPaint(Graphics2D g2, Object o, int i, int i1) {
|
||||
float alpha = bgalpha;
|
||||
float alpha = BACKGROUND_ALPHA;
|
||||
Component c = (Component)o;
|
||||
Composite composite = g2.getComposite();
|
||||
if (composite instanceof AlphaComposite) {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package mage.client.components.ext;
|
||||
|
||||
public enum MessageDialogType {
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR,
|
||||
FLASH_INFO
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package mage.client.components.ext;
|
||||
|
||||
/**
|
||||
* @author mw, noxx
|
||||
*/
|
||||
public class MessageDlg {
|
||||
|
||||
MessageDlg() {}
|
||||
|
||||
public enum Types {
|
||||
Info, Warning, Error, FlashInfo
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package mage.client.components.ext.dlg;
|
||||
|
||||
import mage.client.components.ext.MessageDlg;
|
||||
import mage.client.components.ext.MessageDialogType;
|
||||
import mage.client.components.ext.dlg.impl.ChoiceDialog;
|
||||
import mage.client.components.ext.dlg.impl.StackDialog;
|
||||
|
||||
|
@ -37,146 +37,99 @@ public class DialogContainer extends JPanel {
|
|||
setLayout(null);
|
||||
drawContainer = true;
|
||||
|
||||
if (dialogType == DialogManager.MTGDialogs.MessageDialog) {
|
||||
//backgroundColor = new Color(0, 255, 255, 60);
|
||||
if (params.type == MessageDlg.Types.Warning) {
|
||||
backgroundColor = new Color(255, 0, 0, 90);
|
||||
} else {
|
||||
backgroundColor = new Color(0, 0, 0, 90);
|
||||
switch (dialogType) {
|
||||
case MESSAGE:
|
||||
//backgroundColor = new Color(0, 255, 255, 60);
|
||||
if (params.type == MessageDialogType.WARNING) {
|
||||
backgroundColor = new Color(255, 0, 0, 90);
|
||||
} else {
|
||||
backgroundColor = new Color(0, 0, 0, 90);
|
||||
}
|
||||
alpha = 0;
|
||||
//MessageDlg dlg = new MessageDlg(params);
|
||||
//add(dlg);
|
||||
//dlg.setLocation(X_OFFSET + 10, Y_OFFSET);
|
||||
//dlg.updateSize(params.rect.width, params.rect.height);
|
||||
break;
|
||||
case STACK: {
|
||||
//backgroundColor = new Color(0, 255, 255, 60);
|
||||
backgroundColor = new Color(0, 0, 0, 50);
|
||||
alpha = 0;
|
||||
StackDialog dlg = new StackDialog(params);
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
//int width = Math.min(params.rect.width - 80, 600);
|
||||
int width = params.rect.width;
|
||||
int height = params.rect.height - 80;
|
||||
dlg.updateSize(width, height);
|
||||
break;
|
||||
}
|
||||
alpha = 0;
|
||||
//MessageDlg dlg = new MessageDlg(params);
|
||||
//add(dlg);
|
||||
//dlg.setLocation(X_OFFSET + 10, Y_OFFSET);
|
||||
//dlg.updateSize(params.rect.width, params.rect.height);
|
||||
} else if (dialogType == DialogManager.MTGDialogs.StackDialog) {
|
||||
//backgroundColor = new Color(0, 255, 255, 60);
|
||||
backgroundColor = new Color(0, 0, 0, 50);
|
||||
alpha = 0;
|
||||
StackDialog dlg = new StackDialog(params);
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
//int width = Math.min(params.rect.width - 80, 600);
|
||||
int width = params.rect.width;
|
||||
int height = params.rect.height - 80;
|
||||
dlg.updateSize(width, height);
|
||||
}
|
||||
/*
|
||||
else if (dialogType == DialogManager.MTGDialogs.CombatDialog) {
|
||||
else if (dialogType == DialogManager.MTGDialogs.COMBAT) {
|
||||
backgroundColor = new Color(0, 0, 0, 60);
|
||||
alpha = 0;
|
||||
CombatDialog dlg = new CombatDialog(params);
|
||||
COMBAT dlg = new COMBAT(params);
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
|
||||
}*/ else if (dialogType == DialogManager.MTGDialogs.ChoiceDialog) {
|
||||
}*/
|
||||
case CHOICE: {
|
||||
|
||||
//backgroundColor = new Color(200, 200, 172, 120);
|
||||
//backgroundColor = new Color(180, 150, 200, 120);
|
||||
//backgroundColor = new Color(0, 255, 0, 60);
|
||||
//backgroundColor = new Color(200, 200, 172, 120);
|
||||
//backgroundColor = new Color(180, 150, 200, 120);
|
||||
//backgroundColor = new Color(0, 255, 0, 60);
|
||||
|
||||
//backgroundColor = new Color(139, 46, 173, 20);
|
||||
backgroundColor = new Color(0, 0, 0, 110);
|
||||
//backgroundColor = new Color(139, 46, 173, 0);
|
||||
//backgroundColor = new Color(139, 46, 173, 20);
|
||||
backgroundColor = new Color(0, 0, 0, 110);
|
||||
//backgroundColor = new Color(139, 46, 173, 0);
|
||||
|
||||
alpha = 0;
|
||||
ChoiceDialog dlg = new ChoiceDialog(params, "Choose");
|
||||
add(dlg);
|
||||
//GameManager.getManager().setCurrentChoiceDlg(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
alpha = 0;
|
||||
ChoiceDialog dlg = new ChoiceDialog(params, "Choose");
|
||||
add(dlg);
|
||||
//GameManager.getManager().setCurrentChoiceDlg(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
|
||||
} else if (dialogType == DialogManager.MTGDialogs.GraveDialog) {
|
||||
|
||||
backgroundColor = new Color(0, 0, 0, 110);
|
||||
|
||||
alpha = 0;
|
||||
ChoiceDialog dlg = new ChoiceDialog(params, "Graveyard");
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
|
||||
} else if (dialogType == DialogManager.MTGDialogs.ExileDialog) {
|
||||
|
||||
backgroundColor = new Color(250, 250, 250, 50);
|
||||
|
||||
alpha = 0;
|
||||
ChoiceDialog dlg = new ChoiceDialog(params, "Exile");
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
|
||||
} else if (dialogType == DialogManager.MTGDialogs.EmblemsDialog) {
|
||||
|
||||
backgroundColor = new Color(0, 0, 50, 110);
|
||||
|
||||
alpha = 0;
|
||||
ChoiceDialog dlg = new ChoiceDialog(params, "Command Zone (Commander, Emblems and Planes)");
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
|
||||
} /*else if (dialogType == DialogManager.MTGDialogs.GraveDialog) {
|
||||
backgroundColor = new Color(20, 20, 20, 120);
|
||||
alpha = 0;
|
||||
GraveDialog dlg = new GraveDialog(params);
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
|
||||
} else if (dialogType == DialogManager.MTGDialogs.RevealDialog) {
|
||||
backgroundColor = new Color(90, 135, 190, 80);
|
||||
alpha = 0;
|
||||
RevealDialog dlg = new RevealDialog(params);
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
|
||||
} else if (dialogType == DialogManager.MTGDialogs.AssignDamageDialog) {
|
||||
backgroundColor = new Color(255, 255, 255, 130);
|
||||
alpha = 0;
|
||||
AssignDamageDialog dlg = new AssignDamageDialog(params);
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
} else if (dialogType == DialogManager.MTGDialogs.ManaChoiceDialog) {
|
||||
backgroundColor = new Color(0, 255, 255, 60);
|
||||
alpha = 20;
|
||||
ManaChoiceDialog dlg = new ManaChoiceDialog(params);
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
|
||||
//isGradient = true;
|
||||
gradient = ImageManager.getGradientImage();
|
||||
if (gradient != null) {
|
||||
b = ImageToBufferedImage.toBufferedImage(gradient);
|
||||
b = Transparency.makeImageTranslucent(b, 0.35);
|
||||
Rectangle2D tr = new Rectangle2D.Double(0, 0, params.rect.width, params.rect.height);
|
||||
//gradient = gradient.getScaledInstance(w, h, Image.SCALE_SMOOTH);
|
||||
tp = new TexturePaint(b, tr);
|
||||
break;
|
||||
}
|
||||
case GRAVEYARD: {
|
||||
|
||||
backgroundColor = new Color(0, 0, 0, 110);
|
||||
|
||||
alpha = 0;
|
||||
ChoiceDialog dlg = new ChoiceDialog(params, "Graveyard");
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
|
||||
break;
|
||||
}
|
||||
case EXILE: {
|
||||
|
||||
backgroundColor = new Color(250, 250, 250, 50);
|
||||
|
||||
alpha = 0;
|
||||
ChoiceDialog dlg = new ChoiceDialog(params, "Exile");
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
|
||||
break;
|
||||
}
|
||||
case EMBLEMS: {
|
||||
|
||||
backgroundColor = new Color(0, 0, 50, 110);
|
||||
|
||||
alpha = 0;
|
||||
ChoiceDialog dlg = new ChoiceDialog(params, "Command Zone (Commander, Emblems and Planes)");
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
dlg.updateSize(params.rect.width - 80, params.rect.height - 80);
|
||||
|
||||
break;
|
||||
}
|
||||
} else if (dialogType == DialogManager.MTGDialogs.ChooseDeckDialog) {
|
||||
MWDeckPanel deckPanel = new MWDeckPanel(params.getDeckList(), params.isAI);
|
||||
deckPanel.setVisible(true);
|
||||
deckPanel.setBounds(0,0,480,320);
|
||||
add(deckPanel);
|
||||
drawContainer = false;
|
||||
} else if (dialogType == DialogManager.MTGDialogs.ChooseCommonDialog) {
|
||||
MWChoosePanel choosePanel = new MWChoosePanel(params.getObjectList(), params.getTitle());
|
||||
choosePanel.setVisible(true);
|
||||
choosePanel.setBounds(0,0,440,240);
|
||||
add(choosePanel);
|
||||
drawContainer = false;
|
||||
} else if (dialogType == DialogManager.MTGDialogs.AboutDialog) {
|
||||
backgroundColor = new Color(255, 255, 255, 120);
|
||||
alpha = 0;
|
||||
AboutDialog dlg = new AboutDialog();
|
||||
add(dlg);
|
||||
dlg.setLocation(X_OFFSET + 10, Y_OFFSET + 10);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void cleanUp() {
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.UUID;
|
|||
public class DialogManager extends JComponent implements MouseListener,
|
||||
MouseMotionListener {
|
||||
|
||||
private final static Map<UUID, DialogManager> dialogManagers = new HashMap<>();
|
||||
private static final Map<UUID, DialogManager> dialogManagers = new HashMap<>();
|
||||
|
||||
public static DialogManager getManager(UUID gameId) {
|
||||
if (!dialogManagers.containsKey(gameId)) {
|
||||
|
@ -39,8 +39,8 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
}
|
||||
|
||||
public enum MTGDialogs {
|
||||
none, AboutDialog, MessageDialog, StackDialog, AssignDamageDialog, ManaChoiceDialog, ChoiceDialog, EmblemsDialog, GraveDialog, DialogContainer, CombatDialog,
|
||||
ChooseDeckDialog, ChooseCommonDialog, RevealDialog, ExileDialog
|
||||
NONE, ABOUT, MESSAGE, STACK, ASSIGN_DAMAGE, MANA_CHOICE, CHOICE, EMBLEMS, GRAVEYARD, DialogContainer, COMBAT,
|
||||
CHOOSE_DECK, CHOOSE_COMMON, REVEAL, EXILE
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +58,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
}
|
||||
}
|
||||
|
||||
private MTGDialogs currentDialog = MTGDialogs.none;
|
||||
private MTGDialogs currentDialog = MTGDialogs.NONE;
|
||||
|
||||
private DialogContainer dialogContainer = null;
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
params.gameId = gameId;
|
||||
params.feedbackPanel = feedbackPanel;
|
||||
params.setCards(cards);
|
||||
dialogContainer = new DialogContainer(MTGDialogs.StackDialog, params);
|
||||
dialogContainer = new DialogContainer(MTGDialogs.STACK, params);
|
||||
dialogContainer.setVisible(true);
|
||||
add(dialogContainer);
|
||||
|
||||
|
@ -163,7 +163,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
params.gameId = gameId;
|
||||
//params.feedbackPanel = feedbackPanel;
|
||||
params.setCards(cards);
|
||||
dialogContainer = new DialogContainer(MTGDialogs.GraveDialog, params);
|
||||
dialogContainer = new DialogContainer(MTGDialogs.GRAVEYARD, params);
|
||||
dialogContainer.setVisible(true);
|
||||
add(dialogContainer);
|
||||
|
||||
|
@ -192,7 +192,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
params.bigCard = bigCard;
|
||||
params.gameId = gameId;
|
||||
params.setCards(cards);
|
||||
dialogContainer = new DialogContainer(MTGDialogs.ExileDialog, params);
|
||||
dialogContainer = new DialogContainer(MTGDialogs.EXILE, params);
|
||||
dialogContainer.setVisible(true);
|
||||
add(dialogContainer);
|
||||
|
||||
|
@ -222,7 +222,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
params.gameId = gameId;
|
||||
//params.feedbackPanel = feedbackPanel;
|
||||
params.setCards(cards);
|
||||
dialogContainer = new DialogContainer(MTGDialogs.EmblemsDialog, params);
|
||||
dialogContainer = new DialogContainer(MTGDialogs.EMBLEMS, params);
|
||||
dialogContainer.setVisible(true);
|
||||
add(dialogContainer);
|
||||
|
||||
|
@ -248,7 +248,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
removeAll();
|
||||
}
|
||||
|
||||
this.currentDialog = MTGDialogs.none;
|
||||
this.currentDialog = MTGDialogs.NONE;
|
||||
|
||||
setVisible(false);
|
||||
|
||||
|
@ -312,6 +312,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -360,7 +361,7 @@ public class DialogManager extends JComponent implements MouseListener,
|
|||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
int notches = e.getWheelRotation();
|
||||
// System.out.println("outx:"+notches);
|
||||
// if (currentDialog != null && currentDialog.equals(MTGDialogs.ChooseCommonDialog)) {
|
||||
// if (currentDialog != null && currentDialog.equals(MTGDialogs.CHOOSE_COMMON)) {
|
||||
// System.out.println("out:"+1);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package mage.client.components.ext.dlg;
|
||||
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.components.ext.MessageDlg;
|
||||
import mage.client.components.ext.MessageDialogType;
|
||||
import mage.client.game.FeedbackPanel;
|
||||
import mage.view.CardsView;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +19,7 @@ import java.util.UUID;
|
|||
public class DlgParams {
|
||||
|
||||
public Rectangle rect;
|
||||
public MessageDlg.Types type;
|
||||
public MessageDialogType type;
|
||||
public BigCard bigCard;
|
||||
public FeedbackPanel feedbackPanel;
|
||||
public UUID gameId;
|
||||
|
@ -26,19 +27,19 @@ public class DlgParams {
|
|||
private int playerID;
|
||||
|
||||
private CardsView cards;
|
||||
private ArrayList<String> stringList;
|
||||
private java.util.List<String> stringList;
|
||||
//private ArrayList<DeckInfo> deckList;
|
||||
private ArrayList<Object> objectList;
|
||||
private java.util.List<Object> objectList;
|
||||
|
||||
private String title;
|
||||
private int opponentID;
|
||||
boolean isOptional = false;
|
||||
boolean isChooseAbility = false;
|
||||
boolean isCancelStopsPlaying = true;
|
||||
private boolean isOptional = false;
|
||||
private boolean isChooseAbility = false;
|
||||
private boolean isCancelStopsPlaying = true;
|
||||
|
||||
boolean isAI = false;
|
||||
private boolean isAI = false;
|
||||
|
||||
public HashSet<String> manaChoices = new HashSet<>();
|
||||
private Set<String> manaChoices = new HashSet<>();
|
||||
|
||||
public int getPlayerID() {
|
||||
return playerID;
|
||||
|
@ -74,11 +75,11 @@ public class DlgParams {
|
|||
this.message = message;
|
||||
}
|
||||
|
||||
public HashSet<String> getManaChoices() {
|
||||
public Set<String> getManaChoices() {
|
||||
return manaChoices;
|
||||
}
|
||||
|
||||
public void setManaChoices(HashSet<String> manaChoices) {
|
||||
public void setManaChoices(Set<String> manaChoices) {
|
||||
this.manaChoices = manaChoices;
|
||||
}
|
||||
|
||||
|
@ -98,7 +99,7 @@ public class DlgParams {
|
|||
this.isChooseAbility = isChooseAbility;
|
||||
}
|
||||
|
||||
public ArrayList<String> getStringList() {
|
||||
public java.util.List<String> getStringList() {
|
||||
return stringList;
|
||||
}
|
||||
|
||||
|
@ -114,7 +115,7 @@ public class DlgParams {
|
|||
this.deckList = deckList;
|
||||
}*/
|
||||
|
||||
public ArrayList<Object> getObjectList() {
|
||||
public java.util.List<Object> getObjectList() {
|
||||
return objectList;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.awt.*;
|
|||
/**
|
||||
* @author mw, noxx
|
||||
*/
|
||||
abstract public class IDialogPanel extends JXPanel {
|
||||
public abstract class IDialogPanel extends JXPanel {
|
||||
|
||||
private DlgParams params;
|
||||
private Dimension cardDimension;
|
||||
|
|
|
@ -50,11 +50,12 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
private boolean isCancelStopsPlaying = true;
|
||||
|
||||
private final DlgParams params;
|
||||
|
||||
|
||||
private final String title;
|
||||
|
||||
/**
|
||||
* This is the default constructor
|
||||
*
|
||||
* @param params
|
||||
* @param title
|
||||
*/
|
||||
|
@ -130,18 +131,18 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
return;
|
||||
}
|
||||
|
||||
ArrayList<Component> toRemove = new ArrayList<>();
|
||||
java.util.List<Component> toRemove = new ArrayList<>();
|
||||
for (int i = getComponentCount() - 1; i > 0; i--) {
|
||||
Component o = getComponent(i);
|
||||
if (o instanceof MageCard) {
|
||||
toRemove.add(o);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < toRemove.size(); i++) {
|
||||
remove(toRemove.get(i));
|
||||
for (Component aToRemove : toRemove) {
|
||||
remove(aToRemove);
|
||||
}
|
||||
|
||||
ArrayList<CardView> cardList = new ArrayList<>(cards.values());
|
||||
java.util.List<CardView> cardList = new ArrayList<>(cards.values());
|
||||
|
||||
int width = SettingsManager.instance.getCardSize().width;
|
||||
int height = SettingsManager.instance.getCardSize().height;
|
||||
|
@ -163,7 +164,7 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
CardView card = cardList.get(i);
|
||||
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
|
||||
|
||||
cardImg.setLocation(dx, dy + j*(height + 30));
|
||||
cardImg.setLocation(dx, dy + j * (height + 30));
|
||||
add(cardImg);
|
||||
|
||||
dx += (width + 20);
|
||||
|
@ -237,11 +238,8 @@ public class ChoiceDialog extends IDialogPanel {
|
|||
int h = getDlgParams().rect.height - 90;
|
||||
jButtonNextPage.setBounds(new Rectangle(w / 2 + 45, h - 50, 60, 60));
|
||||
|
||||
if (maxPages > 1) {
|
||||
jButtonNextPage.setVisible(true);
|
||||
} else {
|
||||
jButtonNextPage.setVisible(false);
|
||||
}
|
||||
jButtonNextPage.setVisible(maxPages > 1);
|
||||
|
||||
|
||||
jButtonNextPage.setObserver(new Command() {
|
||||
private static final long serialVersionUID = -3174360416099554104L;
|
||||
|
|
|
@ -78,7 +78,6 @@ public enum MageTray {
|
|||
tray.add(trayIcon);
|
||||
} catch (AWTException e) {
|
||||
log.error("TrayIcon could not be added: ", e);
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
package mage.client.deck.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public enum DeckGeneratorCMC {
|
||||
|
||||
|
@ -51,11 +52,11 @@ public enum DeckGeneratorCMC {
|
|||
this.poolCMCs40 = CMCs40;
|
||||
}
|
||||
|
||||
public ArrayList<CMC> get40CardPoolCMC() {
|
||||
public List<CMC> get40CardPoolCMC() {
|
||||
return this.poolCMCs40;
|
||||
}
|
||||
|
||||
public ArrayList<CMC> get60CardPoolCMC() {
|
||||
public List<CMC> get60CardPoolCMC() {
|
||||
return this.poolCMCs60;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ public class RatioAdjustingSliderPanel extends JPanel {
|
|||
|
||||
private static JLabel createChangingPercentageLabel(final JSlider slider) {
|
||||
|
||||
final JLabel label = new JLabel(" " + String.valueOf(slider.getValue()) + '%');
|
||||
final JLabel label = new JLabel(" " + slider.getValue() + '%');
|
||||
|
||||
slider.addChangeListener(e -> {
|
||||
String value = String.valueOf(slider.getValue());
|
||||
|
|
|
@ -72,15 +72,12 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
currentView = mainModel; // by default we use List View
|
||||
|
||||
listCodeSelected = new CheckBoxList();
|
||||
// remove the all option
|
||||
boolean is_removeFinish = false;
|
||||
|
||||
String[] setCodes = ConstructedFormats.getTypes();
|
||||
java.util.List<String> result = new ArrayList<>();
|
||||
|
||||
for (int i = 0; (i < setCodes.length) && (!is_removeFinish); i++) {
|
||||
String item = setCodes[i];
|
||||
if (!item.equals(ConstructedFormats.ALL)) {
|
||||
for (String item : setCodes) {
|
||||
if (!item.equals(ConstructedFormats.ALL_SETS)) {
|
||||
result.add(item);
|
||||
}
|
||||
}
|
||||
|
@ -360,9 +357,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
for (int itemIndex : choiseValue) {
|
||||
|
||||
java.util.List<String> listReceived = ConstructedFormats.getSetsByFormat(x.getElementAt(itemIndex).toString());
|
||||
listReceived.stream().filter((item) -> (setCodes.contains(item) == false)).forEachOrdered((item) -> {
|
||||
setCodes.add(item);
|
||||
});
|
||||
listReceived.stream().filter(item -> !setCodes.contains(item)).forEachOrdered(setCodes::add);
|
||||
}
|
||||
criteria.setCodes(setCodes.toArray(new String[0]));
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class DeckArea extends javax.swing.JPanel {
|
|||
public int dividerLocationLimited;
|
||||
public int dividerLocationNormal;
|
||||
|
||||
private final static Pattern parser = Pattern.compile("([^|]*)\\|([^|]*)\\|([^|]*)\\|([^|]*)");
|
||||
private static final Pattern parser = Pattern.compile("([^|]*)\\|([^|]*)\\|([^|]*)\\|([^|]*)");
|
||||
|
||||
public static Settings parse(String s) {
|
||||
Matcher m = parser.matcher(s);
|
||||
|
|
|
@ -1119,12 +1119,12 @@ class ImportFilter extends FileFilter {
|
|||
ext = s.substring(i + 1).toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
if (ext != null) {
|
||||
if (ext.toLowerCase(Locale.ENGLISH).equals("dec")
|
||||
|| ext.toLowerCase(Locale.ENGLISH).equals("mwdeck")
|
||||
|| ext.toLowerCase(Locale.ENGLISH).equals("txt")
|
||||
|| ext.toLowerCase(Locale.ENGLISH).equals("dek")
|
||||
|| ext.toLowerCase(Locale.ENGLISH).equals("cod")
|
||||
|| ext.toLowerCase(Locale.ENGLISH).equals("o8d")) {
|
||||
if (ext.equalsIgnoreCase("dec")
|
||||
|| ext.equalsIgnoreCase("mwdeck")
|
||||
|| ext.equalsIgnoreCase("txt")
|
||||
|| ext.equalsIgnoreCase("dek")
|
||||
|| ext.equalsIgnoreCase("cod")
|
||||
|| ext.equalsIgnoreCase("o8d")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import mage.client.dialog.PreferencesDialog;
|
|||
|
||||
public class SortSettingBase extends SortSetting {
|
||||
|
||||
private final static SortSettingBase instance = new SortSettingBase();
|
||||
private static final SortSettingBase instance = new SortSettingBase();
|
||||
|
||||
public static SortSettingBase getInstance() {
|
||||
return instance;
|
||||
|
|
|
@ -10,7 +10,7 @@ import mage.client.dialog.PreferencesDialog;
|
|||
|
||||
public class SortSettingDeck extends SortSetting {
|
||||
|
||||
private final static SortSettingDeck instance = new SortSettingDeck();
|
||||
private static final SortSettingDeck instance = new SortSettingDeck();
|
||||
|
||||
public static SortSettingDeck getInstance() {
|
||||
return instance;
|
||||
|
|
|
@ -10,7 +10,7 @@ import mage.client.dialog.PreferencesDialog;
|
|||
*/
|
||||
public class SortSettingDraft extends SortSetting {
|
||||
|
||||
private final static SortSettingDraft instance = new SortSettingDraft();
|
||||
private static final SortSettingDraft instance = new SortSettingDraft();
|
||||
|
||||
public static SortSettingDraft getInstance() {
|
||||
return instance;
|
||||
|
|
|
@ -265,7 +265,7 @@ public class MageBook extends JComponent {
|
|||
public int showTokens() {
|
||||
jLayeredPane.removeAll();
|
||||
List<Token> tokens = getTokens(currentPage, currentSet);
|
||||
if (tokens != null && tokens.size() > 0) {
|
||||
if (tokens != null && !tokens.isEmpty()) {
|
||||
int size = tokens.size();
|
||||
Rectangle rectangle = new Rectangle();
|
||||
rectangle.translate(OFFSET_X, OFFSET_Y);
|
||||
|
@ -295,7 +295,7 @@ public class MageBook extends JComponent {
|
|||
public int showEmblems(int numTokens) {
|
||||
List<Emblem> emblems = getEmblems(currentPage, currentSet, numTokens);
|
||||
int numEmblems = 0;
|
||||
if (emblems != null && emblems.size() > 0) {
|
||||
if (emblems != null && !emblems.isEmpty()) {
|
||||
int size = emblems.size();
|
||||
numEmblems = size;
|
||||
Rectangle rectangle = new Rectangle();
|
||||
|
|
|
@ -92,7 +92,7 @@ public class ConnectDialog extends MageDialog {
|
|||
MagePreferences.setServerAddress(serverAddress);
|
||||
MagePreferences.setServerPort(Integer.parseInt(txtPort.getText().trim()));
|
||||
MagePreferences.setUserName(serverAddress, txtUserName.getText().trim());
|
||||
MagePreferences.setPassword(serverAddress, txtPassword.getText().trim());
|
||||
MagePreferences.setPassword(serverAddress, String.valueOf(txtPassword.getPassword()).trim());
|
||||
MageFrame.getPreferences().put(KEY_CONNECT_AUTO_CONNECT, Boolean.toString(chkAutoConnect.isSelected()));
|
||||
}
|
||||
|
||||
|
@ -508,7 +508,7 @@ public class ConnectDialog extends MageDialog {
|
|||
connection.setHost(this.txtServer.getText().trim());
|
||||
connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
|
||||
connection.setUsername(this.txtUserName.getText().trim());
|
||||
connection.setPassword(this.txtPassword.getText().trim());
|
||||
connection.setPassword(String.valueOf(this.txtPassword.getPassword()).trim());
|
||||
// force to redownload db
|
||||
boolean redownloadDatabase = (ExpansionRepository.instance.getSetByCode("GRN") == null || CardRepository.instance.findCard("Island") == null);
|
||||
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected() || redownloadDatabase);
|
||||
|
|
|
@ -25,7 +25,7 @@ public class RandomPacksSelectorDialog extends javax.swing.JDialog {
|
|||
private boolean isRandomDraft;
|
||||
private boolean isRichManDraft;
|
||||
private String title = "";
|
||||
public final static String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
|
||||
public static final String randomDraftDescription = ("The selected packs will be randomly distributed to players. Each player may open different packs. Duplicates will be avoided.");
|
||||
|
||||
public RandomPacksSelectorDialog(boolean isRandomDraft, boolean isRichManDraft) {
|
||||
initComponents();
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
package mage.client.dialog;
|
||||
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import javax.swing.SwingWorker;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.SessionHandler;
|
||||
import mage.client.preference.MagePreferences;
|
||||
import mage.remote.Connection;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
public class RegisterUserDialog extends MageDialog {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ConnectDialog.class);
|
||||
|
@ -106,73 +108,73 @@ public class RegisterUserDialog extends MageDialog {
|
|||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(lblPasswordConfirmationReasoning)
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(lblServer)
|
||||
.addComponent(lblUserName)
|
||||
.addComponent(lblPort)
|
||||
.addComponent(lblPassword)
|
||||
.addComponent(lblPasswordConfirmation)
|
||||
.addComponent(lblEmail))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addComponent(lblEmailReasoning)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(btnRegister)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnCancel)))
|
||||
.addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap(22, Short.MAX_VALUE))
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(lblPasswordConfirmationReasoning)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(lblServer)
|
||||
.addComponent(lblUserName)
|
||||
.addComponent(lblPort)
|
||||
.addComponent(lblPassword)
|
||||
.addComponent(lblPasswordConfirmation)
|
||||
.addComponent(lblEmail))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addComponent(lblEmailReasoning)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(btnRegister)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnCancel)))
|
||||
.addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap(22, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(9, 9, 9)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblServer)
|
||||
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblPort)
|
||||
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblUserName)
|
||||
.addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblPassword)
|
||||
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblPasswordConfirmation))
|
||||
.addComponent(lblPasswordConfirmationReasoning)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblEmail)
|
||||
.addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblEmailReasoning)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnCancel)
|
||||
.addComponent(btnRegister))
|
||||
.addContainerGap())
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(9, 9, 9)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblServer)
|
||||
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblPort)
|
||||
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblUserName)
|
||||
.addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblPassword)
|
||||
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblPasswordConfirmation))
|
||||
.addComponent(lblPasswordConfirmationReasoning)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblEmail)
|
||||
.addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblEmailReasoning)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnCancel)
|
||||
.addComponent(btnRegister))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
|
@ -187,7 +189,7 @@ public class RegisterUserDialog extends MageDialog {
|
|||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
private void btnRegisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegisterActionPerformed
|
||||
if (!this.txtPassword.getText().equals(this.txtPasswordConfirmation.getText())) {
|
||||
if (!Arrays.equals(this.txtPassword.getPassword(), this.txtPasswordConfirmation.getPassword())) {
|
||||
MageFrame.getInstance().showError("Passwords don't match.");
|
||||
return;
|
||||
}
|
||||
|
@ -195,7 +197,7 @@ public class RegisterUserDialog extends MageDialog {
|
|||
connection.setHost(this.txtServer.getText().trim());
|
||||
connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
|
||||
connection.setUsername(this.txtUserName.getText().trim());
|
||||
connection.setPassword(this.txtPassword.getText().trim());
|
||||
connection.setPassword(String.valueOf(this.txtPassword.getPassword()).trim());
|
||||
connection.setEmail(this.txtEmail.getText().trim());
|
||||
PreferencesDialog.setProxyInformation(connection);
|
||||
task = new ConnectTask();
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
package mage.client.dialog;
|
||||
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import javax.swing.SwingWorker;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.SessionHandler;
|
||||
import mage.client.preference.MagePreferences;
|
||||
import mage.remote.Connection;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
public class ResetPasswordDialog extends MageDialog {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ResetPasswordDialog.class);
|
||||
|
@ -97,51 +99,51 @@ public class ResetPasswordDialog extends MageDialog {
|
|||
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
||||
jPanel2.setLayout(jPanel2Layout);
|
||||
jPanel2Layout.setHorizontalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jLabel6)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||
.addComponent(lblAuthToken, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblPassword, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(lblPasswordConfirmation, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtAuthToken)
|
||||
.addComponent(txtPassword)
|
||||
.addComponent(txtPasswordConfirmation)))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
|
||||
.addGap(0, 204, Short.MAX_VALUE)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblPasswordConfirmationReasoning, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(btnSubmitNewPassword, javax.swing.GroupLayout.Alignment.TRAILING))))
|
||||
.addContainerGap())
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jLabel6)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||
.addComponent(lblAuthToken, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblPassword, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(lblPasswordConfirmation, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtAuthToken)
|
||||
.addComponent(txtPassword)
|
||||
.addComponent(txtPasswordConfirmation)))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
|
||||
.addGap(0, 204, Short.MAX_VALUE)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(lblPasswordConfirmationReasoning, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(btnSubmitNewPassword, javax.swing.GroupLayout.Alignment.TRAILING))))
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel2Layout.setVerticalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jLabel6)
|
||||
.addGap(24, 24, 24)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblAuthToken)
|
||||
.addComponent(txtAuthToken, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblPassword)
|
||||
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblPasswordConfirmation)
|
||||
.addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblPasswordConfirmationReasoning)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(btnSubmitNewPassword)
|
||||
.addContainerGap(9, Short.MAX_VALUE))
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jLabel6)
|
||||
.addGap(24, 24, 24)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblAuthToken)
|
||||
.addComponent(txtAuthToken, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblPassword)
|
||||
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblPasswordConfirmation)
|
||||
.addComponent(txtPasswordConfirmation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblPasswordConfirmationReasoning)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(btnSubmitNewPassword)
|
||||
.addContainerGap(9, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
|
||||
|
@ -158,33 +160,33 @@ public class ResetPasswordDialog extends MageDialog {
|
|||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(jLabel5)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(lblEmail)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtEmail))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(btnGetAuthToken)))
|
||||
.addContainerGap())
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(jLabel5)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(lblEmail)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtEmail))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(btnGetAuthToken)))
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(jLabel5)
|
||||
.addGap(24, 24, 24)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblEmail)
|
||||
.addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(btnGetAuthToken)
|
||||
.addContainerGap())
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(jLabel5)
|
||||
.addGap(24, 24, 24)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblEmail)
|
||||
.addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(btnGetAuthToken)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
btnCancel.setText("Cancel");
|
||||
|
@ -199,46 +201,46 @@ public class ResetPasswordDialog extends MageDialog {
|
|||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(btnCancel))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(lblServer)
|
||||
.addComponent(lblPort))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtServer)
|
||||
.addComponent(txtPort))))
|
||||
.addContainerGap())
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(btnCancel))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(lblServer)
|
||||
.addComponent(lblPort))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(txtServer)
|
||||
.addComponent(txtPort))))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblServer)
|
||||
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblPort))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnCancel)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(lblServer)
|
||||
.addComponent(txtServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblPort))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnCancel)
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
|
@ -269,11 +271,11 @@ public class ResetPasswordDialog extends MageDialog {
|
|||
MageFrame.getInstance().showError("Please enter an auth token.");
|
||||
return;
|
||||
}
|
||||
if (this.txtPassword.getText().isEmpty()) {
|
||||
if (String.valueOf(this.txtPassword.getPassword()).trim().isEmpty()) {
|
||||
MageFrame.getInstance().showError("Please enter a new password.");
|
||||
return;
|
||||
}
|
||||
if (!this.txtPassword.getText().equals(this.txtPasswordConfirmation.getText())) {
|
||||
if (!Arrays.equals(this.txtPassword.getPassword(), this.txtPasswordConfirmation.getPassword())) {
|
||||
MageFrame.getInstance().showError("Passwords don't match.");
|
||||
return;
|
||||
}
|
||||
|
@ -284,7 +286,7 @@ public class ResetPasswordDialog extends MageDialog {
|
|||
PreferencesDialog.setProxyInformation(connection);
|
||||
connection.setEmail(this.txtEmail.getText().trim());
|
||||
connection.setAuthToken(this.txtAuthToken.getText().trim());
|
||||
connection.setPassword(this.txtPassword.getText().trim());
|
||||
connection.setPassword(String.valueOf(this.txtPassword.getPassword()).trim());
|
||||
|
||||
resetPasswordTask = new ResetPasswordTask();
|
||||
resetPasswordTask.execute();
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.log4j.Logger;
|
|||
import org.mage.card.arcane.CardRendererUtils;
|
||||
import org.ocpsoft.prettytime.Duration;
|
||||
import org.ocpsoft.prettytime.PrettyTime;
|
||||
import org.ocpsoft.prettytime.TimeFormat;
|
||||
import org.ocpsoft.prettytime.units.JustNow;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -82,7 +83,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
final JToggleButton[] filterButtons;
|
||||
|
||||
// time formater
|
||||
private PrettyTime timeFormater = new PrettyTime();
|
||||
private PrettyTime timeFormater = new PrettyTime(Locale.ENGLISH);
|
||||
|
||||
// time ago renderer
|
||||
TableCellRenderer timeAgoCellRenderer = new DefaultTableCellRenderer() {
|
||||
|
@ -219,9 +220,12 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
// tableModel.setSession(session);
|
||||
|
||||
// formater
|
||||
timeFormater.setLocale(Locale.ENGLISH);
|
||||
JustNow jn = timeFormater.getUnit(JustNow.class);
|
||||
jn.setMaxQuantity(1000L * 30L); // 30 seconds gap (show "just now" from 0 to 30 secs)
|
||||
// change default just now from 60 to 30 secs
|
||||
// see workaround for 4.0 versions: https://github.com/ocpsoft/prettytime/issues/152
|
||||
TimeFormat timeFormat = timeFormater.removeUnit(JustNow.class);
|
||||
JustNow newJustNow = new JustNow();
|
||||
newJustNow.setMaxQuantity(1000L * 30L); // 30 seconds gap (show "just now" from 0 to 30 secs)
|
||||
timeFormater.registerUnit(newJustNow, timeFormat);
|
||||
|
||||
// 1. TABLE CURRENT
|
||||
tableTables.createDefaultColumnsFromModel();
|
||||
|
@ -1377,35 +1381,35 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
javax.swing.GroupLayout jPanelTopLayout = new javax.swing.GroupLayout(jPanelTop);
|
||||
jPanelTop.setLayout(jPanelTopLayout);
|
||||
jPanelTopLayout.setHorizontalGroup(
|
||||
jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanelTopLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnNewTable)
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(btnNewTournament)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(filterBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnQuickStart)
|
||||
.addContainerGap(792, Short.MAX_VALUE))
|
||||
jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanelTopLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnNewTable)
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(btnNewTournament)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(filterBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnQuickStart)
|
||||
.addContainerGap(792, Short.MAX_VALUE))
|
||||
);
|
||||
jPanelTopLayout.setVerticalGroup(
|
||||
jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanelTopLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnNewTable)
|
||||
.addComponent(btnNewTournament))
|
||||
.addGroup(jPanelTopLayout.createSequentialGroup()
|
||||
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(filterBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(btnQuickStart))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanelTopLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnNewTable)
|
||||
.addComponent(btnNewTournament))
|
||||
.addGroup(jPanelTopLayout.createSequentialGroup()
|
||||
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(filterBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(btnQuickStart))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
|
@ -1442,12 +1446,12 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
javax.swing.GroupLayout jPanelTablesLayout = new javax.swing.GroupLayout(jPanelTables);
|
||||
jPanelTables.setLayout(jPanelTablesLayout);
|
||||
jPanelTablesLayout.setHorizontalGroup(
|
||||
jPanelTablesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jSplitPaneTables, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
|
||||
jPanelTablesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jSplitPaneTables, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
|
||||
);
|
||||
jPanelTablesLayout.setVerticalGroup(
|
||||
jPanelTablesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jSplitPaneTables, javax.swing.GroupLayout.DEFAULT_SIZE, 672, Short.MAX_VALUE)
|
||||
jPanelTablesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jSplitPaneTables, javax.swing.GroupLayout.DEFAULT_SIZE, 672, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
jSplitPane1.setLeftComponent(jPanelTables);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
|
||||
/*
|
||||
* CombatDialog.java
|
||||
* COMBAT.java
|
||||
*
|
||||
* Created on Feb 10, 2010, 3:35:02 PM
|
||||
*/
|
||||
|
@ -33,7 +33,7 @@ public class CombatDialog extends MageDialog {
|
|||
private int lastX = 500;
|
||||
private int lastY = 300;
|
||||
|
||||
/** Creates new form CombatDialog */
|
||||
/** Creates new form COMBAT */
|
||||
public CombatDialog() {
|
||||
|
||||
JPanel contentPane = new JPanel() {
|
||||
|
|
|
@ -23,9 +23,9 @@ import org.mage.card.arcane.CardRenderer;
|
|||
public final class GUISizeHelper {
|
||||
|
||||
// relate the native image card size to a value of the size scale
|
||||
final static int CARD_IMAGE_WIDTH = 312;
|
||||
final static int CARD_IMAGE_HEIGHT = 445;
|
||||
final static int CARD_IMAG_VALUE = 42;
|
||||
static final int CARD_IMAGE_WIDTH = 312;
|
||||
static final int CARD_IMAGE_HEIGHT = 445;
|
||||
static final int CARD_IMAG_VALUE = 42;
|
||||
|
||||
public static String basicSymbolSize = "small";
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.mortennobel.imagescaling.ResampleOp;
|
|||
*/
|
||||
public final class TransformedImageCache {
|
||||
|
||||
private final static class Key {
|
||||
private static final class Key {
|
||||
|
||||
final int width;
|
||||
final int height;
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.*;
|
|||
*/
|
||||
public final class ConstructedFormats {
|
||||
|
||||
public static final String ALL = "- All Sets";
|
||||
public static final String ALL_SETS = "- All Sets";
|
||||
public static final String STANDARD = "- Standard";
|
||||
public static final String EXTENDED = "- Extended";
|
||||
public static final String FRONTIER = "- Frontier";
|
||||
|
@ -65,7 +65,7 @@ public final class ConstructedFormats {
|
|||
}
|
||||
|
||||
public static List<String> getSetsByFormat(final String format) {
|
||||
if (!format.equals(ALL)) {
|
||||
if (!format.equals(ALL_SETS)) {
|
||||
return underlyingSetCodesPerFormat.get(format);
|
||||
}
|
||||
return all;
|
||||
|
@ -244,7 +244,7 @@ public final class ConstructedFormats {
|
|||
formats.add(0, EXTENDED);
|
||||
formats.add(0, STANDARD);
|
||||
}
|
||||
formats.add(0, ALL);
|
||||
formats.add(0, ALL_SETS);
|
||||
}
|
||||
|
||||
private static String getBlockDisplayName(String blockName) {
|
||||
|
|
|
@ -395,7 +395,7 @@ public abstract class CardRenderer {
|
|||
// Return the width of the drawn symbol
|
||||
protected int drawExpansionSymbol(Graphics2D g, int x, int y, int w, int h) {
|
||||
// Draw the expansion symbol
|
||||
Image setSymbol = ManaSymbols.getSetSymbolImage(cardView.getExpansionSetCode(), cardView.getRarity().getCode());
|
||||
Image setSymbol = ManaSymbols.getSetSymbolImage(cardView.getExpansionSetCode(), cardView.getRarity());
|
||||
int setSymbolWidth;
|
||||
if (setSymbol == null) {
|
||||
// Don't draw anything when we don't have a set symbol
|
||||
|
|
|
@ -34,9 +34,9 @@ public class GlowText extends JLabel {
|
|||
private Color glowColor;
|
||||
private boolean wrap;
|
||||
private int lineCount = 0;
|
||||
private final static SoftValuesLoadingCache<Key, BufferedImage> IMAGE_CACHE;
|
||||
private static final SoftValuesLoadingCache<Key, BufferedImage> IMAGE_CACHE;
|
||||
|
||||
private final static class Key {
|
||||
private static final class Key {
|
||||
|
||||
final int width;
|
||||
final int height;
|
||||
|
|
|
@ -10,8 +10,9 @@ import mage.client.util.GUISizeHelper;
|
|||
import mage.client.util.ImageHelper;
|
||||
import mage.client.util.gui.BufferedImageBuilder;
|
||||
import mage.client.util.gui.GuiDisplayUtil;
|
||||
import mage.constants.Rarity;
|
||||
import mage.utils.StreamUtils;
|
||||
import org.apache.batik.dom.svg.SVGDOMImplementation;
|
||||
import org.apache.batik.anim.dom.SVGDOMImplementation;
|
||||
import org.apache.batik.transcoder.TranscoderException;
|
||||
import org.apache.batik.transcoder.TranscoderInput;
|
||||
import org.apache.batik.transcoder.TranscoderOutput;
|
||||
|
@ -48,10 +49,10 @@ public final class ManaSymbols {
|
|||
private static final Logger LOGGER = Logger.getLogger(ManaSymbols.class);
|
||||
private static final Map<Integer, Map<String, BufferedImage>> manaImages = new HashMap<>();
|
||||
|
||||
private static final Map<String, Map<String, Image>> setImages = new ConcurrentHashMap<>();
|
||||
private static final Map<String, Map<Rarity, Image>> setImages = new ConcurrentHashMap<>();
|
||||
|
||||
private static final HashSet<String> onlyMythics = new HashSet<>();
|
||||
private static final HashSet<String> withoutSymbols = new HashSet<>();
|
||||
private static final Set<String> onlyMythics = new HashSet<>();
|
||||
private static final Set<String> withoutSymbols = new HashSet<>();
|
||||
|
||||
static {
|
||||
onlyMythics.add("DRB");
|
||||
|
@ -172,19 +173,19 @@ public final class ManaSymbols {
|
|||
continue;
|
||||
}
|
||||
|
||||
String[] codes;
|
||||
Set<Rarity> codes;
|
||||
if (onlyMythics.contains(set)) {
|
||||
codes = new String[]{"M"};
|
||||
codes = EnumSet.of(Rarity.MYTHIC);
|
||||
} else {
|
||||
codes = new String[]{"C", "U", "R", "M"};
|
||||
codes = EnumSet.of(Rarity.COMMON, Rarity.UNCOMMON, Rarity.RARE, Rarity.MYTHIC);
|
||||
}
|
||||
|
||||
Map<String, Image> rarityImages = new HashMap<>();
|
||||
Map<Rarity, Image> rarityImages = new HashMap<>();
|
||||
setImages.put(set, rarityImages);
|
||||
|
||||
// load medium size
|
||||
for (String rarityCode : codes) {
|
||||
File file = new File(getResourceSetsPath(ResourceSetSize.MEDIUM) + set + '-' + rarityCode + ".jpg");
|
||||
for (Rarity rarityCode : codes) {
|
||||
File file = new File(getResourceSetsPath(ResourceSetSize.MEDIUM) + set + '-' + rarityCode.getCode() + ".jpg");
|
||||
try {
|
||||
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
|
||||
int width = image.getWidth(null);
|
||||
|
@ -209,7 +210,7 @@ public final class ManaSymbols {
|
|||
file.mkdirs();
|
||||
}
|
||||
String pathRoot = getResourceSetsPath(ResourceSetSize.SMALL) + set;
|
||||
for (String code : codes) {
|
||||
for (Rarity code : codes) {
|
||||
File newFile = new File(pathRoot + '-' + code + ".png");
|
||||
if (!(MageFrame.isSkipSmallSymbolGenerationForExisting() && newFile.exists())) {// skip if option enabled and file already exists
|
||||
file = new File(getResourceSetsPath(ResourceSetSize.MEDIUM) + set + '-' + code + ".png");
|
||||
|
@ -791,23 +792,22 @@ public final class ManaSymbols {
|
|||
}
|
||||
|
||||
public static String replaceSetCodeWithHTML(String set, String rarity, int size) {
|
||||
String _set = set;
|
||||
if (setImagesExist.containsKey(_set)) {
|
||||
if (setImagesExist.containsKey(set)) {
|
||||
int factor = size / 15 + 1;
|
||||
Integer width = setImagesExist.get(_set).width * factor;
|
||||
Integer height = setImagesExist.get(_set).height * factor;
|
||||
return "<img src='" + filePathToUrl(getResourceSetsPath(ResourceSetSize.SMALL)) + _set + '-' + rarity + ".png' alt='" + rarity + "' height='" + height + "' width='" + width + "' >";
|
||||
Integer width = setImagesExist.get(set).width * factor;
|
||||
Integer height = setImagesExist.get(set).height * factor;
|
||||
return "<img src='" + filePathToUrl(getResourceSetsPath(ResourceSetSize.SMALL)) + set + '-' + rarity + ".png' alt='" + rarity + "' height='" + height + "' width='" + width + "' >";
|
||||
} else {
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
public static Image getSetSymbolImage(String set) {
|
||||
return getSetSymbolImage(set, "C");
|
||||
return getSetSymbolImage(set, Rarity.COMMON);
|
||||
}
|
||||
|
||||
public static Image getSetSymbolImage(String set, String rarity) {
|
||||
Map<String, Image> rarityImages = setImages.get(set);
|
||||
public static Image getSetSymbolImage(String set, Rarity rarity) {
|
||||
Map<Rarity, Image> rarityImages = setImages.get(set);
|
||||
if (rarityImages != null) {
|
||||
return rarityImages.get(rarity);
|
||||
} else {
|
||||
|
|
|
@ -63,7 +63,7 @@ import static org.mage.card.arcane.ManaSymbols.getSizedManaSymbol;
|
|||
*/
|
||||
public class ModernCardRenderer extends CardRenderer {
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(ModernCardRenderer.class);
|
||||
private static final Logger LOGGER = Logger.getLogger(ModernCardRenderer.class);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Textures for modern frame cards
|
||||
|
|
|
@ -1,26 +1,9 @@
|
|||
package org.mage.plugins.card;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLayeredPane;
|
||||
import mage.cards.MagePermanent;
|
||||
import mage.cards.action.ActionCallback;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.util.GUISizeHelper;
|
||||
import mage.constants.Rarity;
|
||||
import mage.interfaces.plugin.CardPlugin;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CounterView;
|
||||
|
@ -41,14 +24,21 @@ import org.mage.plugins.card.dl.sources.ScryfallSymbolsSource;
|
|||
import org.mage.plugins.card.images.ImageCache;
|
||||
import org.mage.plugins.card.info.CardInfoPaneImpl;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* {@link CardPlugin} implementation.
|
||||
*
|
||||
* @author nantuko
|
||||
* @version 0.1 01.11.2010 Mage permanents. Sorting card layout.
|
||||
* @version 0.6 17.07.2011 #sortPermanents got option to display non-land
|
||||
* permanents in one pile
|
||||
* @version 0.7 29.07.2011 face down cards support
|
||||
* @author nantuko, JayDi85
|
||||
*/
|
||||
@PluginImplementation
|
||||
@Author(name = "nantuko")
|
||||
|
@ -584,6 +574,10 @@ public class CardPluginImpl implements CardPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
private void symbolsOnFinish() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Download various symbols (mana, tap, set).
|
||||
*
|
||||
|
@ -591,23 +585,25 @@ public class CardPluginImpl implements CardPlugin {
|
|||
*/
|
||||
@Override
|
||||
public void downloadSymbols(String imagesDir) {
|
||||
final DownloadGui g = new DownloadGui(new Downloader());
|
||||
final Downloader downloader = new Downloader();
|
||||
final DownloadGui downloadGui = new DownloadGui(downloader);
|
||||
|
||||
Iterable<DownloadJob> it;
|
||||
LOGGER.info("Symbols download prepare...");
|
||||
Iterable<DownloadJob> jobs;
|
||||
|
||||
it = new GathererSymbols();
|
||||
for (DownloadJob job : it) {
|
||||
g.getDownloader().add(job);
|
||||
jobs = new GathererSymbols();
|
||||
for (DownloadJob job : jobs) {
|
||||
downloader.add(job);
|
||||
}
|
||||
|
||||
it = new GathererSets();
|
||||
for (DownloadJob job : it) {
|
||||
g.getDownloader().add(job);
|
||||
jobs = new GathererSets();
|
||||
for (DownloadJob job : jobs) {
|
||||
downloader.add(job);
|
||||
}
|
||||
|
||||
it = new ScryfallSymbolsSource();
|
||||
for (DownloadJob job : it) {
|
||||
g.getDownloader().add(job);
|
||||
jobs = new ScryfallSymbolsSource();
|
||||
for (DownloadJob job : jobs) {
|
||||
downloader.add(job);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -615,26 +611,56 @@ public class CardPluginImpl implements CardPlugin {
|
|||
for (DownloadJob job : it) {
|
||||
g.getDownloader().add(job);
|
||||
}
|
||||
*/
|
||||
it = new DirectLinksForDownload();
|
||||
for (DownloadJob job : it) {
|
||||
g.getDownloader().add(job);
|
||||
*/
|
||||
|
||||
jobs = new DirectLinksForDownload();
|
||||
for (DownloadJob job : jobs) {
|
||||
downloader.add(job);
|
||||
}
|
||||
|
||||
JDialog d = new JDialog((Frame) null, "Download symbols", false);
|
||||
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
d.addWindowListener(new WindowAdapter() {
|
||||
LOGGER.info("Symbols download needs " + downloader.getJobs().size() + " files");
|
||||
|
||||
// download GUI dialog
|
||||
JDialog dialog = new JDialog((Frame) null, "Download symbols", false);
|
||||
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
dialog.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
g.getDownloader().dispose();
|
||||
ManaSymbols.loadImages();
|
||||
// TODO: check reload process after download (icons do not update)
|
||||
// user force to close window/downloader
|
||||
downloader.cleanup();
|
||||
}
|
||||
});
|
||||
d.setLayout(new BorderLayout());
|
||||
d.add(g);
|
||||
d.pack();
|
||||
d.setVisible(true);
|
||||
dialog.setLayout(new BorderLayout());
|
||||
dialog.add(downloadGui);
|
||||
dialog.pack();
|
||||
dialog.setVisible(true);
|
||||
|
||||
// downloader controller thread
|
||||
SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
downloader.publishAllJobs();
|
||||
downloader.waitFinished();
|
||||
downloader.cleanup();
|
||||
return null;
|
||||
}
|
||||
};
|
||||
// downloader finisher
|
||||
worker.addPropertyChangeListener(new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (evt.getPropertyName().equals("state")) {
|
||||
if (evt.getNewValue() == SwingWorker.StateValue.DONE) {
|
||||
// all done, can close dialog and refresh symbols for UI
|
||||
LOGGER.info("Symbols download finished");
|
||||
dialog.dispose();
|
||||
ManaSymbols.loadImages();
|
||||
ImageCache.clearCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
worker.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,113 +1,105 @@
|
|||
/**
|
||||
* DownloadGui.java
|
||||
*
|
||||
* Created on 25.08.2010
|
||||
*/
|
||||
|
||||
package org.mage.plugins.card.dl;
|
||||
|
||||
import org.mage.plugins.card.dl.DownloadJob.State;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.beans.IndexedPropertyChangeEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoundedRangeModel;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.DefaultBoundedRangeModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
import org.mage.plugins.card.dl.DownloadJob.State;
|
||||
|
||||
|
||||
/**
|
||||
* The class DownloadGui.
|
||||
*
|
||||
* @version V0.0 25.08.2010
|
||||
* Downloader GUI to control and show progress
|
||||
*
|
||||
* @author Clemens Koza
|
||||
*/
|
||||
public class DownloadGui extends JPanel {
|
||||
private static final long serialVersionUID = -7346572382493844327L;
|
||||
private static final long serialVersionUID = -7346572382493844327L;
|
||||
|
||||
private final Downloader d;
|
||||
private final DownloadListener l = new DownloadListener();
|
||||
private final BoundedRangeModel model = new DefaultBoundedRangeModel(0, 0, 0, 0);
|
||||
private final JProgressBar progress = new JProgressBar(model);
|
||||
private final Downloader downloader;
|
||||
private final DownloadListener listener = new DownloadListener();
|
||||
private final BoundedRangeModel progressModel = new DefaultBoundedRangeModel(0, 0, 0, 0);
|
||||
private final JProgressBar progressBar = new JProgressBar(progressModel);
|
||||
|
||||
private final Map<DownloadJob, DownloadPanel> progresses = new HashMap<>();
|
||||
private final JPanel panel = new JPanel();
|
||||
private final Map<DownloadJob, DownloadPanel> jobPanels = new HashMap<>();
|
||||
private final JPanel basicPanel = new JPanel();
|
||||
|
||||
public DownloadGui(Downloader downloader) {
|
||||
super(new BorderLayout());
|
||||
this.d = downloader;
|
||||
downloader.addPropertyChangeListener(l);
|
||||
this.downloader = downloader;
|
||||
downloader.addPropertyChangeListener(listener);
|
||||
|
||||
JPanel p = new JPanel(new BorderLayout());
|
||||
p.setBorder(BorderFactory.createTitledBorder("Progress:"));
|
||||
p.add(progress);
|
||||
JButton b = new JButton("X");
|
||||
b.addActionListener(e -> {
|
||||
d.dispose();
|
||||
p.add(progressBar);
|
||||
JButton closeButton = new JButton("X");
|
||||
closeButton.addActionListener(e -> {
|
||||
this.downloader.cleanup();
|
||||
});
|
||||
p.add(b, BorderLayout.EAST);
|
||||
p.add(closeButton, BorderLayout.EAST);
|
||||
add(p, BorderLayout.NORTH);
|
||||
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
JScrollPane pane = new JScrollPane(panel);
|
||||
basicPanel.setLayout(new BoxLayout(basicPanel, BoxLayout.Y_AXIS));
|
||||
JScrollPane pane = new JScrollPane(basicPanel);
|
||||
pane.setPreferredSize(new Dimension(500, 300));
|
||||
add(pane);
|
||||
for(int i = 0; i < downloader.getJobs().size(); i++) {
|
||||
for (int i = 0; i < downloader.getJobs().size(); i++) {
|
||||
addJob(i, downloader.getJobs().get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public Downloader getDownloader() {
|
||||
return d;
|
||||
return downloader;
|
||||
}
|
||||
|
||||
private class DownloadListener implements PropertyChangeListener {
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String name = evt.getPropertyName();
|
||||
if(evt.getSource() instanceof DownloadJob) {
|
||||
DownloadPanel p = progresses.get(evt.getSource());
|
||||
if (evt.getSource() instanceof DownloadJob) {
|
||||
// one job changes
|
||||
DownloadPanel panel = jobPanels.get(evt.getSource());
|
||||
switch (name) {
|
||||
case "state":
|
||||
if(evt.getOldValue() == State.FINISHED || evt.getOldValue() == State.ABORTED) {
|
||||
if (evt.getOldValue() == State.FINISHED || evt.getOldValue() == State.ABORTED) {
|
||||
// started
|
||||
changeProgress(-1, 0);
|
||||
} if(evt.getNewValue() == State.FINISHED || evt.getOldValue() == State.ABORTED) {
|
||||
changeProgress(+1, 0);
|
||||
} if(p != null) {
|
||||
p.setVisible(p.getJob().getState() != State.FINISHED);
|
||||
p.revalidate();
|
||||
} break;
|
||||
}
|
||||
if (evt.getNewValue() == State.FINISHED || evt.getOldValue() == State.ABORTED) {
|
||||
// finished
|
||||
changeProgress(+1, 0);
|
||||
}
|
||||
if (panel != null) {
|
||||
panel.setVisible(panel.getJob().getState() != State.FINISHED);
|
||||
panel.revalidate();
|
||||
}
|
||||
break;
|
||||
case "message":
|
||||
if(p != null) {
|
||||
JProgressBar bar = p.getBar();
|
||||
String message = p.getJob().getMessage();
|
||||
if (panel != null) {
|
||||
JProgressBar bar = panel.getBar();
|
||||
String message = panel.getJob().getMessage();
|
||||
bar.setStringPainted(message != null);
|
||||
bar.setString(message);
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if(evt.getSource() == d) {
|
||||
if("jobs".equals(name)) {
|
||||
} else if (evt.getSource() == downloader) {
|
||||
// all jobs changes (add/delete)
|
||||
if ("jobs".equals(name)) {
|
||||
IndexedPropertyChangeEvent ev = (IndexedPropertyChangeEvent) evt;
|
||||
int index = ev.getIndex();
|
||||
|
||||
DownloadJob oldValue = (DownloadJob) ev.getOldValue();
|
||||
if(oldValue != null) {
|
||||
if (oldValue != null) {
|
||||
removeJob(index, oldValue);
|
||||
}
|
||||
|
||||
DownloadJob newValue = (DownloadJob) ev.getNewValue();
|
||||
if(newValue != null) {
|
||||
if (newValue != null) {
|
||||
addJob(index, newValue);
|
||||
}
|
||||
}
|
||||
|
@ -116,39 +108,39 @@ public class DownloadGui extends JPanel {
|
|||
}
|
||||
|
||||
private synchronized void addJob(int index, DownloadJob job) {
|
||||
job.addPropertyChangeListener(l);
|
||||
job.addPropertyChangeListener(listener);
|
||||
changeProgress(0, +1);
|
||||
DownloadPanel p = new DownloadPanel(job);
|
||||
progresses.put(job, p);
|
||||
panel.add(p, index);
|
||||
panel.revalidate();
|
||||
jobPanels.put(job, p);
|
||||
basicPanel.add(p, index);
|
||||
basicPanel.revalidate();
|
||||
}
|
||||
|
||||
private synchronized void removeJob(int index, DownloadJob job) {
|
||||
assert progresses.get(job) == panel.getComponent(index);
|
||||
job.removePropertyChangeListener(l);
|
||||
assert jobPanels.get(job) == basicPanel.getComponent(index);
|
||||
job.removePropertyChangeListener(listener);
|
||||
changeProgress(0, -1);
|
||||
progresses.remove(job);
|
||||
panel.remove(index);
|
||||
panel.revalidate();
|
||||
jobPanels.remove(job);
|
||||
basicPanel.remove(index);
|
||||
basicPanel.revalidate();
|
||||
}
|
||||
|
||||
private synchronized void changeProgress(int progress, int total) {
|
||||
progress += model.getValue();
|
||||
total += model.getMaximum();
|
||||
model.setMaximum(total);
|
||||
model.setValue(progress);
|
||||
this.progress.setStringPainted(true);
|
||||
this.progress.setString(progress + "/" + total);
|
||||
progress += progressModel.getValue();
|
||||
total += progressModel.getMaximum();
|
||||
progressModel.setMaximum(total);
|
||||
progressModel.setValue(progress);
|
||||
this.progressBar.setStringPainted(true);
|
||||
this.progressBar.setString(progress + "/" + total);
|
||||
}
|
||||
|
||||
private class DownloadPanel extends JPanel {
|
||||
private static final long serialVersionUID = 1187986738303477168L;
|
||||
|
||||
private final DownloadJob job;
|
||||
private final JProgressBar bar;
|
||||
private final DownloadJob job;
|
||||
private final JProgressBar bar;
|
||||
|
||||
public DownloadPanel(DownloadJob job) {
|
||||
DownloadPanel(DownloadJob job) {
|
||||
super(new BorderLayout());
|
||||
this.job = job;
|
||||
|
||||
|
@ -156,7 +148,7 @@ public class DownloadGui extends JPanel {
|
|||
add(bar = new JProgressBar(job.getProgress()));
|
||||
JButton b = new JButton("X");
|
||||
b.addActionListener(e -> {
|
||||
switch(this.job.getState()) {
|
||||
switch (this.job.getState()) {
|
||||
case NEW:
|
||||
case PREPARING:
|
||||
case WORKING:
|
||||
|
@ -165,7 +157,7 @@ public class DownloadGui extends JPanel {
|
|||
});
|
||||
add(b, BorderLayout.EAST);
|
||||
|
||||
if(job.getState() == State.FINISHED | job.getState() == State.ABORTED) {
|
||||
if (job.getState() == State.FINISHED | job.getState() == State.ABORTED) {
|
||||
changeProgress(+1, 0);
|
||||
}
|
||||
setVisible(job.getState() != State.FINISHED);
|
||||
|
@ -177,15 +169,13 @@ public class DownloadGui extends JPanel {
|
|||
Dimension d = getPreferredSize();
|
||||
d.width = Integer.MAX_VALUE;
|
||||
setMaximumSize(d);
|
||||
// d.width = 500;
|
||||
// setMinimumSize(d);
|
||||
}
|
||||
|
||||
public DownloadJob getJob() {
|
||||
DownloadJob getJob() {
|
||||
return job;
|
||||
}
|
||||
|
||||
public JProgressBar getBar() {
|
||||
JProgressBar getBar() {
|
||||
return bar;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,18 @@
|
|||
/**
|
||||
* DownloadJob.java
|
||||
*
|
||||
* Created on 25.08.2010
|
||||
*/
|
||||
package org.mage.plugins.card.dl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import javax.swing.BoundedRangeModel;
|
||||
import javax.swing.DefaultBoundedRangeModel;
|
||||
import org.mage.plugins.card.dl.beans.properties.Property;
|
||||
import org.mage.plugins.card.dl.lm.AbstractLaternaBean;
|
||||
import org.mage.plugins.card.utils.CardImageUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
* The class DownloadJob.
|
||||
* Downloader job to download one resource
|
||||
*
|
||||
* @version V0.0 25.08.2010
|
||||
* @author Clemens Koza, JayDi85
|
||||
*/
|
||||
public class DownloadJob extends AbstractLaternaBean {
|
||||
|
@ -88,11 +78,8 @@ public class DownloadJob extends AbstractLaternaBean {
|
|||
*/
|
||||
public void setError(String message, Exception error) {
|
||||
if (message == null) {
|
||||
|
||||
message = "Download of " + name + "from " + source.toString() + " caused error: " + error.toString();
|
||||
message = "Download of " + name + " from " + source.toString() + " caused error: " + error.toString();
|
||||
}
|
||||
// log.warn(message, error);
|
||||
log.warn(message);
|
||||
this.state.setValue(State.ABORTED);
|
||||
this.error.setValue(error);
|
||||
this.message.setValue(message);
|
||||
|
@ -116,7 +103,7 @@ public class DownloadJob extends AbstractLaternaBean {
|
|||
return;
|
||||
}
|
||||
|
||||
// change to working state on good prepare call
|
||||
// can continue
|
||||
this.state.setValue(State.WORKING);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,26 +1,9 @@
|
|||
/**
|
||||
* Downloader.java
|
||||
*
|
||||
* Created on 25.08.2010
|
||||
*/
|
||||
package org.mage.plugins.card.dl;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.ConnectException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import javax.swing.BoundedRangeModel;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jetlang.channels.Channel;
|
||||
import org.jetlang.channels.MemoryChannel;
|
||||
import org.jetlang.core.Callback;
|
||||
import org.jetlang.core.Disposable;
|
||||
import org.jetlang.fibers.Fiber;
|
||||
import org.jetlang.fibers.PoolFiberFactory;
|
||||
import org.mage.plugins.card.dl.DownloadJob.Destination;
|
||||
|
@ -28,41 +11,56 @@ import org.mage.plugins.card.dl.DownloadJob.Source;
|
|||
import org.mage.plugins.card.dl.DownloadJob.State;
|
||||
import org.mage.plugins.card.dl.lm.AbstractLaternaBean;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.net.ConnectException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* The class Downloader.
|
||||
* Downloader
|
||||
*
|
||||
* @version V0.0 25.08.2010
|
||||
* @author Clemens Koza
|
||||
* @author Clemens Koza, JayDi85
|
||||
*/
|
||||
public class Downloader extends AbstractLaternaBean implements Disposable {
|
||||
public class Downloader extends AbstractLaternaBean {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Downloader.class);
|
||||
|
||||
private final List<DownloadJob> jobs = properties.list("jobs");
|
||||
private final Channel<DownloadJob> channel = new MemoryChannel<>();
|
||||
private final Channel<DownloadJob> jobsQueue = new MemoryChannel<>();
|
||||
private CountDownLatch worksCount = null;
|
||||
|
||||
private final ExecutorService pool = Executors.newCachedThreadPool();
|
||||
private final List<Fiber> fibers = new ArrayList<>();
|
||||
|
||||
public Downloader() {
|
||||
// prepare 10 threads and start to waiting new download jobs from queue
|
||||
PoolFiberFactory f = new PoolFiberFactory(pool);
|
||||
//subscribe multiple fibers for parallel execution
|
||||
for (int i = 0, numThreads = 10; i < numThreads; i++) {
|
||||
Fiber fiber = f.create();
|
||||
fiber.start();
|
||||
fibers.add(fiber);
|
||||
channel.subscribe(fiber, new DownloadCallback());
|
||||
jobsQueue.subscribe(fiber, new DownloadCallback());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
public void cleanup() {
|
||||
// close all threads and jobs
|
||||
for (DownloadJob j : jobs) {
|
||||
switch (j.getState()) {
|
||||
case NEW:
|
||||
case PREPARING:
|
||||
case WORKING:
|
||||
j.setState(State.ABORTED);
|
||||
break;
|
||||
case ABORTED:
|
||||
case FINISHED:
|
||||
// don't change state
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,16 +68,10 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
|||
f.dispose();
|
||||
}
|
||||
pool.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
dispose();
|
||||
super.finalize();
|
||||
while (worksCount.getCount() != 0) {
|
||||
worksCount.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
public void add(DownloadJob job) {
|
||||
|
@ -94,7 +86,27 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
|||
}
|
||||
job.setState(State.NEW);
|
||||
jobs.add(job);
|
||||
channel.publish(job);
|
||||
}
|
||||
|
||||
public void publishAllJobs() {
|
||||
worksCount = new CountDownLatch(jobs.size());
|
||||
for (DownloadJob job : jobs) {
|
||||
jobsQueue.publish(job);
|
||||
}
|
||||
}
|
||||
|
||||
public void waitFinished() {
|
||||
try {
|
||||
while (worksCount.getCount() != 0) {
|
||||
worksCount.await(60, TimeUnit.SECONDS);
|
||||
|
||||
if (worksCount.getCount() != 0) {
|
||||
logger.warn("Symbols download too long...");
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("Need to stop symbols download...");
|
||||
}
|
||||
}
|
||||
|
||||
public List<DownloadJob> getJobs() {
|
||||
|
@ -111,20 +123,23 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
|||
@Override
|
||||
public void onMessage(DownloadJob job) {
|
||||
|
||||
// start to work
|
||||
// the job won't be processed by multiple threads
|
||||
// each 10 threads gets same jobs, but take to work only one NEW
|
||||
synchronized (job) {
|
||||
if (job.getState() != State.NEW) {
|
||||
return;
|
||||
}
|
||||
|
||||
job.doPrepareAndStartWork();
|
||||
|
||||
if (job.getState() != State.WORKING) {
|
||||
if (job.getState() == State.NEW) {
|
||||
// take new job
|
||||
job.doPrepareAndStartWork();
|
||||
if (job.getState() != State.WORKING) {
|
||||
logger.warn("Can't prepare symbols download job: " + job.getName());
|
||||
worksCount.countDown();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// skip job (other thread takes it)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// real work for new job
|
||||
// download and save data
|
||||
try {
|
||||
Source src = job.getSource();
|
||||
|
@ -132,9 +147,11 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
|||
BoundedRangeModel progress = job.getProgress();
|
||||
|
||||
if (dst.isValid()) {
|
||||
// already done
|
||||
progress.setMaximum(1);
|
||||
progress.setValue(1);
|
||||
} else {
|
||||
// downloading
|
||||
if (dst.exists()) {
|
||||
try {
|
||||
dst.delete();
|
||||
|
@ -149,7 +166,7 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
|||
try {
|
||||
byte[] buf = new byte[8 * 1024];
|
||||
int total = 0;
|
||||
for (int len; (len = is.read(buf)) != -1;) {
|
||||
for (int len; (len = is.read(buf)) != -1; ) {
|
||||
if (job.getState() == State.ABORTED) {
|
||||
throw new IOException("Job was aborted");
|
||||
}
|
||||
|
@ -193,6 +210,8 @@ public class Downloader extends AbstractLaternaBean implements Disposable {
|
|||
logger.warn("Error resource download " + job.getName() + " from " + job.getSource().toString() + ": " + message);
|
||||
} catch (IOException ex) {
|
||||
job.setError(ex);
|
||||
} finally {
|
||||
worksCount.countDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* AbstractLaternaBean.java
|
||||
*
|
||||
* <p>
|
||||
* Created on 25.08.2010
|
||||
*/
|
||||
|
||||
|
@ -16,12 +16,12 @@ import org.mage.plugins.card.dl.beans.properties.bound.BoundProperties;
|
|||
|
||||
/**
|
||||
* The class AbstractLaternaBean.
|
||||
*
|
||||
* @version V0.0 25.08.2010
|
||||
*
|
||||
* @author Clemens Koza
|
||||
* @version V0.0 25.08.2010
|
||||
*/
|
||||
public class AbstractLaternaBean extends AbstractBoundBean {
|
||||
protected static final Logger log = Logger.getLogger(AbstractLaternaBean.class);
|
||||
protected final Properties properties = new BoundProperties(s);
|
||||
protected EventListenerList listeners = new EventListenerList();
|
||||
protected final Properties properties = new BoundProperties(s);
|
||||
protected EventListenerList listeners = new EventListenerList();
|
||||
}
|
||||
|
|
|
@ -34,12 +34,12 @@
|
|||
<dependency>
|
||||
<groupId>org.jboss</groupId>
|
||||
<artifactId>jboss-common-core</artifactId>
|
||||
<version>2.2.22.GA</version>
|
||||
<version>2.5.0.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jboss</groupId>
|
||||
<artifactId>jboss-serialization</artifactId>
|
||||
<version>1.0.3.GA</version>
|
||||
<version>4.2.2.GA</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>concurrent</groupId>
|
||||
|
@ -54,7 +54,7 @@
|
|||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<version>2.8.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- to get the reference to local repository with com\googlecode\jspf\jspf-core\0.9.1\ -->
|
||||
|
|
|
@ -54,7 +54,7 @@ public class SessionImpl implements Session {
|
|||
private ServerState serverState;
|
||||
private SessionState sessionState = SessionState.DISCONNECTED;
|
||||
private Connection connection;
|
||||
private final static int PING_CYCLES = 10;
|
||||
private static final int PING_CYCLES = 10;
|
||||
private final LinkedList<Long> pingTime = new LinkedList<>();
|
||||
private String pingInfo = "";
|
||||
private static boolean debugMode = false;
|
||||
|
|
|
@ -164,10 +164,7 @@ public final class DeckBuilder {
|
|||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
Integer typeCount = colorCount.get(symbol);
|
||||
if (typeCount == null) {
|
||||
typeCount = 0;
|
||||
}
|
||||
Integer typeCount = colorCount.getOrDefault(symbol, 0);
|
||||
typeCount += 1;
|
||||
colorCount.put(symbol, typeCount);
|
||||
}
|
||||
|
@ -243,9 +240,9 @@ public final class DeckBuilder {
|
|||
int type;
|
||||
if (card.isCreature()) {
|
||||
type = 10;
|
||||
} else if (card.getSubtype(null).contains(SubType.EQUIPMENT)) {
|
||||
} else if (card.hasSubtype(SubType.EQUIPMENT, null)) {
|
||||
type = 8;
|
||||
} else if (card.getSubtype(null).contains(SubType.AURA)) {
|
||||
} else if (card.hasSubtype(SubType.AURA, null)) {
|
||||
type = 5;
|
||||
} else if (card.isInstant()) {
|
||||
type = 7;
|
||||
|
@ -283,10 +280,7 @@ public final class DeckBuilder {
|
|||
multicolor += 1;
|
||||
colors.add(symbol);
|
||||
}
|
||||
Integer typeCount = singleCount.get(symbol);
|
||||
if (typeCount == null) {
|
||||
typeCount = 0;
|
||||
}
|
||||
Integer typeCount = singleCount.getOrDefault(symbol, 0);
|
||||
typeCount += 1;
|
||||
singleCount.put(symbol, typeCount);
|
||||
maxSingleCount = Math.max(maxSingleCount, typeCount);
|
||||
|
|
|
@ -12,13 +12,13 @@ public class MageVersion implements Serializable, Comparable<MageVersion> {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public final static int MAGE_VERSION_MAJOR = 1;
|
||||
public final static int MAGE_VERSION_MINOR = 4;
|
||||
public final static int MAGE_VERSION_PATCH = 33;
|
||||
public final static String MAGE_EDITION_INFO = ""; // set "-beta" for 1.4.32-betaV0
|
||||
public final static String MAGE_VERSION_MINOR_PATCH = "V3"; // default
|
||||
public static final int MAGE_VERSION_MAJOR = 1;
|
||||
public static final int MAGE_VERSION_MINOR = 4;
|
||||
public static final int MAGE_VERSION_PATCH = 33;
|
||||
public static final String MAGE_EDITION_INFO = ""; // set "-beta" for 1.4.32-betaV0
|
||||
public static final String MAGE_VERSION_MINOR_PATCH = "V3"; // default
|
||||
// strict mode
|
||||
private final static boolean MAGE_VERSION_MINOR_PATCH_MUST_BE_SAME = true; // set true on uncompatible github changes, set false after new major release (after MAGE_VERSION_PATCH changes)
|
||||
private static final boolean MAGE_VERSION_MINOR_PATCH_MUST_BE_SAME = true; // set true on uncompatible github changes, set false after new major release (after MAGE_VERSION_PATCH changes)
|
||||
|
||||
private final int major;
|
||||
private final int minor;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
<version>1.4.33</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage.server.console</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Mage Server Console</name>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.player.ai;
|
||||
|
||||
import mage.ConditionalMana;
|
||||
|
@ -538,12 +537,10 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
if (targets.isEmpty()) {
|
||||
if (outcome.isGood()) {
|
||||
if (target.canTarget(getId(), abilityControllerId, source, game)) {
|
||||
target.addTarget(abilityControllerId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, abilityControllerId, source, game);
|
||||
}
|
||||
} else if (target.canTarget(getId(), randomOpponentId, source, game)) {
|
||||
target.addTarget(randomOpponentId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, randomOpponentId, source, game);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -554,20 +551,17 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
List<UUID> alreadyTargeted = target.getTargets();
|
||||
if (t.canTarget(abilityControllerId, permanent.getId(), source, game)) {
|
||||
if (alreadyTargeted != null && !alreadyTargeted.contains(permanent.getId())) {
|
||||
target.addTarget(permanent.getId(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, permanent.getId(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (outcome.isGood()) {
|
||||
if (target.canTarget(getId(), abilityControllerId, source, game)) {
|
||||
target.addTarget(abilityControllerId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, abilityControllerId, source, game);
|
||||
}
|
||||
} else if (target.canTarget(getId(), randomOpponentId, source, game)) {
|
||||
target.addTarget(randomOpponentId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, randomOpponentId, source, game);
|
||||
}
|
||||
|
||||
//if (!target.isRequired())
|
||||
|
@ -585,12 +579,10 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
if (targets.isEmpty()) {
|
||||
if (outcome.isGood()) {
|
||||
if (target.canTarget(getId(), abilityControllerId, source, game)) {
|
||||
target.addTarget(abilityControllerId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, abilityControllerId, source, game);
|
||||
}
|
||||
} else if (target.canTarget(getId(), randomOpponentId, source, game)) {
|
||||
target.addTarget(randomOpponentId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, randomOpponentId, source, game);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -601,20 +593,17 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
List<UUID> alreadyTargeted = target.getTargets();
|
||||
if (t.canTarget(abilityControllerId, permanent.getId(), source, game)) {
|
||||
if (alreadyTargeted != null && !alreadyTargeted.contains(permanent.getId())) {
|
||||
target.addTarget(permanent.getId(), source, game);
|
||||
return true;
|
||||
tryAddTarget(target, permanent.getId(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (outcome.isGood()) {
|
||||
if (target.canTarget(getId(), abilityControllerId, source, game)) {
|
||||
target.addTarget(abilityControllerId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, abilityControllerId, source, game);
|
||||
}
|
||||
} else if (target.canTarget(getId(), randomOpponentId, source, game)) {
|
||||
target.addTarget(randomOpponentId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, randomOpponentId, source, game);
|
||||
}
|
||||
|
||||
//if (!target.isRequired())
|
||||
|
@ -632,12 +621,10 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
if (targets.isEmpty()) {
|
||||
if (outcome.isGood()) {
|
||||
if (target.canTarget(getId(), abilityControllerId, source, game)) {
|
||||
target.addTarget(abilityControllerId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, abilityControllerId, source, game);
|
||||
}
|
||||
} else if (target.canTarget(getId(), randomOpponentId, source, game)) {
|
||||
target.addTarget(randomOpponentId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, randomOpponentId, source, game);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -648,8 +635,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
List<UUID> alreadyTargeted = target.getTargets();
|
||||
if (t.canTarget(abilityControllerId, permanent.getId(), source, game)) {
|
||||
if (alreadyTargeted != null && !alreadyTargeted.contains(permanent.getId())) {
|
||||
target.addTarget(permanent.getId(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, permanent.getId(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -667,12 +653,10 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
if (targets.isEmpty()) {
|
||||
if (outcome.isGood()) {
|
||||
if (target.canTarget(getId(), abilityControllerId, source, game)) {
|
||||
target.addTarget(abilityControllerId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, abilityControllerId, source, game);
|
||||
}
|
||||
} else if (target.canTarget(getId(), randomOpponentId, source, game)) {
|
||||
target.addTarget(randomOpponentId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, randomOpponentId, source, game);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -683,20 +667,17 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
List<UUID> alreadyTargeted = target.getTargets();
|
||||
if (t.canTarget(abilityControllerId, permanent.getId(), source, game)) {
|
||||
if (alreadyTargeted != null && !alreadyTargeted.contains(permanent.getId())) {
|
||||
target.addTarget(permanent.getId(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, permanent.getId(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (outcome.isGood()) {
|
||||
if (target.canTarget(getId(), abilityControllerId, source, game)) {
|
||||
target.addTarget(abilityControllerId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, abilityControllerId, source, game);
|
||||
}
|
||||
} else if (target.canTarget(getId(), randomOpponentId, source, game)) {
|
||||
target.addTarget(randomOpponentId, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, randomOpponentId, source, game);
|
||||
}
|
||||
|
||||
//if (!target.isRequired())
|
||||
|
@ -710,8 +691,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
Card card = pickTarget(cards, outcome, target, source, game);
|
||||
if (card != null) {
|
||||
target.addTarget(card.getId(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, card.getId(), source, game);
|
||||
}
|
||||
//if (!target.isRequired())
|
||||
return false;
|
||||
|
@ -720,8 +700,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
List<Card> cards = new ArrayList<>(game.getPlayer(abilityControllerId).getLibrary().getCards(game));
|
||||
Card card = pickTarget(cards, outcome, target, source, game);
|
||||
if (card != null) {
|
||||
target.addTarget(card.getId(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, card.getId(), source, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -731,6 +710,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
Card card = pickTarget(cards, outcome, target, source, game);
|
||||
if (card != null) {
|
||||
target.addTarget(card.getId(), source, game);
|
||||
cards.remove(card); // pickTarget don't remove cards (only on second+ tries)
|
||||
}
|
||||
}
|
||||
return target.isChosen();
|
||||
|
@ -739,8 +719,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
if (!game.getStack().isEmpty()) {
|
||||
for (StackObject o : game.getStack()) {
|
||||
if (o instanceof Spell && !source.getId().equals(o.getStackAbility().getId())) {
|
||||
target.addTarget(o.getId(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, o.getId(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -772,8 +751,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
for (StackObject stackObject : game.getStack()) {
|
||||
if (stackObject instanceof Spell && source != null && !source.getId().equals(stackObject.getStackAbility().getId())) {
|
||||
if (((TargetSpellOrPermanent) target).getFilter().match(stackObject, game)) {
|
||||
target.addTarget(stackObject.getId(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, stackObject.getId(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -790,8 +768,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
Card card = pickTarget(cards, outcome, target, source, game);
|
||||
if (card != null) {
|
||||
target.addTarget(card.getId(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, card.getId(), source, game);
|
||||
}
|
||||
//if (!target.isRequired())
|
||||
return false;
|
||||
|
@ -827,6 +804,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
Card pick = pickTarget(cards, outcome, target, source, game);
|
||||
if (pick != null) {
|
||||
target.addTarget(pick.getId(), source, game);
|
||||
cards.remove(pick); // pickTarget don't remove cards (only on second+ tries)
|
||||
}
|
||||
}
|
||||
return target.isChosen();
|
||||
|
@ -844,6 +822,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
Card pick = pickTarget(cards, outcome, target, source, game);
|
||||
if (pick != null) {
|
||||
target.addTarget(pick.getId(), source, game);
|
||||
cards.remove(pick); // pickTarget don't remove cards (only on second+ tries)
|
||||
}
|
||||
}
|
||||
return target.isChosen();
|
||||
|
@ -874,8 +853,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
Card card = pickTarget(cards, outcome, target, source, game);
|
||||
if (card != null) {
|
||||
target.addTarget(card.getId(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, card.getId(), source, game);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -914,8 +892,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
if (target.getOriginalTarget() instanceof TargetCreatureOrPlayerAmount
|
||||
|| target.getOriginalTarget() instanceof TargetAnyTargetAmount) {
|
||||
if (outcome == Outcome.Damage && game.getPlayer(opponentId).getLife() <= target.getAmountRemaining()) {
|
||||
target.addTarget(opponentId, target.getAmountRemaining(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, opponentId, target.getAmountRemaining(), source, game);
|
||||
}
|
||||
List<Permanent> targets;
|
||||
if (outcome.isGood()) {
|
||||
|
@ -926,21 +903,17 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
for (Permanent permanent : targets) {
|
||||
if (target.canTarget(getId(), permanent.getId(), source, game)) {
|
||||
if (permanent.getToughness().getValue() <= target.getAmountRemaining()) {
|
||||
target.addTarget(permanent.getId(), permanent.getToughness().getValue(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, permanent.getId(), permanent.getToughness().getValue(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (outcome.isGood() && target.canTarget(getId(), getId(), source, game)) {
|
||||
target.addTarget(opponentId, target.getAmountRemaining(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, opponentId, target.getAmountRemaining(), source, game);
|
||||
} else if (target.canTarget(getId(), opponentId, source, game)) {
|
||||
// no permanent target so take opponent
|
||||
target.addTarget(opponentId, target.getAmountRemaining(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, opponentId, target.getAmountRemaining(), source, game);
|
||||
} else if (target.canTarget(getId(), playerId, source, game)) {
|
||||
target.addTarget(opponentId, target.getAmountRemaining(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, opponentId, target.getAmountRemaining(), source, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -954,8 +927,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
for (Permanent permanent : targets) {
|
||||
if (target.canTarget(getId(), permanent.getId(), source, game)) {
|
||||
if (permanent.getToughness().getValue() <= target.getAmountRemaining()) {
|
||||
target.addTarget(permanent.getId(), permanent.getToughness().getValue(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, permanent.getId(), permanent.getToughness().getValue(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -966,16 +938,14 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
if (target.canTarget(getId(), permanent.getId(), source, game)) {
|
||||
if (permanent.isCreature()) {
|
||||
if (permanent.getToughness().getValue() <= target.getAmountRemaining()) {
|
||||
target.addTarget(permanent.getId(), permanent.getToughness().getValue(), source, game);
|
||||
return true;
|
||||
tryAddTarget(target, permanent.getId(), permanent.getToughness().getValue(), source, game);
|
||||
} else {
|
||||
possibleTarget = permanent;
|
||||
}
|
||||
} else if (permanent.isPlaneswalker()) {
|
||||
int loy = permanent.getCounters(game).getCount(CounterType.LOYALTY);
|
||||
if (loy <= target.getAmountRemaining()) {
|
||||
target.addTarget(permanent.getId(), loy, source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, permanent.getId(), loy, source, game);
|
||||
} else {
|
||||
possibleTarget = permanent;
|
||||
}
|
||||
|
@ -984,8 +954,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
}
|
||||
if (possibleTarget != null) {
|
||||
target.addTarget(possibleTarget.getId(), target.getAmountRemaining(), source, game);
|
||||
return true;
|
||||
return tryAddTarget(target, possibleTarget.getId(), target.getAmountRemaining(), source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1653,7 +1622,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
cardChoices.remove(card);
|
||||
} else {
|
||||
// We don't have any valid target to choose so stop choosing
|
||||
return target.getTargets().size() < target.getNumberOfTargets();
|
||||
return target.getTargets().size() >= target.getNumberOfTargets();
|
||||
}
|
||||
if (outcome == Outcome.Neutral && target.getTargets().size() > target.getNumberOfTargets() + (target.getMaxNumberOfTargets() - target.getNumberOfTargets()) / 2) {
|
||||
return true;
|
||||
|
@ -1677,7 +1646,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
cardChoices.remove(card);
|
||||
} else {
|
||||
// We don't have any valid target to choose so stop choosing
|
||||
break;
|
||||
return target.getTargets().size() >= target.getNumberOfTargets();
|
||||
}
|
||||
if (outcome == Outcome.Neutral && target.getTargets().size() > target.getNumberOfTargets() + (target.getMaxNumberOfTargets() - target.getNumberOfTargets()) / 2) {
|
||||
return true;
|
||||
|
@ -2438,6 +2407,23 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
return new ComputerPlayer(this);
|
||||
}
|
||||
|
||||
private boolean tryAddTarget(Target target, UUID id, Ability source, Game game) {
|
||||
// workaround to to check successfull targets add
|
||||
int before = target.getTargets().size();
|
||||
target.addTarget(id, source, game);
|
||||
int after = target.getTargets().size();
|
||||
return before != after;
|
||||
}
|
||||
|
||||
private boolean tryAddTarget(Target target, UUID id, int amount, Ability source, Game game) {
|
||||
// workaround to to check successfull targets add
|
||||
int before = target.getTargets().size();
|
||||
target.addTarget(id, amount, source, game);
|
||||
int after = target.getTargets().size();
|
||||
return before != after;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a possible target player
|
||||
*/
|
||||
|
|
|
@ -234,7 +234,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
}
|
||||
}
|
||||
if (possibleTargets.size() == 1) {
|
||||
target.addTarget(possibleTargets.iterator().next(), source, game);
|
||||
target.addTarget(possibleTargets.iterator().next(), source, game); // todo: addtryaddtarget or return type (see computerPlayer)
|
||||
return true;
|
||||
}
|
||||
Iterator<UUID> it = possibleTargets.iterator();
|
||||
|
@ -243,7 +243,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
for (int i = 0; i < targetNum; i++) {
|
||||
targetId = it.next();
|
||||
}
|
||||
target.addTarget(targetId, source, game);
|
||||
target.addTarget(targetId, source, game);// todo: addtryaddtarget or return type (see computerPlayer)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -297,7 +297,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
}
|
||||
Card card = cards.getRandom(game);
|
||||
if (card != null) {
|
||||
target.addTarget(card.getId(), source, game);
|
||||
target.addTarget(card.getId(), source, game); // todo: addtryaddtarget or return type (see computerPlayer)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -315,7 +315,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
}
|
||||
}
|
||||
if (possibleTargets.size() == 1) {
|
||||
target.addTarget(possibleTargets.iterator().next(), target.getAmountRemaining(), source, game);
|
||||
target.addTarget(possibleTargets.iterator().next(), target.getAmountRemaining(), source, game); // todo: addtryaddtarget or return type (see computerPlayer)
|
||||
return true;
|
||||
}
|
||||
Iterator<UUID> it = possibleTargets.iterator();
|
||||
|
@ -324,7 +324,7 @@ public class SimulatedPlayerMCTS extends MCTSPlayer {
|
|||
for (int i = 0; i < targetNum; i++) {
|
||||
targetId = it.next();
|
||||
}
|
||||
target.addTarget(targetId, RandomUtil.nextInt(target.getAmountRemaining()) + 1, source, game);
|
||||
target.addTarget(targetId, RandomUtil.nextInt(target.getAmountRemaining()) + 1, source, game); // todo: addtryaddtarget or return type (see computerPlayer)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,13 @@
|
|||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.1.17</version>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- server xml config needs optional dependency for jaxb-impl -->
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
|
@ -200,31 +206,31 @@
|
|||
<dependency>
|
||||
<groupId>com.google.api-client</groupId>
|
||||
<artifactId>google-api-client</artifactId>
|
||||
<version>1.25.0</version>
|
||||
<version>1.28.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.apis</groupId>
|
||||
<artifactId>google-api-services-gmail</artifactId>
|
||||
<version>v1-rev82-1.23.0</version>
|
||||
<version>v1-rev20190120-1.28.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.oauth-client</groupId>
|
||||
<artifactId>google-oauth-client-java6</artifactId>
|
||||
<version>1.25.0</version>
|
||||
<version>1.28.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.oauth-client</groupId>
|
||||
<artifactId>google-oauth-client-jetty</artifactId>
|
||||
<version>1.25.0</version>
|
||||
<version>1.28.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4.7</version>
|
||||
<version>1.5.0-b01</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -9,9 +9,6 @@ import com.j256.ormlite.stmt.SelectArg;
|
|||
import com.j256.ormlite.support.ConnectionSource;
|
||||
import com.j256.ormlite.support.DatabaseConnection;
|
||||
import com.j256.ormlite.table.TableUtils;
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.RepositoryUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
@ -21,6 +18,10 @@ import org.apache.shiro.crypto.hash.Hash;
|
|||
import org.apache.shiro.crypto.hash.Sha256Hash;
|
||||
import org.apache.shiro.crypto.hash.SimpleHash;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
public enum AuthorizedUserRepository {
|
||||
|
||||
instance;
|
||||
|
@ -108,7 +109,7 @@ public enum AuthorizedUserRepository {
|
|||
public void closeDB() {
|
||||
try {
|
||||
if (dao != null && dao.getConnectionSource() != null) {
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection();
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection(dao.getTableName());
|
||||
conn.executeStatement("shutdown compact", 0);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
|
|
|
@ -30,8 +30,8 @@ import org.jboss.remoting.callback.InvokerCallbackHandler;
|
|||
public class Session {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Session.class);
|
||||
private final static Pattern alphabetsPattern = Pattern.compile("[a-zA-Z]");
|
||||
private final static Pattern digitsPattern = Pattern.compile("[0-9]");
|
||||
private static final Pattern alphabetsPattern = Pattern.compile("[a-zA-Z]");
|
||||
private static final Pattern digitsPattern = Pattern.compile("[0-9]");
|
||||
|
||||
private final String sessionId;
|
||||
private UUID userId;
|
||||
|
|
|
@ -29,7 +29,6 @@ public enum UserManager {
|
|||
|
||||
private List<UserView> userInfoList = new ArrayList<>();
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(UserManager.class);
|
||||
|
||||
private final ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
private final ConcurrentHashMap<UUID, User> users = new ConcurrentHashMap<>();
|
||||
|
@ -59,7 +58,7 @@ public enum UserManager {
|
|||
|
||||
public Optional<User> getUser(UUID userId) {
|
||||
if (!users.containsKey(userId)) {
|
||||
LOGGER.trace(String.format("User with id %s could not be found", userId));
|
||||
logger.warn(String.format("User with id %s could not be found", userId));;
|
||||
return Optional.empty();
|
||||
} else {
|
||||
return Optional.of(users.get(userId));
|
||||
|
@ -130,10 +129,10 @@ public enum UserManager {
|
|||
-> USER_EXECUTOR.execute(
|
||||
() -> {
|
||||
try {
|
||||
LOGGER.info("USER REMOVE - " + user.getName() + " (" + reason.toString() + ") userId: " + userId + " [" + user.getGameInfo() + ']');
|
||||
logger.info("USER REMOVE - " + user.getName() + " (" + reason.toString() + ") userId: " + userId + " [" + user.getGameInfo() + ']');
|
||||
user.removeUserFromAllTables(reason);
|
||||
ChatManager.instance.removeUser(user.getId(), reason);
|
||||
LOGGER.debug("USER REMOVE END - " + user.getName());
|
||||
logger.debug("USER REMOVE END - " + user.getName());
|
||||
} catch (Exception ex) {
|
||||
handleException(ex);
|
||||
}
|
||||
|
@ -248,12 +247,12 @@ public enum UserManager {
|
|||
|
||||
public void handleException(Exception ex) {
|
||||
if (ex != null) {
|
||||
LOGGER.fatal("User manager exception ", ex);
|
||||
logger.fatal("User manager exception ", ex);
|
||||
if (ex.getStackTrace() != null) {
|
||||
LOGGER.fatal(ex.getStackTrace());
|
||||
logger.fatal(ex.getStackTrace());
|
||||
}
|
||||
} else {
|
||||
LOGGER.fatal("User manager exception - null");
|
||||
logger.fatal("User manager exception - null");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class DraftSession {
|
||||
|
||||
protected final static Logger logger = Logger.getLogger(DraftSession.class);
|
||||
protected static final Logger logger = Logger.getLogger(DraftSession.class);
|
||||
|
||||
protected final UUID userId;
|
||||
protected final UUID playerId;
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class GameSessionWatcher {
|
||||
|
||||
protected final static Logger logger = Logger.getLogger(GameSessionWatcher.class);
|
||||
protected static final Logger logger = Logger.getLogger(GameSessionWatcher.class);
|
||||
|
||||
protected final UUID userId;
|
||||
protected final Game game;
|
||||
|
|
|
@ -4,15 +4,18 @@ import com.j256.ormlite.dao.Dao;
|
|||
import com.j256.ormlite.dao.DaoManager;
|
||||
import com.j256.ormlite.jdbc.JdbcConnectionSource;
|
||||
import com.j256.ormlite.stmt.QueryBuilder;
|
||||
import com.j256.ormlite.stmt.SelectArg;
|
||||
import com.j256.ormlite.support.ConnectionSource;
|
||||
import com.j256.ormlite.support.DatabaseConnection;
|
||||
import com.j256.ormlite.table.TableUtils;
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import mage.cards.repository.RepositoryUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public enum TableRecordRepository {
|
||||
|
||||
instance;
|
||||
|
@ -55,19 +58,19 @@ public enum TableRecordRepository {
|
|||
public List<TableRecord> getAfter(long endTimeMs) {
|
||||
try {
|
||||
QueryBuilder<TableRecord, Object> qb = dao.queryBuilder();
|
||||
qb.where().gt("endTimeMs", endTimeMs);
|
||||
qb.where().gt("endTimeMs", new SelectArg(endTimeMs));
|
||||
qb.orderBy("endTimeMs", true);
|
||||
return dao.query(qb.prepare());
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(TableRecordRepository.class).error("Error getting table_records from DB - ", ex);
|
||||
}
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public void closeDB() {
|
||||
try {
|
||||
if (dao != null && dao.getConnectionSource() != null) {
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection();
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection(dao.getTableName());
|
||||
conn.executeStatement("shutdown compact", 0);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.j256.ormlite.dao.Dao;
|
|||
import com.j256.ormlite.dao.DaoManager;
|
||||
import com.j256.ormlite.jdbc.JdbcConnectionSource;
|
||||
import com.j256.ormlite.stmt.QueryBuilder;
|
||||
import com.j256.ormlite.stmt.SelectArg;
|
||||
import com.j256.ormlite.support.ConnectionSource;
|
||||
import com.j256.ormlite.support.DatabaseConnection;
|
||||
import com.j256.ormlite.table.TableUtils;
|
||||
|
@ -15,10 +16,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public enum UserStatsRepository {
|
||||
|
||||
|
@ -70,7 +68,7 @@ public enum UserStatsRepository {
|
|||
public UserStats getUser(String userName) {
|
||||
try {
|
||||
QueryBuilder<UserStats, Object> qb = dao.queryBuilder();
|
||||
qb.limit(1L).where().eq("userName", userName);
|
||||
qb.limit(1L).where().eq("userName", new SelectArg(userName));
|
||||
List<UserStats> users = dao.query(qb.prepare());
|
||||
if (!users.isEmpty()) {
|
||||
return users.get(0);
|
||||
|
@ -88,17 +86,17 @@ public enum UserStatsRepository {
|
|||
} catch (SQLException ex) {
|
||||
Logger.getLogger(UserStatsRepository.class).error("Error getting all users from DB - ", ex);
|
||||
}
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public long getLatestEndTimeMs() {
|
||||
try {
|
||||
QueryBuilder<UserStats, Object> qb = dao.queryBuilder();
|
||||
QueryBuilder<UserStats, Object> qb = dao.queryBuilder();
|
||||
qb.orderBy("endTimeMs", false).limit(1L);
|
||||
List<UserStats> users = dao.query(qb.prepare());
|
||||
List<UserStats> users = dao.query(qb.prepare());
|
||||
if (!users.isEmpty()) {
|
||||
return users.get(0).getEndTimeMs();
|
||||
}
|
||||
return users.get(0).getEndTimeMs();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(UserStatsRepository.class).error("Error getting the latest end time from DB - ", ex);
|
||||
}
|
||||
|
@ -110,7 +108,7 @@ public enum UserStatsRepository {
|
|||
public List<String> updateUserStats() {
|
||||
Set<String> updatedUsers = new HashSet<>();
|
||||
// Lock the DB so that no other updateUserStats runs at the same time.
|
||||
synchronized(this) {
|
||||
synchronized (this) {
|
||||
long latestEndTimeMs = this.getLatestEndTimeMs();
|
||||
List<TableRecord> records = TableRecordRepository.instance.getAfter(latestEndTimeMs);
|
||||
for (TableRecord record : records) {
|
||||
|
@ -125,9 +123,9 @@ public enum UserStatsRepository {
|
|||
for (ResultProtos.MatchPlayerProto player : match.getPlayersList()) {
|
||||
UserStats userStats = this.getUser(player.getName());
|
||||
ResultProtos.UserStatsProto proto =
|
||||
userStats != null
|
||||
? userStats.getProto()
|
||||
: ResultProtos.UserStatsProto.newBuilder().setName(player.getName()).build();
|
||||
userStats != null
|
||||
? userStats.getProto()
|
||||
: ResultProtos.UserStatsProto.newBuilder().setName(player.getName()).build();
|
||||
ResultProtos.UserStatsProto.Builder builder = ResultProtos.UserStatsProto.newBuilder(proto)
|
||||
.setMatches(proto.getMatches() + 1);
|
||||
switch (player.getQuit()) {
|
||||
|
@ -369,7 +367,7 @@ public enum UserStatsRepository {
|
|||
public void closeDB() {
|
||||
try {
|
||||
if (dao != null && dao.getConnectionSource() != null) {
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection();
|
||||
DatabaseConnection conn = dao.getConnectionSource().getReadWriteConnection(dao.getTableName());
|
||||
conn.executeStatement("shutdown compact", 0);
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class TournamentSession {
|
||||
|
||||
protected final static Logger logger = Logger.getLogger(TournamentSession.class);
|
||||
protected static final Logger logger = Logger.getLogger(TournamentSession.class);
|
||||
|
||||
protected final UUID userId;
|
||||
protected final UUID playerId;
|
||||
|
|
|
@ -12,6 +12,8 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public final class Config {
|
||||
|
||||
private Config(){}
|
||||
|
||||
private static final Logger logger = Logger.getLogger(Config.class);
|
||||
|
||||
static {
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.io.File;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.concurrent.Executors;
|
||||
|
@ -52,7 +53,6 @@ public enum ServerMessagesUtil {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public List<String> getMessages() {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
|
@ -66,9 +66,7 @@ public enum ServerMessagesUtil {
|
|||
log.debug("Reading server messages...");
|
||||
List<String> motdMessages = readFromFile();
|
||||
List<String> newMessages = new ArrayList<>();
|
||||
if (motdMessages != null) {
|
||||
newMessages.addAll(motdMessages);
|
||||
}
|
||||
newMessages.addAll(motdMessages);
|
||||
newMessages.add(getServerStatistics());
|
||||
newMessages.add(getServerStatistics2());
|
||||
|
||||
|
@ -83,7 +81,7 @@ public enum ServerMessagesUtil {
|
|||
|
||||
private List<String> readFromFile() {
|
||||
if (ignore) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
File externalFile = null;
|
||||
if (pathToExternalMessages != null) {
|
||||
|
@ -120,7 +118,7 @@ public enum ServerMessagesUtil {
|
|||
}
|
||||
if (is == null) {
|
||||
log.warn("Couldn't find server.msg");
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Scanner scanner = null;
|
||||
|
@ -133,8 +131,8 @@ public enum ServerMessagesUtil {
|
|||
newMessages.add(message.trim());
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
log.error(e,e);
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
} finally {
|
||||
StreamUtils.closeQuietly(scanner);
|
||||
StreamUtils.closeQuietly(is);
|
||||
|
@ -168,7 +166,7 @@ public enum ServerMessagesUtil {
|
|||
return statistics.toString();
|
||||
}
|
||||
|
||||
// private Timer timer = new Timer(1000 * 60, new ActionListener() {
|
||||
// private Timer timer = new Timer(1000 * 60, new ActionListener() {
|
||||
// public void actionPerformed(ActionEvent e) {
|
||||
// reloadMessages();
|
||||
// }
|
||||
|
|
|
@ -11,6 +11,8 @@ import mage.players.Player;
|
|||
*/
|
||||
public final class Splitter {
|
||||
|
||||
private Splitter(){}
|
||||
|
||||
public static List<UUID> split(Game game, UUID playerId) {
|
||||
List<UUID> players = new ArrayList<>();
|
||||
//players.add(playerId); // add original player
|
||||
|
|
|
@ -31,6 +31,8 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public final class SystemUtil {
|
||||
|
||||
private SystemUtil(){}
|
||||
|
||||
public static final DateFormat dateFormat = new SimpleDateFormat("yy-M-dd HH:mm:ss");
|
||||
|
||||
private static final String INIT_FILE_PATH = "config" + File.separator + "init.txt";
|
||||
|
@ -120,7 +122,7 @@ public final class SystemUtil {
|
|||
String cardInfo = card.getName() + " - " + card.getExpansionSetCode();
|
||||
|
||||
// optional info
|
||||
ArrayList<String> resInfo = new ArrayList<>();
|
||||
List<String> resInfo = new ArrayList<>();
|
||||
for (String param : commandParams) {
|
||||
switch (param) {
|
||||
case PARAM_COLOR_COST:
|
||||
|
@ -147,7 +149,7 @@ public final class SystemUtil {
|
|||
}
|
||||
}
|
||||
|
||||
if (resInfo.size() > 0) {
|
||||
if (!resInfo.isEmpty()) {
|
||||
cardInfo += ": " + resInfo.stream().collect(Collectors.joining("; "));
|
||||
}
|
||||
|
||||
|
@ -555,12 +557,9 @@ public final class SystemUtil {
|
|||
* @return
|
||||
*/
|
||||
private static Optional<Player> findPlayer(Game game, String name) {
|
||||
for (Player player : game.getPlayers().values()) {
|
||||
if (player.getName().equals(name)) {
|
||||
return Optional.of(player);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
return game.getPlayers().values().stream()
|
||||
.filter(player -> player.getName().equals(name)).findFirst();
|
||||
|
||||
}
|
||||
|
||||
public static String sanitize(String input) {
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
<version>1.4.33</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-sets</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Mage Sets</name>
|
||||
|
|
|
@ -20,7 +20,7 @@ import mage.filter.predicate.permanent.ControllerPredicate;
|
|||
*/
|
||||
public final class AdaptiveAutomaton extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control of the chosen type");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control of the chosen type");
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||
|
|
|
@ -25,7 +25,7 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
*/
|
||||
public final class AgentOfShauku extends CardImpl {
|
||||
|
||||
final static FilterControlledPermanent filter = new FilterControlledLandPermanent("a land");
|
||||
static final FilterControlledPermanent filter = new FilterControlledLandPermanent("a land");
|
||||
|
||||
public AgentOfShauku(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{B}");
|
||||
|
|
|
@ -83,8 +83,7 @@ class AjanisLastStandTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD
|
||||
&& zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||
if (zEvent.isDiesEvent()) {
|
||||
if (zEvent.getTarget().isControlledBy(controllerId)
|
||||
&& (zEvent.getTarget().isCreature()
|
||||
|| zEvent.getTarget().isPlaneswalker())) {
|
||||
|
|
|
@ -25,7 +25,7 @@ import mage.filter.predicate.permanent.ControllerPredicate;
|
|||
*/
|
||||
public final class AltacBloodseeker extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls");
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||
|
|
|
@ -22,7 +22,7 @@ import mage.filter.predicate.mageobject.ColorPredicate;
|
|||
*/
|
||||
public final class AmrouSeekers extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent notArtificatOrWhite = new FilterCreaturePermanent("except by artifact creatures and/or white creatures");
|
||||
private static final FilterCreaturePermanent notArtificatOrWhite = new FilterCreaturePermanent("except by artifact creatures and/or white creatures");
|
||||
|
||||
static {
|
||||
notArtificatOrWhite.add(Predicates.not(
|
||||
|
|
|
@ -26,7 +26,7 @@ import mage.target.TargetPermanent;
|
|||
*/
|
||||
public final class AngelOfSanctions extends CardImpl {
|
||||
|
||||
private final static FilterNonlandPermanent filter = new FilterNonlandPermanent();
|
||||
private static final FilterNonlandPermanent filter = new FilterNonlandPermanent();
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||
|
|
|
@ -17,7 +17,7 @@ import mage.filter.predicate.mageobject.ColorPredicate;
|
|||
*/
|
||||
public final class AngelsFeather extends CardImpl {
|
||||
|
||||
private final static FilterSpell filter = new FilterSpell("a white spell");
|
||||
private static final FilterSpell filter = new FilterSpell("a white spell");
|
||||
|
||||
static {
|
||||
filter.add(new ColorPredicate(ObjectColor.WHITE));
|
||||
|
|
|
@ -20,7 +20,7 @@ import mage.target.targetpointer.SecondTargetPointer;
|
|||
*/
|
||||
public final class AngrathsFury extends CardImpl {
|
||||
|
||||
private final static FilterCard filter = new FilterCard("Angrath, Minotaur Pirate");
|
||||
private static final FilterCard filter = new FilterCard("Angrath, Minotaur Pirate");
|
||||
|
||||
static {
|
||||
filter.add(new NamePredicate(filter.getMessage()));
|
||||
|
|
|
@ -189,7 +189,7 @@ class AnimateDeadAttachEffect extends OneShotEffect {
|
|||
|
||||
class AnimateDeadChangeAbilityEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
||||
private final static Ability newAbility = new EnchantAbility("creature put onto the battlefield with Animate Dead");
|
||||
private static final Ability newAbility = new EnchantAbility("creature put onto the battlefield with Animate Dead");
|
||||
|
||||
static {
|
||||
newAbility.setRuleAtTheTop(true);
|
||||
|
|
|
@ -19,12 +19,12 @@ import mage.watchers.common.BloodthirstWatcher;
|
|||
*/
|
||||
public final class Antagonism extends CardImpl {
|
||||
|
||||
private static final String rule = "{this} deals 2 damage to that player unless one of his or her opponents was dealt damage this turn";
|
||||
private static final String rule = "{this} deals 2 damage to that player unless one of their opponents was dealt damage this turn";
|
||||
|
||||
public Antagonism(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{R}");
|
||||
|
||||
// At the beginning of each player's end step, Antagonism deals 2 damage to that player unless one of his or her opponents was dealt damage this turn.
|
||||
// At the beginning of each player's end step, Antagonism deals 2 damage to that player unless one of their opponents was dealt damage this turn.
|
||||
this.addAbility(new BeginningOfEndStepTriggeredAbility(new ConditionalOneShotEffect(new DamageTargetEffect(2),
|
||||
new OpponentWasNotDealtDamageCondition(), rule), TargetController.ANY, false));
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class AquitectsWill extends CardImpl {
|
||||
|
||||
private final static FilterControlledPermanent filter = new FilterControlledPermanent("Merfolk");
|
||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent("Merfolk");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate(SubType.MERFOLK));
|
||||
|
|
|
@ -23,7 +23,7 @@ import mage.filter.predicate.mageobject.SupertypePredicate;
|
|||
*/
|
||||
public final class ArenaOfTheAncients extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent legendaryFilter = new FilterCreaturePermanent("legendary creatures");
|
||||
private static final FilterCreaturePermanent legendaryFilter = new FilterCreaturePermanent("legendary creatures");
|
||||
static {
|
||||
legendaryFilter.add(new SupertypePredicate(SuperType.LEGENDARY));
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ class AthreosDiesCreatureTriggeredAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||
if (zEvent.isDiesEvent()) {
|
||||
if (zEvent.getTarget() != null && filter.match(zEvent.getTarget(), sourceId, controllerId, game)) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setValue("creatureId", event.getTargetId());
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class AvoidFate extends CardImpl {
|
||||
|
||||
private final static FilterSpell filter = new FilterSpell("instant or Aura spell that targets a permanent you control");
|
||||
private static final FilterSpell filter = new FilterSpell("instant or Aura spell that targets a permanent you control");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.or(new CardTypePredicate(CardType.INSTANT), new SubtypePredicate(SubType.AURA)));
|
||||
|
|
|
@ -26,7 +26,7 @@ import mage.target.common.TargetActivatedAbility;
|
|||
*/
|
||||
public final class AyeshaTanaka extends CardImpl {
|
||||
|
||||
private final static FilterStackObject filter = new FilterStackObject("activated ability from an artifact source");
|
||||
private static final FilterStackObject filter = new FilterStackObject("activated ability from an artifact source");
|
||||
|
||||
static {
|
||||
filter.add(new ArtifactSourcePredicate());
|
||||
|
|
|
@ -28,7 +28,7 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public final class BanisherPriest extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls");
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||
|
|
|
@ -21,7 +21,7 @@ import mage.target.TargetPermanent;
|
|||
*/
|
||||
public final class BanishingLight extends CardImpl {
|
||||
|
||||
private final static FilterNonlandPermanent filter = new FilterNonlandPermanent();
|
||||
private static final FilterNonlandPermanent filter = new FilterNonlandPermanent();
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||
|
|
|
@ -70,7 +70,7 @@ public final class BaruFistOfKrosa extends CardImpl {
|
|||
|
||||
class BaruFistOfKrosaEffect extends OneShotEffect {
|
||||
|
||||
final static FilterControlledPermanent filter = new FilterControlledLandPermanent("lands you control");
|
||||
static final FilterControlledPermanent filter = new FilterControlledLandPermanent("lands you control");
|
||||
|
||||
BaruFistOfKrosaEffect() {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
|
|
|
@ -24,7 +24,7 @@ import mage.filter.predicate.permanent.CommanderPredicate;
|
|||
*/
|
||||
public final class BastionProtector extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("Commander creatures");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Commander creatures");
|
||||
|
||||
static {
|
||||
filter.add(CommanderPredicate.instance);
|
||||
|
|
|
@ -35,7 +35,7 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public final class BishopOfBinding extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls");
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||
|
|
|
@ -25,7 +25,7 @@ import mage.filter.common.FilterCreaturePermanent;
|
|||
*/
|
||||
public final class BladewingsThrall extends CardImpl {
|
||||
|
||||
final static private String RULE = "{this} has flying as long as you control a Dragon";
|
||||
static final private String RULE = "{this} has flying as long as you control a Dragon";
|
||||
|
||||
public BladewingsThrall(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}{B}");
|
||||
|
|
|
@ -48,7 +48,7 @@ public final class BlightHerder extends CardImpl {
|
|||
|
||||
class BlightHerderEffect extends OneShotEffect {
|
||||
|
||||
private final static FilterCard filter = new FilterCard("cards your opponents own from exile");
|
||||
private static final FilterCard filter = new FilterCard("cards your opponents own from exile");
|
||||
|
||||
static {
|
||||
filter.add(new OwnerPredicate(TargetController.OPPONENT));
|
||||
|
|
|
@ -24,8 +24,8 @@ import mage.filter.common.FilterControlledEnchantmentPermanent;
|
|||
*/
|
||||
public final class BloodCursedKnight extends CardImpl {
|
||||
|
||||
final static private String rule1 = "As long as you control an enchantment, {this} gets +1/+1";
|
||||
final static private String rule2 = "and has lifelink";
|
||||
static final private String rule1 = "As long as you control an enchantment, {this} gets +1/+1";
|
||||
static final private String rule2 = "and has lifelink";
|
||||
|
||||
public BloodCursedKnight(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}{B}");
|
||||
|
|
|
@ -21,7 +21,7 @@ import mage.filter.predicate.permanent.ControllerPredicate;
|
|||
*/
|
||||
public final class Bloodbriar extends CardImpl {
|
||||
|
||||
private final static FilterPermanent filter = new FilterPermanent("another permanent");
|
||||
private static final FilterPermanent filter = new FilterPermanent("another permanent");
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||
|
|
|
@ -25,7 +25,7 @@ import mage.filter.predicate.permanent.CommanderPredicate;
|
|||
*/
|
||||
public final class BloodswornSteward extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("Commander creatures");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Commander creatures");
|
||||
static {
|
||||
filter.add(CommanderPredicate.instance);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import mage.target.common.TargetControlledPermanent;
|
|||
*/
|
||||
public final class BogGlider extends CardImpl {
|
||||
|
||||
final static FilterControlledPermanent landFilter = new FilterControlledLandPermanent("a land");
|
||||
static final FilterControlledPermanent landFilter = new FilterControlledLandPermanent("a land");
|
||||
private static final FilterPermanentCard filter = new FilterPermanentCard("Mercenary permanent card with converted mana cost 2 or less");
|
||||
|
||||
static {
|
||||
|
|
|
@ -17,7 +17,7 @@ import mage.filter.predicate.permanent.ControllerPredicate;
|
|||
*/
|
||||
public final class BoilingEarth extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("creature your opponents control");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature your opponents control");
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||
|
|
|
@ -96,7 +96,7 @@ class DiesWhileInGraveyardTriggeredAbility extends TriggeredAbilityImpl {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||
if (zEvent.isDiesEvent()) {
|
||||
if (filter.match(zEvent.getTarget(), sourceId, controllerId, game)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class BoundByMoonsilver extends CardImpl {
|
||||
|
||||
private final static FilterControlledPermanent filter = new FilterControlledPermanent("another permanent");
|
||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent("another permanent");
|
||||
|
||||
static {
|
||||
filter.add(AnotherPredicate.instance);
|
||||
|
|
|
@ -31,7 +31,7 @@ public final class BrandedBrawlers extends CardImpl {
|
|||
filter.add(Predicates.not(TappedPredicate.instance));
|
||||
}
|
||||
|
||||
final static private String rule = "{this} can't block if you control an untapped land";
|
||||
static final private String rule = "{this} can't block if you control an untapped land";
|
||||
|
||||
public BrandedBrawlers(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}");
|
||||
|
|
|
@ -84,7 +84,7 @@ class BridgeFromBelowAbility extends TriggeredAbilityImpl {
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() == Zone.GRAVEYARD) {
|
||||
if (zEvent.isDiesEvent()) {
|
||||
Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
|
||||
if (permanent != null && filter.match(permanent, sourceId, controllerId, game)) {
|
||||
return true;
|
||||
|
|
|
@ -24,7 +24,7 @@ import mage.target.common.TargetActivatedAbility;
|
|||
*/
|
||||
public final class BrownOuphe extends CardImpl {
|
||||
|
||||
private final static FilterStackObject filter = new FilterStackObject("activated ability from an artifact source");
|
||||
private static final FilterStackObject filter = new FilterStackObject("activated ability from an artifact source");
|
||||
|
||||
static {
|
||||
filter.add(new ArtifactSourcePredicate());
|
||||
|
|
|
@ -56,7 +56,7 @@ public final class BudokaGardener extends CardImpl {
|
|||
|
||||
class BudokaGardenerEffect extends OneShotEffect {
|
||||
|
||||
final static FilterControlledPermanent filterLands = new FilterControlledLandPermanent("lands you control");
|
||||
static final FilterControlledPermanent filterLands = new FilterControlledLandPermanent("lands you control");
|
||||
|
||||
BudokaGardenerEffect() {
|
||||
super(Outcome.PutLandInPlay);
|
||||
|
|
|
@ -19,7 +19,7 @@ import mage.filter.predicate.mageobject.SupertypePredicate;
|
|||
*/
|
||||
public final class BurningEarth extends CardImpl {
|
||||
|
||||
private final static FilterLandPermanent filter = new FilterLandPermanent("a player taps a nonbasic land");
|
||||
private static final FilterLandPermanent filter = new FilterLandPermanent("a player taps a nonbasic land");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(new SupertypePredicate(SuperType.BASIC)));
|
||||
|
|
|
@ -33,7 +33,7 @@ import mage.target.targetpointer.FixedTarget;
|
|||
*/
|
||||
public final class CapturedByTheConsulate extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.NOT_YOU));
|
||||
|
|
|
@ -24,7 +24,7 @@ import mage.target.TargetPermanent;
|
|||
*/
|
||||
public final class CastOut extends CardImpl {
|
||||
|
||||
private final static FilterNonlandPermanent filter = new FilterNonlandPermanent();
|
||||
private static final FilterNonlandPermanent filter = new FilterNonlandPermanent();
|
||||
|
||||
static {
|
||||
filter.add(new ControllerPredicate(TargetController.OPPONENT));
|
||||
|
|
|
@ -24,7 +24,7 @@ import mage.game.permanent.token.EldraziScionToken;
|
|||
*/
|
||||
public final class CatacombSifter extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature you control");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature you control");
|
||||
static {
|
||||
filter.add(AnotherPredicate.instance);
|
||||
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class ChampionOfDusk extends CardImpl {
|
||||
|
||||
private final static FilterControlledPermanent filter = new FilterControlledPermanent("Vampires you control");
|
||||
private static final FilterControlledPermanent filter = new FilterControlledPermanent("Vampires you control");
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate(SubType.VAMPIRE));
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class ChampionOfLambholt extends CardImpl {
|
||||
|
||||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature");
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature");
|
||||
|
||||
static {
|
||||
filter.add(AnotherPredicate.instance);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue