mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Fixed the Yacht clas so it now works.
Lists and Maps are instantiated as they should be in GameState which were creating NullPointers Introduced ServerLog to server to client threads for bug reporting Introduced some print statements to test the game state updating upon receiving key presses tags: #story[989] #refactor #fix
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
package seng302.gameServer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import seng302.models.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import seng302.models.Yacht;
|
||||
import seng302.server.messages.BoatActionType;
|
||||
|
||||
@@ -15,8 +13,6 @@ import seng302.server.messages.BoatActionType;
|
||||
*/
|
||||
public class GameState {
|
||||
|
||||
private static final Integer HEADING_STEP = 3;
|
||||
|
||||
private static Long previousUpdateTime;
|
||||
public static Double windDirection;
|
||||
private static Double windSpeed;
|
||||
@@ -30,6 +26,8 @@ public class GameState {
|
||||
public GameState(String hostIpAddress) {
|
||||
windDirection = 170d;
|
||||
windSpeed = 0d;
|
||||
yachts = new HashMap<>();
|
||||
players = new ArrayList<>();
|
||||
|
||||
|
||||
GameState.hostIpAddress = hostIpAddress;
|
||||
@@ -56,8 +54,8 @@ public class GameState {
|
||||
players.remove(player);
|
||||
}
|
||||
|
||||
public static void addYacht(Integer sourceId, Yacht yatch) {
|
||||
yachts.put(sourceId, yatch);
|
||||
public static void addYacht(Integer sourceId, Yacht yacht) {
|
||||
yachts.put(sourceId, yacht);
|
||||
}
|
||||
|
||||
public static Boolean getIsRaceStarted() {
|
||||
@@ -82,25 +80,38 @@ public class GameState {
|
||||
|
||||
public static void updateBoat(Integer sourceId, BoatActionType actionType) {
|
||||
Yacht playerYacht = yachts.get(sourceId);
|
||||
System.out.println("-----------------------");
|
||||
switch (actionType) {
|
||||
case VMG:
|
||||
System.out.println("Snapping to VMG");
|
||||
// TODO: 22/07/17 wmu16 - Add in the vmg calculation code here
|
||||
break;
|
||||
case SAILS_IN:
|
||||
playerYacht.toggleSailIn();
|
||||
System.out.println("Toggling Sails");
|
||||
break;
|
||||
case SAILS_OUT:
|
||||
playerYacht.toggleSailIn();
|
||||
System.out.println("Toggling Sails");
|
||||
break;
|
||||
case TACK_GYBE:
|
||||
playerYacht.tackGybe(windDirection);
|
||||
System.out.println("Tack/Gybe");
|
||||
break;
|
||||
case UPWIND:
|
||||
playerYacht.turnUpwind();
|
||||
System.out.println("Moving upwind");
|
||||
break;
|
||||
case DOWNWIND:
|
||||
playerYacht.turnDownwind();
|
||||
System.out.println("Moving downwind");
|
||||
break;
|
||||
}
|
||||
|
||||
System.out.println("-----------------------");
|
||||
System.out.println("Heading: " + playerYacht.getHeading());
|
||||
System.out.println("Sails are in: " + playerYacht.getSailIn());
|
||||
System.out.println("-----------------------\n");
|
||||
}
|
||||
|
||||
public static void update() {
|
||||
|
||||
Reference in New Issue
Block a user