aligning action labels with documented examples

This commit is contained in:
Arthur Paulino 2017-12-31 09:34:43 -03:00
parent cca68ba139
commit 04374e6e0a
10 changed files with 58 additions and 58 deletions

View File

@ -15,8 +15,8 @@ public class CubotBattery extends CpuHardware {
public static final char HWID = 0x000A; public static final char HWID = 0x000A;
private Cubot cubot; private Cubot cubot;
private static final int POLL = 1; private static final int BATTERY_POLL = 1;
private static final int GET_MAX_CAPACITY = 2; private static final int BATTERY_GET_MAX_CAPACITY = 2;
public CubotBattery(Cubot cubot) { public CubotBattery(Cubot cubot) {
this.cubot = cubot; this.cubot = cubot;
@ -27,10 +27,10 @@ public class CubotBattery extends CpuHardware {
int a = getCpu().getRegisterSet().getRegister("A").getValue(); int a = getCpu().getRegisterSet().getRegister("A").getValue();
if (a == POLL) { if (a == BATTERY_POLL) {
getCpu().getRegisterSet().getRegister("B").setValue(cubot.getEnergy()); getCpu().getRegisterSet().getRegister("B").setValue(cubot.getEnergy());
} else if (a == GET_MAX_CAPACITY) { } else if (a == BATTERY_GET_MAX_CAPACITY) {
getCpu().getRegisterSet().getRegister("B").setValue(cubot.getMaxEnergy()); getCpu().getRegisterSet().getRegister("B").setValue(cubot.getMaxEnergy());
} else if (a == 0xFFFF) { } else if (a == 0xFFFF) {
cubot.setEnergy(cubot.getMaxEnergy()); cubot.setEnergy(cubot.getMaxEnergy());

View File

@ -17,10 +17,10 @@ public class CubotComPort extends CpuHardware {
private Cubot cubot; private Cubot cubot;
private static final int SELF_CLEAR = 0; private static final int COMPORT_SELF_CLEAR = 0;
private static final int POLL = 1; private static final int COMPORT_POLL = 1;
private static final int FRONT_PORT_OUT = 2; private static final int COMPORT_FRONT_PORT_OUT = 2;
private static final int SELF_OUT = 3; private static final int COMPORT_SELF_OUT = 3;
public CubotComPort(Cubot cubot) { public CubotComPort(Cubot cubot) {
this.cubot = cubot; this.cubot = cubot;
@ -33,12 +33,12 @@ public class CubotComPort extends CpuHardware {
int a = getCpu().getRegisterSet().getRegister("A").getValue(); int a = getCpu().getRegisterSet().getRegister("A").getValue();
if (a == SELF_CLEAR) { if (a == COMPORT_SELF_CLEAR) {
cubot.getConsoleMessagesBuffer().clear(); cubot.getConsoleMessagesBuffer().clear();
cubot.setConsoleMode(Cubot.ConsoleMode.CLEAR); cubot.setConsoleMode(Cubot.ConsoleMode.CLEAR);
} else if (a == POLL) { } else if (a == COMPORT_POLL) {
if (cubot.spendEnergy(4)) { if (cubot.spendEnergy(4)) {
@ -60,7 +60,7 @@ public class CubotComPort extends CpuHardware {
} }
} else if (a == FRONT_PORT_OUT) { } else if (a == COMPORT_FRONT_PORT_OUT) {
if (cubot.spendEnergy(20)) { if (cubot.spendEnergy(20)) {
//Get object directly in front of the Cubot //Get object directly in front of the Cubot
@ -89,7 +89,7 @@ public class CubotComPort extends CpuHardware {
} }
} }
} else if (a == SELF_OUT) { } else if (a == COMPORT_SELF_OUT) {
if (cubot.spendEnergy(1)) { if (cubot.spendEnergy(1)) {

View File

@ -16,9 +16,9 @@ public class CubotDrill extends CpuHardware {
public static final int DEFAULT_ADDRESS = 5; public static final int DEFAULT_ADDRESS = 5;
private static final int POLL = 1; private static final int DRILL_POLL = 1;
private static final int GATHER_SLOW = 2; private static final int DRILL_GATHER_SLOW = 2;
private static final int GATHER_FAST = 3; private static final int DRILL_GATHER_FAST = 3;
private Cubot cubot; private Cubot cubot;
@ -35,11 +35,11 @@ public class CubotDrill extends CpuHardware {
public void handleInterrupt(Status status) { public void handleInterrupt(Status status) {
int a = getCpu().getRegisterSet().getRegister("A").getValue(); int a = getCpu().getRegisterSet().getRegister("A").getValue();
if (a == POLL) { if (a == DRILL_POLL) {
getCpu().getRegisterSet().getRegister("B").setValue(0); getCpu().getRegisterSet().getRegister("B").setValue(0);
} else if (a == GATHER_SLOW || a == GATHER_FAST) { } else if (a == DRILL_GATHER_SLOW || a == DRILL_GATHER_FAST) {
if (cubot.spendEnergy(1400)) { if (cubot.spendEnergy(1400)) {
if (cubot.getCurrentAction() == Action.IDLE) { if (cubot.getCurrentAction() == Action.IDLE) {

View File

@ -14,9 +14,9 @@ public class CubotFloppyDrive extends CpuHardware {
public static final int DEFAULT_ADDRESS = 0x000B; public static final int DEFAULT_ADDRESS = 0x000B;
private static final int POLL = 1; private static final int FLOPPY_POLL = 1;
private static final int READ_SECTOR = 2; private static final int FLOPPY_READ_SECTOR = 2;
private static final int WRITE_SECTOR = 3; private static final int FLOPPY_WRITE_SECTOR = 3;
private Cubot cubot; private Cubot cubot;
private FloppyDisk floppyDisk; private FloppyDisk floppyDisk;
@ -31,7 +31,7 @@ public class CubotFloppyDrive extends CpuHardware {
public void handleInterrupt(Status status) { public void handleInterrupt(Status status) {
int a = getCpu().getRegisterSet().getRegister("A").getValue(); int a = getCpu().getRegisterSet().getRegister("A").getValue();
if (a == POLL) { if (a == FLOPPY_POLL) {
if (floppyDisk != null) { if (floppyDisk != null) {
getCpu().getRegisterSet().getRegister("B").setValue(0); getCpu().getRegisterSet().getRegister("B").setValue(0);
@ -39,7 +39,7 @@ public class CubotFloppyDrive extends CpuHardware {
getCpu().getRegisterSet().getRegister("B").setValue(1); getCpu().getRegisterSet().getRegister("B").setValue(1);
} }
} else if (a == READ_SECTOR) { } else if (a == FLOPPY_READ_SECTOR) {
if (floppyDisk == null) { if (floppyDisk == null) {
getCpu().getRegisterSet().getRegister("B").setValue(0); getCpu().getRegisterSet().getRegister("B").setValue(0);
@ -55,7 +55,7 @@ public class CubotFloppyDrive extends CpuHardware {
} }
} else if (a == WRITE_SECTOR) { } else if (a == FLOPPY_WRITE_SECTOR) {
if (floppyDisk == null) { if (floppyDisk == null) {
getCpu().getRegisterSet().getRegister("B").setValue(0); getCpu().getRegisterSet().getRegister("B").setValue(0);
} else { } else {

View File

@ -17,11 +17,11 @@ public class CubotHologram extends CpuHardware {
private Cubot cubot; private Cubot cubot;
private static final int CLEAR = 0; private static final int HOLO_CLEAR = 0;
private static final int DISPLAY_HEX = 1; private static final int HOLO_DISPLAY_HEX = 1;
private static final int DISPLAY_STRING = 2; private static final int HOLO_DISPLAY_STRING = 2;
private static final int DISPLAY_DEC = 3; private static final int HOLO_DISPLAY_DEC = 3;
private static final int DISPLAY_COLOR = 4; private static final int HOLO_DISPLAY_COLOR = 4;
private static final int STR_MAX_LEN = 8; private static final int STR_MAX_LEN = 8;
@ -34,13 +34,13 @@ public class CubotHologram extends CpuHardware {
char a = getCpu().getRegisterSet().getRegister("A").getValue(); char a = getCpu().getRegisterSet().getRegister("A").getValue();
if (a == CLEAR) { if (a == HOLO_CLEAR) {
cubot.setHologramMode(Cubot.HologramMode.CLEARED); cubot.setHologramMode(Cubot.HologramMode.CLEARED);
} else if (a == DISPLAY_HEX) { } else if (a == HOLO_DISPLAY_HEX) {
char b = getCpu().getRegisterSet().getRegister("B").getValue(); char b = getCpu().getRegisterSet().getRegister("B").getValue();
cubot.setHologram(b); cubot.setHologram(b);
cubot.setHologramMode(Cubot.HologramMode.HEX); cubot.setHologramMode(Cubot.HologramMode.HEX);
} else if (a == DISPLAY_STRING) { } else if (a == HOLO_DISPLAY_STRING) {
char x = getCpu().getRegisterSet().getRegister("X").getValue(); char x = getCpu().getRegisterSet().getRegister("X").getValue();
//Display zero-terminated string starting at X (max 8 chars) //Display zero-terminated string starting at X (max 8 chars)
@ -59,13 +59,13 @@ public class CubotHologram extends CpuHardware {
cubot.setHologramString(holoString.toString()); cubot.setHologramString(holoString.toString());
cubot.setHologramMode(Cubot.HologramMode.STRING); cubot.setHologramMode(Cubot.HologramMode.STRING);
} else if (a == DISPLAY_DEC) { } else if (a == HOLO_DISPLAY_DEC) {
//Display decimal number //Display decimal number
char b = getCpu().getRegisterSet().getRegister("B").getValue(); char b = getCpu().getRegisterSet().getRegister("B").getValue();
cubot.setHologram(b); cubot.setHologram(b);
cubot.setHologramMode(Cubot.HologramMode.DEC); cubot.setHologramMode(Cubot.HologramMode.DEC);
} else if (a == DISPLAY_COLOR) { } else if (a == HOLO_DISPLAY_COLOR) {
if (cubot.spendEnergy(4)) { if (cubot.spendEnergy(4)) {
int b = getCpu().getRegisterSet().getRegister("B").getValue(); int b = getCpu().getRegisterSet().getRegister("B").getValue();

View File

@ -16,8 +16,8 @@ public class CubotInventory extends CpuHardware {
private Cubot cubot; private Cubot cubot;
private static final int CLEAR = 0; private static final int INV_CLEAR = 0;
private static final int POLL = 1; private static final int INV_POLL = 1;
public CubotInventory(Cubot cubot) { public CubotInventory(Cubot cubot) {
this.cubot = cubot; this.cubot = cubot;
@ -33,11 +33,11 @@ public class CubotInventory extends CpuHardware {
int a = getCpu().getRegisterSet().getRegister("A").getValue(); int a = getCpu().getRegisterSet().getRegister("A").getValue();
if (a == POLL) { if (a == INV_POLL) {
getCpu().getRegisterSet().getRegister("B").setValue(cubot.getHeldItem()); getCpu().getRegisterSet().getRegister("B").setValue(cubot.getHeldItem());
} else if (a == CLEAR) { } else if (a == INV_CLEAR) {
if (cubot.spendEnergy(100)) { if (cubot.spendEnergy(100)) {
cubot.setHeldItem(0); cubot.setHeldItem(0);
} }

View File

@ -9,8 +9,8 @@ public class CubotKeyboard extends CpuHardware {
public static final int DEFAULT_ADDRESS = 4; public static final int DEFAULT_ADDRESS = 4;
private static final int CLEAR_BUFFER = 0; private static final int KEYBOARD_CLEAR_BUFFER = 0;
private static final int FETCH_KEY = 1; private static final int KEYBOARD_FETCH_KEY = 1;
/** /**
* Hardware ID (Should be unique) * Hardware ID (Should be unique)
@ -33,11 +33,11 @@ public class CubotKeyboard extends CpuHardware {
int a = getCpu().getRegisterSet().getRegister("A").getValue(); int a = getCpu().getRegisterSet().getRegister("A").getValue();
if (a == CLEAR_BUFFER) { if (a == KEYBOARD_CLEAR_BUFFER) {
cubot.clearKeyboardBuffer(); cubot.clearKeyboardBuffer();
} else if (a == FETCH_KEY) { } else if (a == KEYBOARD_FETCH_KEY) {
//pop //pop
int key = 0; int key = 0;
if (cubot.getKeyboardBuffer().size() > 0) { if (cubot.getKeyboardBuffer().size() > 0) {

View File

@ -22,8 +22,8 @@ public class CubotLaser extends CpuHardware {
private Cubot cubot; private Cubot cubot;
private static final int WITHDRAW = 1; private static final int LASER_WITHDRAW = 1;
private static final int DEPOSIT = 2; private static final int LASER_DEPOSIT = 2;
public CubotLaser(Cubot cubot) { public CubotLaser(Cubot cubot) {
@ -42,7 +42,7 @@ public class CubotLaser extends CpuHardware {
int b = getCpu().getRegisterSet().getRegister("B").getValue(); int b = getCpu().getRegisterSet().getRegister("B").getValue();
if (a == WITHDRAW) { if (a == LASER_WITHDRAW) {
Point frontTile = cubot.getFrontTile(); Point frontTile = cubot.getFrontTile();
@ -65,8 +65,8 @@ public class CubotLaser extends CpuHardware {
} }
} else if (a == DEPOSIT) { } else if (a == LASER_DEPOSIT) {
// TODO
} }
} }

View File

@ -14,8 +14,8 @@ public class CubotLeg extends CpuHardware implements JSONSerialisable {
public static final String NAME = "Cubot Leg"; public static final String NAME = "Cubot Leg";
private static final int SET_DIR = 1; private static final int LEGS_SET_DIR = 1;
private static final int SET_DIR_AND_WALK = 2; private static final int LEGS_SET_DIR_AND_WALK = 2;
/** /**
* Hardware ID (Should be unique) * Hardware ID (Should be unique)
@ -38,7 +38,7 @@ public class CubotLeg extends CpuHardware implements JSONSerialisable {
int a = getCpu().getRegisterSet().getRegister("A").getValue(); int a = getCpu().getRegisterSet().getRegister("A").getValue();
int b = getCpu().getRegisterSet().getRegister("B").getValue(); int b = getCpu().getRegisterSet().getRegister("B").getValue();
if (a == SET_DIR) { if (a == LEGS_SET_DIR) {
Direction dir = Direction.getDirection(b); Direction dir = Direction.getDirection(b);
@ -53,7 +53,7 @@ public class CubotLeg extends CpuHardware implements JSONSerialisable {
} }
} else if (a == SET_DIR_AND_WALK) { } else if (a == LEGS_SET_DIR_AND_WALK) {
if (cubot.getMaxEnergy() >= 100) { if (cubot.getMaxEnergy() >= 100) {
Direction dir = Direction.getDirection(b); Direction dir = Direction.getDirection(b);

View File

@ -24,10 +24,10 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable {
private Cubot cubot; private Cubot cubot;
private static final int GET_POS = 1; private static final int LIDAR_GET_POS = 1;
private static final int GET_PATH = 2; private static final int LIDAR_GET_PATH = 2;
private static final int GET_MAP = 3; private static final int LIDAR_GET_MAP = 3;
private static final int GET_WORLD_POS = 4; private static final int LIDAR_GET_WORLD_POS = 4;
private static final int MEMORY_MAP_START = 0x0100; private static final int MEMORY_MAP_START = 0x0100;
private static final int MEMORY_PATH_START = 0x0000; private static final int MEMORY_PATH_START = 0x0000;
@ -48,11 +48,11 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable {
int a = getCpu().getRegisterSet().getRegister("A").getValue(); int a = getCpu().getRegisterSet().getRegister("A").getValue();
switch (a) { switch (a) {
case GET_POS: case LIDAR_GET_POS:
getCpu().getRegisterSet().getRegister("X").setValue(cubot.getX()); getCpu().getRegisterSet().getRegister("X").setValue(cubot.getX());
getCpu().getRegisterSet().getRegister("Y").setValue(cubot.getY()); getCpu().getRegisterSet().getRegister("Y").setValue(cubot.getY());
break; break;
case GET_PATH: case LIDAR_GET_PATH:
if (cubot.spendEnergy(50)) { if (cubot.spendEnergy(50)) {
int b = getCpu().getRegisterSet().getRegister("B").getValue(); int b = getCpu().getRegisterSet().getRegister("B").getValue();
int destX = getCpu().getRegisterSet().getRegister("X").getValue(); int destX = getCpu().getRegisterSet().getRegister("X").getValue();
@ -108,7 +108,7 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable {
break; break;
case GET_MAP: case LIDAR_GET_MAP:
if (cubot.spendEnergy(10)) { if (cubot.spendEnergy(10)) {
char[][] mapInfo = cubot.getWorld().getMapInfo(); char[][] mapInfo = cubot.getWorld().getMapInfo();
@ -121,7 +121,7 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable {
} }
break; break;
case GET_WORLD_POS: case LIDAR_GET_WORLD_POS:
getCpu().getRegisterSet().getRegister("X").setValue(cubot.getWorld().getX()); getCpu().getRegisterSet().getRegister("X").setValue(cubot.getWorld().getX());
getCpu().getRegisterSet().getRegister("Y").setValue(cubot.getWorld().getY()); getCpu().getRegisterSet().getRegister("Y").setValue(cubot.getWorld().getY());
break; break;