mirror of
https://github.com/correl/mage.git
synced 2024-12-27 03:00:13 +00:00
Merge branch 'master' of https://github.com/magefree/mage.git
This commit is contained in:
commit
80beadbee2
12 changed files with 306 additions and 65 deletions
|
@ -26,8 +26,11 @@ public class HoverButton extends JPanel implements MouseListener {
|
||||||
private int textOffsetY = 0;
|
private int textOffsetY = 0;
|
||||||
private int textOffsetButtonY = 2;
|
private int textOffsetButtonY = 2;
|
||||||
private int textOffsetX = -1;
|
private int textOffsetX = -1;
|
||||||
|
private int topTextOffsetX = -1;
|
||||||
private Dimension overlayImageSize;
|
private Dimension overlayImageSize;
|
||||||
|
|
||||||
|
private String topText;
|
||||||
|
|
||||||
private boolean isHovered = false;
|
private boolean isHovered = false;
|
||||||
private boolean isSelected = false;
|
private boolean isSelected = false;
|
||||||
private boolean drawSet = false;
|
private boolean drawSet = false;
|
||||||
|
@ -36,6 +39,7 @@ public class HoverButton extends JPanel implements MouseListener {
|
||||||
private Command observer = null;
|
private Command observer = null;
|
||||||
private Command onHover = null;
|
private Command onHover = null;
|
||||||
private Color textColor = Color.white;
|
private Color textColor = Color.white;
|
||||||
|
private Color textBGColor = Color.black;
|
||||||
|
|
||||||
static final Font textFont = new Font("Arial", Font.PLAIN, 12);
|
static final Font textFont = new Font("Arial", Font.PLAIN, 12);
|
||||||
static final Font textFontMini = new Font("Arial", Font.PLAIN, 11);
|
static final Font textFontMini = new Font("Arial", Font.PLAIN, 11);
|
||||||
|
@ -100,6 +104,18 @@ public class HoverButton extends JPanel implements MouseListener {
|
||||||
} else {
|
} else {
|
||||||
g.drawImage(disabledImage, 0, 0, imageSize.width, imageSize.height, this);
|
g.drawImage(disabledImage, 0, 0, imageSize.width, imageSize.height, this);
|
||||||
}
|
}
|
||||||
|
if (topText != null) {
|
||||||
|
if (useMiniFont) {
|
||||||
|
g2d.setFont(textFontMini);
|
||||||
|
} else {
|
||||||
|
g2d.setFont(textFont);
|
||||||
|
}
|
||||||
|
topTextOffsetX = calculateOffsetForTop(g2d, topText);
|
||||||
|
g2d.setColor(textBGColor);
|
||||||
|
g2d.drawString(topText, topTextOffsetX+1, 13);
|
||||||
|
g2d.setColor(textColor);
|
||||||
|
g2d.drawString(topText, topTextOffsetX, 12);
|
||||||
|
}
|
||||||
if (overlayImage != null) {
|
if (overlayImage != null) {
|
||||||
g.drawImage(overlayImage, (imageSize.width - overlayImageSize.width) / 2, 10, this);
|
g.drawImage(overlayImage, (imageSize.width - overlayImageSize.width) / 2, 10, this);
|
||||||
} else if (set != null) {
|
} else if (set != null) {
|
||||||
|
@ -136,6 +152,15 @@ public class HoverButton extends JPanel implements MouseListener {
|
||||||
return textOffsetX;
|
return textOffsetX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int calculateOffsetForTop(Graphics2D g2d, String text) {
|
||||||
|
if (topTextOffsetX == -1) { // calculate once
|
||||||
|
FontRenderContext frc = g2d.getFontRenderContext();
|
||||||
|
int textWidth = (int) textFont.getStringBounds(text, frc).getWidth();
|
||||||
|
topTextOffsetX = (imageSize.width - textWidth) / 2;
|
||||||
|
}
|
||||||
|
return topTextOffsetX;
|
||||||
|
}
|
||||||
|
|
||||||
public void setTextColor(Color textColor) {
|
public void setTextColor(Color textColor) {
|
||||||
this.textColor = textColor;
|
this.textColor = textColor;
|
||||||
}
|
}
|
||||||
|
@ -242,4 +267,8 @@ public class HoverButton extends JPanel implements MouseListener {
|
||||||
observer.execute();
|
observer.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTopText(String topText) {
|
||||||
|
this.topText = topText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,6 +182,8 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.avatar.setText(player.getName());
|
this.avatar.setText(player.getName());
|
||||||
|
String priorityTimeValue = getPriorityTimeLeftString(player);
|
||||||
|
this.avatar.setTopText(priorityTimeValue);
|
||||||
this.btnPlayer.setText(player.getName());
|
this.btnPlayer.setText(player.getName());
|
||||||
if (player.isActive()) {
|
if (player.isActive()) {
|
||||||
this.avatar.setBorder(greenBorder);
|
this.avatar.setBorder(greenBorder);
|
||||||
|
@ -216,6 +218,11 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
update(player.getManaPool());
|
update(player.getManaPool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getPriorityTimeLeftString(PlayerView player) {
|
||||||
|
int priorityTimeLeft = player.getPriorityTimeLeft();
|
||||||
|
return priorityTimeLeft / 3600 + ":" + (priorityTimeLeft % 3600) / 60 + ":" + priorityTimeLeft % 60;
|
||||||
|
}
|
||||||
|
|
||||||
protected void update(ManaPoolView pool) {
|
protected void update(ManaPoolView pool) {
|
||||||
manaLabels.get("B").setText(Integer.toString(pool.getBlack()));
|
manaLabels.get("B").setText(Integer.toString(pool.getBlack()));
|
||||||
manaLabels.get("R").setText(Integer.toString(pool.getRed()));
|
manaLabels.get("R").setText(Integer.toString(pool.getRed()));
|
||||||
|
|
|
@ -63,6 +63,7 @@ public class PlayerView implements Serializable {
|
||||||
private List<EmblemView> emblemList = new ArrayList<EmblemView>();
|
private List<EmblemView> emblemList = new ArrayList<EmblemView>();
|
||||||
private List<UUID> attachments = new ArrayList<UUID>();
|
private List<UUID> attachments = new ArrayList<UUID>();
|
||||||
private int statesSavedSize;
|
private int statesSavedSize;
|
||||||
|
private int priorityTimeLeft;
|
||||||
|
|
||||||
public PlayerView(Player player, GameState state, Game game) {
|
public PlayerView(Player player, GameState state, Game game) {
|
||||||
this.playerId = player.getId();
|
this.playerId = player.getId();
|
||||||
|
@ -108,6 +109,7 @@ public class PlayerView implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.statesSavedSize = player.getStoredBookmark();
|
this.statesSavedSize = player.getStoredBookmark();
|
||||||
|
this.priorityTimeLeft = player.getPriorityTimeLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean showInBattlefield(Permanent permanent, GameState state) {
|
private boolean showInBattlefield(Permanent permanent, GameState state) {
|
||||||
|
@ -191,4 +193,8 @@ public class PlayerView implements Serializable {
|
||||||
public int getStatesSavedSize() {
|
public int getStatesSavedSize() {
|
||||||
return statesSavedSize;
|
return statesSavedSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPriorityTimeLeft() {
|
||||||
|
return priorityTimeLeft;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,6 @@
|
||||||
|
|
||||||
package mage.player.human;
|
package mage.player.human;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.RangeOfInfluence;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.*;
|
import mage.abilities.*;
|
||||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||||
|
@ -46,6 +41,9 @@ import mage.cards.Cards;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
import mage.choices.ChoiceImpl;
|
import mage.choices.ChoiceImpl;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.RangeOfInfluence;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.filter.common.FilterAttackingCreature;
|
import mage.filter.common.FilterAttackingCreature;
|
||||||
import mage.filter.common.FilterBlockingCreature;
|
import mage.filter.common.FilterBlockingCreature;
|
||||||
import mage.filter.common.FilterCreatureForCombat;
|
import mage.filter.common.FilterCreatureForCombat;
|
||||||
|
@ -67,6 +65,9 @@ import mage.target.common.TargetDefender;
|
||||||
import mage.util.ManaUtil;
|
import mage.util.ManaUtil;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -98,40 +99,43 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
super(player);
|
super(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitForResponse() {
|
protected void waitForResponse(Game game) {
|
||||||
response.clear();
|
response.clear();
|
||||||
log.debug("Waiting response from player: " + getId());
|
log.debug("Waiting response from player: " + getId());
|
||||||
|
game.resumeTimer(playerId);
|
||||||
synchronized(response) {
|
synchronized(response) {
|
||||||
try {
|
try {
|
||||||
response.wait();
|
response.wait();
|
||||||
log.debug("Got response from player: " + getId());
|
log.debug("Got response from player: " + getId());
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
game.pauseTimer(playerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitForBooleanResponse() {
|
protected void waitForBooleanResponse(Game game) {
|
||||||
do {
|
do {
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
} while (response.getBoolean() == null && !abort);
|
} while (response.getBoolean() == null && !abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitForUUIDResponse() {
|
protected void waitForUUIDResponse(Game game) {
|
||||||
do {
|
do {
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
} while (response.getUUID() == null && !abort);
|
} while (response.getUUID() == null && !abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitForStringResponse() {
|
protected void waitForStringResponse(Game game) {
|
||||||
do {
|
do {
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
} while (response.getString() == null && !abort);
|
} while (response.getString() == null && !abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitForIntegerResponse() {
|
protected void waitForIntegerResponse(Game game) {
|
||||||
do {
|
do {
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
} while (response.getInteger() == null && !abort);
|
} while (response.getInteger() == null && !abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +147,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
.append(getHand().size() > nextHandSize?"down to ":"for free, draw ")
|
.append(getHand().size() > nextHandSize?"down to ":"for free, draw ")
|
||||||
.append(nextHandSize)
|
.append(nextHandSize)
|
||||||
.append(nextHandSize == 1?" card?":" cards?").toString());
|
.append(nextHandSize == 1?" card?":" cards?").toString());
|
||||||
waitForBooleanResponse();
|
waitForBooleanResponse(game);
|
||||||
if (!abort) {
|
if (!abort) {
|
||||||
return response.getBoolean();
|
return response.getBoolean();
|
||||||
}
|
}
|
||||||
|
@ -154,7 +158,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
public boolean chooseUse(Outcome outcome, String message, Game game) {
|
public boolean chooseUse(Outcome outcome, String message, Game game) {
|
||||||
updateGameStatePriority("chooseUse", game);
|
updateGameStatePriority("chooseUse", game);
|
||||||
game.fireAskPlayerEvent(playerId, message);
|
game.fireAskPlayerEvent(playerId, message);
|
||||||
waitForBooleanResponse();
|
waitForBooleanResponse(game);
|
||||||
if (!abort) {
|
if (!abort) {
|
||||||
return response.getBoolean();
|
return response.getBoolean();
|
||||||
}
|
}
|
||||||
|
@ -175,7 +179,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
}
|
}
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
game.fireChooseEvent(playerId, replacementEffectChoice);
|
game.fireChooseEvent(playerId, replacementEffectChoice);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
log.debug("Choose effect: " + response.getString());
|
log.debug("Choose effect: " + response.getString());
|
||||||
if (response.getString() != null) {
|
if (response.getString() != null) {
|
||||||
replacementEffectChoice.setChoice(response.getString());
|
replacementEffectChoice.setChoice(response.getString());
|
||||||
|
@ -196,7 +200,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
updateGameStatePriority("choose(3)", game);
|
updateGameStatePriority("choose(3)", game);
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
game.fireChooseEvent(playerId, choice);
|
game.fireChooseEvent(playerId, choice);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getString() != null) {
|
if (response.getString() != null) {
|
||||||
choice.setChoice(response.getString());
|
choice.setChoice(response.getString());
|
||||||
return true;
|
return true;
|
||||||
|
@ -218,7 +222,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
Set<UUID> cards = target.possibleTargets(null, playerId, game);
|
Set<UUID> cards = target.possibleTargets(null, playerId, game);
|
||||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, target.isRequired(), options);
|
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, target.isRequired(), options);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (target instanceof TargetPermanent) {
|
if (target instanceof TargetPermanent) {
|
||||||
if (((TargetPermanent)target).canTarget(playerId, response.getUUID(), sourceId, game, false)) {
|
if (((TargetPermanent)target).canTarget(playerId, response.getUUID(), sourceId, game, false)) {
|
||||||
|
@ -267,7 +271,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
Set<UUID> possibleTargets = target.possibleTargets(source==null?null:source.getSourceId(), playerId, game);
|
Set<UUID> possibleTargets = target.possibleTargets(source==null?null:source.getSourceId(), playerId, game);
|
||||||
boolean required = possibleTargets.isEmpty() ? false : target.isRequired();
|
boolean required = possibleTargets.isEmpty() ? false : target.isRequired();
|
||||||
game.fireSelectTargetEvent(playerId, target.getMessage(), possibleTargets, required, getOptions(target));
|
game.fireSelectTargetEvent(playerId, target.getMessage(), possibleTargets, required, getOptions(target));
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (possibleTargets.contains(response.getUUID())) {
|
if (possibleTargets.contains(response.getUUID())) {
|
||||||
if (target instanceof TargetPermanent) {
|
if (target instanceof TargetPermanent) {
|
||||||
|
@ -323,7 +327,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
options.put("chosen", (Serializable)chosen);
|
options.put("chosen", (Serializable)chosen);
|
||||||
}
|
}
|
||||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, required, options);
|
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, required, options);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (target.canTarget(response.getUUID(), cards, game)) {
|
if (target.canTarget(response.getUUID(), cards, game)) {
|
||||||
target.add(response.getUUID(), game);
|
target.add(response.getUUID(), game);
|
||||||
|
@ -358,7 +362,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, target.isRequired(), null);
|
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, target.isRequired(), null);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (target.canTarget(response.getUUID(), cards, game)) {
|
if (target.canTarget(response.getUUID(), cards, game)) {
|
||||||
target.addTarget(response.getUUID(), source, game);
|
target.addTarget(response.getUUID(), source, game);
|
||||||
|
@ -383,7 +387,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
updateGameStatePriority("chooseTargetAmount", game);
|
updateGameStatePriority("chooseTargetAmount", game);
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
game.fireSelectTargetEvent(playerId, target.getMessage() + "\n Amount remaining:" + target.getAmountRemaining(), target.possibleTargets(source==null?null:source.getId(), playerId, game), target.isRequired(), null);
|
game.fireSelectTargetEvent(playerId, target.getMessage() + "\n Amount remaining:" + target.getAmountRemaining(), target.possibleTargets(source==null?null:source.getId(), playerId, game), target.isRequired(), null);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (target.canTarget(response.getUUID(), source, game)) {
|
if (target.canTarget(response.getUUID(), source, game)) {
|
||||||
UUID targetId = response.getUUID();
|
UUID targetId = response.getUUID();
|
||||||
|
@ -412,7 +416,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
}
|
}
|
||||||
updateGameStatePriority("priority", game);
|
updateGameStatePriority("priority", game);
|
||||||
game.firePriorityEvent(playerId);
|
game.firePriorityEvent(playerId);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getBoolean() != null) {
|
if (response.getBoolean() != null) {
|
||||||
pass(game);
|
pass(game);
|
||||||
return false;
|
return false;
|
||||||
|
@ -450,7 +454,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
updateGameStatePriority("chooseTriggeredAbility", game);
|
updateGameStatePriority("chooseTriggeredAbility", game);
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
game.fireSelectTargetEvent(playerId, "Pick triggered ability (goes to the stack first)", abilities);
|
game.fireSelectTargetEvent(playerId, "Pick triggered ability (goes to the stack first)", abilities);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
for (TriggeredAbility ability: abilities) {
|
for (TriggeredAbility ability: abilities) {
|
||||||
if (ability.getId().equals(response.getUUID())) {
|
if (ability.getId().equals(response.getUUID())) {
|
||||||
|
@ -466,7 +470,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
public boolean playMana(ManaCost unpaid, Game game) {
|
public boolean playMana(ManaCost unpaid, Game game) {
|
||||||
updateGameStatePriority("playMana", game);
|
updateGameStatePriority("playMana", game);
|
||||||
game.firePlayManaEvent(playerId, "Pay " + unpaid.getText());
|
game.firePlayManaEvent(playerId, "Pay " + unpaid.getText());
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getBoolean() != null) {
|
if (response.getBoolean() != null) {
|
||||||
return false;
|
return false;
|
||||||
} else if (response.getUUID() != null) {
|
} else if (response.getUUID() != null) {
|
||||||
|
@ -500,7 +504,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
public int announceXMana(int min, int max, String message, Game game, Ability ability) {
|
public int announceXMana(int min, int max, String message, Game game, Ability ability) {
|
||||||
updateGameStatePriority("announceXMana", game);
|
updateGameStatePriority("announceXMana", game);
|
||||||
game.fireGetAmountEvent(playerId, message, min, max);
|
game.fireGetAmountEvent(playerId, message, min, max);
|
||||||
waitForIntegerResponse();
|
waitForIntegerResponse(game);
|
||||||
return response.getInteger();
|
return response.getInteger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -530,7 +534,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
game.fireSelectEvent(playerId, "Select attackers");
|
game.fireSelectEvent(playerId, "Select attackers");
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getBoolean() != null) {
|
if (response.getBoolean() != null) {
|
||||||
return;
|
return;
|
||||||
} else if (response.getInteger() != null) {
|
} else if (response.getInteger() != null) {
|
||||||
|
@ -593,7 +597,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
filter.add(new ControllerIdPredicate(defendingPlayerId));
|
filter.add(new ControllerIdPredicate(defendingPlayerId));
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
game.fireSelectEvent(playerId, "Select blockers");
|
game.fireSelectEvent(playerId, "Select blockers");
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getBoolean() != null) {
|
if (response.getBoolean() != null) {
|
||||||
return;
|
return;
|
||||||
} else if (response.getInteger() != null) {
|
} else if (response.getInteger() != null) {
|
||||||
|
@ -622,7 +626,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
updateGameStatePriority("chooseAttackerOrder", game);
|
updateGameStatePriority("chooseAttackerOrder", game);
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
game.fireSelectTargetEvent(playerId, "Pick attacker", attackers, true);
|
game.fireSelectTargetEvent(playerId, "Pick attacker", attackers, true);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
for (Permanent perm: attackers) {
|
for (Permanent perm: attackers) {
|
||||||
if (perm.getId().equals(response.getUUID())) {
|
if (perm.getId().equals(response.getUUID())) {
|
||||||
|
@ -640,7 +644,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
updateGameStatePriority("chooseBlockerOrder", game);
|
updateGameStatePriority("chooseBlockerOrder", game);
|
||||||
while (!abort) {
|
while (!abort) {
|
||||||
game.fireSelectTargetEvent(playerId, "Pick blocker", blockers, true);
|
game.fireSelectTargetEvent(playerId, "Pick blocker", blockers, true);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
for (Permanent perm: blockers) {
|
for (Permanent perm: blockers) {
|
||||||
if (perm.getId().equals(response.getUUID())) {
|
if (perm.getId().equals(response.getUUID())) {
|
||||||
|
@ -656,7 +660,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
updateGameStatePriority("selectCombatGroup", game);
|
updateGameStatePriority("selectCombatGroup", game);
|
||||||
TargetAttackingCreature target = new TargetAttackingCreature();
|
TargetAttackingCreature target = new TargetAttackingCreature();
|
||||||
game.fireSelectTargetEvent(playerId, "Select attacker to block", target.possibleTargets(null, playerId, game), target.isRequired(), null);
|
game.fireSelectTargetEvent(playerId, "Select attacker to block", target.possibleTargets(null, playerId, game), target.isRequired(), null);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getBoolean() != null) {
|
if (response.getBoolean() != null) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if (response.getUUID() != null) {
|
} else if (response.getUUID() != null) {
|
||||||
|
@ -696,7 +700,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
public int getAmount(int min, int max, String message, Game game) {
|
public int getAmount(int min, int max, String message, Game game) {
|
||||||
updateGameStatePriority("getAmount", game);
|
updateGameStatePriority("getAmount", game);
|
||||||
game.fireGetAmountEvent(playerId, message, min, max);
|
game.fireGetAmountEvent(playerId, message, min, max);
|
||||||
waitForIntegerResponse();
|
waitForIntegerResponse(game);
|
||||||
return response.getInteger();
|
return response.getInteger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -719,7 +723,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
updateGameStatePriority("specialAction", game);
|
updateGameStatePriority("specialAction", game);
|
||||||
LinkedHashMap<UUID, SpecialAction> specialActions = game.getState().getSpecialActions().getControlledBy(playerId);
|
LinkedHashMap<UUID, SpecialAction> specialActions = game.getState().getSpecialActions().getControlledBy(playerId);
|
||||||
game.fireGetChoiceEvent(playerId, name, new ArrayList<SpecialAction>(specialActions.values()));
|
game.fireGetChoiceEvent(playerId, name, new ArrayList<SpecialAction>(specialActions.values()));
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (specialActions.containsKey(response.getUUID())) {
|
if (specialActions.containsKey(response.getUUID())) {
|
||||||
activateAbility(specialActions.get(response.getUUID()), game);
|
activateAbility(specialActions.get(response.getUUID()), game);
|
||||||
|
@ -737,7 +741,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
game.fireGetChoiceEvent(playerId, name, new ArrayList<ActivatedAbility>(abilities.values()));
|
game.fireGetChoiceEvent(playerId, name, new ArrayList<ActivatedAbility>(abilities.values()));
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (abilities.containsKey(response.getUUID())) {
|
if (abilities.containsKey(response.getUUID())) {
|
||||||
activateAbility(abilities.get(response.getUUID()), game);
|
activateAbility(abilities.get(response.getUUID()), game);
|
||||||
|
@ -757,7 +761,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
return (SpellAbility) useableAbilities.values().iterator().next();
|
return (SpellAbility) useableAbilities.values().iterator().next();
|
||||||
} else if (useableAbilities != null && useableAbilities.size() > 0) {
|
} else if (useableAbilities != null && useableAbilities.size() > 0) {
|
||||||
game.fireGetChoiceEvent(playerId, name, new ArrayList<ActivatedAbility>(useableAbilities.values()));
|
game.fireGetChoiceEvent(playerId, name, new ArrayList<ActivatedAbility>(useableAbilities.values()));
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
if (useableAbilities.containsKey(response.getUUID())) {
|
if (useableAbilities.containsKey(response.getUUID())) {
|
||||||
return (SpellAbility) useableAbilities.get(response.getUUID());
|
return (SpellAbility) useableAbilities.get(response.getUUID());
|
||||||
|
@ -785,7 +789,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
modeMap.put(mode.getId(), modeText);
|
modeMap.put(mode.getId(), modeText);
|
||||||
}
|
}
|
||||||
game.fireGetModeEvent(playerId, "Choose Mode", modeMap);
|
game.fireGetModeEvent(playerId, "Choose Mode", modeMap);
|
||||||
waitForResponse();
|
waitForResponse(game);
|
||||||
if (response.getUUID() != null) {
|
if (response.getUUID() != null) {
|
||||||
for (Mode mode: modes.values()) {
|
for (Mode mode: modes.values()) {
|
||||||
if (mode.getId().equals(response.getUUID())) {
|
if (mode.getId().equals(response.getUUID())) {
|
||||||
|
@ -802,7 +806,7 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
|
||||||
public boolean choosePile(Outcome outcome, String message, List<? extends Card> pile1, List<? extends Card> pile2, Game game) {
|
public boolean choosePile(Outcome outcome, String message, List<? extends Card> pile1, List<? extends Card> pile2, Game game) {
|
||||||
updateGameStatePriority("choosePile", game);
|
updateGameStatePriority("choosePile", game);
|
||||||
game.fireChoosePileEvent(playerId, message, pile1, pile2);
|
game.fireChoosePileEvent(playerId, message, pile1, pile2);
|
||||||
waitForBooleanResponse();
|
waitForBooleanResponse(game);
|
||||||
if (!abort) {
|
if (!abort) {
|
||||||
return response.getBoolean();
|
return response.getBoolean();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.MageException;
|
import mage.MageException;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
|
@ -37,6 +36,7 @@ import mage.cards.decks.Deck;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.cards.repository.CardInfo;
|
import mage.cards.repository.CardInfo;
|
||||||
import mage.cards.repository.CardRepository;
|
import mage.cards.repository.CardRepository;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.GameException;
|
import mage.game.GameException;
|
||||||
import mage.game.events.Listener;
|
import mage.game.events.Listener;
|
||||||
|
@ -45,14 +45,12 @@ import mage.game.events.TableEvent;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.server.*;
|
import mage.server.*;
|
||||||
|
import mage.server.game.timer.PriorityTimer;
|
||||||
import mage.server.util.Splitter;
|
import mage.server.util.Splitter;
|
||||||
import mage.server.util.SystemUtil;
|
import mage.server.util.SystemUtil;
|
||||||
import mage.server.util.ThreadExecutor;
|
import mage.server.util.ThreadExecutor;
|
||||||
import mage.view.AbilityPickerView;
|
import mage.view.*;
|
||||||
import mage.view.CardsView;
|
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
import mage.view.GameView;
|
|
||||||
import mage.view.PermanentView;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
@ -75,6 +73,13 @@ public class GameController implements GameCallback {
|
||||||
|
|
||||||
private ConcurrentHashMap<UUID, GameSession> gameSessions = new ConcurrentHashMap<UUID, GameSession>();
|
private ConcurrentHashMap<UUID, GameSession> gameSessions = new ConcurrentHashMap<UUID, GameSession>();
|
||||||
private ConcurrentHashMap<UUID, GameWatcher> watchers = new ConcurrentHashMap<UUID, GameWatcher>();
|
private ConcurrentHashMap<UUID, GameWatcher> watchers = new ConcurrentHashMap<UUID, GameWatcher>();
|
||||||
|
private ConcurrentHashMap<UUID, PriorityTimer> timers = new ConcurrentHashMap<UUID, PriorityTimer>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time each player has during the game to play using his\her priority.
|
||||||
|
*/
|
||||||
|
private static final int PRIORITY_TIME_SEC = 62;
|
||||||
|
|
||||||
private ConcurrentHashMap<UUID, UUID> userPlayerMap;
|
private ConcurrentHashMap<UUID, UUID> userPlayerMap;
|
||||||
private UUID gameSessionId;
|
private UUID gameSessionId;
|
||||||
private Game game;
|
private Game game;
|
||||||
|
@ -106,6 +111,8 @@ public class GameController implements GameCallback {
|
||||||
@Override
|
@Override
|
||||||
public void event(TableEvent event) {
|
public void event(TableEvent event) {
|
||||||
try {
|
try {
|
||||||
|
PriorityTimer timer;
|
||||||
|
UUID playerId;
|
||||||
switch (event.getEventType()) {
|
switch (event.getEventType()) {
|
||||||
case UPDATE:
|
case UPDATE:
|
||||||
updateGame();
|
updateGame();
|
||||||
|
@ -124,6 +131,43 @@ public class GameController implements GameCallback {
|
||||||
case ERROR:
|
case ERROR:
|
||||||
error(event.getMessage(), event.getException());
|
error(event.getMessage(), event.getException());
|
||||||
break;
|
break;
|
||||||
|
case INIT_TIMER:
|
||||||
|
final UUID initPlayerId = event.getPlayerId();
|
||||||
|
if (initPlayerId == null) {
|
||||||
|
throw new IllegalStateException("INIT_TIMER: playerId can't be null");
|
||||||
|
}
|
||||||
|
long delay = 250L; // run each 250 ms
|
||||||
|
timer = new PriorityTimer(PRIORITY_TIME_SEC, delay, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
game.concede(initPlayerId);
|
||||||
|
logger.info("Game timeout for player: " + initPlayerId + ". Conceding.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
timers.put(initPlayerId, timer);
|
||||||
|
timer.init();
|
||||||
|
break;
|
||||||
|
case RESUME_TIMER:
|
||||||
|
playerId = event.getPlayerId();
|
||||||
|
if (playerId == null) {
|
||||||
|
throw new IllegalStateException("RESUME_TIMER: playerId can't be null");
|
||||||
|
}
|
||||||
|
timer = timers.get(playerId);
|
||||||
|
if (timer == null) {
|
||||||
|
throw new IllegalStateException("RESUME_TIMER: couldn't find timer for player: " + playerId);
|
||||||
|
}
|
||||||
|
timer.resume();
|
||||||
|
break;
|
||||||
|
case PAUSE_TIMER:
|
||||||
|
playerId = event.getPlayerId();
|
||||||
|
if (playerId == null) {
|
||||||
|
throw new IllegalStateException("PAUSE_TIMER: playerId can't be null");
|
||||||
|
}
|
||||||
|
timer = timers.get(playerId);
|
||||||
|
if (timer == null) {
|
||||||
|
throw new IllegalStateException("PAUSE_TIMER: couldn't find timer for player: " + playerId);
|
||||||
|
}
|
||||||
|
timer.pause();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
logger.fatal("Table event listener error ", ex);
|
logger.fatal("Table event listener error ", ex);
|
||||||
|
@ -388,6 +432,12 @@ public class GameController implements GameCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void updateGame() {
|
private synchronized void updateGame() {
|
||||||
|
for (Player player: game.getState().getPlayers().values()) {
|
||||||
|
PriorityTimer timer = timers.get(player.getId());
|
||||||
|
if (timer != null) {
|
||||||
|
player.setPriorityTimeLeft(timer.getCount());
|
||||||
|
}
|
||||||
|
}
|
||||||
for (final GameSession gameSession: gameSessions.values()) {
|
for (final GameSession gameSession: gameSessions.values()) {
|
||||||
gameSession.update();
|
gameSession.update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
package mage.server.game.timer;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author noxx
|
||||||
|
*/
|
||||||
|
public class PriorityTimer extends TimerTask {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(PriorityTimer.class);
|
||||||
|
|
||||||
|
private int count;
|
||||||
|
|
||||||
|
private long delay;
|
||||||
|
|
||||||
|
private Runnable taskOnTimeout;
|
||||||
|
|
||||||
|
private States state = States.NONE;
|
||||||
|
|
||||||
|
enum States {
|
||||||
|
NONE,
|
||||||
|
INIT,
|
||||||
|
RUNNING,
|
||||||
|
PAUSED,
|
||||||
|
FINISHED
|
||||||
|
}
|
||||||
|
|
||||||
|
public PriorityTimer(int count, long delay, Runnable taskOnTimeout) {
|
||||||
|
this.count = count;
|
||||||
|
this.delay = delay;
|
||||||
|
this.taskOnTimeout = taskOnTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
state = States.INIT;
|
||||||
|
Timer timer = new Timer("Priority Timer", false);
|
||||||
|
long delayMs = delay * (int) (1000L / delay);
|
||||||
|
timer.scheduleAtFixedRate(this, delayMs, delayMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
if (state == States.NONE) {
|
||||||
|
throw new IllegalStateException("Timer should have been initialized first");
|
||||||
|
}
|
||||||
|
if (state == States.FINISHED) {
|
||||||
|
throw new IllegalStateException("Timer has already finished its work");
|
||||||
|
}
|
||||||
|
state = States.RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pause() {
|
||||||
|
state = States.PAUSED;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
state = States.FINISHED;
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resume() {
|
||||||
|
if (state == States.FINISHED) {
|
||||||
|
throw new IllegalStateException("Timer has already finished its work");
|
||||||
|
}
|
||||||
|
state = States.RUNNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (state == States.RUNNING) {
|
||||||
|
count--;
|
||||||
|
}
|
||||||
|
if (logger.isDebugEnabled()) logger.debug("Count is: " + count);
|
||||||
|
//System.out.println("Count is: " + count);
|
||||||
|
if (count <= 0) {
|
||||||
|
cancel();
|
||||||
|
taskOnTimeout.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
long delay = 250L;
|
||||||
|
int count = 5;
|
||||||
|
PriorityTimer timer = new PriorityTimer(count, delay, new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
System.out.println("Exit");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
timer.init();
|
||||||
|
timer.start();
|
||||||
|
Thread.sleep(2000);
|
||||||
|
timer.pause();
|
||||||
|
Thread.sleep(3000);
|
||||||
|
timer.resume();
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,12 +28,6 @@
|
||||||
|
|
||||||
package mage.sets.scarsofmirrodin;
|
package mage.sets.scarsofmirrodin;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.constants.*;
|
|
||||||
import mage.constants.Rarity;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -51,6 +45,7 @@ import mage.abilities.effects.common.UntapTargetEffect;
|
||||||
import mage.abilities.effects.common.continious.BecomesCreatureTargetEffect;
|
import mage.abilities.effects.common.continious.BecomesCreatureTargetEffect;
|
||||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
import mage.constants.*;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.common.FilterLandPermanent;
|
import mage.filter.common.FilterLandPermanent;
|
||||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||||
|
@ -62,6 +57,8 @@ import mage.game.permanent.token.Token;
|
||||||
import mage.target.common.TargetCreatureOrPlayer;
|
import mage.target.common.TargetCreatureOrPlayer;
|
||||||
import mage.target.common.TargetLandPermanent;
|
import mage.target.common.TargetLandPermanent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Loki, North
|
* @author Loki, North
|
||||||
|
@ -95,7 +92,7 @@ public class KothOfTheHammer extends CardImpl<KothOfTheHammer> {
|
||||||
// -2: Add {R} to your mana pool for each Mountain you control.
|
// -2: Add {R} to your mana pool for each Mountain you control.
|
||||||
this.addAbility(new LoyaltyAbility(new DynamicManaEffect(Mana.RedMana, new PermanentsOnBattlefieldCount(filterCount)), -2));
|
this.addAbility(new LoyaltyAbility(new DynamicManaEffect(Mana.RedMana, new PermanentsOnBattlefieldCount(filterCount)), -2));
|
||||||
|
|
||||||
// -5: You get an emblem with "Mountains you control have ‘{T}: This land deals 1 damage to target creature or player.'
|
// -5: You get an emblem with "Mountains you control have '{T}: This land deals 1 damage to target creature or player.'
|
||||||
this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new KothOfTheHammerEmblem()), -5));
|
this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new KothOfTheHammerEmblem()), -5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,6 @@
|
||||||
|
|
||||||
package mage.game;
|
package mage.game;
|
||||||
|
|
||||||
import mage.constants.MultiplayerAttackOption;
|
|
||||||
import mage.constants.RangeOfInfluence;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.MageItem;
|
import mage.MageItem;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -44,6 +41,10 @@ import mage.cards.Card;
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.MultiplayerAttackOption;
|
||||||
|
import mage.constants.RangeOfInfluence;
|
||||||
|
import mage.constants.Zone;
|
||||||
import mage.game.combat.Combat;
|
import mage.game.combat.Combat;
|
||||||
import mage.game.command.Emblem;
|
import mage.game.command.Emblem;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
|
@ -65,7 +66,6 @@ import mage.util.functions.ApplyToPermanent;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import mage.constants.Duration;
|
|
||||||
|
|
||||||
public interface Game extends MageItem, Serializable {
|
public interface Game extends MageItem, Serializable {
|
||||||
|
|
||||||
|
@ -225,4 +225,9 @@ public interface Game extends MageItem, Serializable {
|
||||||
// controlling the behaviour of replacement effects
|
// controlling the behaviour of replacement effects
|
||||||
void setScopeRelevant(boolean scopeRelevant);
|
void setScopeRelevant(boolean scopeRelevant);
|
||||||
public boolean getScopeRelevant();
|
public boolean getScopeRelevant();
|
||||||
|
|
||||||
|
// players' timers
|
||||||
|
void initTimer(UUID playerId);
|
||||||
|
void resumeTimer(UUID playerId);
|
||||||
|
void pauseTimer(UUID playerId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
package mage.game;
|
package mage.game;
|
||||||
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.ActivatedAbility;
|
import mage.abilities.ActivatedAbility;
|
||||||
|
@ -49,12 +48,14 @@ import mage.actions.impl.MageAction;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.cards.CardsImpl;
|
import mage.cards.CardsImpl;
|
||||||
|
import mage.cards.SplitCard;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.choices.Choice;
|
import mage.choices.Choice;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.Filter;
|
import mage.filter.Filter;
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.common.FilterPlaneswalkerPermanent;
|
import mage.filter.common.FilterPlaneswalkerPermanent;
|
||||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||||
import mage.filter.predicate.mageobject.NamePredicate;
|
import mage.filter.predicate.mageobject.NamePredicate;
|
||||||
|
@ -89,8 +90,6 @@ import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import mage.cards.SplitCard;
|
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializable {
|
public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializable {
|
||||||
|
@ -590,6 +589,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
protected void init(UUID choosingPlayerId, GameOptions gameOptions) {
|
protected void init(UUID choosingPlayerId, GameOptions gameOptions) {
|
||||||
for (Player player: state.getPlayers().values()) {
|
for (Player player: state.getPlayers().values()) {
|
||||||
player.beginTurn(this);
|
player.beginTurn(this);
|
||||||
|
initTimer(player.getId());
|
||||||
}
|
}
|
||||||
if (startMessage == null || startMessage.isEmpty()) {
|
if (startMessage == null || startMessage.isEmpty()) {
|
||||||
startMessage = "Game has started";
|
startMessage = "Game has started";
|
||||||
|
@ -1946,4 +1946,20 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
||||||
public void setStartMessage(String startMessage) {
|
public void setStartMessage(String startMessage) {
|
||||||
this.startMessage = startMessage;
|
this.startMessage = startMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initTimer(UUID playerId) {
|
||||||
|
tableEventSource.fireTableEvent(EventType.INIT_TIMER, playerId, null, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resumeTimer(UUID playerId) {
|
||||||
|
tableEventSource.fireTableEvent(EventType.RESUME_TIMER, playerId, null, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pauseTimer(UUID playerId) {
|
||||||
|
tableEventSource.fireTableEvent(EventType.PAUSE_TIMER, playerId, null, this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,8 @@ import java.util.UUID;
|
||||||
public class TableEvent extends EventObject implements ExternalEvent, Serializable {
|
public class TableEvent extends EventObject implements ExternalEvent, Serializable {
|
||||||
|
|
||||||
public enum EventType {
|
public enum EventType {
|
||||||
UPDATE, INFO, STATUS, REVEAL, LOOK, START_DRAFT, START_MATCH, SIDEBOARD, CONSTRUCT, SUBMIT_DECK, END, ERROR
|
UPDATE, INFO, STATUS, REVEAL, LOOK, START_DRAFT, START_MATCH, SIDEBOARD, CONSTRUCT, SUBMIT_DECK, END, ERROR,
|
||||||
|
INIT_TIMER, RESUME_TIMER, PAUSE_TIMER
|
||||||
}
|
}
|
||||||
|
|
||||||
private Game game;
|
private Game game;
|
||||||
|
|
|
@ -299,4 +299,18 @@ public interface Player extends MageItem, Copyable<Player> {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void revealFaceDownCard(Card card, Game game);
|
void revealFaceDownCard(Card card, Game game);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set seconds left to play the game.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
void setPriorityTimeLeft(int timeLeft);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns seconds left to play the game.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int getPriorityTimeLeft();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
|
|
||||||
package mage.players;
|
package mage.players;
|
||||||
|
|
||||||
import mage.constants.*;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.*;
|
import mage.abilities.*;
|
||||||
|
@ -46,10 +44,13 @@ import mage.actions.MageDrawAction;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.cards.CardsImpl;
|
import mage.cards.CardsImpl;
|
||||||
|
import mage.cards.SplitCard;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
|
import mage.constants.*;
|
||||||
import mage.counters.Counter;
|
import mage.counters.Counter;
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.counters.Counters;
|
import mage.counters.Counters;
|
||||||
|
import mage.filter.FilterCard;
|
||||||
import mage.filter.common.FilterCreatureForCombat;
|
import mage.filter.common.FilterCreatureForCombat;
|
||||||
import mage.game.ExileZone;
|
import mage.game.ExileZone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -59,11 +60,13 @@ import mage.game.events.DamagedPlayerEvent;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
import mage.game.events.GameEvent.EventType;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.game.stack.Spell;
|
||||||
import mage.game.stack.StackAbility;
|
import mage.game.stack.StackAbility;
|
||||||
import mage.game.stack.StackObject;
|
import mage.game.stack.StackObject;
|
||||||
import mage.players.net.UserData;
|
import mage.players.net.UserData;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.TargetAmount;
|
import mage.target.TargetAmount;
|
||||||
|
import mage.target.TargetCard;
|
||||||
import mage.target.common.TargetCardInLibrary;
|
import mage.target.common.TargetCardInLibrary;
|
||||||
import mage.target.common.TargetDiscard;
|
import mage.target.common.TargetDiscard;
|
||||||
import mage.watchers.common.BloodthirstWatcher;
|
import mage.watchers.common.BloodthirstWatcher;
|
||||||
|
@ -72,11 +75,6 @@ import org.apache.log4j.Logger;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import mage.cards.SplitCard;
|
|
||||||
import mage.filter.FilterCard;
|
|
||||||
import mage.game.stack.Spell;
|
|
||||||
import mage.target.TargetCard;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Serializable {
|
public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Serializable {
|
||||||
|
|
||||||
|
@ -108,6 +106,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
protected boolean passedTurn;
|
protected boolean passedTurn;
|
||||||
protected int turns;
|
protected int turns;
|
||||||
protected int storedBookmark = -1;
|
protected int storedBookmark = -1;
|
||||||
|
protected int priorityTimeLeft;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This indicates that player passed all turns until his own turn starts.
|
* This indicates that player passed all turns until his own turn starts.
|
||||||
|
@ -1793,4 +1792,14 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
||||||
this.revealCards(name, cards, game);
|
this.revealCards(name, cards, game);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPriorityTimeLeft(int timeLeft) {
|
||||||
|
priorityTimeLeft = timeLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriorityTimeLeft() {
|
||||||
|
return priorityTimeLeft;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue