mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
replaced enum comparison from equals to ==
This commit is contained in:
parent
1c4bf298eb
commit
ac8962cb29
31 changed files with 264 additions and 318 deletions
|
@ -44,6 +44,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.Sets;
|
import mage.cards.Sets;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
|
@ -73,7 +74,6 @@ import mage.view.SimpleCardView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class DeckEditorPanel extends javax.swing.JPanel {
|
public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
|
@ -288,7 +288,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
this.deckArea.clearDeckEventListeners();
|
this.deckArea.clearDeckEventListeners();
|
||||||
this.deckArea.addDeckEventListener(
|
this.deckArea.addDeckEventListener(
|
||||||
(Listener<Event>) event -> {
|
(Listener<Event>) event -> {
|
||||||
if (mode.equals(DeckEditorMode.FREE_BUILDING)) {
|
if (mode == DeckEditorMode.FREE_BUILDING){
|
||||||
switch (event.getEventName()) {
|
switch (event.getEventName()) {
|
||||||
case "double-click": {
|
case "double-click": {
|
||||||
SimpleCardView cardView = (SimpleCardView) event.getSource();
|
SimpleCardView cardView = (SimpleCardView) event.getSource();
|
||||||
|
@ -336,7 +336,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}else{
|
||||||
// constructing phase or sideboarding during match -> card goes always to sideboard
|
// constructing phase or sideboarding during match -> card goes always to sideboard
|
||||||
switch (event.getEventName()) {
|
switch (event.getEventName()) {
|
||||||
case "double-click":
|
case "double-click":
|
||||||
|
@ -376,7 +376,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
this.deckArea.clearSideboardEventListeners();
|
this.deckArea.clearSideboardEventListeners();
|
||||||
this.deckArea.addSideboardEventListener(
|
this.deckArea.addSideboardEventListener(
|
||||||
(Listener<Event>) event -> {
|
(Listener<Event>) event -> {
|
||||||
if (mode.equals(DeckEditorMode.FREE_BUILDING)) {
|
if (mode == DeckEditorMode.FREE_BUILDING) {
|
||||||
// normal edit mode
|
// normal edit mode
|
||||||
switch (event.getEventName()) {
|
switch (event.getEventName()) {
|
||||||
case "double-click":
|
case "double-click":
|
||||||
|
@ -598,7 +598,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
AudioManager.playOnCountdown1();
|
AudioManager.playOnCountdown1();
|
||||||
}
|
}
|
||||||
if (timeToSubmit > 0) {
|
if (timeToSubmit > 0) {
|
||||||
timeToSubmit --;
|
timeToSubmit--;
|
||||||
btnSubmitTimer.setText("Submit (" + timeToSubmit + ")");
|
btnSubmitTimer.setText("Submit (" + timeToSubmit + ")");
|
||||||
btnSubmitTimer.setToolTipText("Submit your deck in " + timeToSubmit + " seconds!");
|
btnSubmitTimer.setToolTipText("Submit your deck in " + timeToSubmit + " seconds!");
|
||||||
}
|
}
|
||||||
|
@ -711,84 +711,84 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
jPanel1.setLayout(jPanel1Layout);
|
jPanel1.setLayout(jPanel1Layout);
|
||||||
jPanel1Layout.setHorizontalGroup(
|
jPanel1Layout.setHorizontalGroup(
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
/*.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
|
/*.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))*/
|
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))*/
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addGap(6, 6, 6)
|
.addGap(6, 6, 6)
|
||||||
.addComponent(lblDeckName)
|
.addComponent(lblDeckName)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
|
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
|
||||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnSave)
|
.addComponent(btnSave)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnLoad)
|
.addComponent(btnLoad)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnNew)
|
.addComponent(btnNew)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(btnExit))
|
.addComponent(btnExit))
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnImport)
|
.addComponent(btnImport)
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnGenDeck)
|
.addComponent(btnGenDeck)
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnAddLand)
|
.addComponent(btnAddLand)
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnSubmit)
|
.addComponent(btnSubmit)
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(btnSubmitTimer))
|
.addComponent(btnSubmitTimer))
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(txtTimeRemaining))
|
.addComponent(txtTimeRemaining))
|
||||||
)
|
)
|
||||||
.addContainerGap()));
|
.addContainerGap()));
|
||||||
jPanel1Layout.setVerticalGroup(
|
jPanel1Layout.setVerticalGroup(
|
||||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(lblDeckName))
|
.addComponent(lblDeckName))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(btnSave)
|
.addComponent(btnSave)
|
||||||
.addComponent(btnLoad)
|
.addComponent(btnLoad)
|
||||||
.addComponent(btnNew)
|
.addComponent(btnNew)
|
||||||
.addComponent(btnExit))
|
.addComponent(btnExit))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(btnImport)
|
.addComponent(btnImport)
|
||||||
.addComponent(btnGenDeck)
|
.addComponent(btnGenDeck)
|
||||||
.addComponent(btnAddLand)
|
.addComponent(btnAddLand)
|
||||||
.addComponent(btnSubmit)
|
.addComponent(btnSubmit)
|
||||||
.addComponent(btnSubmitTimer))
|
.addComponent(btnSubmitTimer))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(txtTimeRemaining))
|
.addComponent(txtTimeRemaining))
|
||||||
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
//.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
|
||||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
|
||||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
|
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)));
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
this.setLayout(layout);
|
this.setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addGap(0, 0, 0)
|
.addGap(0, 0, 0)
|
||||||
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)));
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addComponent(jPanel1, 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(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
|
.addComponent(jSplitPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1023,7 +1023,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
deck = Deck.load(DeckImporterUtil.importDeck(path), true, true);
|
deck = Deck.load(DeckImporterUtil.importDeck(path), true, true);
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading generated deck", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading generated deck", JOptionPane.ERROR_MESSAGE);
|
||||||
}catch (DeckGeneratorException ex) {
|
} catch (DeckGeneratorException ex) {
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Generator error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Generator error", JOptionPane.ERROR_MESSAGE);
|
||||||
} finally {
|
} finally {
|
||||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class AddLandDialog extends MageDialog {
|
||||||
public void showDialog(Deck deck, DeckEditorMode mode) {
|
public void showDialog(Deck deck, DeckEditorMode mode) {
|
||||||
this.deck = deck;
|
this.deck = deck;
|
||||||
SortedSet<String> landSetNames = new TreeSet<>();
|
SortedSet<String> landSetNames = new TreeSet<>();
|
||||||
if (!mode.equals(DeckEditorMode.FREE_BUILDING)) {
|
if (mode!=DeckEditorMode.FREE_BUILDING) {
|
||||||
// decide from which sets basic lands are taken from
|
// decide from which sets basic lands are taken from
|
||||||
for (String setCode : deck.getExpansionSetCodes()) {
|
for (String setCode : deck.getExpansionSetCodes()) {
|
||||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(setCode);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import javax.swing.JPopupMenu;
|
||||||
import javax.swing.Popup;
|
import javax.swing.Popup;
|
||||||
import javax.swing.PopupFactory;
|
import javax.swing.PopupFactory;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
import mage.cards.action.TransferData;
|
import mage.cards.action.TransferData;
|
||||||
|
@ -78,6 +79,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
|
|
||||||
CLOSED, NORMAL, ROTATED
|
CLOSED, NORMAL, ROTATED
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date enlargeredViewOpened;
|
private Date enlargeredViewOpened;
|
||||||
private volatile EnlargedWindowState enlargedWindowState = EnlargedWindowState.CLOSED;
|
private volatile EnlargedWindowState enlargedWindowState = EnlargedWindowState.CLOSED;
|
||||||
//private volatile boolean enlargedImageWindowOpen = false;
|
//private volatile boolean enlargedImageWindowOpen = false;
|
||||||
|
@ -156,7 +158,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
|| !tooltipCard.equals(data.card)
|
|| !tooltipCard.equals(data.card)
|
||||||
|| SessionHandler.getSession() == null
|
|| SessionHandler.getSession() == null
|
||||||
|| !popupTextWindowOpen
|
|| !popupTextWindowOpen
|
||||||
|| !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
|| enlargedWindowState != EnlargedWindowState.CLOSED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,21 +178,21 @@ public class MageActionCallback implements ActionCallback {
|
||||||
public void showPopup(final Component popupContainer, final Component infoPane) throws InterruptedException {
|
public void showPopup(final Component popupContainer, final Component infoPane) throws InterruptedException {
|
||||||
final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
if (!popupTextWindowOpen
|
if (!popupTextWindowOpen
|
||||||
|| !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
|| enlargedWindowState != EnlargedWindowState.CLOSED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.locationOnScreen == null) {
|
if (data.locationOnScreen == null) {
|
||||||
data.locationOnScreen = data.component.getLocationOnScreen();
|
data.locationOnScreen = data.component.getLocationOnScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40);
|
Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40);
|
||||||
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, infoPane, parentComponent);
|
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, infoPane, parentComponent);
|
||||||
location.translate(-parentPoint.x, -parentPoint.y);
|
location.translate(-parentPoint.x, -parentPoint.y);
|
||||||
popupContainer.setLocation(location);
|
popupContainer.setLocation(location);
|
||||||
popupContainer.setVisible(true);
|
popupContainer.setVisible(true);
|
||||||
c.repaint();
|
c.repaint();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -402,7 +404,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
} else {
|
} else {
|
||||||
popupTextWindowOpen = true;
|
popupTextWindowOpen = true;
|
||||||
}
|
}
|
||||||
if (!enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
if (enlargedWindowState != EnlargedWindowState.CLOSED) {
|
||||||
cancelTimeout();
|
cancelTimeout();
|
||||||
displayEnlargedCard(mageCard.getOriginal(), transferData);
|
displayEnlargedCard(mageCard.getOriginal(), transferData);
|
||||||
}
|
}
|
||||||
|
@ -417,7 +419,6 @@ public class MageActionCallback implements ActionCallback {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hides the text popup window
|
* Hides the text popup window
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void hideTooltipPopup() {
|
public void hideTooltipPopup() {
|
||||||
this.tooltipCard = null;
|
this.tooltipCard = null;
|
||||||
|
@ -461,13 +462,13 @@ public class MageActionCallback implements ActionCallback {
|
||||||
@Override
|
@Override
|
||||||
public void mouseWheelMoved(MouseWheelEvent e, TransferData transferData) {
|
public void mouseWheelMoved(MouseWheelEvent e, TransferData transferData) {
|
||||||
int notches = e.getWheelRotation();
|
int notches = e.getWheelRotation();
|
||||||
if (!enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
if (enlargedWindowState != EnlargedWindowState.CLOSED) {
|
||||||
// same move direction will be ignored, opposite direction closes the enlarged window
|
// same move direction will be ignored, opposite direction closes the enlarged window
|
||||||
if (new Date().getTime() - enlargeredViewOpened.getTime() > 1000) {
|
if (new Date().getTime() - enlargeredViewOpened.getTime() > 1000) {
|
||||||
// if the opening is back more than 1 seconds close anyway
|
// if the opening is back more than 1 seconds close anyway
|
||||||
hideEnlargedCard();
|
hideEnlargedCard();
|
||||||
handleOverNewView(transferData);
|
handleOverNewView(transferData);
|
||||||
} else if (enlargeMode.equals(EnlargeMode.NORMAL)) {
|
} else if (enlargeMode == EnlargeMode.NORMAL) {
|
||||||
if (notches > 0) {
|
if (notches > 0) {
|
||||||
hideEnlargedCard();
|
hideEnlargedCard();
|
||||||
handleOverNewView(transferData);
|
handleOverNewView(transferData);
|
||||||
|
@ -491,10 +492,10 @@ public class MageActionCallback implements ActionCallback {
|
||||||
* Show the big card image on mouse position while hovering over a card
|
* Show the big card image on mouse position while hovering over a card
|
||||||
*
|
*
|
||||||
* @param showAlternative defines if the original image (if it's a copied
|
* @param showAlternative defines if the original image (if it's a copied
|
||||||
* card) or the opposite side of a transformable card will be shown
|
* card) or the opposite side of a transformable card will be shown
|
||||||
*/
|
*/
|
||||||
public void enlargeCard(EnlargeMode showAlternative) {
|
public void enlargeCard(EnlargeMode showAlternative) {
|
||||||
if (enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
if (enlargedWindowState == EnlargedWindowState.CLOSED) {
|
||||||
this.enlargeMode = showAlternative;
|
this.enlargeMode = showAlternative;
|
||||||
CardView cardView = null;
|
CardView cardView = null;
|
||||||
if (popupData != null) {
|
if (popupData != null) {
|
||||||
|
@ -515,7 +516,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideEnlargedCard() {
|
public void hideEnlargedCard() {
|
||||||
if (!enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
if (enlargedWindowState != EnlargedWindowState.CLOSED) {
|
||||||
enlargedWindowState = EnlargedWindowState.CLOSED;
|
enlargedWindowState = EnlargedWindowState.CLOSED;
|
||||||
try {
|
try {
|
||||||
Component cardPreviewContainer = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
|
Component cardPreviewContainer = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
|
||||||
|
@ -535,21 +536,21 @@ public class MageActionCallback implements ActionCallback {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
if (enlargedWindowState == EnlargedWindowState.CLOSED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MageComponents mageComponentCardPreviewContainer;
|
MageComponents mageComponentCardPreviewContainer;
|
||||||
MageComponents mageComponentCardPreviewPane;
|
MageComponents mageComponentCardPreviewPane;
|
||||||
if (cardView.isToRotate()) {
|
if (cardView.isToRotate()) {
|
||||||
if (enlargedWindowState.equals(EnlargedWindowState.NORMAL)) {
|
if (enlargedWindowState == EnlargedWindowState.NORMAL) {
|
||||||
hideEnlargedCard();
|
hideEnlargedCard();
|
||||||
enlargedWindowState = EnlargedWindowState.ROTATED;
|
enlargedWindowState = EnlargedWindowState.ROTATED;
|
||||||
}
|
}
|
||||||
mageComponentCardPreviewContainer = MageComponents.CARD_PREVIEW_CONTAINER_ROTATED;
|
mageComponentCardPreviewContainer = MageComponents.CARD_PREVIEW_CONTAINER_ROTATED;
|
||||||
mageComponentCardPreviewPane = MageComponents.CARD_PREVIEW_PANE_ROTATED;
|
mageComponentCardPreviewPane = MageComponents.CARD_PREVIEW_PANE_ROTATED;
|
||||||
} else {
|
} else {
|
||||||
if (enlargedWindowState.equals(EnlargedWindowState.ROTATED)) {
|
if (enlargedWindowState == EnlargedWindowState.ROTATED) {
|
||||||
hideEnlargedCard();
|
hideEnlargedCard();
|
||||||
enlargedWindowState = EnlargedWindowState.NORMAL;
|
enlargedWindowState = EnlargedWindowState.NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -608,7 +609,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
// XXX: scaled to fit width
|
// XXX: scaled to fit width
|
||||||
bigCard.setCard(mageCard.getOriginal().getId(), enlargeMode, image, mageCard.getOriginal().getRules(), mageCard.getOriginal().isToRotate());
|
bigCard.setCard(mageCard.getOriginal().getId(), enlargeMode, image, mageCard.getOriginal().getRules(), mageCard.getOriginal().isToRotate());
|
||||||
// if it's an ability, show only the ability text as overlay
|
// if it's an ability, show only the ability text as overlay
|
||||||
if (mageCard.getOriginal().isAbility() && enlargeMode.equals(EnlargeMode.NORMAL)) {
|
if (mageCard.getOriginal().isAbility() && enlargeMode == EnlargeMode.NORMAL) {
|
||||||
bigCard.showTextComponent();
|
bigCard.showTextComponent();
|
||||||
} else {
|
} else {
|
||||||
bigCard.hideTextComponent();
|
bigCard.hideTextComponent();
|
||||||
|
|
|
@ -244,7 +244,7 @@ public class CardView extends SimpleCardView {
|
||||||
Zone cardZone = game.getState().getZone(card.getId());
|
Zone cardZone = game.getState().getZone(card.getId());
|
||||||
if (card.isFaceDown(game)) {
|
if (card.isFaceDown(game)) {
|
||||||
showFaceUp = false;
|
showFaceUp = false;
|
||||||
if (!Zone.BATTLEFIELD.equals(cardZone)) {
|
if (Zone.BATTLEFIELD!=cardZone) {
|
||||||
if (showFaceDownCard) {
|
if (showFaceDownCard) {
|
||||||
showFaceUp = true;
|
showFaceUp = true;
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ public class CardView extends SimpleCardView {
|
||||||
this.rarity = Rarity.NA;
|
this.rarity = Rarity.NA;
|
||||||
this.rules = new ArrayList<>();
|
this.rules = new ArrayList<>();
|
||||||
this.rules.add(stackAbility.getRule());
|
this.rules.add(stackAbility.getRule());
|
||||||
if (stackAbility.getZone().equals(Zone.COMMAND)) {
|
if (stackAbility.getZone()==Zone.COMMAND) {
|
||||||
this.expansionSetCode = stackAbility.getExpansionSetCode();
|
this.expansionSetCode = stackAbility.getExpansionSetCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,11 +82,11 @@ public class ChatMessage implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUserMessage() {
|
public boolean isUserMessage() {
|
||||||
return color != null && (color.equals(MessageColor.BLUE) || color.equals(MessageColor.YELLOW));
|
return color != null && (color==MessageColor.BLUE || color==MessageColor.YELLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStatusMessage() {
|
public boolean isStatusMessage() {
|
||||||
return color != null && color.equals(MessageColor.ORANGE);
|
return color != null && color== MessageColor.ORANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.SkillLevel;
|
import mage.constants.SkillLevel;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -43,7 +44,6 @@ import mage.game.match.MatchPlayer;
|
||||||
import mage.game.tournament.TournamentPlayer;
|
import mage.game.tournament.TournamentPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class TableView implements Serializable {
|
public class TableView implements Serializable {
|
||||||
|
@ -67,19 +67,19 @@ public class TableView implements Serializable {
|
||||||
private final boolean rated;
|
private final boolean rated;
|
||||||
private final boolean passworded;
|
private final boolean passworded;
|
||||||
|
|
||||||
public TableView(Table table) {
|
public TableView(Table table) {
|
||||||
this.tableId = table.getId();
|
this.tableId = table.getId();
|
||||||
this.gameType = table.getGameType();
|
this.gameType = table.getGameType();
|
||||||
this.tableName = table.getName();
|
this.tableName = table.getName();
|
||||||
String tableNameInfo = null;
|
String tableNameInfo = null;
|
||||||
if (tableName != null && !tableName.isEmpty()) {
|
if (tableName != null && !tableName.isEmpty()) {
|
||||||
tableNameInfo = " [" + table.getName() + "]";
|
tableNameInfo = " [" + table.getName() + "]";
|
||||||
}
|
}
|
||||||
this.controllerName = table.getControllerName();
|
this.controllerName = table.getControllerName();
|
||||||
this.tableState = table.getState();
|
this.tableState = table.getState();
|
||||||
if (table.getState().equals(TableState.WAITING) ||
|
if (table.getState() == TableState.WAITING ||
|
||||||
table.getState().equals(TableState.READY_TO_START) ||
|
table.getState() == TableState.READY_TO_START ||
|
||||||
table.getState().equals(TableState.STARTING) ) {
|
table.getState() == TableState.STARTING) {
|
||||||
this.createTime = table.getCreateTime();
|
this.createTime = table.getCreateTime();
|
||||||
} else {
|
} else {
|
||||||
if (table.isTournament()) {
|
if (table.isTournament()) {
|
||||||
|
@ -89,22 +89,22 @@ public class TableView implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.isTournament = table.isTournament();
|
this.isTournament = table.isTournament();
|
||||||
for (Seat seat: table.getSeats()) {
|
for (Seat seat : table.getSeats()) {
|
||||||
seats.add(new SeatView(seat));
|
seats.add(new SeatView(seat));
|
||||||
}
|
}
|
||||||
if (!table.isTournament()) {
|
if (!table.isTournament()) {
|
||||||
// MATCH
|
// MATCH
|
||||||
if (table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.READY_TO_START)) {
|
if (table.getState()==TableState.WAITING || table.getState()==TableState.READY_TO_START) {
|
||||||
tableStateText = table.getState().toString() + " (" + table.getMatch().getPlayers().size() + "/"+ table.getSeats().length + ")";
|
tableStateText = table.getState().toString() + " (" + table.getMatch().getPlayers().size() + "/" + table.getSeats().length + ")";
|
||||||
} else {
|
} else {
|
||||||
tableStateText = table.getState().toString();
|
tableStateText = table.getState().toString();
|
||||||
}
|
}
|
||||||
for (Game game: table.getMatch().getGames()) {
|
for (Game game : table.getMatch().getGames()) {
|
||||||
games.add(game.getId());
|
games.add(game.getId());
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
StringBuilder sbScore = new StringBuilder();
|
StringBuilder sbScore = new StringBuilder();
|
||||||
for(MatchPlayer matchPlayer: table.getMatch().getPlayers()) {
|
for (MatchPlayer matchPlayer : table.getMatch().getPlayers()) {
|
||||||
if (matchPlayer.getPlayer() == null) {
|
if (matchPlayer.getPlayer() == null) {
|
||||||
sb.append(", ").append("[unknown]");
|
sb.append(", ").append("[unknown]");
|
||||||
sbScore.append("-").append(matchPlayer.getWins());
|
sbScore.append("-").append(matchPlayer.getWins());
|
||||||
|
@ -112,7 +112,7 @@ public class TableView implements Serializable {
|
||||||
sb.append(", ").append(matchPlayer.getName());
|
sb.append(", ").append(matchPlayer.getName());
|
||||||
sbScore.append("-").append(matchPlayer.getWins());
|
sbScore.append("-").append(matchPlayer.getWins());
|
||||||
} else {
|
} else {
|
||||||
sbScore.insert(0,matchPlayer.getWins()).insert(0," Score: ");
|
sbScore.insert(0, matchPlayer.getWins()).insert(0, " Score: ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (table.getMatch().getDraws() > 0) {
|
if (table.getMatch().getDraws() > 0) {
|
||||||
|
@ -138,12 +138,12 @@ public class TableView implements Serializable {
|
||||||
this.rated = table.getMatch().getOptions().isRated();
|
this.rated = table.getMatch().getOptions().isRated();
|
||||||
this.passworded = !table.getMatch().getOptions().getPassword().isEmpty();
|
this.passworded = !table.getMatch().getOptions().getPassword().isEmpty();
|
||||||
} else {
|
} else {
|
||||||
// TOURNAMENT
|
// TOURNAMENT
|
||||||
if (table.getTournament().getOptions().getNumberRounds() > 0) {
|
if (table.getTournament().getOptions().getNumberRounds() > 0) {
|
||||||
this.gameType = new StringBuilder(this.gameType).append(" ").append(table.getTournament().getOptions().getNumberRounds()).append(" Rounds").toString();
|
this.gameType = new StringBuilder(this.gameType).append(" ").append(table.getTournament().getOptions().getNumberRounds()).append(" Rounds").toString();
|
||||||
}
|
}
|
||||||
StringBuilder sb1 = new StringBuilder();
|
StringBuilder sb1 = new StringBuilder();
|
||||||
for (TournamentPlayer tp: table.getTournament().getPlayers()) {
|
for (TournamentPlayer tp : table.getTournament().getPlayers()) {
|
||||||
if (!tp.getPlayer().getName().equals(table.getControllerName())) {
|
if (!tp.getPlayer().getName().equals(table.getControllerName())) {
|
||||||
sb1.append(", ").append(tp.getPlayer().getName());
|
sb1.append(", ").append(tp.getPlayer().getName());
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ public class TableView implements Serializable {
|
||||||
infoText.append(" Fr.Mul: ").append(table.getTournament().getOptions().getMatchOptions().getFreeMulligans());
|
infoText.append(" Fr.Mul: ").append(table.getTournament().getOptions().getMatchOptions().getFreeMulligans());
|
||||||
}
|
}
|
||||||
if (table.getTournament().getTournamentType().isLimited()) {
|
if (table.getTournament().getTournamentType().isLimited()) {
|
||||||
infoText.append(" Constr.: ").append(table.getTournament().getOptions().getLimitedOptions().getConstructionTime()/60).append(" Min.");
|
infoText.append(" Constr.: ").append(table.getTournament().getOptions().getLimitedOptions().getConstructionTime() / 60).append(" Min.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DUELING:
|
case DUELING:
|
||||||
|
@ -172,13 +172,13 @@ public class TableView implements Serializable {
|
||||||
case DRAFTING:
|
case DRAFTING:
|
||||||
Draft draft = table.getTournament().getDraft();
|
Draft draft = table.getTournament().getDraft();
|
||||||
if (draft != null) {
|
if (draft != null) {
|
||||||
stateText.append(" ").append(draft.getBoosterNum()).append("/").append(draft.getCardNum() -1);
|
stateText.append(" ").append(draft.getBoosterNum()).append("/").append(draft.getCardNum() - 1);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
this.additionalInfo = infoText.toString();
|
this.additionalInfo = infoText.toString();
|
||||||
this.tableStateText = stateText.toString();
|
this.tableStateText = stateText.toString();
|
||||||
this.deckType = table.getDeckType() + " " + table.getTournament().getBoosterInfo() + (tableNameInfo != null ? tableNameInfo : "");
|
this.deckType = table.getDeckType() + " " + table.getTournament().getBoosterInfo() + (tableNameInfo != null ? tableNameInfo : "");
|
||||||
this.skillLevel = table.getTournament().getOptions().getMatchOptions().getSkillLevel();
|
this.skillLevel = table.getTournament().getOptions().getMatchOptions().getSkillLevel();
|
||||||
this.quitRatio = Integer.toString(table.getTournament().getOptions().getQuitRatio());
|
this.quitRatio = Integer.toString(table.getTournament().getOptions().getQuitRatio());
|
||||||
this.limited = table.getTournament().getOptions().getMatchOptions().isLimited();
|
this.limited = table.getTournament().getOptions().getMatchOptions().isLimited();
|
||||||
|
@ -226,6 +226,7 @@ public class TableView implements Serializable {
|
||||||
public boolean isTournament() {
|
public boolean isTournament() {
|
||||||
return this.isTournament;
|
return this.isTournament;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAdditionalInfo() {
|
public String getAdditionalInfo() {
|
||||||
return this.additionalInfo;
|
return this.additionalInfo;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +250,7 @@ public class TableView implements Serializable {
|
||||||
public boolean isRated() {
|
public boolean isRated() {
|
||||||
return rated;
|
return rated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPassworded() {
|
public boolean isPassworded() {
|
||||||
return passworded;
|
return passworded;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
import mage.cards.repository.CardRepository;
|
||||||
import mage.server.util.SystemUtil;
|
import mage.server.util.SystemUtil;
|
||||||
|
@ -44,7 +45,6 @@ import mage.view.ChatMessage.SoundToPlay;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class ChatManager {
|
public class ChatManager {
|
||||||
|
@ -116,9 +116,9 @@ public class ChatManager {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Pattern cardNamePattern = Pattern.compile("\\[(.*?)\\]");
|
final Pattern cardNamePattern = Pattern.compile("\\[(.*?)\\]");
|
||||||
|
|
||||||
public void broadcast(UUID chatId, String userName, String message, MessageColor color, boolean withTime, MessageType messageType, SoundToPlay soundToPlay) {
|
public void broadcast(UUID chatId, String userName, String message, MessageColor color, boolean withTime, MessageType messageType, SoundToPlay soundToPlay) {
|
||||||
ChatSession chatSession = chatSessions.get(chatId);
|
ChatSession chatSession = chatSessions.get(chatId);
|
||||||
if (chatSession != null) {
|
if (chatSession != null) {
|
||||||
|
@ -132,7 +132,7 @@ public class ChatManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!messageType.equals(MessageType.GAME)) {
|
if (messageType != MessageType.GAME) {
|
||||||
User user = UserManager.getInstance().getUserByName(userName);
|
User user = UserManager.getInstance().getUserByName(userName);
|
||||||
if (message != null && userName != null && !userName.equals("")) {
|
if (message != null && userName != null && !userName.equals("")) {
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ public class ChatManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messageType.equals(MessageType.TALK)) {
|
if (messageType == MessageType.TALK) {
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (user.getChatLockedUntil() != null) {
|
if (user.getChatLockedUntil() != null) {
|
||||||
if (user.getChatLockedUntil().compareTo(Calendar.getInstance().getTime()) > 0) {
|
if (user.getChatLockedUntil().compareTo(Calendar.getInstance().getTime()) > 0) {
|
||||||
|
@ -249,7 +249,6 @@ public class ChatManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* use mainly for announcing that a user connection was lost or that a user
|
* use mainly for announcing that a user connection was lost or that a user
|
||||||
* has reconnected
|
* has reconnected
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,12 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
import mage.view.ChatMessage;
|
import mage.view.ChatMessage;
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
|
@ -40,8 +34,14 @@ import mage.view.ChatMessage.MessageType;
|
||||||
import mage.view.ChatMessage.SoundToPlay;
|
import mage.view.ChatMessage.SoundToPlay;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class ChatSession {
|
public class ChatSession {
|
||||||
|
@ -79,7 +79,7 @@ public class ChatSession {
|
||||||
}
|
}
|
||||||
if (userId != null && clients.containsKey(userId)) {
|
if (userId != null && clients.containsKey(userId)) {
|
||||||
String userName = clients.get(userId);
|
String userName = clients.get(userId);
|
||||||
if (!reason.equals(DisconnectReason.LostConnection)) { // for lost connection the user will be reconnected or session expire so no remove of chat yet
|
if (reason != DisconnectReason.LostConnection) { // for lost connection the user will be reconnected or session expire so no remove of chat yet
|
||||||
clients.remove(userId);
|
clients.remove(userId);
|
||||||
logger.debug(userName + "(" + reason.toString() + ")" + " removed from chatId " + chatId);
|
logger.debug(userName + "(" + reason.toString() + ")" + " removed from chatId " + chatId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -580,7 +580,7 @@ public class MageServerImpl implements MageServer {
|
||||||
@Override
|
@Override
|
||||||
public boolean leaveTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
public boolean leaveTable(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||||
TableState tableState = TableManager.getInstance().getController(tableId).getTableState();
|
TableState tableState = TableManager.getInstance().getController(tableId).getTableState();
|
||||||
if (!tableState.equals(TableState.WAITING) && !tableState.equals(TableState.READY_TO_START)) {
|
if (tableState!=TableState.WAITING && tableState!=TableState.READY_TO_START) {
|
||||||
// table was already started, so player can't leave anymore now
|
// table was already started, so player can't leave anymore now
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,13 @@ package mage.server;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
import org.jboss.remoting.callback.InvokerCallbackHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class SessionManager {
|
public class SessionManager {
|
||||||
|
@ -47,6 +47,7 @@ public class SessionManager {
|
||||||
public static SessionManager getInstance() {
|
public static SessionManager getInstance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public Session getSession(String sessionId) {
|
public Session getSession(String sessionId) {
|
||||||
|
@ -127,7 +128,7 @@ public class SessionManager {
|
||||||
public void disconnect(String sessionId, DisconnectReason reason) {
|
public void disconnect(String sessionId, DisconnectReason reason) {
|
||||||
Session session = sessions.get(sessionId);
|
Session session = sessions.get(sessionId);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
if (!reason.equals(DisconnectReason.AdminDisconnect)) {
|
if (reason != DisconnectReason.AdminDisconnect) {
|
||||||
if (!sessions.containsKey(sessionId)) {
|
if (!sessions.containsKey(sessionId)) {
|
||||||
// session was removed meanwhile by another thread so we can return
|
// session was removed meanwhile by another thread so we can return
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -34,6 +34,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
|
@ -72,7 +73,6 @@ import mage.view.ChatMessage;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class TableController {
|
public class TableController {
|
||||||
|
@ -294,14 +294,14 @@ public class TableController {
|
||||||
user.showUserMessage("Join Table", message);
|
user.showUserMessage("Join Table", message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check power level for table (currently only used for EDH/Commander table)
|
// Check power level for table (currently only used for EDH/Commander table)
|
||||||
int edhPowerLevel = table.getMatch().getOptions().getEdhPowerLevel();
|
int edhPowerLevel = table.getMatch().getOptions().getEdhPowerLevel();
|
||||||
if (edhPowerLevel > 0 && table.getValidator().getName().toLowerCase().equals("commander")) {
|
if (edhPowerLevel > 0 && table.getValidator().getName().toLowerCase().equals("commander")) {
|
||||||
int deckEdhPowerLevel = table.getValidator().getEdhPowerLevel(deck);
|
int deckEdhPowerLevel = table.getValidator().getEdhPowerLevel(deck);
|
||||||
if (deckEdhPowerLevel > edhPowerLevel) {
|
if (deckEdhPowerLevel > edhPowerLevel) {
|
||||||
String message = new StringBuilder("Your deck appears to be too powerful for this table.\n\nReduce the number of extra turn cards, infect, counters, fogs, reconsider your commander. ")
|
String message = new StringBuilder("Your deck appears to be too powerful for this table.\n\nReduce the number of extra turn cards, infect, counters, fogs, reconsider your commander. ")
|
||||||
.append("\nThe table requirement has a maximum power level of ").append(edhPowerLevel).append (" whilst your deck has a calculated power level of ")
|
.append("\nThe table requirement has a maximum power level of ").append(edhPowerLevel).append(" whilst your deck has a calculated power level of ")
|
||||||
.append(deckEdhPowerLevel).toString();
|
.append(deckEdhPowerLevel).toString();
|
||||||
user.showUserMessage("Join Table", message);
|
user.showUserMessage("Join Table", message);
|
||||||
return false;
|
return false;
|
||||||
|
@ -412,7 +412,7 @@ public class TableController {
|
||||||
} else {
|
} else {
|
||||||
logger.fatal("Tournament == null table: " + table.getId() + " userId: " + userId);
|
logger.fatal("Tournament == null table: " + table.getId() + " userId: " + userId);
|
||||||
}
|
}
|
||||||
} else if (TableState.SIDEBOARDING.equals(table.getState())) {
|
} else if (TableState.SIDEBOARDING == table.getState()) {
|
||||||
match.updateDeck(playerId, deck);
|
match.updateDeck(playerId, deck);
|
||||||
} else {
|
} else {
|
||||||
// deck was meanwhile submitted so the autoupdate can be ignored
|
// deck was meanwhile submitted so the autoupdate can be ignored
|
||||||
|
@ -438,7 +438,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public boolean replayTable(UUID userId) {
|
// public boolean replayTable(UUID userId) {
|
||||||
// if (table.getState() != TableState.FINISHED) {
|
// if (table.getState() != TableState.FINISHED) {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
@ -476,8 +476,8 @@ public class TableController {
|
||||||
}
|
}
|
||||||
if (table != null
|
if (table != null
|
||||||
&& this.userId != null && this.userId.equals(userId) // tourn. sub tables have no creator user
|
&& this.userId != null && this.userId.equals(userId) // tourn. sub tables have no creator user
|
||||||
&& (table.getState().equals(TableState.WAITING)
|
&& (table.getState() == TableState.WAITING
|
||||||
|| table.getState().equals(TableState.READY_TO_START))) {
|
|| table.getState() == TableState.READY_TO_START)) {
|
||||||
// table not started yet and user is the owner, remove the table
|
// table not started yet and user is the owner, remove the table
|
||||||
TableManager.getInstance().removeTable(table.getId());
|
TableManager.getInstance().removeTable(table.getId());
|
||||||
} else {
|
} else {
|
||||||
|
@ -500,7 +500,7 @@ public class TableController {
|
||||||
logger.debug("User not found - userId: " + userId + " tableId:" + table.getId());
|
logger.debug("User not found - userId: " + userId + " tableId:" + table.getId());
|
||||||
}
|
}
|
||||||
userPlayerMap.remove(userId);
|
userPlayerMap.remove(userId);
|
||||||
} else if (!table.getState().equals(TableState.FINISHED)) {
|
} else if (table.getState() != TableState.FINISHED) {
|
||||||
if (table.isTournament()) {
|
if (table.isTournament()) {
|
||||||
logger.debug("Quit tournament sub tables for userId: " + userId);
|
logger.debug("Quit tournament sub tables for userId: " + userId);
|
||||||
TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(), userId);
|
TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(), userId);
|
||||||
|
@ -517,7 +517,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
match.quitMatch(playerId);
|
match.quitMatch(playerId);
|
||||||
} else {
|
} else {
|
||||||
if (table.getState().equals(TableState.SIDEBOARDING)) {
|
if (table.getState() == TableState.SIDEBOARDING) {
|
||||||
if (!matchPlayer.isDoneSideboarding()) {
|
if (!matchPlayer.isDoneSideboarding()) {
|
||||||
// submit deck to finish sideboarding and trigger match start / end
|
// submit deck to finish sideboarding and trigger match start / end
|
||||||
matchPlayer.submitDeck(matchPlayer.getDeck());
|
matchPlayer.submitDeck(matchPlayer.getDeck());
|
||||||
|
@ -546,7 +546,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void startMatch() {
|
public synchronized void startMatch() {
|
||||||
if (table.getState().equals(TableState.STARTING)) {
|
if (table.getState() == TableState.STARTING) {
|
||||||
try {
|
try {
|
||||||
if (table.isTournamentSubTable()) {
|
if (table.isTournamentSubTable()) {
|
||||||
logger.info("Tourn. match started id:" + match.getId() + " tournId: " + table.getTournament().getId());
|
logger.info("Tourn. match started id:" + match.getId() + " tournId: " + table.getTournament().getId());
|
||||||
|
@ -630,7 +630,7 @@ public class TableController {
|
||||||
|
|
||||||
public synchronized void startTournament(UUID userId) {
|
public synchronized void startTournament(UUID userId) {
|
||||||
try {
|
try {
|
||||||
if (userId.equals(this.userId) && table.getState().equals(TableState.STARTING)) {
|
if (userId.equals(this.userId) && table.getState() == TableState.STARTING) {
|
||||||
tournament.setStartTime();
|
tournament.setStartTime();
|
||||||
TournamentManager.getInstance().createTournamentSession(tournament, userPlayerMap, table.getId());
|
TournamentManager.getInstance().createTournamentSession(tournament, userPlayerMap, table.getId());
|
||||||
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
for (Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||||
|
@ -762,7 +762,6 @@ public class TableController {
|
||||||
/**
|
/**
|
||||||
* Tables of normal matches or tournament sub tables are no longer needed,
|
* Tables of normal matches or tournament sub tables are no longer needed,
|
||||||
* if the match ends.
|
* if the match ends.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private void closeTable() {
|
private void closeTable() {
|
||||||
this.matchEnd();
|
this.matchEnd();
|
||||||
|
@ -778,7 +777,7 @@ public class TableController {
|
||||||
if (!matchPlayer.hasQuit()) {
|
if (!matchPlayer.hasQuit()) {
|
||||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
if (table.getState().equals(TableState.SIDEBOARDING)) {
|
if (table.getState()==TableState.SIDEBOARDING) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (table.isTournamentSubTable()) {
|
if (table.isTournamentSubTable()) {
|
||||||
sb.append("Your tournament match of round ");
|
sb.append("Your tournament match of round ");
|
||||||
|
@ -843,7 +842,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void swapSeats(int seatNum1, int seatNum2) {
|
public void swapSeats(int seatNum1, int seatNum2) {
|
||||||
if (table.getState().equals(TableState.READY_TO_START)) {
|
if (table.getState()==TableState.READY_TO_START) {
|
||||||
if (seatNum1 >= 0 && seatNum2 >= 0 && seatNum1 < table.getSeats().length && seatNum2 < table.getSeats().length) {
|
if (seatNum1 >= 0 && seatNum2 >= 0 && seatNum1 < table.getSeats().length && seatNum2 < table.getSeats().length) {
|
||||||
Player swapPlayer = table.getSeats()[seatNum1].getPlayer();
|
Player swapPlayer = table.getSeats()[seatNum1].getPlayer();
|
||||||
String swapType = table.getSeats()[seatNum1].getPlayerType();
|
String swapType = table.getSeats()[seatNum1].getPlayerType();
|
||||||
|
@ -876,7 +875,7 @@ public class TableController {
|
||||||
|
|
||||||
public boolean isTournamentStillValid() {
|
public boolean isTournamentStillValid() {
|
||||||
if (table.getTournament() != null) {
|
if (table.getTournament() != null) {
|
||||||
if (!table.getState().equals(TableState.WAITING) && !table.getState().equals(TableState.READY_TO_START) && !table.getState().equals(TableState.STARTING)) {
|
if (table.getState() != TableState.WAITING && table.getState() != TableState.READY_TO_START && table.getState() != TableState.STARTING) {
|
||||||
TournamentController tournamentController = TournamentManager.getInstance().getTournamentController(table.getTournament().getId());
|
TournamentController tournamentController = TournamentManager.getInstance().getTournamentController(table.getTournament().getId());
|
||||||
if (tournamentController != null) {
|
if (tournamentController != null) {
|
||||||
return tournamentController.isTournamentStillValid(table.getState());
|
return tournamentController.isTournamentStillValid(table.getState());
|
||||||
|
@ -923,7 +922,7 @@ public class TableController {
|
||||||
int humanPlayers = 0;
|
int humanPlayers = 0;
|
||||||
int aiPlayers = 0;
|
int aiPlayers = 0;
|
||||||
int validHumanPlayers = 0;
|
int validHumanPlayers = 0;
|
||||||
if (!(table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.STARTING) || table.getState().equals(TableState.READY_TO_START))) {
|
if (!(table.getState() == TableState.WAITING || table.getState() == TableState.STARTING || table.getState() == TableState.READY_TO_START)) {
|
||||||
if (match == null) {
|
if (match == null) {
|
||||||
logger.debug("- Match table with no match:");
|
logger.debug("- Match table with no match:");
|
||||||
logger.debug("-- matchId:" + match.getId() + " [" + match.getName() + "]");
|
logger.debug("-- matchId:" + match.getId() + " [" + match.getName() + "]");
|
||||||
|
@ -947,9 +946,9 @@ public class TableController {
|
||||||
}
|
}
|
||||||
if (matchPlayer.getPlayer().isHuman()) {
|
if (matchPlayer.getPlayer().isHuman()) {
|
||||||
humanPlayers++;
|
humanPlayers++;
|
||||||
if ((table.getState().equals(TableState.WAITING)
|
if ((table.getState() == TableState.WAITING
|
||||||
|| table.getState().equals(TableState.STARTING)
|
|| table.getState() == TableState.STARTING
|
||||||
|| table.getState().equals(TableState.READY_TO_START))
|
|| table.getState() == TableState.READY_TO_START)
|
||||||
|| !match.isDoneSideboarding()
|
|| !match.isDoneSideboarding()
|
||||||
|| (!matchPlayer.hasQuit() && match.getGame() != null && matchPlayer.getPlayer().isInGame())) {
|
|| (!matchPlayer.hasQuit() && match.getGame() != null && matchPlayer.getPlayer().isInGame())) {
|
||||||
User user = UserManager.getInstance().getUser(userPlayerEntry.getKey());
|
User user = UserManager.getInstance().getUser(userPlayerEntry.getKey());
|
||||||
|
@ -990,7 +989,7 @@ public class TableController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean changeTableStateToStarting() {
|
public synchronized boolean changeTableStateToStarting() {
|
||||||
if (!getTable().getState().equals(TableState.READY_TO_START)) {
|
if (getTable().getState() != TableState.READY_TO_START) {
|
||||||
// tournament is not ready, can't start
|
// tournament is not ready, can't start
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,7 +344,7 @@ public class TableManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If table is not finished, the table has to be removed completly because it's not a normal state (if finished it will be removed in GamesRoomImpl.Update())
|
// If table is not finished, the table has to be removed completly because it's not a normal state (if finished it will be removed in GamesRoomImpl.Update())
|
||||||
if (!table.getState().equals(TableState.FINISHED)) {
|
if (table.getState()!=TableState.FINISHED) {
|
||||||
if (game != null) {
|
if (game != null) {
|
||||||
GameManager.getInstance().removeGame(game.getId());
|
GameManager.getInstance().removeGame(game.getId());
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,7 @@ public class TableManager {
|
||||||
tableCopy.addAll(tables.values());
|
tableCopy.addAll(tables.values());
|
||||||
for (Table table : tableCopy) {
|
for (Table table : tableCopy) {
|
||||||
try {
|
try {
|
||||||
if (!table.getState().equals(TableState.FINISHED)) {
|
if (table.getState()!=TableState.FINISHED) {
|
||||||
// remove tables and games not valid anymore
|
// remove 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.getCreateTime() : table.getCreateTime()) +" (" + table.getState().toString() + ") " + (table.isTournament() ? "- Tournament":""));
|
||||||
TableController tableController = getController(table.getId());
|
TableController tableController = getController(table.getId());
|
||||||
|
|
|
@ -37,6 +37,7 @@ import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
|
@ -61,7 +62,6 @@ import mage.view.TableClientMessage;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class User {
|
public class User {
|
||||||
|
@ -199,7 +199,7 @@ public class User {
|
||||||
|
|
||||||
public void lostConnection() {
|
public void lostConnection() {
|
||||||
// Because watched games don't get restored after reconnection call stop watching
|
// Because watched games don't get restored after reconnection call stop watching
|
||||||
for (Iterator<UUID> iterator = watchedGames.iterator(); iterator.hasNext();) {
|
for (Iterator<UUID> iterator = watchedGames.iterator(); iterator.hasNext(); ) {
|
||||||
UUID gameId = iterator.next();
|
UUID gameId = iterator.next();
|
||||||
GameManager.getInstance().stopWatching(gameId, userId);
|
GameManager.getInstance().stopWatching(gameId, userId);
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
|
@ -208,7 +208,7 @@ public class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return userState.equals(UserState.Connected) || userState.equals(UserState.Reconnected);
|
return userState == UserState.Connected || userState == UserState.Reconnected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisconnectDuration() {
|
public String getDisconnectDuration() {
|
||||||
|
@ -762,7 +762,7 @@ public class User {
|
||||||
public int getNumberOfNotStartedTables() {
|
public int getNumberOfNotStartedTables() {
|
||||||
int number = 0;
|
int number = 0;
|
||||||
for (Table table : tables.values()) {
|
for (Table table : tables.values()) {
|
||||||
if (table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.STARTING)) {
|
if (table.getState() == TableState.WAITING || table.getState() == TableState.STARTING) {
|
||||||
number++;
|
number++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -772,7 +772,7 @@ public class User {
|
||||||
public int getNumberOfNotFinishedTables() {
|
public int getNumberOfNotFinishedTables() {
|
||||||
int number = 0;
|
int number = 0;
|
||||||
for (Table table : tables.values()) {
|
for (Table table : tables.values()) {
|
||||||
if (table.getState().equals(TableState.FINISHED)) {
|
if (table.getState() == TableState.FINISHED) {
|
||||||
number++;
|
number++;
|
||||||
} else {
|
} else {
|
||||||
TableController tableController = TableManager.getInstance().getController(table.getId());
|
TableController tableController = TableManager.getInstance().getController(table.getId());
|
||||||
|
|
|
@ -37,6 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
|
@ -58,7 +59,6 @@ import mage.view.UsersView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
||||||
|
@ -232,11 +232,11 @@ class TableListSorter implements Comparator<Table> {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Table one, Table two) {
|
public int compare(Table one, Table two) {
|
||||||
if (one.getState() != null && two.getState() != null) {
|
if (one.getState() != null && two.getState() != null) {
|
||||||
if (!TableState.SIDEBOARDING.equals(one.getState()) && !TableState.DUELING.equals(one.getState())) {
|
if (TableState.SIDEBOARDING != one.getState() && TableState.DUELING != one.getState()) {
|
||||||
if (one.getState().compareTo(two.getState()) != 0) {
|
if (one.getState().compareTo(two.getState()) != 0) {
|
||||||
return one.getState().compareTo(two.getState());
|
return one.getState().compareTo(two.getState());
|
||||||
}
|
}
|
||||||
} else if (!TableState.SIDEBOARDING.equals(two.getState()) && !TableState.DUELING.equals(two.getState())) {
|
} else if (TableState.SIDEBOARDING != two.getState() && TableState.DUELING != two.getState()) {
|
||||||
if (one.getState().compareTo(two.getState()) != 0) {
|
if (one.getState().compareTo(two.getState()) != 0) {
|
||||||
return one.getState().compareTo(two.getState());
|
return one.getState().compareTo(two.getState());
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,7 +302,7 @@ public class TournamentController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initTournament() {
|
private void initTournament() {
|
||||||
if (!TableManager.getInstance().getTable(tableId).getState().equals(TableState.DUELING)) {
|
if (TableManager.getInstance().getTable(tableId).getState()!=TableState.DUELING) {
|
||||||
TableManager.getInstance().initTournament(tableId);
|
TableManager.getInstance().initTournament(tableId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,7 +385,7 @@ public class TournamentController {
|
||||||
// quit active matches of that tournament
|
// quit active matches of that tournament
|
||||||
TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(), userId);
|
TableManager.getInstance().userQuitTournamentSubTables(tournament.getId(), userId);
|
||||||
status = TourneyQuitStatus.DURING_ROUND;
|
status = TourneyQuitStatus.DURING_ROUND;
|
||||||
} else if (tournamentPlayer.getState().equals(TournamentPlayerState.DRAFTING)) {
|
} else if (tournamentPlayer.getState()==TournamentPlayerState.DRAFTING) {
|
||||||
info = "during Draft phase";
|
info = "during Draft phase";
|
||||||
if (!checkToReplaceDraftPlayerByAi(userId, tournamentPlayer)) {
|
if (!checkToReplaceDraftPlayerByAi(userId, tournamentPlayer)) {
|
||||||
this.abortDraftTournament();
|
this.abortDraftTournament();
|
||||||
|
@ -399,7 +399,7 @@ public class TournamentController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
status = TourneyQuitStatus.DURING_DRAFTING;
|
status = TourneyQuitStatus.DURING_DRAFTING;
|
||||||
} else if (tournamentPlayer.getState().equals(TournamentPlayerState.CONSTRUCTING)) {
|
} else if (tournamentPlayer.getState()==TournamentPlayerState.CONSTRUCTING) {
|
||||||
info = "during Construction phase";
|
info = "during Construction phase";
|
||||||
status = TourneyQuitStatus.DURING_CONSTRUCTION;
|
status = TourneyQuitStatus.DURING_CONSTRUCTION;
|
||||||
} else {
|
} else {
|
||||||
|
@ -523,7 +523,7 @@ public class TournamentController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (activePlayers < 2 && !tableState.equals(TableState.WAITING)) {
|
if (activePlayers < 2 && tableState!=TableState.WAITING) {
|
||||||
logger.debug("Tournament has less than 2 active players - tournamentId: " + tournament.getId() + " state: " + tableState.toString());
|
logger.debug("Tournament has less than 2 active players - tournamentId: " + tournament.getId() + " state: " + tableState.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,5 @@
|
||||||
package mage.server.util;
|
package mage.server.util;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
import mage.cards.repository.CardRepository;
|
||||||
|
@ -19,6 +8,14 @@ import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
|
@ -129,14 +126,17 @@ public class SystemUtil {
|
||||||
// Put the card in Exile to start. Otherwise the game doesn't know where to remove the card from.
|
// Put the card in Exile to start. Otherwise the game doesn't know where to remove the card from.
|
||||||
game.getExile().getPermanentExile().add(card);
|
game.getExile().getPermanentExile().add(card);
|
||||||
game.setZone(card.getId(), Zone.EXILED);
|
game.setZone(card.getId(), Zone.EXILED);
|
||||||
if (zone.equals(Zone.BATTLEFIELD)) {
|
switch (zone) {
|
||||||
card.putOntoBattlefield(game, Zone.EXILED, null, player.getId());
|
case BATTLEFIELD:
|
||||||
} else if (zone.equals(Zone.LIBRARY)) {
|
card.putOntoBattlefield(game, Zone.EXILED, null, player.getId());
|
||||||
card.setZone(Zone.LIBRARY, game);
|
break;
|
||||||
game.getExile().getPermanentExile().remove(card);
|
case LIBRARY:
|
||||||
player.getLibrary().putOnTop(card, game);
|
card.setZone(Zone.LIBRARY, game);
|
||||||
} else {
|
game.getExile().getPermanentExile().remove(card);
|
||||||
card.moveToZone(zone, null, game, false);
|
player.getLibrary().putOnTop(card, game);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
card.moveToZone(zone, null, game, false);
|
||||||
}
|
}
|
||||||
logger.info("Added card to player's " + zone.toString() + ": " + card.getName() + ", player = " + player.getName());
|
logger.info("Added card to player's " + zone.toString() + ": " + card.getName() + ", player = " + player.getName());
|
||||||
}
|
}
|
||||||
|
@ -176,8 +176,8 @@ public class SystemUtil {
|
||||||
/**
|
/**
|
||||||
* Get a diff between two dates
|
* Get a diff between two dates
|
||||||
*
|
*
|
||||||
* @param date1 the oldest date
|
* @param date1 the oldest date
|
||||||
* @param date2 the newest date
|
* @param date2 the newest date
|
||||||
* @param timeUnit the unit in which you want the diff
|
* @param timeUnit the unit in which you want the diff
|
||||||
* @return the diff value, in the provided unit
|
* @return the diff value, in the provided unit
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
package mage.cards.e;
|
package mage.cards.e;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility;
|
import mage.abilities.common.PutCardIntoGraveFromAnywhereAllTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
@ -43,13 +44,12 @@ import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Plopman
|
* @author Plopman
|
||||||
*/
|
*/
|
||||||
public class EnergyField extends CardImpl {
|
public class EnergyField extends CardImpl {
|
||||||
|
|
||||||
public EnergyField(UUID ownerId, CardSetInfo setInfo) {
|
public EnergyField(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{U}");
|
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{U}");
|
||||||
|
|
||||||
|
|
||||||
// Prevent all damage that would be dealt to you by sources you don't control.
|
// Prevent all damage that would be dealt to you by sources you don't control.
|
||||||
|
@ -100,8 +100,8 @@ class EnergyFieldEffect extends PreventionEffectImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER)) {
|
if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER) {
|
||||||
if (event.getTargetId().equals(source.getControllerId()) && game.getControllerId(event.getSourceId()) != source.getControllerId()){
|
if (event.getTargetId().equals(source.getControllerId()) && game.getControllerId(event.getSourceId()) != source.getControllerId()) {
|
||||||
return super.applies(event, source, game);
|
return super.applies(event, source, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
package mage.cards.f;
|
package mage.cards.f;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
@ -39,13 +40,12 @@ import mage.game.events.GameEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author North
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class FarsightMask extends CardImpl {
|
public class FarsightMask extends CardImpl {
|
||||||
|
|
||||||
public FarsightMask(UUID ownerId, CardSetInfo setInfo) {
|
public FarsightMask(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{5}");
|
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{5}");
|
||||||
|
|
||||||
// Whenever a source an opponent controls deals damage to you, if Farsight Mask is untapped, you may draw a card.
|
// Whenever a source an opponent controls deals damage to you, if Farsight Mask is untapped, you may draw a card.
|
||||||
this.addAbility(new FarsightMaskTriggeredAbility());
|
this.addAbility(new FarsightMaskTriggeredAbility());
|
||||||
|
@ -78,7 +78,7 @@ class FarsightMaskTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
return event.getType().equals(GameEvent.EventType.DAMAGED_PLAYER);
|
return event.getType() == GameEvent.EventType.DAMAGED_PLAYER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
package mage.cards.f;
|
package mage.cards.f;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
|
@ -51,7 +52,6 @@ import mage.target.TargetPermanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class FrenziedFugue extends CardImpl {
|
public class FrenziedFugue extends CardImpl {
|
||||||
|
@ -98,13 +98,13 @@ class FrenziedFugueTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
return event.getType().equals(EventType.ENTERS_THE_BATTLEFIELD) || event.getType().equals(EventType.UPKEEP_STEP_PRE);
|
return event.getType() == EventType.ENTERS_THE_BATTLEFIELD || event.getType() == EventType.UPKEEP_STEP_PRE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
boolean result;
|
boolean result;
|
||||||
if (event.getType().equals(EventType.ENTERS_THE_BATTLEFIELD)) {
|
if (event.getType()==EventType.ENTERS_THE_BATTLEFIELD) {
|
||||||
result = event.getTargetId().equals(this.getSourceId());
|
result = event.getTargetId().equals(this.getSourceId());
|
||||||
} else {
|
} else {
|
||||||
result = event.getPlayerId().equals(this.getControllerId());
|
result = event.getPlayerId().equals(this.getControllerId());
|
||||||
|
|
|
@ -135,7 +135,7 @@ class MetallicMimicReplacementEffect extends ReplacementEffectImpl {
|
||||||
return enteringCreature != null && sourcePermanent != null
|
return enteringCreature != null && sourcePermanent != null
|
||||||
&& enteringCreature.getControllerId().equals(source.getControllerId())
|
&& enteringCreature.getControllerId().equals(source.getControllerId())
|
||||||
&& enteringCreature.getCardType().contains(CardType.CREATURE)
|
&& enteringCreature.getCardType().contains(CardType.CREATURE)
|
||||||
&& enteringCreature.getSubtype(game).contains((String) game.getState().getValue(sourcePermanent.getId() + "_type"))
|
&& enteringCreature.getSubtype(game).contains(game.getState().getValue(sourcePermanent.getId() + "_type"))
|
||||||
&& !event.getTargetId().equals(source.getSourceId());
|
&& !event.getTargetId().equals(source.getSourceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,8 +174,8 @@ public class CascadeTest extends CardTestPlayerBase {
|
||||||
// Choose one - You draw five cards and you lose 5 life;
|
// Choose one - You draw five cards and you lose 5 life;
|
||||||
// or put an X/X black Demon creature token with flying onto the battlefield, where X is the number of cards in your hand as the token enters the battlefield.
|
// or put an X/X black Demon creature token with flying onto the battlefield, where X is the number of cards in your hand as the token enters the battlefield.
|
||||||
// Entwine {4} (Choose both if you pay the entwine cost.)
|
// Entwine {4} (Choose both if you pay the entwine cost.)
|
||||||
//addCard(Zone.LIBRARY, playerA, "Promise of Power", 10);
|
addCard(Zone.LIBRARY, playerA, "Promise of Power", 1);
|
||||||
addCard(Zone.LIBRARY, playerA, "Silvercoat Lion", 2);
|
// addCard(Zone.LIBRARY, playerA, "Silvercoat Lion", 2);
|
||||||
|
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 3);
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
|
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
|
||||||
|
|
|
@ -30,6 +30,7 @@ package mage.abilities;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
|
@ -76,7 +77,6 @@ import mage.watchers.Watcher;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public abstract class AbilityImpl implements Ability {
|
public abstract class AbilityImpl implements Ability {
|
||||||
|
@ -197,7 +197,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
boolean effectResult = effect.apply(game, this);
|
boolean effectResult = effect.apply(game, this);
|
||||||
result &= effectResult;
|
result &= effectResult;
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
if (!this.getAbilityType().equals(AbilityType.MANA)) {
|
if (this.getAbilityType() != AbilityType.MANA) {
|
||||||
if (!effectResult) {
|
if (!effectResult) {
|
||||||
if (this.getSourceId() != null) {
|
if (this.getSourceId() != null) {
|
||||||
MageObject mageObject = game.getObject(this.getSourceId());
|
MageObject mageObject = game.getObject(this.getSourceId());
|
||||||
|
@ -267,7 +267,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
* If the player wishes to splice any cards onto the spell (see rule 702.45), he
|
* If the player wishes to splice any cards onto the spell (see rule 702.45), he
|
||||||
* or she reveals those cards in his or her hand.
|
* or she reveals those cards in his or her hand.
|
||||||
*/
|
*/
|
||||||
if (this.abilityType.equals(AbilityType.SPELL)) {
|
if (this.abilityType == AbilityType.SPELL) {
|
||||||
game.getContinuousEffects().applySpliceEffects(this, game);
|
game.getContinuousEffects().applySpliceEffects(this, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,8 +290,8 @@ public abstract class AbilityImpl implements Ability {
|
||||||
// or her intentions to pay any or all of those costs (see rule 601.2e).
|
// or her intentions to pay any or all of those costs (see rule 601.2e).
|
||||||
// A player can't apply two alternative methods of casting or two alternative costs to a single spell.
|
// A player can't apply two alternative methods of casting or two alternative costs to a single spell.
|
||||||
if (!activateAlternateOrAdditionalCosts(sourceObject, noMana, controller, game)) {
|
if (!activateAlternateOrAdditionalCosts(sourceObject, noMana, controller, game)) {
|
||||||
if (getAbilityType().equals(AbilityType.SPELL)
|
if (getAbilityType() == AbilityType.SPELL
|
||||||
&& ((SpellAbility) this).getSpellAbilityType().equals(SpellAbilityType.FACE_DOWN_CREATURE)) {
|
&& ((SpellAbility) this).getSpellAbilityType() == SpellAbilityType.FACE_DOWN_CREATURE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
VariableManaCost variableManaCost = handleManaXCosts(game, noMana, controller);
|
VariableManaCost variableManaCost = handleManaXCosts(game, noMana, controller);
|
||||||
String announceString = handleOtherXCosts(game, controller);
|
String announceString = handleOtherXCosts(game, controller);
|
||||||
// For effects from cards like Void Winnower x costs have to be set
|
// For effects from cards like Void Winnower x costs have to be set
|
||||||
if (this.getAbilityType().equals(AbilityType.SPELL)
|
if (this.getAbilityType() == AbilityType.SPELL
|
||||||
&& game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL_LATE, getId(), getSourceId(), getControllerId()), this)) {
|
&& game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.CAST_SPELL_LATE, getId(), getSourceId(), getControllerId()), this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
// and/or zones become the target of a spell trigger at this point; they'll wait to be put on
|
// and/or zones become the target of a spell trigger at this point; they'll wait to be put on
|
||||||
// the stack until the spell has finished being cast.)
|
// the stack until the spell has finished being cast.)
|
||||||
|
|
||||||
if (sourceObject != null && !this.getAbilityType().equals(AbilityType.TRIGGERED)) { // triggered abilities check this already in playerImpl.triggerAbility
|
if (sourceObject != null && this.getAbilityType() != AbilityType.TRIGGERED) { // triggered abilities check this already in playerImpl.triggerAbility
|
||||||
sourceObject.adjustTargets(this, game);
|
sourceObject.adjustTargets(this, game);
|
||||||
}
|
}
|
||||||
// Flashback abilities haven't made the choices the underlying spell might need for targeting.
|
// Flashback abilities haven't made the choices the underlying spell might need for targeting.
|
||||||
|
@ -408,7 +408,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
activated = true;
|
activated = true;
|
||||||
// fire if tapped for mana (may only fire now because else costs of ability itself can be payed with mana of abilities that trigger for that event
|
// fire if tapped for mana (may only fire now because else costs of ability itself can be payed with mana of abilities that trigger for that event
|
||||||
if (this.getAbilityType().equals(AbilityType.MANA)) {
|
if (this.getAbilityType() == AbilityType.MANA) {
|
||||||
for (Cost cost : costs) {
|
for (Cost cost : costs) {
|
||||||
if (cost instanceof TapSourceCost) {
|
if (cost instanceof TapSourceCost) {
|
||||||
Mana mana = null;
|
Mana mana = null;
|
||||||
|
@ -466,10 +466,10 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
// controller specific alternate spell costs
|
// controller specific alternate spell costs
|
||||||
if (!noMana && !alternativeCostisUsed) {
|
if (!noMana && !alternativeCostisUsed) {
|
||||||
if (this.getAbilityType().equals(AbilityType.SPELL)
|
if (this.getAbilityType() == AbilityType.SPELL
|
||||||
// 117.9a Only one alternative cost can be applied to any one spell as it’s being cast.
|
// 117.9a Only one alternative cost can be applied to any one spell as it’s being cast.
|
||||||
// So an alternate spell ability can't be paid with Omniscience
|
// So an alternate spell ability can't be paid with Omniscience
|
||||||
&& !((SpellAbility) this).getSpellAbilityType().equals(SpellAbilityType.BASE_ALTERNATE)) {
|
&& ((SpellAbility) this).getSpellAbilityType() != SpellAbilityType.BASE_ALTERNATE) {
|
||||||
for (AlternativeSourceCosts alternativeSourceCosts : controller.getAlternativeSourceCosts()) {
|
for (AlternativeSourceCosts alternativeSourceCosts : controller.getAlternativeSourceCosts()) {
|
||||||
if (alternativeSourceCosts.isAvailable(this, game)) {
|
if (alternativeSourceCosts.isAvailable(this, game)) {
|
||||||
if (alternativeSourceCosts.askToActivateAlternativeCosts(this, game)) {
|
if (alternativeSourceCosts.askToActivateAlternativeCosts(this, game)) {
|
||||||
|
@ -489,10 +489,8 @@ public abstract class AbilityImpl implements Ability {
|
||||||
* Handles the setting of non mana X costs
|
* Handles the setting of non mana X costs
|
||||||
*
|
*
|
||||||
* @param controller
|
* @param controller
|
||||||
*
|
|
||||||
* @param game
|
* @param game
|
||||||
* @return announce message
|
* @return announce message
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
protected String handleOtherXCosts(Game game, Player controller) {
|
protected String handleOtherXCosts(Game game, Player controller) {
|
||||||
String announceString = null;
|
String announceString = null;
|
||||||
|
@ -873,7 +871,6 @@ public abstract class AbilityImpl implements Ability {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param game
|
* @param game
|
||||||
* @param source
|
* @param source
|
||||||
* @return
|
* @return
|
||||||
|
@ -883,7 +880,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
if (!this.hasSourceObjectAbility(game, source, event)) {
|
if (!this.hasSourceObjectAbility(game, source, event)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (zone.equals(Zone.COMMAND)) {
|
if (zone == Zone.COMMAND) {
|
||||||
if (this.getSourceId() == null) { // commander effects
|
if (this.getSourceId() == null) { // commander effects
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1027,7 +1024,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
sb.append("unknown");
|
sb.append("unknown");
|
||||||
}
|
}
|
||||||
if (object instanceof Spell && ((Spell) object).getSpellAbilities().size() > 1) {
|
if (object instanceof Spell && ((Spell) object).getSpellAbilities().size() > 1) {
|
||||||
if (((Spell) object).getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
|
if (((Spell) object).getSpellAbility().getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) {
|
||||||
Spell spell = (Spell) object;
|
Spell spell = (Spell) object;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (SpellAbility spellAbility : spell.getSpellAbilities()) {
|
for (SpellAbility spellAbility : spell.getSpellAbilities()) {
|
||||||
|
|
|
@ -37,7 +37,6 @@ import mage.game.permanent.Permanent;
|
||||||
import mage.game.permanent.PermanentToken;
|
import mage.game.permanent.PermanentToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class DiesTriggeredAbility extends ZoneChangeTriggeredAbility {
|
public class DiesTriggeredAbility extends ZoneChangeTriggeredAbility {
|
||||||
|
@ -69,7 +68,7 @@ public class DiesTriggeredAbility extends ZoneChangeTriggeredAbility {
|
||||||
@Override
|
@Override
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
if (super.checkEventType(event, game)) {
|
if (super.checkEventType(event, game)) {
|
||||||
return ((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD) && ((ZoneChangeEvent) event).getToZone().equals(Zone.GRAVEYARD);
|
return ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD && ((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@ import mage.game.events.GameEvent.EventType;
|
||||||
import mage.game.events.ZoneChangeEvent;
|
import mage.game.events.ZoneChangeEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class EntersBattlefieldOrLeavesSourceTriggeredAbility extends TriggeredAbilityImpl {
|
public class EntersBattlefieldOrLeavesSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
@ -68,7 +67,7 @@ public class EntersBattlefieldOrLeavesSourceTriggeredAbility extends TriggeredAb
|
||||||
}
|
}
|
||||||
if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) {
|
if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.getSourceId())) {
|
||||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||||
if (zEvent.getFromZone().equals(Zone.BATTLEFIELD)) {
|
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ public abstract class ManaEffect extends OneShotEffect {
|
||||||
* @param source
|
* @param source
|
||||||
*/
|
*/
|
||||||
public void checkToFirePossibleEvents(Mana mana, Game game, Ability source) {
|
public void checkToFirePossibleEvents(Mana mana, Game game, Ability source) {
|
||||||
if (source.getAbilityType().equals(AbilityType.MANA)) {
|
if (source.getAbilityType()==AbilityType.MANA) {
|
||||||
for (Cost cost: source.getCosts()) {
|
for (Cost cost: source.getCosts()) {
|
||||||
if (cost instanceof TapSourceCost) {
|
if (cost instanceof TapSourceCost) {
|
||||||
ManaEvent event = new ManaEvent(GameEvent.EventType.TAPPED_FOR_MANA, source.getSourceId(), source.getSourceId(), source.getControllerId(), mana);
|
ManaEvent event = new ManaEvent(GameEvent.EventType.TAPPED_FOR_MANA, source.getSourceId(), source.getSourceId(), source.getControllerId(), mana);
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class PreventDamageToControllerEffect extends PreventionEffectImpl {
|
||||||
sb.append("combat ");
|
sb.append("combat ");
|
||||||
}
|
}
|
||||||
sb.append("damage that would be dealt to you");
|
sb.append("damage that would be dealt to you");
|
||||||
if (duration.equals(Duration.EndOfTurn)) {
|
if (duration == Duration.EndOfTurn) {
|
||||||
sb.append(" this turn");
|
sb.append(" this turn");
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
package mage.abilities.keyword;
|
package mage.abilities.keyword;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.SpecialAction;
|
import mage.abilities.SpecialAction;
|
||||||
|
@ -30,7 +31,6 @@ import mage.target.Target;
|
||||||
import mage.target.common.TargetControlledPermanent;
|
import mage.target.common.TargetControlledPermanent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public class ImproviseAbility extends SimpleStaticAbility implements AlternateManaPaymentAbility {
|
public class ImproviseAbility extends SimpleStaticAbility implements AlternateManaPaymentAbility {
|
||||||
|
@ -59,7 +59,7 @@ public class ImproviseAbility extends SimpleStaticAbility implements AlternateMa
|
||||||
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
|
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
if (controller != null && game.getBattlefield().contains(filterUntapped, controller.getId(), 1, game)) {
|
if (controller != null && game.getBattlefield().contains(filterUntapped, controller.getId(), 1, game)) {
|
||||||
if (source.getAbilityType().equals(AbilityType.SPELL) && unpaid.getMana().getGeneric() > 0) {
|
if (source.getAbilityType() == AbilityType.SPELL && unpaid.getMana().getGeneric() > 0) {
|
||||||
SpecialAction specialAction = new ImproviseSpecialAction(unpaid);
|
SpecialAction specialAction = new ImproviseSpecialAction(unpaid);
|
||||||
specialAction.setControllerId(source.getControllerId());
|
specialAction.setControllerId(source.getControllerId());
|
||||||
specialAction.setSourceId(source.getSourceId());
|
specialAction.setSourceId(source.getSourceId());
|
||||||
|
|
|
@ -107,7 +107,7 @@ public abstract class Phase implements Serializable {
|
||||||
if (game.isPaused() || game.gameOver(null)) {
|
if (game.isPaused() || game.gameOver(null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (game.getTurn().isEndTurnRequested() && !step.getType().equals(PhaseStep.CLEANUP)) {
|
if (game.getTurn().isEndTurnRequested() && step.getType()!=PhaseStep.CLEANUP) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
currentStep = step;
|
currentStep = step;
|
||||||
|
|
|
@ -27,55 +27,20 @@
|
||||||
*/
|
*/
|
||||||
package mage.players;
|
package mage.players;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.ConditionalMana;
|
import mage.ConditionalMana;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Abilities;
|
import mage.abilities.*;
|
||||||
import mage.abilities.AbilitiesImpl;
|
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.ActivatedAbility;
|
|
||||||
import mage.abilities.DelayedTriggeredAbility;
|
|
||||||
import mage.abilities.Mode;
|
|
||||||
import mage.abilities.PlayLandAbility;
|
|
||||||
import mage.abilities.SpecialAction;
|
|
||||||
import mage.abilities.SpellAbility;
|
|
||||||
import mage.abilities.TriggeredAbility;
|
|
||||||
import mage.abilities.common.PassAbility;
|
import mage.abilities.common.PassAbility;
|
||||||
import mage.abilities.common.delayed.AtTheEndOfTurnStepPostDelayedTriggeredAbility;
|
import mage.abilities.common.delayed.AtTheEndOfTurnStepPostDelayedTriggeredAbility;
|
||||||
import mage.abilities.costs.AdjustingSourceCosts;
|
import mage.abilities.costs.*;
|
||||||
import mage.abilities.costs.AlternativeCostSourceAbility;
|
|
||||||
import mage.abilities.costs.AlternativeSourceCosts;
|
|
||||||
import mage.abilities.costs.Cost;
|
|
||||||
import mage.abilities.costs.Costs;
|
|
||||||
import mage.abilities.costs.OptionalAdditionalSourceCosts;
|
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
import mage.abilities.costs.mana.ManaCosts;
|
import mage.abilities.costs.mana.ManaCosts;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
import mage.abilities.effects.RestrictionEffect;
|
import mage.abilities.effects.RestrictionEffect;
|
||||||
import mage.abilities.effects.RestrictionUntapNotMoreThanEffect;
|
import mage.abilities.effects.RestrictionUntapNotMoreThanEffect;
|
||||||
import mage.abilities.effects.common.LoseControlOnOtherPlayersControllerEffect;
|
import mage.abilities.effects.common.LoseControlOnOtherPlayersControllerEffect;
|
||||||
import mage.abilities.keyword.ConvokeAbility;
|
import mage.abilities.keyword.*;
|
||||||
import mage.abilities.keyword.FlashbackAbility;
|
|
||||||
import mage.abilities.keyword.HexproofAbility;
|
|
||||||
import mage.abilities.keyword.InfectAbility;
|
|
||||||
import mage.abilities.keyword.LifelinkAbility;
|
|
||||||
import mage.abilities.keyword.ProtectionAbility;
|
|
||||||
import mage.abilities.keyword.ShroudAbility;
|
|
||||||
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
||||||
import mage.abilities.mana.ManaOptions;
|
import mage.abilities.mana.ManaOptions;
|
||||||
import mage.actions.MageDrawAction;
|
import mage.actions.MageDrawAction;
|
||||||
|
@ -84,17 +49,7 @@ import mage.cards.Cards;
|
||||||
import mage.cards.CardsImpl;
|
import mage.cards.CardsImpl;
|
||||||
import mage.cards.SplitCard;
|
import mage.cards.SplitCard;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.constants.AbilityType;
|
import mage.constants.*;
|
||||||
import mage.constants.AsThoughEffectType;
|
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.ManaType;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.PhaseStep;
|
|
||||||
import mage.constants.PlayerAction;
|
|
||||||
import mage.constants.RangeOfInfluence;
|
|
||||||
import mage.constants.SpellAbilityType;
|
|
||||||
import mage.constants.TimingRule;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.counters.Counter;
|
import mage.counters.Counter;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.counters.Counters;
|
import mage.counters.Counters;
|
||||||
|
@ -105,12 +60,7 @@ import mage.filter.common.FilterCreatureForCombat;
|
||||||
import mage.filter.common.FilterCreatureForCombatBlock;
|
import mage.filter.common.FilterCreatureForCombatBlock;
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||||
import mage.game.ExileZone;
|
import mage.game.*;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.Graveyard;
|
|
||||||
import mage.game.Table;
|
|
||||||
import mage.game.ZoneChangeInfo;
|
|
||||||
import mage.game.ZonesHandler;
|
|
||||||
import mage.game.combat.CombatGroup;
|
import mage.game.combat.CombatGroup;
|
||||||
import mage.game.command.CommandObject;
|
import mage.game.command.CommandObject;
|
||||||
import mage.game.events.DamagePlayerEvent;
|
import mage.game.events.DamagePlayerEvent;
|
||||||
|
@ -137,6 +87,11 @@ import mage.util.GameLog;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public abstract class PlayerImpl implements Player, Serializable {
|
public abstract class PlayerImpl implements Player, Serializable {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(PlayerImpl.class);
|
private static final Logger logger = Logger.getLogger(PlayerImpl.class);
|
||||||
|
@ -472,7 +427,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called before apply effects
|
* called before apply effects
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void reset() {
|
public void reset() {
|
||||||
|
@ -701,7 +655,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param amount
|
* @param amount
|
||||||
* @param source
|
* @param source
|
||||||
* @param game
|
* @param game
|
||||||
|
@ -998,7 +951,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
if (game == null || ability == null) {
|
if (game == null || ability == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ability.getSpellAbilityType().equals(SpellAbilityType.BASE)) {
|
if (ability.getSpellAbilityType() != SpellAbilityType.BASE) {
|
||||||
ability = chooseSpellAbilityForCast(ability, game, noMana);
|
ability = chooseSpellAbilityForCast(ability, game, noMana);
|
||||||
}
|
}
|
||||||
//20091005 - 601.2a
|
//20091005 - 601.2a
|
||||||
|
@ -1221,7 +1174,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
//if player has taken an action then reset all player passed flags
|
//if player has taken an action then reset all player passed flags
|
||||||
justActivatedType = null;
|
justActivatedType = null;
|
||||||
if (result) {
|
if (result) {
|
||||||
if (isHuman() && (ability.getAbilityType().equals(AbilityType.SPELL) || ability.getAbilityType().equals(AbilityType.ACTIVATED))) {
|
if (isHuman() && (ability.getAbilityType() == AbilityType.SPELL || ability.getAbilityType() == AbilityType.ACTIVATED)) {
|
||||||
if (ability.isUsesStack()) { // if the ability does not use the stack (e.g. Suspend) auto pass would go to next phase unintended
|
if (ability.isUsesStack()) { // if the ability does not use the stack (e.g. Suspend) auto pass would go to next phase unintended
|
||||||
setJustActivatedType(ability.getAbilityType());
|
setJustActivatedType(ability.getAbilityType());
|
||||||
}
|
}
|
||||||
|
@ -1269,8 +1222,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
LinkedHashMap<UUID, ActivatedAbility> useable = new LinkedHashMap<>();
|
LinkedHashMap<UUID, ActivatedAbility> useable = new LinkedHashMap<>();
|
||||||
for (Ability ability : object.getAbilities()) {
|
for (Ability ability : object.getAbilities()) {
|
||||||
if (ability instanceof SpellAbility) {
|
if (ability instanceof SpellAbility) {
|
||||||
if (((SpellAbility) ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
|
if (((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) {
|
||||||
if (zone.equals(Zone.HAND)) {
|
if (zone == Zone.HAND) {
|
||||||
// Fix so you don't need to choose Fuse twice
|
// Fix so you don't need to choose Fuse twice
|
||||||
useable.clear();
|
useable.clear();
|
||||||
useable.put(ability.getId(), (SpellAbility) ability);
|
useable.put(ability.getId(), (SpellAbility) ability);
|
||||||
|
@ -1280,7 +1233,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (((SpellAbility) ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT)) {
|
if (((SpellAbility) ability).getSpellAbilityType() == SpellAbilityType.SPLIT) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
useable.put(ability.getId(), (SpellAbility) ability);
|
useable.put(ability.getId(), (SpellAbility) ability);
|
||||||
|
@ -1297,7 +1250,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
// ManaOptions availableMana = getManaAvailable(game); // can only be activated if mana calculation works flawless otherwise player can't play spells they could play if calculation would work correctly
|
// ManaOptions availableMana = getManaAvailable(game); // can only be activated if mana calculation works flawless otherwise player can't play spells they could play if calculation would work correctly
|
||||||
// availableMana.addMana(manaPool.getMana());
|
// availableMana.addMana(manaPool.getMana());
|
||||||
for (Ability ability : object.getAbilities()) {
|
for (Ability ability : object.getAbilities()) {
|
||||||
if (canUse || ability.getAbilityType().equals(AbilityType.SPECIAL_ACTION)) {
|
if (canUse || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) {
|
||||||
if (ability.getZone().match(zone)) {
|
if (ability.getZone().match(zone)) {
|
||||||
if (ability instanceof ActivatedAbility) {
|
if (ability instanceof ActivatedAbility) {
|
||||||
if (ability instanceof ActivatedManaAbilityImpl) {
|
if (ability instanceof ActivatedManaAbilityImpl) {
|
||||||
|
@ -1320,9 +1273,9 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (zone != Zone.HAND) {
|
if (zone != Zone.HAND) {
|
||||||
if (Zone.GRAVEYARD.equals(zone) && canPlayCardsFromGraveyard()) {
|
if (Zone.GRAVEYARD == zone && canPlayCardsFromGraveyard()) {
|
||||||
for (ActivatedAbility ability : object.getAbilities().getPlayableAbilities(Zone.HAND)) {
|
for (ActivatedAbility ability : object.getAbilities().getPlayableAbilities(Zone.HAND)) {
|
||||||
if (canUse || ability.getAbilityType().equals(AbilityType.SPECIAL_ACTION)) {
|
if (canUse || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) {
|
||||||
if (ability.getManaCosts().isEmpty() && ability.getCosts().isEmpty() && ability instanceof SpellAbility) {
|
if (ability.getManaCosts().isEmpty() && ability.getCosts().isEmpty() && ability instanceof SpellAbility) {
|
||||||
continue; // You can't play spells from graveyard that have no costs
|
continue; // You can't play spells from graveyard that have no costs
|
||||||
}
|
}
|
||||||
|
@ -1334,7 +1287,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
}
|
}
|
||||||
if (zone != Zone.BATTLEFIELD && game.getContinuousEffects().asThough(object.getId(), AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, this.getId(), game)) {
|
if (zone != Zone.BATTLEFIELD && game.getContinuousEffects().asThough(object.getId(), AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, this.getId(), game)) {
|
||||||
for (Ability ability : object.getAbilities()) {
|
for (Ability ability : object.getAbilities()) {
|
||||||
if (canUse || ability.getAbilityType().equals(AbilityType.SPECIAL_ACTION)) {
|
if (canUse || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) {
|
||||||
if (ability.getManaCosts().isEmpty() && ability.getCosts().isEmpty() && ability instanceof SpellAbility && !(ability.getSourceId() == getCastSourceIdWithAlternateMana())) {
|
if (ability.getManaCosts().isEmpty() && ability.getCosts().isEmpty() && ability instanceof SpellAbility && !(ability.getSourceId() == getCastSourceIdWithAlternateMana())) {
|
||||||
continue; // You can't play spells that have no costs, unless you can play them without paying their mana costs
|
continue; // You can't play spells that have no costs, unless you can play them without paying their mana costs
|
||||||
}
|
}
|
||||||
|
@ -1358,7 +1311,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
if (otherAbilities != null) {
|
if (otherAbilities != null) {
|
||||||
boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game);
|
boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game);
|
||||||
for (ActivatedAbility ability : otherAbilities) {
|
for (ActivatedAbility ability : otherAbilities) {
|
||||||
if (canUse || ability.getAbilityType().equals(AbilityType.SPECIAL_ACTION)) {
|
if (canUse || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) {
|
||||||
Card card = game.getCard(ability.getSourceId());
|
Card card = game.getCard(ability.getSourceId());
|
||||||
if (card.isSplitCard() && ability instanceof FlashbackAbility) {
|
if (card.isSplitCard() && ability instanceof FlashbackAbility) {
|
||||||
FlashbackAbility flashbackAbility;
|
FlashbackAbility flashbackAbility;
|
||||||
|
@ -1401,7 +1354,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
LinkedHashMap<UUID, ActivatedManaAbilityImpl> useable = new LinkedHashMap<>();
|
LinkedHashMap<UUID, ActivatedManaAbilityImpl> useable = new LinkedHashMap<>();
|
||||||
boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game);
|
boolean canUse = !(object instanceof Permanent) || ((Permanent) object).canUseActivatedAbilities(game);
|
||||||
for (ActivatedManaAbilityImpl ability : object.getAbilities().getActivatedManaAbilities(zone)) {
|
for (ActivatedManaAbilityImpl ability : object.getAbilities().getActivatedManaAbilities(zone)) {
|
||||||
if (canUse || ability.getAbilityType().equals(AbilityType.SPECIAL_ACTION)) {
|
if (canUse || ability.getAbilityType() == AbilityType.SPECIAL_ACTION) {
|
||||||
if (ability.canActivate(playerId, game)) {
|
if (ability.canActivate(playerId, game)) {
|
||||||
useable.put(ability.getId(), ability);
|
useable.put(ability.getId(), ability);
|
||||||
}
|
}
|
||||||
|
@ -2057,7 +2010,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
passedUntilEndOfTurn = true;
|
passedUntilEndOfTurn = true;
|
||||||
passedUntilStackResolved = false;
|
passedUntilStackResolved = false;
|
||||||
passedUntilEndStepBeforeMyTurn = false;
|
passedUntilEndStepBeforeMyTurn = false;
|
||||||
skippedAtLeastOnce = !PhaseStep.END_TURN.equals(game.getTurn().getStepType());
|
skippedAtLeastOnce = PhaseStep.END_TURN != game.getTurn().getStepType();
|
||||||
this.skip();
|
this.skip();
|
||||||
break;
|
break;
|
||||||
case PASS_PRIORITY_UNTIL_NEXT_TURN: // F4
|
case PASS_PRIORITY_UNTIL_NEXT_TURN: // F4
|
||||||
|
@ -2088,7 +2041,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
passedUntilNextMain = true;
|
passedUntilNextMain = true;
|
||||||
passedUntilStackResolved = false;
|
passedUntilStackResolved = false;
|
||||||
passedUntilEndStepBeforeMyTurn = false;
|
passedUntilEndStepBeforeMyTurn = false;
|
||||||
skippedAtLeastOnce = !(game.getTurn().getStepType().equals(PhaseStep.POSTCOMBAT_MAIN) || game.getTurn().getStepType().equals(PhaseStep.PRECOMBAT_MAIN));
|
skippedAtLeastOnce = !(game.getTurn().getStepType() == PhaseStep.POSTCOMBAT_MAIN || game.getTurn().getStepType() == PhaseStep.PRECOMBAT_MAIN);
|
||||||
this.skip();
|
this.skip();
|
||||||
break;
|
break;
|
||||||
case PASS_PRIORITY_UNTIL_STACK_RESOLVED: //F8
|
case PASS_PRIORITY_UNTIL_STACK_RESOLVED: //F8
|
||||||
|
@ -2333,7 +2286,6 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
/**
|
/**
|
||||||
* @param game
|
* @param game
|
||||||
* @param appliedEffects
|
* @param appliedEffects
|
||||||
*
|
|
||||||
* @return true if player won the toss
|
* @return true if player won the toss
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -2470,9 +2422,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param ability
|
* @param ability
|
||||||
* @param available if null, it won't be checked if enough mana is available
|
* @param available if null, it won't be checked if enough mana is available
|
||||||
* @param sourceObject
|
* @param sourceObject
|
||||||
* @param game
|
* @param game
|
||||||
* @return
|
* @return
|
||||||
|
@ -2608,7 +2559,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
if (!(sourceObject instanceof Permanent)) {
|
if (!(sourceObject instanceof Permanent)) {
|
||||||
Ability sourceAbility = null;
|
Ability sourceAbility = null;
|
||||||
for (Ability landAbility : sourceObject.getAbilities()) {
|
for (Ability landAbility : sourceObject.getAbilities()) {
|
||||||
if (landAbility.getAbilityType().equals(AbilityType.PLAY_LAND)) {
|
if (landAbility.getAbilityType() == AbilityType.PLAY_LAND) {
|
||||||
sourceAbility = landAbility;
|
sourceAbility = landAbility;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2779,10 +2730,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
* Creates a list of card ids that are currently playable.<br>
|
* Creates a list of card ids that are currently playable.<br>
|
||||||
* Used to mark the playable cards in GameView
|
* Used to mark the playable cards in GameView
|
||||||
*
|
*
|
||||||
* @return A Set of cardIds that are playable
|
|
||||||
*
|
|
||||||
* @param game
|
* @param game
|
||||||
*
|
* @return A Set of cardIds that are playable
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> getPlayableInHand(Game game
|
public Set<UUID> getPlayableInHand(Game game
|
||||||
|
@ -3189,8 +3138,8 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
case HAND:
|
case HAND:
|
||||||
for (Card card : cards) {
|
for (Card card : cards) {
|
||||||
fromZone = game.getState().getZone(card.getId());
|
fromZone = game.getState().getZone(card.getId());
|
||||||
boolean hideCard = fromZone.equals(Zone.LIBRARY)
|
boolean hideCard = fromZone == Zone.LIBRARY
|
||||||
|| (card.isFaceDown(game) && !fromZone.equals(Zone.STACK) && !fromZone.equals(Zone.BATTLEFIELD));
|
|| (card.isFaceDown(game) && fromZone != Zone.STACK && fromZone != Zone.BATTLEFIELD);
|
||||||
if (moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, !hideCard)) {
|
if (moveCardToHandWithInfo(card, source == null ? null : source.getSourceId(), game, !hideCard)) {
|
||||||
successfulMovedCards.add(card);
|
successfulMovedCards.add(card);
|
||||||
}
|
}
|
||||||
|
@ -3199,7 +3148,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
case EXILED:
|
case EXILED:
|
||||||
for (Card card : cards) {
|
for (Card card : cards) {
|
||||||
fromZone = game.getState().getZone(card.getId());
|
fromZone = game.getState().getZone(card.getId());
|
||||||
boolean withName = (fromZone.equals(Zone.BATTLEFIELD) || fromZone.equals(Zone.STACK)) || !card.isFaceDown(game);
|
boolean withName = (fromZone == Zone.BATTLEFIELD || fromZone == Zone.STACK) || !card.isFaceDown(game);
|
||||||
if (moveCardToExileWithInfo(card, null, "", source == null ? null : source.getSourceId(), game, fromZone, withName)) {
|
if (moveCardToExileWithInfo(card, null, "", source == null ? null : source.getSourceId(), game, fromZone, withName)) {
|
||||||
successfulMovedCards.add(card);
|
successfulMovedCards.add(card);
|
||||||
}
|
}
|
||||||
|
@ -3212,7 +3161,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
} else {
|
} else {
|
||||||
fromZone = game.getState().getZone(card.getId());
|
fromZone = game.getState().getZone(card.getId());
|
||||||
}
|
}
|
||||||
boolean hideCard = fromZone.equals(Zone.HAND) || fromZone.equals(Zone.LIBRARY);
|
boolean hideCard = fromZone == Zone.HAND || fromZone == Zone.LIBRARY;
|
||||||
if (moveCardToLibraryWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone, true, !hideCard)) {
|
if (moveCardToLibraryWithInfo(card, source == null ? null : source.getSourceId(), game, fromZone, true, !hideCard)) {
|
||||||
successfulMovedCards.add(card);
|
successfulMovedCards.add(card);
|
||||||
}
|
}
|
||||||
|
@ -3253,7 +3202,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, boolean withName) {
|
public boolean moveCardToHandWithInfo(Card card, UUID sourceId, Game game, boolean withName) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
Zone fromZone = game.getState().getZone(card.getId());
|
Zone fromZone = game.getState().getZone(card.getId());
|
||||||
if (fromZone.equals(Zone.BATTLEFIELD) && !(card instanceof Permanent)) {
|
if (fromZone == Zone.BATTLEFIELD && !(card instanceof Permanent)) {
|
||||||
card = game.getPermanent(card.getId());
|
card = game.getPermanent(card.getId());
|
||||||
}
|
}
|
||||||
if (card.moveToZone(Zone.HAND, sourceId, game, false)) {
|
if (card.moveToZone(Zone.HAND, sourceId, game, false)) {
|
||||||
|
@ -3280,7 +3229,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
// identify cards from one owner
|
// identify cards from one owner
|
||||||
Cards cards = new CardsImpl();
|
Cards cards = new CardsImpl();
|
||||||
UUID ownerId = null;
|
UUID ownerId = null;
|
||||||
for (Iterator<Card> it = allCards.iterator(); it.hasNext();) {
|
for (Iterator<Card> it = allCards.iterator(); it.hasNext(); ) {
|
||||||
Card card = it.next();
|
Card card = it.next();
|
||||||
if (cards.isEmpty()) {
|
if (cards.isEmpty()) {
|
||||||
ownerId = card.getOwnerId();
|
ownerId = card.getOwnerId();
|
||||||
|
@ -3343,7 +3292,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
||||||
public boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
|
public boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
// Zone fromZone = game.getState().getZone(card.getId());
|
// Zone fromZone = game.getState().getZone(card.getId());
|
||||||
if (card.moveToZone(Zone.GRAVEYARD, sourceId, game, fromZone != null ? fromZone.equals(Zone.BATTLEFIELD) : false)) {
|
if (card.moveToZone(Zone.GRAVEYARD, sourceId, game, fromZone != null ? fromZone == Zone.BATTLEFIELD : false)) {
|
||||||
if (!game.isSimulation()) {
|
if (!game.isSimulation()) {
|
||||||
if (card instanceof PermanentCard && game.getCard(card.getId()) != null) {
|
if (card instanceof PermanentCard && game.getCard(card.getId()) != null) {
|
||||||
card = game.getCard(card.getId());
|
card = game.getCard(card.getId());
|
||||||
|
|
|
@ -36,6 +36,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
@ -49,7 +50,6 @@ import mage.players.Player;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public abstract class TargetImpl implements Target {
|
public abstract class TargetImpl implements Target {
|
||||||
|
@ -184,7 +184,7 @@ public abstract class TargetImpl implements Target {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRequired(Ability ability) {
|
public boolean isRequired(Ability ability) {
|
||||||
return ability == null || ability.isActivated() || !(ability.getAbilityType().equals(AbilityType.SPELL) || ability.getAbilityType().equals(AbilityType.ACTIVATED));
|
return ability == null || ability.isActivated() || !(ability.getAbilityType() == AbilityType.SPELL || ability.getAbilityType() == AbilityType.ACTIVATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.constants.WatcherScope;
|
import mage.constants.WatcherScope;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
|
@ -80,7 +81,7 @@ public class CardsPutIntoGraveyardWatcher extends Watcher {
|
||||||
++amount;
|
++amount;
|
||||||
}
|
}
|
||||||
amountOfCardsThisTurn.put(playerId, amount);
|
amountOfCardsThisTurn.put(playerId, amount);
|
||||||
if (((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)) {
|
if (((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
|
||||||
cardsPutToGraveyardFromBattlefield.add(new MageObjectReference(event.getTargetId(), game));
|
cardsPutToGraveyardFromBattlefield.add(new MageObjectReference(event.getTargetId(), game));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue