mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Added method to send server debug messages to players
Tags: #story[1246]
This commit is contained in:
@@ -1,35 +1,12 @@
|
|||||||
package seng302.gameServer;
|
package seng302.gameServer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Set;
|
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import seng302.gameServer.messages.BoatAction;
|
import seng302.gameServer.messages.*;
|
||||||
import seng302.gameServer.messages.BoatStatus;
|
import seng302.model.*;
|
||||||
import seng302.gameServer.messages.ChatterMessage;
|
|
||||||
import seng302.gameServer.messages.CustomizeRequestType;
|
|
||||||
import seng302.gameServer.messages.MarkRoundingMessage;
|
|
||||||
import seng302.gameServer.messages.MarkType;
|
|
||||||
import seng302.gameServer.messages.Message;
|
|
||||||
import seng302.gameServer.messages.RoundingBoatStatus;
|
|
||||||
import seng302.gameServer.messages.YachtEventCodeMessage;
|
|
||||||
import seng302.gameServer.messages.YachtEventType;
|
|
||||||
import seng302.model.GeoPoint;
|
|
||||||
import seng302.model.Limit;
|
|
||||||
import seng302.model.Player;
|
|
||||||
import seng302.model.PolarTable;
|
|
||||||
import seng302.model.ServerYacht;
|
|
||||||
import seng302.model.mark.CompoundMark;
|
import seng302.model.mark.CompoundMark;
|
||||||
import seng302.model.mark.Mark;
|
import seng302.model.mark.Mark;
|
||||||
import seng302.model.mark.MarkOrder;
|
import seng302.model.mark.MarkOrder;
|
||||||
@@ -38,6 +15,10 @@ import seng302.model.token.TokenType;
|
|||||||
import seng302.utilities.GeoUtility;
|
import seng302.utilities.GeoUtility;
|
||||||
import seng302.utilities.XMLParser;
|
import seng302.utilities.XMLParser;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Static class to hold information about the current state of the game (model)
|
* A Static class to hold information about the current state of the game (model)
|
||||||
* Also contains logic for updating itself on regular time intervals on its own thread
|
* Also contains logic for updating itself on regular time intervals on its own thread
|
||||||
@@ -791,25 +772,27 @@ public class GameState implements Runnable {
|
|||||||
roundingMark.getSourceID()));
|
roundingMark.getSourceID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendServerMessage(String message){
|
||||||
|
notifyMessageListeners(new ChatterMessage(
|
||||||
|
420,
|
||||||
|
"SERVER: " + message
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
public static void processChatter(ChatterMessage chatterMessage, boolean isHost) {
|
public static void processChatter(ChatterMessage chatterMessage, boolean isHost) {
|
||||||
String chatterText = chatterMessage.getMessage();
|
String chatterText = chatterMessage.getMessage();
|
||||||
String[] words = chatterText.split("\\s+");
|
String[] words = chatterText.split("\\s+");
|
||||||
if (words.length > 2 && isHost) {
|
if (words.length > 2 && isHost) {
|
||||||
switch (words[2].trim()) {
|
switch (words[2].trim()) {
|
||||||
case ">speed":
|
case "/speed":
|
||||||
try {
|
try {
|
||||||
setSpeedMultiplier(Double.valueOf(words[3]));
|
sendServerMessage("Speed modifier set to x" + words[3]);
|
||||||
notifyMessageListeners(new ChatterMessage(
|
|
||||||
chatterMessage.getMessage_type(),
|
|
||||||
"SERVER: Speed modifier set to x" + words[3]
|
|
||||||
));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger logger = LoggerFactory.getLogger(GameState.class);
|
Logger logger = LoggerFactory.getLogger(GameState.class);
|
||||||
logger.error("cannot parse >speed value");
|
logger.error("cannot parse >speed value");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case ">finish":
|
case "/finish":
|
||||||
notifyMessageListeners(new ChatterMessage(
|
notifyMessageListeners(new ChatterMessage(
|
||||||
chatterMessage.getMessage_type(),
|
chatterMessage.getMessage_type(),
|
||||||
"SERVER: Game will now finish"
|
"SERVER: Game will now finish"
|
||||||
|
|||||||
@@ -2,12 +2,6 @@ package seng302.visualiser.controllers;
|
|||||||
|
|
||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXDialog;
|
import com.jfoenix.controls.JFXDialog;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.collections.ListChangeListener;
|
import javafx.collections.ListChangeListener;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
@@ -33,6 +27,13 @@ import seng302.visualiser.GameView;
|
|||||||
import seng302.visualiser.controllers.cells.PlayerCell;
|
import seng302.visualiser.controllers.cells.PlayerCell;
|
||||||
import seng302.visualiser.controllers.dialogs.BoatCustomizeController;
|
import seng302.visualiser.controllers.dialogs.BoatCustomizeController;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class LobbyController implements Initializable {
|
public class LobbyController implements Initializable {
|
||||||
|
|
||||||
//--------FXML BEGIN--------//
|
//--------FXML BEGIN--------//
|
||||||
|
|||||||
Reference in New Issue
Block a user