mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
completed Room handling
This commit is contained in:
parent
e7bb3a0dbf
commit
bc51a8fc79
13 changed files with 357 additions and 147 deletions
|
|
@ -94,6 +94,7 @@ import mage.view.DraftPickView;
|
|||
import mage.view.GameView;
|
||||
import mage.view.MatchView;
|
||||
import mage.view.RoomUsersView;
|
||||
import mage.view.RoomView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.TournamentView;
|
||||
import mage.view.UserDataView;
|
||||
|
|
@ -419,22 +420,22 @@ public class Main implements MageServer {
|
|||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// //FIXME: why no sessionId here???
|
||||
// public List<TableView> getTables(UUID roomId) throws MageException {
|
||||
@Override
|
||||
//FIXME: why no sessionId here???
|
||||
public RoomView getRoom(UUID roomId) {
|
||||
// try {
|
||||
// GamesRoom room = GamesRoomManager.getInstance().getRoom(roomId);
|
||||
// if (room != null) {
|
||||
// return room.getTables();
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
GamesRoom room = GamesRoomManager.getInstance().getRoom(roomId);
|
||||
if (room != null) {
|
||||
return new RoomView(room.getRoomUsersInfo(), room.getTables(), room.getFinished());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
// }
|
||||
// catch (Exception ex) {
|
||||
// handleException(ex);
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// //FIXME: why no sessionId here???
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public interface GamesRoom extends Room {
|
|||
|
||||
List<TableView> getTables();
|
||||
List<MatchView> getFinished();
|
||||
List<RoomUsersView> getRoomUsersInfo();
|
||||
RoomUsersView getRoomUsersInfo();
|
||||
boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException;
|
||||
boolean joinTournamentTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws GameException;
|
||||
TableView createTable(UUID userId, MatchOptions options);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
private static final ScheduledExecutorService updateExecutor = Executors.newSingleThreadScheduledExecutor();
|
||||
private static List<TableView> tableView = new ArrayList<>();
|
||||
private static List<MatchView> matchView = new ArrayList<>();
|
||||
private static List<RoomUsersView> roomUsersView = new ArrayList<>();
|
||||
private static RoomUsersView roomUsersView;
|
||||
|
||||
private final ConcurrentHashMap<UUID, Table> tables = new ConcurrentHashMap<>();
|
||||
|
||||
|
|
@ -128,13 +128,13 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
}
|
||||
|
||||
Collections.sort(users, new UserNameSorter());
|
||||
List<RoomUsersView> roomUserInfo = new ArrayList<>();
|
||||
roomUserInfo.add(new RoomUsersView(users,
|
||||
// List<RoomUsersView> roomUserInfo = new ArrayList<>();
|
||||
roomUsersView = new RoomUsersView(users,
|
||||
GameManager.getInstance().getNumberActiveGames(),
|
||||
ThreadExecutor.getInstance().getActiveThreads(ThreadExecutor.getInstance().getGameExecutor()),
|
||||
ConfigSettings.getInstance().getMaxGameThreads()
|
||||
));
|
||||
roomUsersView = roomUserInfo;
|
||||
);
|
||||
// roomUsersView = roomUserInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -210,7 +210,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<RoomUsersView> getRoomUsersInfo() {
|
||||
public RoomUsersView getRoomUsersInfo() {
|
||||
return roomUsersView;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue