Skip to content

Commit

Permalink
Add the "survey coords" command function
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneLamoureux committed Jan 30, 2021
1 parent ff54773 commit 008b875
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'com.etiennelamoureux'
version = '1.0.0'
version = '1.1.0'
sourceCompatibility = '11'

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ private void run(Deque<String> arguments) {

switch (command) {
case SURVEY: {
hyperspaceCoordinates =
hyperspaceCoordinatesService.survey(arguments.pop(), arguments.pop());
try {
Float.parseFloat(arguments.peek());
hyperspaceCoordinates = hyperspaceCoordinatesService.survey(arguments.pop(),
Float.parseFloat(arguments.pop()), Float.parseFloat(arguments.pop()),
Float.parseFloat(arguments.pop()));
} catch (NumberFormatException e) {
hyperspaceCoordinates =
hyperspaceCoordinatesService.survey(arguments.pop(), arguments.pop());
}
break;
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public HyperspaceCoordinates survey(String system, String base) {
coordinatesRepository.findOneBySystemAndBase(system, base).blur());
}

public HyperspaceCoordinates survey(String system, float x, float y, float z) {
return new HyperspaceCoordinates(IdUtil.generate(system), new Coordinates(x, y, z).blur());
}

public HyperspaceCoordinates refresh(String string) {
HyperspaceCoordinates hyperspaceCoordinates = new HyperspaceCoordinates(string);

Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ usage: java -jar reverseFLHook.jar <command> <arguments> [<flags>]

# Commands
survey <system> <base>; Generates hyperspace coordinates (MK3 precision, valid for [28, 35] days)
survey <system> <x> <y> <z>; Generates hyperspace coordinates (MK3 precision, valid for [28, 35] days)
refresh <coords>; Generates new hyperspace coordinates at the same location as the ones provided (valid for [28, 35] days)

# Arguments
system System nickname, e.g. 'ew01' for Tau-37
base Base nickname, e.g. 'ew01_01_base' for Freeport-10
x X component of the coordinates, e.g. first number from the "/pos" server command
y Y component of the coordinates, e.g. second number from the "/pos" server command
z Z component of the coordinates, e.g. third number from the "/pos" server command
coords Full hyperspace coordinates string, e.g. '16FE3679-B69CDBB3-341841A5-C6AD29C4-DAFAA176-FD8A5201-2DFD9B72'

# Flags
Expand All @@ -16,7 +20,8 @@ usage: java -jar reverseFLHook.jar <command> <arguments> [<flags>]

# Examples
java -jar reverseFLHook.jar survey ew01 ew01_01_base -auto
java -jar reverseFLHook.ar refresh 16FE3679-B69CDBB3-341841A5-C6AD29C4-DAFAA176-FD8A5201-2DFD9B72 -copy
java -jar reverseFLHook.jar survey fp7_system -30937 -3400 -13054
java -jar reverseFLHook.jar refresh 16FE3679-B69CDBB3-341841A5-C6AD29C4-DAFAA176-FD8A5201-2DFD9B72 -copy

# License
BSD 3-Clause License (Revised), Etienne Lamoureux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ public class CommandLineControllerITest {
private ApplicationContext applicationContext;

@Test
public void whenSurveyingThenDontThrow() throws Exception {
public void whenSurveyingBaseThenDontThrow() throws Exception {
CommandLineController commandLineController =
applicationContext.getBean(CommandLineController.class);
commandLineController.run("survey", "ew01", "ew01_01_base");
}

@Test
public void whenSurveyingPositionThenDontThrow() throws Exception {
CommandLineController commandLineController =
applicationContext.getBean(CommandLineController.class);
commandLineController.run("survey", "fp7_system", "-30937", "-3400", "-13054");
}

@Test
public void whenRefreshingThenDontThrow() throws Exception {
CommandLineController commandLineController =
Expand Down

0 comments on commit 008b875

Please sign in to comment.