mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
Improved player quits / leaves mage handling for tournaments (not perfect yet, will more improve it).
This commit is contained in:
parent
0d1e45fff6
commit
85b8edf630
12 changed files with 155 additions and 34 deletions
|
|
@ -66,7 +66,10 @@
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace max="32767" attributes="0"/>
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
<Component id="btnCloseWindow" min="-2" pref="129" max="-2" attributes="0"/>
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Component id="btnCloseWindow" alignment="1" min="-2" pref="129" max="-2" attributes="0"/>
|
||||||
|
<Component id="btnQuitTournament" alignment="1" min="-2" pref="129" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
@ -80,6 +83,7 @@
|
||||||
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="lblStartTime" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="lblStartTime" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="txtStartTime" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="txtStartTime" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="btnQuitTournament" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
|
@ -152,6 +156,15 @@
|
||||||
<Property name="focusable" type="boolean" value="false"/>
|
<Property name="focusable" type="boolean" value="false"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</Component>
|
||||||
|
<Component class="javax.swing.JButton" name="btnQuitTournament">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Quit Tournament"/>
|
||||||
|
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuitTournamentActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
<Component class="javax.swing.JButton" name="btnCloseWindow">
|
<Component class="javax.swing.JButton" name="btnCloseWindow">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="text" type="java.lang.String" value="Close Window"/>
|
<Property name="text" type="java.lang.String" value="Close Window"/>
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,8 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
matchesModel = new TournamentMatchesTableModel();
|
matchesModel = new TournamentMatchesTableModel();
|
||||||
|
|
||||||
initComponents();
|
initComponents();
|
||||||
|
btnQuitTournament.setVisible(false);
|
||||||
|
|
||||||
df = DateFormat.getDateTimeInstance();
|
df = DateFormat.getDateTimeInstance();
|
||||||
|
|
||||||
tablePlayers.createDefaultColumnsFromModel();
|
tablePlayers.createDefaultColumnsFromModel();
|
||||||
|
|
@ -124,6 +125,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
else {
|
else {
|
||||||
hideTournament();
|
hideTournament();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getTournamentId() {
|
public UUID getTournamentId() {
|
||||||
|
|
@ -169,6 +171,20 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
matchesModel.loadData(tournament);
|
matchesModel.loadData(tournament);
|
||||||
this.tablePlayers.repaint();
|
this.tablePlayers.repaint();
|
||||||
this.tableMatches.repaint();
|
this.tableMatches.repaint();
|
||||||
|
|
||||||
|
// player is active in tournament
|
||||||
|
btnQuitTournament.setVisible(false);
|
||||||
|
if (tournament.getEndTime() == null) {
|
||||||
|
for (TournamentPlayerView player : tournament.getPlayers()) {
|
||||||
|
if (player.getName().equals(session.getUserName())) {
|
||||||
|
if (!player.hasQuit()) {
|
||||||
|
btnQuitTournament.setVisible(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startTasks() {
|
public void startTasks() {
|
||||||
|
|
@ -204,6 +220,7 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
txtStartTime = new javax.swing.JTextField();
|
txtStartTime = new javax.swing.JTextField();
|
||||||
lablEndTime = new javax.swing.JLabel();
|
lablEndTime = new javax.swing.JLabel();
|
||||||
txtEndTime = new javax.swing.JTextField();
|
txtEndTime = new javax.swing.JTextField();
|
||||||
|
btnQuitTournament = new javax.swing.JButton();
|
||||||
btnCloseWindow = new javax.swing.JButton();
|
btnCloseWindow = new javax.swing.JButton();
|
||||||
jSplitPane2 = new javax.swing.JSplitPane();
|
jSplitPane2 = new javax.swing.JSplitPane();
|
||||||
jSplitPane1 = new javax.swing.JSplitPane();
|
jSplitPane1 = new javax.swing.JSplitPane();
|
||||||
|
|
@ -246,6 +263,14 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
txtEndTime.setText("jTextField2");
|
txtEndTime.setText("jTextField2");
|
||||||
txtEndTime.setFocusable(false);
|
txtEndTime.setFocusable(false);
|
||||||
|
|
||||||
|
btnQuitTournament.setText("Quit Tournament");
|
||||||
|
btnQuitTournament.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||||
|
btnQuitTournament.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
btnQuitTournamentActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
btnCloseWindow.setText("Close Window");
|
btnCloseWindow.setText("Close Window");
|
||||||
btnCloseWindow.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
btnCloseWindow.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||||
btnCloseWindow.addActionListener(new java.awt.event.ActionListener() {
|
btnCloseWindow.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
|
@ -278,7 +303,9 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(txtStartTime, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
.addComponent(txtStartTime, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(btnCloseWindow, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addGroup(actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(btnCloseWindow, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(btnQuitTournament, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
actionPanelLayout.setVerticalGroup(
|
actionPanelLayout.setVerticalGroup(
|
||||||
|
|
@ -289,7 +316,8 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
.addComponent(lblName, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(lblName, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(lblStartTime)
|
.addComponent(lblStartTime)
|
||||||
.addComponent(txtStartTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
.addComponent(txtStartTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(btnQuitTournament))
|
||||||
.addGap(9, 9, 9)
|
.addGap(9, 9, 9)
|
||||||
.addGroup(actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(actionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(lblType)
|
.addComponent(lblType)
|
||||||
|
|
@ -345,10 +373,19 @@ public class TournamentPanel extends javax.swing.JPanel {
|
||||||
hideTournament();
|
hideTournament();
|
||||||
}//GEN-LAST:event_btnCloseWindowActionPerformed
|
}//GEN-LAST:event_btnCloseWindowActionPerformed
|
||||||
|
|
||||||
|
private void btnQuitTournamentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitTournamentActionPerformed
|
||||||
|
// TODO add your handling code here:
|
||||||
|
if (JOptionPane.showConfirmDialog(this, "Are you sure you want to quit the tournament?", "Confirm quit tournament", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||||
|
MageFrame.getSession().quitTournament(tournamentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}//GEN-LAST:event_btnQuitTournamentActionPerformed
|
||||||
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JPanel actionPanel;
|
private javax.swing.JPanel actionPanel;
|
||||||
private javax.swing.JButton btnCloseWindow;
|
private javax.swing.JButton btnCloseWindow;
|
||||||
|
private javax.swing.JButton btnQuitTournament;
|
||||||
private mage.client.chat.ChatPanel chatPanel1;
|
private mage.client.chat.ChatPanel chatPanel1;
|
||||||
private javax.swing.JScrollPane jScrollPane1;
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
private javax.swing.JScrollPane jScrollPane2;
|
private javax.swing.JScrollPane jScrollPane2;
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@ public interface MageServer {
|
||||||
//tournament methods
|
//tournament methods
|
||||||
void startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
void startTournament(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||||
void joinTournament(UUID draftId, String sessionId) throws MageException;
|
void joinTournament(UUID draftId, String sessionId) throws MageException;
|
||||||
|
void quitTournament(UUID tournamentId, String sessionId) throws MageException;
|
||||||
TournamentView getTournament(UUID tournamentId) throws MageException;
|
TournamentView getTournament(UUID tournamentId) throws MageException;
|
||||||
|
|
||||||
//draft methods
|
//draft methods
|
||||||
|
|
|
||||||
|
|
@ -953,6 +953,20 @@ public class SessionImpl implements Session {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public boolean quitTournament(UUID tournamentId) {
|
||||||
|
try {
|
||||||
|
if (isConnected()) {
|
||||||
|
server.quitTournament(tournamentId, sessionId);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (MageException ex) {
|
||||||
|
handleMageException(ex);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
handleThrowable(t);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean undo(UUID gameId) {
|
public boolean undo(UUID gameId) {
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,8 @@ public interface GamePlay {
|
||||||
|
|
||||||
boolean quitMatch(UUID gameId);
|
boolean quitMatch(UUID gameId);
|
||||||
|
|
||||||
|
boolean quitTournament(UUID tournamentId);
|
||||||
|
|
||||||
boolean submitDeck(UUID tableId, DeckCardLists deck);
|
boolean submitDeck(UUID tableId, DeckCardLists deck);
|
||||||
|
|
||||||
boolean updateDeck(UUID tableId, DeckCardLists deck);
|
boolean updateDeck(UUID tableId, DeckCardLists deck);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
package mage.view;
|
package mage.view;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import mage.constants.TournamentPlayerState;
|
||||||
import mage.game.tournament.TournamentPlayer;
|
import mage.game.tournament.TournamentPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,6 +43,7 @@ public class TournamentPlayerView implements Serializable {
|
||||||
private String state;
|
private String state;
|
||||||
private String results;
|
private String results;
|
||||||
private int points;
|
private int points;
|
||||||
|
private boolean quit;
|
||||||
|
|
||||||
TournamentPlayerView(TournamentPlayer player) {
|
TournamentPlayerView(TournamentPlayer player) {
|
||||||
this.name = player.getPlayer().getName();
|
this.name = player.getPlayer().getName();
|
||||||
|
|
@ -52,6 +54,7 @@ public class TournamentPlayerView implements Serializable {
|
||||||
this.state = sb.toString();
|
this.state = sb.toString();
|
||||||
this.points = player.getPoints();
|
this.points = player.getPoints();
|
||||||
this.results = player.getResults();
|
this.results = player.getResults();
|
||||||
|
this.quit = player.getState().equals(TournamentPlayerState.ELIMINATED) || player.getState().equals(TournamentPlayerState.CANCELED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
@ -69,4 +72,9 @@ public class TournamentPlayerView implements Serializable {
|
||||||
public String getResults() {
|
public String getResults() {
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasQuit() {
|
||||||
|
return quit;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -584,6 +584,17 @@ public class MageServerImpl implements MageServer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void quitTournament(final UUID tournamentId, final String sessionId) throws MageException {
|
||||||
|
execute("quitTournament", sessionId, new Action() {
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||||
|
TournamentManager.getInstance().quit(tournamentId, userId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void undo(final UUID gameId, final String sessionId) throws MageException {
|
public void undo(final UUID gameId, final String sessionId) throws MageException {
|
||||||
execute("undo", sessionId, new Action() {
|
execute("undo", sessionId, new Action() {
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.Tournament;
|
import mage.game.tournament.Tournament;
|
||||||
import mage.game.tournament.TournamentPairing;
|
import mage.game.tournament.TournamentPairing;
|
||||||
import mage.game.tournament.TournamentPlayer;
|
import mage.game.tournament.TournamentPlayer;
|
||||||
|
import mage.players.Player;
|
||||||
import mage.server.ChatManager;
|
import mage.server.ChatManager;
|
||||||
import mage.server.TableManager;
|
import mage.server.TableManager;
|
||||||
import mage.server.UserManager;
|
import mage.server.UserManager;
|
||||||
|
|
@ -237,10 +238,10 @@ public class TournamentController {
|
||||||
public void submitDeck(UUID playerId, Deck deck) {
|
public void submitDeck(UUID playerId, Deck deck) {
|
||||||
if (tournamentSessions.containsKey(playerId)) {
|
if (tournamentSessions.containsKey(playerId)) {
|
||||||
TournamentPlayer player = tournament.getPlayer(playerId);
|
TournamentPlayer player = tournament.getPlayer(playerId);
|
||||||
if (player != null) {
|
if (player != null && !player.hasQuit()) {
|
||||||
|
tournamentSessions.get(playerId).submitDeck(deck);
|
||||||
ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getName() + " has submitted his tournament deck", MessageColor.BLACK);
|
ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getName() + " has submitted his tournament deck", MessageColor.BLACK);
|
||||||
}
|
}
|
||||||
tournamentSessions.get(playerId).submitDeck(deck);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,23 +258,37 @@ public class TournamentController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public UUID getSessionId() {
|
|
||||||
// return this.sessionId;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public UUID getChatId() {
|
public UUID getChatId() {
|
||||||
return chatId;
|
return chatId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kill(UUID userId) {
|
public void quit(UUID userId) {
|
||||||
if (userPlayerMap.containsKey(userId)) {
|
UUID playerId = userPlayerMap.get(userId);
|
||||||
tournamentSessions.get(userPlayerMap.get(userId)).setKilled();
|
if (playerId != null) {
|
||||||
tournamentSessions.remove(userPlayerMap.get(userId));
|
TournamentPlayer player = tournament.getPlayer(playerId);
|
||||||
leave(userId);
|
if (player != null) {
|
||||||
userPlayerMap.remove(userId);
|
ChatManager.getInstance().broadcast(chatId, "", player.getPlayer().getName() + " has quit the tournament", MessageColor.BLACK);
|
||||||
|
String info;
|
||||||
|
if (tournament.isDoneConstructing()) {
|
||||||
|
info = new StringBuilder("during round ").append(tournament.getRounds().size()).toString();
|
||||||
|
} else {
|
||||||
|
info = "during Construction phase";
|
||||||
|
}
|
||||||
|
player.setQuit(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void kill(UUID userId) {
|
||||||
|
quit(userId);
|
||||||
|
// if (userPlayerMap.containsKey(userId)) {
|
||||||
|
// tournamentSessions.get(userPlayerMap.get(userId)).setKilled();
|
||||||
|
// tournamentSessions.remove(userPlayerMap.get(userId));
|
||||||
|
// leave(userId);
|
||||||
|
// userPlayerMap.remove(userId);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
private void leave(UUID userId) {
|
private void leave(UUID userId) {
|
||||||
tournament.leave(getPlayerId(userId));
|
tournament.leave(getPlayerId(userId));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,11 @@ public class TournamentManager {
|
||||||
controllers.get(tournamentId).join(userId);
|
controllers.get(tournamentId).join(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void quit(UUID tournamentId, UUID userId) {
|
||||||
|
controllers.get(tournamentId).quit(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void kill(UUID tournamentId, UUID userId) {
|
public void kill(UUID tournamentId, UUID userId) {
|
||||||
controllers.get(tournamentId).kill(userId);
|
controllers.get(tournamentId).kill(userId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ public class TournamentSession {
|
||||||
|
|
||||||
public void setKilled() {
|
public void setKilled() {
|
||||||
killed = true;
|
killed = true;
|
||||||
|
TournamentManager.getInstance().kill(tournament.getId(), userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void setupTimeout(int seconds) {
|
private synchronized void setupTimeout(int seconds) {
|
||||||
|
|
|
||||||
|
|
@ -23,36 +23,36 @@ import mage.game.Game;
|
||||||
*/
|
*/
|
||||||
public class ConditionalActivatedAbility extends ActivatedAbilityImpl<ConditionalActivatedAbility> {
|
public class ConditionalActivatedAbility extends ActivatedAbilityImpl<ConditionalActivatedAbility> {
|
||||||
|
|
||||||
private Condition condition;
|
private Condition condition;
|
||||||
private String staticText = "";
|
private String ruleText = "";
|
||||||
|
|
||||||
private static final Effects emptyEffects = new Effects();
|
private static final Effects emptyEffects = new Effects();
|
||||||
|
|
||||||
public ConditionalActivatedAbility(Zone zone, Effect effect, ManaCosts cost, Condition condition, String rule) {
|
public ConditionalActivatedAbility(Zone zone, Effect effect, ManaCosts cost, Condition condition, String rule) {
|
||||||
super(zone, effect, cost);
|
super(zone, effect, cost);
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
this.staticText = rule;
|
this.ruleText = rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionalActivatedAbility(Zone zone, Effect effect, Costs costs, Condition condition, String rule) {
|
public ConditionalActivatedAbility(Zone zone, Effect effect, Costs costs, Condition condition, String rule) {
|
||||||
super(zone, effect, costs);
|
super(zone, effect, costs);
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
this.staticText = rule;
|
this.ruleText = rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionalActivatedAbility(Zone zone, Effect effect, Cost cost, Condition condition, String rule) {
|
public ConditionalActivatedAbility(Zone zone, Effect effect, Cost cost, Condition condition, String rule) {
|
||||||
super(zone, effect, cost);
|
super(zone, effect, cost);
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
this.staticText = rule;
|
this.ruleText = rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionalActivatedAbility(ConditionalActivatedAbility ability) {
|
public ConditionalActivatedAbility(final ConditionalActivatedAbility ability) {
|
||||||
super(ability);
|
super(ability);
|
||||||
this.condition = ability.condition;
|
this.condition = ability.condition;
|
||||||
this.staticText = ability.staticText;
|
this.ruleText = ability.ruleText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Effects getEffects(Game game, EffectType effectType) {
|
public Effects getEffects(Game game, EffectType effectType) {
|
||||||
if (!condition.apply(game, this)) {
|
if (!condition.apply(game, this)) {
|
||||||
return emptyEffects;
|
return emptyEffects;
|
||||||
|
|
@ -60,8 +60,8 @@ public class ConditionalActivatedAbility extends ActivatedAbilityImpl<Conditiona
|
||||||
return super.getEffects(game, effectType);
|
return super.getEffects(game, effectType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canActivate(UUID playerId, Game game) {
|
public boolean canActivate(UUID playerId, Game game) {
|
||||||
if (!condition.apply(game, this)) {
|
if (!condition.apply(game, this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -73,8 +73,8 @@ public class ConditionalActivatedAbility extends ActivatedAbilityImpl<Conditiona
|
||||||
return new ConditionalActivatedAbility(this);
|
return new ConditionalActivatedAbility(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getRule() {
|
public String getRule() {
|
||||||
return staticText;
|
return ruleText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ public class TournamentPlayer {
|
||||||
protected Deck deck;
|
protected Deck deck;
|
||||||
protected String results = "";
|
protected String results = "";
|
||||||
protected boolean eliminated = false;
|
protected boolean eliminated = false;
|
||||||
|
protected boolean quit = false;
|
||||||
protected boolean doneConstructing;
|
protected boolean doneConstructing;
|
||||||
protected boolean joined = false;
|
protected boolean joined = false;
|
||||||
|
|
||||||
|
|
@ -149,5 +150,18 @@ public class TournamentPlayer {
|
||||||
public void setStateInfo(String stateInfo) {
|
public void setStateInfo(String stateInfo) {
|
||||||
this.stateInfo = stateInfo;
|
this.stateInfo = stateInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasQuit() {
|
||||||
|
return quit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuit(String info) {
|
||||||
|
setEliminated();
|
||||||
|
this.setState(TournamentPlayerState.CANCELED);
|
||||||
|
this.setStateInfo(info);
|
||||||
|
this.quit = true;
|
||||||
|
this.doneConstructing = true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue