mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
personal game messages
This commit is contained in:
parent
6a70d1ee6d
commit
c783cbc41f
8 changed files with 71 additions and 14 deletions
|
@ -220,6 +220,14 @@ public class CallbackClientImpl implements CallbackClient {
|
||||||
logger.warn("message out of sequence - ignoring");
|
logger.warn("message out of sequence - ignoring");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (callback.getMethod().equals("gameInformPersonal")) {
|
||||||
|
GameClientMessage message = (GameClientMessage) callback.getData();
|
||||||
|
GamePanel panel = frame.getGame(callback.getObjectId());
|
||||||
|
if (panel != null) {
|
||||||
|
JOptionPane.showMessageDialog(panel, message.getMessage(), "Game message",
|
||||||
|
JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (callback.getMethod().equals("sideboard")) {
|
else if (callback.getMethod().equals("sideboard")) {
|
||||||
TableClientMessage message = (TableClientMessage) callback.getData();
|
TableClientMessage message = (TableClientMessage) callback.getData();
|
||||||
DeckView deckView = message.getDeck();
|
DeckView deckView = message.getDeck();
|
||||||
|
|
|
@ -168,6 +168,9 @@ public class GameController implements GameCallback {
|
||||||
case LOOK:
|
case LOOK:
|
||||||
lookAtCards(event.getPlayerId(), event.getMessage(), event.getCards());
|
lookAtCards(event.getPlayerId(), event.getMessage(), event.getCards());
|
||||||
break;
|
break;
|
||||||
|
case PERSONAL_MESSAGE:
|
||||||
|
informPersonal(event.getPlayerId(), event.getMessage());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch (MageException ex) {
|
} catch (MageException ex) {
|
||||||
logger.fatal("Player event listener error ", ex);
|
logger.fatal("Player event listener error ", ex);
|
||||||
|
@ -519,6 +522,14 @@ public class GameController implements GameCallback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private synchronized void informPersonal(UUID playerId, final String message) throws MageException {
|
||||||
|
perform(playerId, new Command() {
|
||||||
|
public void execute(UUID playerId) {
|
||||||
|
gameSessions.get(playerId).informPersonal(message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void error(String message, Exception ex) {
|
private void error(String message, Exception ex) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(message).append(ex.toString());
|
sb.append(message).append(ex.toString());
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
|
|
||||||
package mage.server.game;
|
package mage.server.game;
|
||||||
|
|
||||||
import java.rmi.RemoteException;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
import mage.server.User;
|
import mage.server.User;
|
||||||
|
@ -38,6 +36,9 @@ import mage.view.GameClientMessage;
|
||||||
import mage.view.GameView;
|
import mage.view.GameView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.rmi.RemoteException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -84,6 +85,15 @@ public class GameWatcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void informPersonal(final String message) {
|
||||||
|
if (!killed) {
|
||||||
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
|
if (user != null) {
|
||||||
|
user.fireCallback(new ClientCallback("gameInformPersonal", game.getId(), new GameClientMessage(getGameView(), message)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void gameOver(final String message) {
|
public void gameOver(final String message) {
|
||||||
if (!killed) {
|
if (!killed) {
|
||||||
User user = UserManager.getInstance().getUser(userId);
|
User user = UserManager.getInstance().getUser(userId);
|
||||||
|
|
|
@ -109,6 +109,7 @@ public class DamageTargetEffect extends OneShotEffect<DamageTargetEffect> {
|
||||||
}
|
}
|
||||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
game.informPlayer(player, "You were dealt 3 damage");
|
||||||
player.damage(amount.calculate(game, source), source.getSourceId(), game, false, preventable);
|
player.damage(amount.calculate(game, source), source.getSourceId(), game, false, preventable);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
|
|
||||||
package mage.game.events;
|
package mage.game.events;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.ActivatedAbility;
|
import mage.abilities.ActivatedAbility;
|
||||||
import mage.abilities.TriggeredAbility;
|
import mage.abilities.TriggeredAbility;
|
||||||
|
@ -37,6 +35,9 @@ import mage.cards.Card;
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -44,7 +45,7 @@ import mage.game.permanent.Permanent;
|
||||||
public class PlayerQueryEvent extends EventObject implements ExternalEvent, Serializable {
|
public class PlayerQueryEvent extends EventObject implements ExternalEvent, Serializable {
|
||||||
|
|
||||||
public enum QueryType {
|
public enum QueryType {
|
||||||
ASK, CHOOSE, CHOOSE_ABILITY, CHOOSE_MODE, PICK_TARGET, PICK_ABILITY, SELECT, PLAY_MANA, PLAY_X_MANA, AMOUNT, LOOK, PICK_CARD, CONSTRUCT, CHOOSE_PILE
|
ASK, CHOOSE, CHOOSE_ABILITY, CHOOSE_MODE, PICK_TARGET, PICK_ABILITY, SELECT, PLAY_MANA, PLAY_X_MANA, AMOUNT, LOOK, PICK_CARD, CONSTRUCT, CHOOSE_PILE, PERSONAL_MESSAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
private String message;
|
private String message;
|
||||||
|
@ -127,6 +128,13 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
||||||
this.pile2 = pile2;
|
this.pile2 = pile2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PlayerQueryEvent(UUID playerId, String message) {
|
||||||
|
super(playerId);
|
||||||
|
this.queryType = QueryType.PERSONAL_MESSAGE;
|
||||||
|
this.message = message;
|
||||||
|
this.playerId = playerId;
|
||||||
|
}
|
||||||
|
|
||||||
public static PlayerQueryEvent askEvent(UUID playerId, String message) {
|
public static PlayerQueryEvent askEvent(UUID playerId, String message) {
|
||||||
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.ASK, 0, 0, false);
|
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.ASK, 0, 0, false);
|
||||||
}
|
}
|
||||||
|
@ -195,6 +203,9 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
|
||||||
return new PlayerQueryEvent(playerId, message, QueryType.CONSTRUCT, time);
|
return new PlayerQueryEvent(playerId, message, QueryType.CONSTRUCT, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlayerQueryEvent informPersonal(UUID playerId, String message) {
|
||||||
|
return new PlayerQueryEvent(playerId, message);
|
||||||
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
|
|
|
@ -28,14 +28,15 @@
|
||||||
|
|
||||||
package mage.game.events;
|
package mage.game.events;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import mage.abilities.ActivatedAbility;
|
||||||
import java.util.*;
|
import mage.abilities.TriggeredAbility;
|
||||||
|
|
||||||
import mage.abilities.*;
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -117,4 +118,8 @@ public class PlayerQueryEventSource implements EventSource<PlayerQueryEvent>, Se
|
||||||
dispatcher.fireEvent(PlayerQueryEvent.construct(playerId, message, time));
|
dispatcher.fireEvent(PlayerQueryEvent.construct(playerId, message, time));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void informPlayer(UUID playerId, String message) {
|
||||||
|
dispatcher.fireEvent(PlayerQueryEvent.informPersonal(playerId, message));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,6 @@
|
||||||
|
|
||||||
package mage.game.events;
|
package mage.game.events;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.EventObject;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -38,6 +35,10 @@ import mage.game.draft.Draft;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.TournamentPairing;
|
import mage.game.tournament.TournamentPairing;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.EventObject;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -82,6 +83,11 @@ public class TableEvent extends EventObject implements ExternalEvent, Serializab
|
||||||
this.ex = ex;
|
this.ex = ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TableEvent(EventType eventType, UUID playerId, String message, Game game) {
|
||||||
|
this(eventType, message, game);
|
||||||
|
this.playerId = playerId;
|
||||||
|
}
|
||||||
|
|
||||||
public TableEvent(EventType eventType, UUID playerId, Deck deck, int timeout) {
|
public TableEvent(EventType eventType, UUID playerId, Deck deck, int timeout) {
|
||||||
super(playerId);
|
super(playerId);
|
||||||
this.playerId = playerId;
|
this.playerId = playerId;
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
|
|
||||||
package mage.game.events;
|
package mage.game.events;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.cards.Cards;
|
import mage.cards.Cards;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -38,6 +36,9 @@ import mage.game.events.TableEvent.EventType;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.game.tournament.TournamentPairing;
|
import mage.game.tournament.TournamentPairing;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -59,6 +60,10 @@ public class TableEventSource implements EventSource<TableEvent>, Serializable {
|
||||||
dispatcher.fireEvent(new TableEvent(eventType, message, game));
|
dispatcher.fireEvent(new TableEvent(eventType, message, game));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void fireTableEvent(EventType eventType, UUID playerId, String message, Game game) {
|
||||||
|
dispatcher.fireEvent(new TableEvent(eventType, playerId, message, game));
|
||||||
|
}
|
||||||
|
|
||||||
public void fireTableEvent(EventType eventType, String message, Exception ex, Game game) {
|
public void fireTableEvent(EventType eventType, String message, Exception ex, Game game) {
|
||||||
dispatcher.fireEvent(new TableEvent(eventType, message, ex, game));
|
dispatcher.fireEvent(new TableEvent(eventType, message, ex, game));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue