mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Fixed typos in tests and additional refactor
This commit is contained in:
parent
4d8369afbc
commit
ede06098e0
7 changed files with 652 additions and 648 deletions
|
@ -20,7 +20,8 @@
|
||||||
|
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.awt.Component;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
|
@ -28,12 +29,6 @@ import java.awt.event.MouseEvent;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import javax.swing.DefaultListModel;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JList;
|
|
||||||
import javax.swing.ListCellRenderer;
|
|
||||||
import javax.swing.ListModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extended JList that contains CheckBoxes. If necessary a CheckBoxListItem
|
* An extended JList that contains CheckBoxes. If necessary a CheckBoxListItem
|
||||||
* wrapper is added around the displayed object in any of the Model methods,
|
* wrapper is added around the displayed object in any of the Model methods,
|
||||||
|
@ -45,7 +40,9 @@ import javax.swing.ListModel;
|
||||||
*/
|
*/
|
||||||
public class CheckBoxList extends JList {
|
public class CheckBoxList extends JList {
|
||||||
|
|
||||||
/** for serialization */
|
/**
|
||||||
|
* for serialization
|
||||||
|
*/
|
||||||
private static final long serialVersionUID = -4359573373359270258L;
|
private static final long serialVersionUID = -4359573373359270258L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,10 +53,14 @@ public class CheckBoxList extends JList {
|
||||||
*/
|
*/
|
||||||
protected class CheckBoxListItem {
|
protected class CheckBoxListItem {
|
||||||
|
|
||||||
/** whether item is checked or not */
|
/**
|
||||||
|
* whether item is checked or not
|
||||||
|
*/
|
||||||
private boolean m_Checked = false;
|
private boolean m_Checked = false;
|
||||||
|
|
||||||
/** the actual object */
|
/**
|
||||||
|
* the actual object
|
||||||
|
*/
|
||||||
private Object m_Content = null;
|
private Object m_Content = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,7 +140,9 @@ public class CheckBoxList extends JList {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class CheckBoxListModel extends DefaultListModel {
|
public class CheckBoxListModel extends DefaultListModel {
|
||||||
|
|
||||||
/** for serialization */
|
/**
|
||||||
|
* for serialization
|
||||||
|
*/
|
||||||
private static final long serialVersionUID = 7772455499540273507L;
|
private static final long serialVersionUID = 7772455499540273507L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,7 +281,7 @@ public class CheckBoxList extends JList {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(int index) {
|
public Object getElementAt(int index) {
|
||||||
return ((CheckBoxListItem) super.getElementAt(index));//.getContent();
|
return super.getElementAt(index);//.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -494,7 +497,9 @@ public class CheckBoxList extends JList {
|
||||||
public class CheckBoxListRenderer extends JCheckBox implements
|
public class CheckBoxListRenderer extends JCheckBox implements
|
||||||
ListCellRenderer {
|
ListCellRenderer {
|
||||||
|
|
||||||
/** for serialization */
|
/**
|
||||||
|
* for serialization
|
||||||
|
*/
|
||||||
private static final long serialVersionUID = 1059591605858524586L;
|
private static final long serialVersionUID = 1059591605858524586L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -581,24 +586,13 @@ public class CheckBoxList extends JList {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setModel(ListModel model) {
|
public void setModel(ListModel model) {
|
||||||
if (!(model instanceof CheckBoxListModel)) {
|
if (model instanceof CheckBoxListModel) {
|
||||||
if (model instanceof javax.swing.DefaultListModel) {
|
|
||||||
super.setModel((CheckBoxListModel)model);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Model must be an instance of CheckBoxListModel!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
super.setModel(model);
|
super.setModel(model);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Model must be an instance of CheckBoxListModel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public void setModel(DefaultListModel model) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Model must be an ins12313tance of CheckBoxListModel!");
|
|
||||||
}*/
|
|
||||||
/**
|
/**
|
||||||
* Constructs a CheckBoxListModel from an array of objects and then applies
|
* Constructs a CheckBoxListModel from an array of objects and then applies
|
||||||
* setModel to it.
|
* setModel to it.
|
||||||
|
@ -671,6 +665,7 @@ public class CheckBoxList extends JList {
|
||||||
this.setChecked(i, true);
|
this.setChecked(i, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void uncheckAll() {
|
public void uncheckAll() {
|
||||||
int[] choiceToUncheck = this.getCheckedIndices();
|
int[] choiceToUncheck = this.getCheckedIndices();
|
||||||
for (int itemIndex : choiceToUncheck) {
|
for (int itemIndex : choiceToUncheck) {
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.constants.Constants;
|
import mage.constants.Constants;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
import mage.interfaces.callback.ClientCallbackMethod;
|
import mage.interfaces.callback.ClientCallbackMethod;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.players.net.UserGroup;
|
import mage.players.net.UserGroup;
|
||||||
import static mage.server.DisconnectReason.LostConnection;
|
|
||||||
import mage.server.game.GamesRoom;
|
import mage.server.game.GamesRoom;
|
||||||
import mage.server.game.GamesRoomManager;
|
import mage.server.game.GamesRoomManager;
|
||||||
import mage.server.util.ConfigSettings;
|
import mage.server.util.ConfigSettings;
|
||||||
|
@ -23,6 +17,14 @@ import org.jboss.remoting.callback.Callback;
|
||||||
import org.jboss.remoting.callback.HandleCallbackException;
|
import org.jboss.remoting.callback.HandleCallbackException;
|
||||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import static mage.server.DisconnectReason.LostConnection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -201,9 +203,11 @@ public class Session {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<User> selectUser = UserManager.instance.createUser(userName, host, authorizedUser);
|
Optional<User> selectUser = UserManager.instance.createUser(userName, host, authorizedUser);
|
||||||
boolean reconnect = false;
|
boolean reconnect = false;
|
||||||
if (!selectUser.isPresent()) { // user already exists
|
if (!selectUser.isPresent()) {
|
||||||
|
// user already connected
|
||||||
selectUser = UserManager.instance.getUserByName(userName);
|
selectUser = UserManager.instance.getUserByName(userName);
|
||||||
if (selectUser.isPresent()) {
|
if (selectUser.isPresent()) {
|
||||||
User user = selectUser.get();
|
User user = selectUser.get();
|
||||||
|
@ -222,6 +226,9 @@ public class Session {
|
||||||
} else {
|
} else {
|
||||||
return "User name " + userName + " already in use (or your IP address changed)";
|
return "User name " + userName + " already in use (or your IP address changed)";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// code never goes here
|
||||||
|
return "Can't find connected user name " + userName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
User user = selectUser.get();
|
User user = selectUser.get();
|
||||||
|
@ -240,7 +247,6 @@ public class Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connectAdmin() {
|
public void connectAdmin() {
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
|
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.locks.Lock;
|
|
||||||
import java.util.concurrent.locks.ReadWriteLock;
|
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
|
@ -31,6 +19,18 @@ import mage.server.game.GamesRoomManager;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.locks.Lock;
|
||||||
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -415,7 +415,7 @@ public enum TableManager {
|
||||||
if (table.getState() != TableState.FINISHED
|
if (table.getState() != TableState.FINISHED
|
||||||
&& ((System.currentTimeMillis() - table.getStartTime().getTime()) / 1000) > 30) { // removeUserFromAllTablesAndChat only if table started longer than 30 seconds ago
|
&& ((System.currentTimeMillis() - table.getStartTime().getTime()) / 1000) > 30) { // removeUserFromAllTablesAndChat only if table started longer than 30 seconds ago
|
||||||
// removeUserFromAllTablesAndChat tables and games not valid anymore
|
// removeUserFromAllTablesAndChat tables and games not valid anymore
|
||||||
logger.debug(table.getId() + " [" + table.getName() + "] " + formatter.format(table.getStartTime() == null ? table.getCreateTime() : table.getCreateTime()) + " (" + table.getState().toString() + ") " + (table.isTournament() ? "- Tournament" : ""));
|
logger.debug(table.getId() + " [" + table.getName() + "] " + formatter.format(table.getStartTime() != null ? table.getStartTime() : table.getCreateTime()) + " (" + table.getState().toString() + ") " + (table.isTournament() ? "- Tournament" : ""));
|
||||||
getController(table.getId()).ifPresent(tableController -> {
|
getController(table.getId()).ifPresent(tableController -> {
|
||||||
if ((table.isTournament() && !tableController.isTournamentStillValid())
|
if ((table.isTournament() && !tableController.isTournamentStillValid())
|
||||||
|| (!table.isTournament() && !tableController.isMatchTableStillValid())) {
|
|| (!table.isTournament() && !tableController.isMatchTableStillValid())) {
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package mage.cards.v;
|
package mage.cards.v;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
@ -17,8 +13,11 @@ import mage.game.Game;
|
||||||
import mage.players.Library;
|
import mage.players.Library;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author noahg
|
* @author noahg
|
||||||
*/
|
*/
|
||||||
public final class VigeanIntuition extends CardImpl {
|
public final class VigeanIntuition extends CardImpl {
|
||||||
|
@ -74,14 +73,22 @@ class VigeanIntuitionEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
|
if (sourceObject == null || player == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Library library = player.getLibrary();
|
Library library = player.getLibrary();
|
||||||
if (player != null && sourceObject != null && library != null) {
|
if (library == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Choice choiceImpl = new ChoiceImpl();
|
Choice choiceImpl = new ChoiceImpl();
|
||||||
choiceImpl.setChoices(choice);
|
choiceImpl.setChoices(choice);
|
||||||
if (player.choose(Outcome.Neutral, choiceImpl, game)) {
|
if (player.choose(Outcome.Neutral, choiceImpl, game)) {
|
||||||
CardType type = null;
|
|
||||||
String choosenType = choiceImpl.getChoice();
|
String choosenType = choiceImpl.getChoice();
|
||||||
|
if (choosenType == null || choosenType.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CardType type = null;
|
||||||
if (choosenType.equals(CardType.ARTIFACT.toString())) {
|
if (choosenType.equals(CardType.ARTIFACT.toString())) {
|
||||||
type = CardType.ARTIFACT;
|
type = CardType.ARTIFACT;
|
||||||
} else if (choosenType.equals(CardType.LAND.toString())) {
|
} else if (choosenType.equals(CardType.LAND.toString())) {
|
||||||
|
@ -117,7 +124,6 @@ class VigeanIntuitionEffect extends OneShotEffect {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -30,7 +30,7 @@ public class PaintersServantTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
addCard(Zone.HAND, playerB, "Lightning Bolt");
|
addCard(Zone.HAND, playerB, "Lightning Bolt");
|
||||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||||
addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion");
|
addCard(Zone.GRAVEYARD, playerB, "Silvercoat Lion");
|
||||||
|
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Painter's Servant");
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Painter's Servant");
|
||||||
setChoice(playerA, "Blue");
|
setChoice(playerA, "Blue");
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package org.mage.test.cards.continuous;
|
package org.mage.test.cards.continuous;
|
||||||
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
@ -11,7 +10,6 @@ import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class SubTypeChangingEffectsTest extends CardTestPlayerBase {
|
public class SubTypeChangingEffectsTest extends CardTestPlayerBase {
|
||||||
|
@ -29,7 +27,7 @@ public class SubTypeChangingEffectsTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
addCard(Zone.HAND, playerB, "Silvercoat Lion");
|
addCard(Zone.HAND, playerB, "Silvercoat Lion");
|
||||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||||
addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion");
|
addCard(Zone.GRAVEYARD, playerB, "Silvercoat Lion");
|
||||||
|
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Conspiracy");
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Conspiracy");
|
||||||
setChoice(playerA, "Orc");
|
setChoice(playerA, "Orc");
|
||||||
|
@ -105,7 +103,7 @@ public class SubTypeChangingEffectsTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
addCard(Zone.HAND, playerB, "Silvercoat Lion");
|
addCard(Zone.HAND, playerB, "Silvercoat Lion");
|
||||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||||
addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion");
|
addCard(Zone.GRAVEYARD, playerB, "Silvercoat Lion");
|
||||||
|
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Conspiracy");
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Conspiracy");
|
||||||
setChoice(playerA, "Orc");
|
setChoice(playerA, "Orc");
|
||||||
|
@ -159,7 +157,7 @@ public class SubTypeChangingEffectsTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
addCard(Zone.HAND, playerB, "Silvercoat Lion");
|
addCard(Zone.HAND, playerB, "Silvercoat Lion");
|
||||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||||
addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion");
|
addCard(Zone.GRAVEYARD, playerB, "Silvercoat Lion");
|
||||||
|
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Arcane Adaptation");
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Arcane Adaptation");
|
||||||
setChoice(playerA, "Orc");
|
setChoice(playerA, "Orc");
|
||||||
|
@ -246,7 +244,7 @@ public class SubTypeChangingEffectsTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
addCard(Zone.HAND, playerB, "Silvercoat Lion");
|
addCard(Zone.HAND, playerB, "Silvercoat Lion");
|
||||||
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
|
||||||
addCard(Zone.GRAVEYARD, playerA, "Silvercoat Lion");
|
addCard(Zone.GRAVEYARD, playerB, "Silvercoat Lion");
|
||||||
|
|
||||||
castSpell(1, PhaseStep.UPKEEP, playerA, "Advent of the Wurm");
|
castSpell(1, PhaseStep.UPKEEP, playerA, "Advent of the Wurm");
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ public class BecomesCreatureTypeTargetEffect extends ContinuousEffectImpl {
|
||||||
super(effect);
|
super(effect);
|
||||||
this.subtypes.addAll(effect.subtypes);
|
this.subtypes.addAll(effect.subtypes);
|
||||||
this.loseOther = effect.loseOther;
|
this.loseOther = effect.loseOther;
|
||||||
this.loseOther = effect.loseOther;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue