From 98606247f6a16bbbae0afd717113d303c4ae8cee Mon Sep 17 00:00:00 2001 From: Arthur Paulino Date: Sat, 30 Dec 2017 19:15:31 -0300 Subject: [PATCH] changing action labels to be concise with constants without conflicts - arthur --- .../simon987/cubotplugin/CubotBattery.java | 6 +++--- .../net/simon987/cubotplugin/CubotDrill.java | 10 +++++----- .../cubotplugin/CubotFloppyDrive.java | 12 +++++------ .../simon987/cubotplugin/CubotHologram.java | 20 +++++++++---------- .../simon987/cubotplugin/CubotInventory.java | 8 ++++---- .../net/simon987/cubotplugin/CubotLaser.java | 10 +++++----- .../net/simon987/cubotplugin/CubotLeg.java | 8 ++++---- .../net/simon987/cubotplugin/CubotLidar.java | 16 +++++++-------- .../net/simon987/cubotplugin/Keyboard.java | 8 ++++---- 9 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotBattery.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotBattery.java index 93f57d2..a59bea8 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotBattery.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotBattery.java @@ -15,8 +15,8 @@ public class CubotBattery extends CpuHardware { public static final char HWID = 0x000A; private Cubot cubot; - private static final int POLL = 1; - private static final int GET_MAX_CAPACITY = 2; + private static final int BATTERY_POLL = 1; + private static final int BATTERY_GET_MAX_CAPACITY = 2; public CubotBattery(Cubot cubot) { this.cubot = cubot; @@ -30,7 +30,7 @@ public class CubotBattery extends CpuHardware { if (a == POLL) { 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()); } else if (a == 0xFFFF) { cubot.setEnergy(cubot.getMaxEnergy()); diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java index 6faf457..e5d954a 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotDrill.java @@ -16,9 +16,9 @@ public class CubotDrill extends CpuHardware { public static final int DEFAULT_ADDRESS = 5; - private static final int POLL = 1; - private static final int GATHER_SLOW = 2; - private static final int GATHER_FAST = 3; + private static final int DRILL_POLL = 1; + private static final int DRILL_GATHER_SLOW = 2; + private static final int DRILL_GATHER_FAST = 3; private Cubot cubot; @@ -35,11 +35,11 @@ public class CubotDrill extends CpuHardware { public void handleInterrupt(Status status) { int a = getCpu().getRegisterSet().getRegister("A").getValue(); - if (a == POLL) { + if (a == DRILL_POLL) { 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.getCurrentAction() == Action.IDLE) { diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotFloppyDrive.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotFloppyDrive.java index efa609e..3b11a06 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotFloppyDrive.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotFloppyDrive.java @@ -14,9 +14,9 @@ public class CubotFloppyDrive extends CpuHardware { public static final int DEFAULT_ADDRESS = 0x000B; - private static final int POLL = 1; - private static final int READ_SECTOR = 2; - private static final int WRITE_SECTOR = 3; + private static final int FLOPPY_POLL = 1; + private static final int FLOPPY_READ_SECTOR = 2; + private static final int FLOPPY_WRITE_SECTOR = 3; private Cubot cubot; private FloppyDisk floppyDisk; @@ -31,7 +31,7 @@ public class CubotFloppyDrive extends CpuHardware { public void handleInterrupt(Status status) { int a = getCpu().getRegisterSet().getRegister("A").getValue(); - if (a == POLL) { + if (a == FLOPPY_POLL) { if (floppyDisk != null) { getCpu().getRegisterSet().getRegister("B").setValue(0); @@ -39,7 +39,7 @@ public class CubotFloppyDrive extends CpuHardware { getCpu().getRegisterSet().getRegister("B").setValue(1); } - } else if (a == READ_SECTOR) { + } else if (a == FLOPPY_READ_SECTOR) { if (floppyDisk == null) { 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) { getCpu().getRegisterSet().getRegister("B").setValue(0); } else { diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotHologram.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotHologram.java index 9729311..697966d 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotHologram.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotHologram.java @@ -17,11 +17,11 @@ public class CubotHologram extends CpuHardware { private Cubot cubot; - private static final int CLEAR = 0; - private static final int DISPLAY_HEX = 1; - private static final int DISPLAY_STRING = 2; - private static final int DISPLAY_DEC = 3; - private static final int DISPLAY_COLOR = 4; + private static final int HOLO_CLEAR = 0; + private static final int HOLO_DISPLAY_HEX = 1; + private static final int HOLO_DISPLAY_STRING = 2; + private static final int HOLO_DISPLAY_DEC = 3; + private static final int HOLO_DISPLAY_COLOR = 4; private static final int STR_MAX_LEN = 8; @@ -34,13 +34,13 @@ public class CubotHologram extends CpuHardware { char a = getCpu().getRegisterSet().getRegister("A").getValue(); - if (a == CLEAR) { + if (a == HOLO_CLEAR) { cubot.setHologramMode(Cubot.HologramMode.CLEARED); - } else if (a == DISPLAY_HEX) { + } else if (a == HOLO_DISPLAY_HEX) { char b = getCpu().getRegisterSet().getRegister("B").getValue(); cubot.setHologram(b); cubot.setHologramMode(Cubot.HologramMode.HEX); - } else if (a == DISPLAY_STRING) { + } else if (a == HOLO_DISPLAY_STRING) { char x = getCpu().getRegisterSet().getRegister("X").getValue(); //Display zero-terminated string starting at X (max 8 chars) @@ -59,13 +59,13 @@ public class CubotHologram extends CpuHardware { cubot.setHologramString(holoString.toString()); cubot.setHologramMode(Cubot.HologramMode.STRING); - } else if (a == DISPLAY_DEC) { + } else if (a == HOLO_DISPLAY_DEC) { //Display decimal number char b = getCpu().getRegisterSet().getRegister("B").getValue(); cubot.setHologram(b); cubot.setHologramMode(Cubot.HologramMode.DEC); - } else if (a == DISPLAY_COLOR) { + } else if (a == HOLO_DISPLAY_COLOR) { if (cubot.spendEnergy(4)) { int b = getCpu().getRegisterSet().getRegister("B").getValue(); diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotInventory.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotInventory.java index bf44d46..efd4342 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotInventory.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotInventory.java @@ -16,8 +16,8 @@ public class CubotInventory extends CpuHardware { private Cubot cubot; - private static final int CLEAR = 0; - private static final int POLL = 1; + private static final int INV_CLEAR = 0; + private static final int INV_POLL = 1; public CubotInventory(Cubot cubot) { this.cubot = cubot; @@ -33,11 +33,11 @@ public class CubotInventory extends CpuHardware { int a = getCpu().getRegisterSet().getRegister("A").getValue(); - if (a == POLL) { + if (a == INV_POLL) { getCpu().getRegisterSet().getRegister("B").setValue(cubot.getHeldItem()); - } else if (a == CLEAR) { + } else if (a == INV_CLEAR) { if (cubot.spendEnergy(100)) { cubot.setHeldItem(0); } diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java index 41688e2..e66bbf1 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLaser.java @@ -22,8 +22,8 @@ public class CubotLaser extends CpuHardware { private Cubot cubot; - private static final int WITHDRAW = 1; - private static final int DEPOSIT = 2; + private static final int LASER_WITHDRAW = 1; + private static final int LASER_DEPOSIT = 2; public CubotLaser(Cubot cubot) { @@ -42,7 +42,7 @@ public class CubotLaser extends CpuHardware { int b = getCpu().getRegisterSet().getRegister("B").getValue(); - if (a == WITHDRAW) { + if (a == LASER_WITHDRAW) { Point frontTile = cubot.getFrontTile(); @@ -65,8 +65,8 @@ public class CubotLaser extends CpuHardware { } - } else if (a == DEPOSIT) { - + } else if (a == LASER_DEPOSIT) { + // TODO } } diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLeg.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLeg.java index b10a456..d5195fe 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLeg.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLeg.java @@ -14,8 +14,8 @@ public class CubotLeg extends CpuHardware implements JSONSerialisable { public static final String NAME = "Cubot Leg"; - private static final int SET_DIR = 1; - private static final int SET_DIR_AND_WALK = 2; + private static final int LEGS_SET_DIR = 1; + private static final int LEGS_SET_DIR_AND_WALK = 2; /** * Hardware ID (Should be unique) @@ -38,7 +38,7 @@ public class CubotLeg extends CpuHardware implements JSONSerialisable { int a = getCpu().getRegisterSet().getRegister("A").getValue(); int b = getCpu().getRegisterSet().getRegister("B").getValue(); - if (a == SET_DIR) { + if (a == LEGS_SET_DIR) { 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) { Direction dir = Direction.getDirection(b); diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java index ccfaa36..70974a7 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/CubotLidar.java @@ -24,10 +24,10 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable { private Cubot cubot; - private static final int GET_POS = 1; - private static final int GET_PATH = 2; - private static final int GET_MAP = 3; - private static final int GET_WORLD_POS = 4; + private static final int LIDAR_GET_POS = 1; + private static final int LIDAR_GET_PATH = 2; + private static final int LIDAR_GET_MAP = 3; + private static final int LIDAR_GET_WORLD_POS = 4; private static final int MEMORY_MAP_START = 0x0100; 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(); switch (a) { - case GET_POS: + case LIDAR_GET_POS: getCpu().getRegisterSet().getRegister("X").setValue(cubot.getX()); getCpu().getRegisterSet().getRegister("Y").setValue(cubot.getY()); break; - case GET_PATH: + case LIDAR_GET_PATH: if (cubot.spendEnergy(50)) { int b = getCpu().getRegisterSet().getRegister("B").getValue(); int destX = getCpu().getRegisterSet().getRegister("X").getValue(); @@ -108,7 +108,7 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable { break; - case GET_MAP: + case LIDAR_GET_MAP: if (cubot.spendEnergy(10)) { char[][] mapInfo = cubot.getWorld().getMapInfo(); @@ -121,7 +121,7 @@ public class CubotLidar extends CpuHardware implements JSONSerialisable { } break; - case GET_WORLD_POS: + case LIDAR_GET_WORLD_POS: getCpu().getRegisterSet().getRegister("X").setValue(cubot.getWorld().getX()); getCpu().getRegisterSet().getRegister("Y").setValue(cubot.getWorld().getY()); break; diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Keyboard.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Keyboard.java index ec05d59..d113075 100644 --- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Keyboard.java +++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Keyboard.java @@ -9,8 +9,8 @@ public class Keyboard extends CpuHardware { public static final int DEFAULT_ADDRESS = 4; - private static final int CLEAR_BUFFER = 0; - private static final int FETCH_KEY = 1; + private static final int KEYBOARD_CLEAR = 0; + private static final int KEYBOARD_FETCH_KEY = 1; /** * Hardware ID (Should be unique) @@ -33,11 +33,11 @@ public class Keyboard extends CpuHardware { int a = getCpu().getRegisterSet().getRegister("A").getValue(); - if (a == CLEAR_BUFFER) { + if (a == KEYBOARD_CLEAR) { cubot.clearKeyboardBuffer(); - } else if (a == FETCH_KEY) { + } else if (a == KEYBOARD_FETCH_KEY) { //pop int key = 0; if (cubot.getKeyboardBuffer().size() > 0) {