mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 21:02:08 -08:00
Sending user data. Sending avatar to server on connect.
This commit is contained in:
parent
32d4d854f4
commit
bf1a49dd0b
27 changed files with 202 additions and 38 deletions
|
|
@ -36,12 +36,7 @@ import mage.cards.decks.DeckCardLists;
|
|||
import mage.game.GameException;
|
||||
import mage.game.tournament.TournamentOptions;
|
||||
import mage.utils.MageVersion;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.GameView;
|
||||
import mage.view.MatchView;
|
||||
import mage.view.TournamentView;
|
||||
import mage.view.UserView;
|
||||
import mage.view.*;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -53,6 +48,7 @@ public interface MageServer {
|
|||
public boolean registerAdmin(String password, String sessionId, MageVersion version) throws MageException;
|
||||
public void deregisterClient(String sessionId) throws MageException;
|
||||
|
||||
public boolean setUserData(String userName, String sessionId, UserDataView userDataView) throws MageException;
|
||||
public ServerState getServerState() throws MageException;
|
||||
|
||||
//table methods
|
||||
|
|
|
|||
|
|
@ -47,13 +47,7 @@ import mage.interfaces.MageServer;
|
|||
import mage.interfaces.ServerState;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.utils.CompressUtil;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.GameTypeView;
|
||||
import mage.view.MatchView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.TournamentTypeView;
|
||||
import mage.view.TournamentView;
|
||||
import mage.view.UserView;
|
||||
import mage.view.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jboss.remoting.Client;
|
||||
import org.jboss.remoting.ConnectionListener;
|
||||
|
|
@ -153,10 +147,14 @@ public class Session {
|
|||
|
||||
this.sessionId = callbackClient.getSessionId();
|
||||
boolean registerResult = false;
|
||||
if (connection.getPassword() == null)
|
||||
if (connection.getPassword() == null) {
|
||||
UserDataView userDataView = new UserDataView(0);
|
||||
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
|
||||
registerResult = server.registerClient(connection.getUsername(), sessionId, client.getVersion());
|
||||
else
|
||||
server.setUserData(connection.getUsername(), sessionId, userDataView);
|
||||
} else {
|
||||
registerResult = server.registerAdmin(connection.getPassword(), sessionId, client.getVersion());
|
||||
}
|
||||
if (registerResult) {
|
||||
sessionState = SessionState.CONNECTED;
|
||||
serverState = server.getServerState();
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ public class PlayerView implements Serializable {
|
|||
private SimpleCardsView graveyard = new SimpleCardsView();
|
||||
private Map<UUID, PermanentView> battlefield = new HashMap<UUID, PermanentView>();
|
||||
private CardView topCard;
|
||||
private UserDataView userDataView;
|
||||
|
||||
public PlayerView(Player player, GameState state, Game game) {
|
||||
this.playerId = player.getId();
|
||||
|
|
@ -80,6 +81,11 @@ public class PlayerView implements Serializable {
|
|||
}
|
||||
this.topCard = player.isTopCardRevealed() && player.getLibrary().size() > 0 ?
|
||||
new CardView(player.getLibrary().getFromTop(game)) : null;
|
||||
if (player.getUserData() != null) {
|
||||
this.userDataView = new UserDataView(player.getUserData());
|
||||
} else {
|
||||
this.userDataView = new UserDataView(0);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean showInBattlefield(Permanent permanent, GameState state) {
|
||||
|
|
@ -143,4 +149,8 @@ public class PlayerView implements Serializable {
|
|||
public CardView getTopCard() {
|
||||
return this.topCard;
|
||||
}
|
||||
|
||||
public UserDataView getUserData() {
|
||||
return this.userDataView;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue