mirror of
https://github.com/correl/mage.git
synced 2025-01-13 11:01:58 +00:00
[minor] some formatting
This commit is contained in:
parent
105df2197f
commit
8c56231e15
3 changed files with 49 additions and 30 deletions
|
@ -55,6 +55,7 @@ import org.apache.log4j.Logger;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
|
@ -721,8 +722,8 @@ public class MageServerImpl implements MageServer {
|
|||
return new ServerState(
|
||||
GameFactory.getInstance().getGameTypes(),
|
||||
TournamentFactory.getInstance().getTournamentTypes(),
|
||||
PlayerFactory.getInstance().getPlayerTypes().toArray(new String[0]),
|
||||
DeckValidatorFactory.getInstance().getDeckTypes().toArray(new String[0]),
|
||||
PlayerFactory.getInstance().getPlayerTypes().toArray(new String[PlayerFactory.getInstance().getPlayerTypes().size()]),
|
||||
DeckValidatorFactory.getInstance().getDeckTypes().toArray(new String[DeckValidatorFactory.getInstance().getDeckTypes().size()]),
|
||||
testMode,
|
||||
Main.getVersion());
|
||||
}
|
||||
|
@ -841,7 +842,7 @@ public class MageServerImpl implements MageServer {
|
|||
@Override
|
||||
public void execute() {
|
||||
for (User user : UserManager.getInstance().getUsers()) {
|
||||
if (message.toLowerCase().startsWith("warn")) {
|
||||
if (message.toLowerCase(Locale.ENGLISH).startsWith("warn")) {
|
||||
user.fireCallback(new ClientCallback("serverMessage", null, new ChatMessage("SERVER", message, null, MessageColor.RED)));
|
||||
} else {
|
||||
user.fireCallback(new ClientCallback("serverMessage", null, new ChatMessage("SERVER", message, null, MessageColor.BLUE)));
|
||||
|
|
|
@ -57,8 +57,9 @@ public class GameManager {
|
|||
}
|
||||
|
||||
public void joinGame(UUID gameId, UUID userId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).join(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyChatSession(UUID gameId) {
|
||||
|
@ -66,64 +67,76 @@ public class GameManager {
|
|||
}
|
||||
|
||||
public UUID getChatId(UUID gameId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
return gameControllers.get(gameId).getChatId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void sendPlayerUUID(UUID gameId, UUID userId, UUID data) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).sendPlayerUUID(userId, data);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPlayerString(UUID gameId, UUID userId, String data) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).sendPlayerString(userId, data);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPlayerBoolean(UUID gameId, UUID userId, Boolean data) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).sendPlayerBoolean(userId, data);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPlayerInteger(UUID gameId, UUID userId, Integer data) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).sendPlayerInteger(userId, data);
|
||||
}
|
||||
}
|
||||
|
||||
public void concedeGame(UUID gameId, UUID userId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).concede(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void undo(UUID gameId, UUID userId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).undo(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void passPriorityUntilNextYourTurn(UUID gameId, UUID userId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).passPriorityUntilNextYourTurn(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void passTurnPriority(UUID gameId, UUID userId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).passTurnPriority(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void restorePriority(UUID gameId, UUID userId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).restorePriority(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void watchGame(UUID gameId, UUID userId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).watch(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void stopWatching(UUID gameId, UUID userId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).stopWatching(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSession(UUID userId) {
|
||||
|
@ -133,24 +146,28 @@ public class GameManager {
|
|||
}
|
||||
|
||||
public void kill(UUID gameId, UUID userId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).kill(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void cheat(UUID gameId, UUID userId, UUID playerId, DeckCardLists deckList) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).cheat(userId, playerId, deckList);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean cheat(UUID gameId, UUID userId, UUID playerId, String cardName) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
return gameControllers.get(gameId).cheat(userId, playerId, cardName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void timeout(UUID gameId, UUID userId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).timeout(userId);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeGame(UUID gameId) {
|
||||
|
@ -158,13 +175,15 @@ public class GameManager {
|
|||
}
|
||||
|
||||
public void saveGame(UUID gameId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
gameControllers.get(gameId).saveGame();
|
||||
}
|
||||
}
|
||||
|
||||
public GameView getGameView(UUID gameId, UUID userId, UUID playerId) {
|
||||
if (gameControllers.containsKey(gameId))
|
||||
if (gameControllers.containsKey(gameId)) {
|
||||
return gameControllers.get(gameId).getGameView(playerId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -115,9 +115,6 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
List<CardsView> piles = new ArrayList<CardsView>();
|
||||
piles.add(pile1);
|
||||
piles.add(pile2);
|
||||
user.fireCallback(new ClientCallback("gameChoosePile", game.getId(), new GameClientMessage(message, pile1, pile2)));
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +125,7 @@ public class GameSession extends GameWatcher {
|
|||
setupTimeout();
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null) {
|
||||
user.fireCallback(new ClientCallback("gameChoose", game.getId(), new GameClientMessage(choices.toArray(new String[0]), message)));
|
||||
user.fireCallback(new ClientCallback("gameChoose", game.getId(), new GameClientMessage(choices.toArray(new String[choices.size()]), message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,8 +170,9 @@ public class GameSession extends GameWatcher {
|
|||
}
|
||||
|
||||
private synchronized void setupTimeout() {
|
||||
if (!useTimeout)
|
||||
if (!useTimeout) {
|
||||
return;
|
||||
}
|
||||
cancelTimeout();
|
||||
futureTimeout = timeoutExecutor.schedule(
|
||||
new Runnable() {
|
||||
|
@ -222,8 +220,8 @@ public class GameSession extends GameWatcher {
|
|||
|
||||
if (player.getPlayersUnderYourControl().size() > 0) {
|
||||
Map<String, SimpleCardsView> handCards = new HashMap<String, SimpleCardsView>();
|
||||
for (UUID playerId : player.getPlayersUnderYourControl()) {
|
||||
Player opponent = game.getPlayer(playerId);
|
||||
for (UUID controlledPlayerId : player.getPlayersUnderYourControl()) {
|
||||
Player opponent = game.getPlayer(controlledPlayerId);
|
||||
handCards.put(opponent.getName(), new SimpleCardsView(opponent.getHand().getCards(game)));
|
||||
}
|
||||
gameView.setOpponentHands(handCards);
|
||||
|
@ -243,8 +241,9 @@ public class GameSession extends GameWatcher {
|
|||
|
||||
public void removeGame() {
|
||||
User user = UserManager.getInstance().getUser(userId);
|
||||
if (user != null)
|
||||
if (user != null) {
|
||||
user.removeGame(playerId);
|
||||
}
|
||||
}
|
||||
|
||||
public UUID getGameId() {
|
||||
|
|
Loading…
Reference in a new issue