mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
added startMatch and joinGame
This commit is contained in:
parent
19ad01ced8
commit
58e85df735
17 changed files with 220 additions and 46 deletions
|
|
@ -514,20 +514,20 @@ public class Main implements MageServer {
|
|||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean startMatch(final String sessionId, final UUID roomId, final UUID tableId) throws MageException {
|
||||
// if (!TableManager.getInstance().getController(tableId).changeTableState(TableState.STARTING)) {
|
||||
// return false;
|
||||
// }
|
||||
@Override
|
||||
public boolean startMatch(final String sessionId, final UUID roomId, final UUID tableId) {
|
||||
if (!TableManager.getInstance().getController(tableId).changeTableState(TableState.STARTING)) {
|
||||
return false;
|
||||
}
|
||||
// execute("startMatch", sessionId, new Action() {
|
||||
// @Override
|
||||
// public void execute() {
|
||||
// UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||
// TableManager.getInstance().startMatch(userId, roomId, tableId);
|
||||
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||
TableManager.getInstance().startMatch(userId, roomId, tableId);
|
||||
// }
|
||||
// });
|
||||
// return true;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public void startChallenge(final String sessionId, final UUID roomId, final UUID tableId, final UUID challengeId) throws MageException {
|
||||
|
|
@ -704,16 +704,17 @@ public class Main implements MageServer {
|
|||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void joinGame(final UUID gameId, final String sessionId) throws MageException {
|
||||
@Override
|
||||
public UUID joinGame(final UUID gameId, final String sessionId) {
|
||||
// execute("joinGame", sessionId, new Action() {
|
||||
// @Override
|
||||
// public void execute() {
|
||||
// UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||
// GameManager.getInstance().joinGame(gameId, userId);
|
||||
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||
GameManager.getInstance().joinGame(gameId, userId);
|
||||
return GameManager.getInstance().getChatId(gameId);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public void joinDraft(final UUID draftId, final String sessionId) throws MageException {
|
||||
|
|
@ -1382,4 +1383,8 @@ public class Main implements MageServer {
|
|||
server.joinedTable(sessionId, roomId, tableId, chatId, owner, tournament);
|
||||
}
|
||||
|
||||
public void gameStarted(String sessionId, UUID gameId, UUID playerId) {
|
||||
server.gameStarted(sessionId, gameId, playerId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -581,7 +581,7 @@ public class TableController {
|
|||
if (!match.getPlayer(entry.getValue()).hasQuit()) {
|
||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||
if (user != null) {
|
||||
user.ccGameStarted(match.getGame().getId(), entry.getValue());
|
||||
user.gameStarted(match.getGame().getId(), entry.getValue());
|
||||
|
||||
if (creator == null) {
|
||||
creator = user.getName();
|
||||
|
|
|
|||
|
|
@ -193,8 +193,9 @@ public class User {
|
|||
Main.getInstance().joinedTable(sessionId, roomId, tableId, chatId, owner, tournament);
|
||||
}
|
||||
|
||||
public void ccGameStarted(final UUID gameId, final UUID playerId) {
|
||||
fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, playerId)));
|
||||
public void gameStarted(final UUID gameId, final UUID playerId) {
|
||||
// fireCallback(new ClientCallback("startGame", gameId, new TableClientMessage(gameId, playerId)));
|
||||
Main.getInstance().gameStarted(sessionId, gameId, playerId);
|
||||
}
|
||||
|
||||
public void ccDraftStarted(final UUID draftId, final UUID playerId) {
|
||||
|
|
@ -298,7 +299,7 @@ public class User {
|
|||
}
|
||||
|
||||
for (Entry<UUID, GameSessionPlayer> entry: gameSessions.entrySet()) {
|
||||
ccGameStarted(entry.getValue().getGameId(), entry.getKey());
|
||||
gameStarted(entry.getValue().getGameId(), entry.getKey());
|
||||
entry.getValue().init();
|
||||
GameManager.getInstance().sendPlayerString(entry.getValue().getGameId(), userId, "");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue