Merge branch 'master' into CommandFactory

# Conflicts:
#	racevisionGame/src/main/java/mock/app/ConnectionAcceptor.java
#	racevisionGame/src/main/java/mock/app/Event.java
#	racevisionGame/src/main/java/mock/model/commandFactory/TackGybeCommand.java
#	racevisionGame/src/main/java/mock/model/commandFactory/VMGCommand.java
#	racevisionGame/src/main/java/visualiser/gameController/ControllerServer.java
This commit is contained in:
zwu18
2017-08-12 03:18:24 +12:00
103 changed files with 6241 additions and 1880 deletions
@@ -1,23 +1,24 @@
package mock.model.commandFactory;
import java.util.Stack;
import java.util.ArrayDeque;
import java.util.Queue;
/**
* Wraps multiple commands into a composite to execute queued commands during a frame.
*/
public class CompositeCommand implements Command {
private Stack<Command> commands;
private Queue<Command> commands;
public CompositeCommand() {
this.commands = new Stack<>();
this.commands = new ArrayDeque<>();
}
public void addCommand(Command command) {
commands.push(command);
commands.add(command);
}
@Override
public void execute() {
while(!commands.isEmpty()) commands.pop().execute();
while(!commands.isEmpty()) commands.remove().execute();
}
}
@@ -15,16 +15,23 @@ public class WindCommand implements Command {
public WindCommand(MockRace race, MockBoat boat, boolean upwind) {
this.race = race;
this.boat = boat;
this.direction = upwind? 1 : -1;
this.direction = upwind? -1 : 1;
}
@Override
public void execute() {
boat.setAutoVMG(false);
double wind = race.getWindDirection().degrees();
double heading = boat.getBearing().degrees();
double offset = 3;
if(wind - heading < 0) offset *= -1 * direction;
double offset = 3.0;
offset *= direction;
double headWindDelta = wind - heading;
if ((headWindDelta < 0) || (headWindDelta > 180)) offset *= -1;
boat.setBearing(Bearing.fromDegrees(heading + offset));
}
}