mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Changed the boatType attribute from all around the place from String lit to enum
#story[1274]
This commit is contained in:
@@ -18,6 +18,7 @@ import seng302.utilities.XMLParser;
|
|||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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)
|
||||||
@@ -704,7 +705,7 @@ public class GameState implements Runnable {
|
|||||||
playerYacht.setBoatColor(yachtColor);
|
playerYacht.setBoatColor(yachtColor);
|
||||||
} else if (requestType.equals(CustomizeRequestType.SHAPE)) {
|
} else if (requestType.equals(CustomizeRequestType.SHAPE)) {
|
||||||
String type = new String(customizeData);
|
String type = new String(customizeData);
|
||||||
playerYacht.setBoatType(type);
|
playerYacht.setBoatType(BoatMeshType.valueOf(type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import seng302.model.stream.packets.PacketType;
|
|||||||
import seng302.model.stream.packets.StreamPacket;
|
import seng302.model.stream.packets.StreamPacket;
|
||||||
import seng302.model.stream.xml.generator.RaceXMLTemplate;
|
import seng302.model.stream.xml.generator.RaceXMLTemplate;
|
||||||
import seng302.utilities.XMLGenerator;
|
import seng302.utilities.XMLGenerator;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class describing a single connection to a Client for the purposes of sending and receiving on
|
* A class describing a single connection to a Client for the purposes of sending and receiving on
|
||||||
@@ -125,7 +126,7 @@ public class ServerToClientThread implements Runnable {
|
|||||||
lName = all.get(ThreadLocalRandom.current().nextInt(0, all.size()));
|
lName = all.get(ThreadLocalRandom.current().nextInt(0, all.size()));
|
||||||
|
|
||||||
ServerYacht yacht = new ServerYacht(
|
ServerYacht yacht = new ServerYacht(
|
||||||
"DINGHY", sourceId, sourceId.toString(), fName, fName + " " + lName, "NZ"
|
BoatMeshType.DINGHY, sourceId, sourceId.toString(), fName, fName + " " + lName, "NZ"
|
||||||
);
|
);
|
||||||
|
|
||||||
player = new Player(socket, yacht);
|
player = new Player(socket, yacht);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import javafx.beans.property.ReadOnlyLongWrapper;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses)
|
* Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses)
|
||||||
@@ -37,7 +38,7 @@ public class ClientYacht extends Observable {
|
|||||||
private Logger logger = LoggerFactory.getLogger(ClientYacht.class);
|
private Logger logger = LoggerFactory.getLogger(ClientYacht.class);
|
||||||
|
|
||||||
|
|
||||||
private String boatType;
|
private BoatMeshType boatType;
|
||||||
private Integer sourceId;
|
private Integer sourceId;
|
||||||
private String hullID; //matches HullNum in the XML spec.
|
private String hullID; //matches HullNum in the XML spec.
|
||||||
private String shortName;
|
private String shortName;
|
||||||
@@ -64,7 +65,7 @@ public class ClientYacht extends Observable {
|
|||||||
private ReadOnlyIntegerWrapper placingProperty = new ReadOnlyIntegerWrapper();
|
private ReadOnlyIntegerWrapper placingProperty = new ReadOnlyIntegerWrapper();
|
||||||
private Color colour;
|
private Color colour;
|
||||||
|
|
||||||
public ClientYacht(String boatType, Integer sourceId, String hullID, String shortName,
|
public ClientYacht(BoatMeshType boatType, Integer sourceId, String hullID, String shortName,
|
||||||
String boatName, String country) {
|
String boatName, String country) {
|
||||||
this.boatType = boatType;
|
this.boatType = boatType;
|
||||||
this.sourceId = sourceId;
|
this.sourceId = sourceId;
|
||||||
@@ -88,7 +89,7 @@ public class ClientYacht extends Observable {
|
|||||||
super.addObserver(o);
|
super.addObserver(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBoatType() {
|
public BoatMeshType getBoatType() {
|
||||||
return boatType;
|
return boatType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import seng302.utilities.GeoUtility;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses)
|
* Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses)
|
||||||
@@ -25,7 +26,7 @@ public class ServerYacht {
|
|||||||
public static final Double TURN_STEP = 5.0;
|
public static final Double TURN_STEP = 5.0;
|
||||||
|
|
||||||
//Boat info
|
//Boat info
|
||||||
private String boatType;
|
private BoatMeshType boatType;
|
||||||
private Integer sourceId;
|
private Integer sourceId;
|
||||||
private String hullID; //matches HullNum in the XML spec.
|
private String hullID; //matches HullNum in the XML spec.
|
||||||
private String shortName;
|
private String shortName;
|
||||||
@@ -57,7 +58,7 @@ public class ServerYacht {
|
|||||||
private Long powerUpStartTime;
|
private Long powerUpStartTime;
|
||||||
|
|
||||||
|
|
||||||
public ServerYacht(String boatType, Integer sourceId, String hullID, String shortName,
|
public ServerYacht(BoatMeshType boatType, Integer sourceId, String hullID, String shortName,
|
||||||
String boatName, String country) {
|
String boatName, String country) {
|
||||||
this.boatType = boatType;
|
this.boatType = boatType;
|
||||||
this.boatStatus = BoatStatus.PRESTART;
|
this.boatStatus = BoatStatus.PRESTART;
|
||||||
@@ -421,11 +422,11 @@ public class ServerYacht {
|
|||||||
return boatColor;
|
return boatColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBoatType(String boatType) {
|
public void setBoatType(BoatMeshType boatType) {
|
||||||
this.boatType = boatType;
|
this.boatType = boatType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBoatType() {
|
public BoatMeshType getBoatType() {
|
||||||
return boatType;
|
return boatType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import seng302.model.stream.xml.parser.RaceXMLData;
|
|||||||
import seng302.model.stream.xml.parser.RegattaXMLData;
|
import seng302.model.stream.xml.parser.RegattaXMLData;
|
||||||
import seng302.model.token.Token;
|
import seng302.model.token.Token;
|
||||||
import seng302.model.token.TokenType;
|
import seng302.model.token.TokenType;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for parsing XML documents
|
* Utilities for parsing XML documents
|
||||||
@@ -139,7 +140,7 @@ public class XMLParser {
|
|||||||
if (currentBoat.getNodeName().equals("Boat")) {
|
if (currentBoat.getNodeName().equals("Boat")) {
|
||||||
// Boat boat = new Boat(currentBoat);
|
// Boat boat = new Boat(currentBoat);
|
||||||
ClientYacht yacht = new ClientYacht(
|
ClientYacht yacht = new ClientYacht(
|
||||||
XMLParser.getNodeAttributeString(currentBoat, "Type"),
|
BoatMeshType.valueOf(XMLParser.getNodeAttributeString(currentBoat, "Type")),
|
||||||
XMLParser.getNodeAttributeInt(currentBoat, "SourceID"),
|
XMLParser.getNodeAttributeInt(currentBoat, "SourceID"),
|
||||||
XMLParser.getNodeAttributeString(currentBoat, "HullNum"),
|
XMLParser.getNodeAttributeString(currentBoat, "HullNum"),
|
||||||
XMLParser.getNodeAttributeString(currentBoat, "ShortName"),
|
XMLParser.getNodeAttributeString(currentBoat, "ShortName"),
|
||||||
|
|||||||
@@ -460,7 +460,7 @@ public class GameView3D {
|
|||||||
final List<Group> wakes = new ArrayList<>();
|
final List<Group> wakes = new ArrayList<>();
|
||||||
for (ClientYacht clientYacht : yachts) {
|
for (ClientYacht clientYacht : yachts) {
|
||||||
Color colour = clientYacht.getColour();
|
Color colour = clientYacht.getColour();
|
||||||
newBoat = new BoatObject(BoatMeshType.getBoatMeshType(clientYacht.getBoatType()));
|
newBoat = new BoatObject(clientYacht.getBoatType());
|
||||||
newBoat.setFill(colour);
|
newBoat.setFill(colour);
|
||||||
boatObjects.put(clientYacht, newBoat);
|
boatObjects.put(clientYacht, newBoat);
|
||||||
wakesGroup.getChildren().add(newBoat.getWake());
|
wakesGroup.getChildren().add(newBoat.getWake());
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class PlayerCell {
|
|||||||
this.playerId = playerId;
|
this.playerId = playerId;
|
||||||
this.name = yacht.getBoatName();
|
this.name = yacht.getBoatName();
|
||||||
this.boatColor = yacht.getColour();
|
this.boatColor = yacht.getColour();
|
||||||
this.boatType = BoatMeshType.getBoatMeshType(yacht.getBoatType());
|
this.boatType = yacht.getBoatType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|||||||
@@ -111,8 +111,8 @@ public class BoatCustomizeController implements Initializable{
|
|||||||
this.lobbyController = lobbyController;
|
this.lobbyController = lobbyController;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentBoat(String boatType) {
|
public void setCurrentBoat(BoatMeshType boatType) {
|
||||||
currentBoat = BoatMeshType.getBoatMeshType(boatType);
|
currentBoat = boatType;
|
||||||
displayCurrentBoat();
|
displayCurrentBoat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,19 +29,6 @@ public enum BoatMeshType {
|
|||||||
this.fixedSail = fixedSail;
|
this.fixedSail = fixedSail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BoatMeshType getBoatMeshType(String boatType) {
|
|
||||||
switch (boatType){
|
|
||||||
case "DINGHY":
|
|
||||||
return DINGHY;
|
|
||||||
case "CAT_ATE_A_MERINGUE":
|
|
||||||
return CAT_ATE_A_MERINGUE;
|
|
||||||
case "PIRATE_SHIP":
|
|
||||||
return PIRATE_SHIP;
|
|
||||||
default:
|
|
||||||
return DINGHY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//TODO kre39 make something not terrible to cycle through boat types
|
//TODO kre39 make something not terrible to cycle through boat types
|
||||||
public static BoatMeshType getNextBoatType(BoatMeshType boatType) {
|
public static BoatMeshType getNextBoatType(BoatMeshType boatType) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import seng302.gameServer.GameState;
|
import seng302.gameServer.GameState;
|
||||||
import seng302.utilities.GeoUtility;
|
import seng302.utilities.GeoUtility;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
|
||||||
import static seng302.gameServer.GameState.checkCollision;
|
import static seng302.gameServer.GameState.checkCollision;
|
||||||
|
|
||||||
@@ -14,8 +15,10 @@ import static seng302.gameServer.GameState.checkCollision;
|
|||||||
*/
|
*/
|
||||||
public class UpdateYachtTest {
|
public class UpdateYachtTest {
|
||||||
|
|
||||||
private ServerYacht yacht1 = new ServerYacht("Yacht", 1, "1", "Yacht" + 1, "Yacht" + 1, "Test1");
|
private ServerYacht yacht1 = new ServerYacht(BoatMeshType.DINGHY, 1, "1", "Yacht" + 1,
|
||||||
private ServerYacht yacht2 = new ServerYacht("Yacht", 2, "2", "Yacht" + 2, "Yacht" + 2, "Test2");
|
"Yacht" + 1, "Test1");
|
||||||
|
private ServerYacht yacht2 = new ServerYacht(BoatMeshType.DINGHY, 2, "2", "Yacht" + 2,
|
||||||
|
"Yacht" + 2, "Test2");
|
||||||
private GeoPoint geoPoint1 = new GeoPoint(50.0, 50.0);
|
private GeoPoint geoPoint1 = new GeoPoint(50.0, 50.0);
|
||||||
private GeoPoint geoPoint2 = GeoUtility.getGeoCoordinate(geoPoint1, 90.0, 50.0);
|
private GeoPoint geoPoint2 = GeoUtility.getGeoCoordinate(geoPoint1, 90.0, 50.0);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import org.junit.AfterClass;
|
|||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import seng302.gameServer.GameState;
|
import seng302.gameServer.GameState;
|
||||||
import seng302.model.ServerYacht;
|
import seng302.model.ServerYacht;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
|
||||||
|
|
||||||
public class YachtTest {
|
public class YachtTest {
|
||||||
@@ -17,7 +18,7 @@ public class YachtTest {
|
|||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() {
|
public static void setUp() {
|
||||||
new GameState("localhost");
|
new GameState("localhost");
|
||||||
y1 = new ServerYacht("Yacht", 1, "Y1", "Y1", "Yacht 1", "C1");
|
y1 = new ServerYacht(BoatMeshType.DINGHY, 1, "Y1", "Y1", "Yacht 1", "C1");
|
||||||
gs = new GameState("localhost");
|
gs = new GameState("localhost");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,11 +25,4 @@ public class BoatMeshTypeTest {
|
|||||||
Assert.assertEquals(BoatMeshType.DINGHY, prevBoat);
|
Assert.assertEquals(BoatMeshType.DINGHY, prevBoat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetBoatMeshType() {
|
|
||||||
BoatMeshType currentBoat = BoatMeshType.getBoatMeshType("DINGHY");
|
|
||||||
Assert.assertEquals(BoatMeshType.DINGHY, currentBoat);
|
|
||||||
BoatMeshType wrongBoat = BoatMeshType.getBoatMeshType("NOT A REAL BOAT");
|
|
||||||
Assert.assertEquals(BoatMeshType.DINGHY, wrongBoat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import seng302.model.ClientYacht;
|
import seng302.model.ClientYacht;
|
||||||
|
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by kre39 on 6/08/17.
|
* Created by kre39 on 6/08/17.
|
||||||
@@ -16,7 +17,7 @@ public class BoatSailAnimationToggleTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception{
|
public void setup() throws Exception{
|
||||||
yacht = new ClientYacht("Yacht", 1, "YACHT", "YAC", "Test Yacht", "NZ");
|
yacht = new ClientYacht(BoatMeshType.DINGHY, 1, "YACHT", "YAC", "Test Yacht", "NZ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user