mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-10 14:26:45 +00:00
Merge branch 'master' into dockerize
This commit is contained in:
commit
079a63e39c
@ -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;
|
||||
@ -27,10 +27,10 @@ public class CubotBattery extends CpuHardware {
|
||||
|
||||
int a = getCpu().getRegisterSet().getRegister("A").getValue();
|
||||
|
||||
if (a == POLL) {
|
||||
if (a == BATTERY_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());
|
||||
|
@ -17,10 +17,10 @@ public class CubotComPort extends CpuHardware {
|
||||
|
||||
private Cubot cubot;
|
||||
|
||||
private static final int SELF_CLEAR = 0;
|
||||
private static final int POLL = 1;
|
||||
private static final int FRONT_PORT_OUT = 2;
|
||||
private static final int SELF_OUT = 3;
|
||||
private static final int COMPORT_SELF_CLEAR = 0;
|
||||
private static final int COMPORT_POLL = 1;
|
||||
private static final int COMPORT_FRONT_PORT_OUT = 2;
|
||||
private static final int COMPORT_SELF_OUT = 3;
|
||||
|
||||
public CubotComPort(Cubot cubot) {
|
||||
this.cubot = cubot;
|
||||
@ -33,12 +33,12 @@ public class CubotComPort extends CpuHardware {
|
||||
|
||||
int a = getCpu().getRegisterSet().getRegister("A").getValue();
|
||||
|
||||
if (a == SELF_CLEAR) {
|
||||
if (a == COMPORT_SELF_CLEAR) {
|
||||
|
||||
cubot.getConsoleMessagesBuffer().clear();
|
||||
cubot.setConsoleMode(Cubot.ConsoleMode.CLEAR);
|
||||
|
||||
} else if (a == POLL) {
|
||||
} else if (a == COMPORT_POLL) {
|
||||
|
||||
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)) {
|
||||
//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)) {
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ public class CubotKeyboard 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_BUFFER = 0;
|
||||
private static final int KEYBOARD_FETCH_KEY = 1;
|
||||
|
||||
/**
|
||||
* Hardware ID (Should be unique)
|
||||
@ -33,11 +33,11 @@ public class CubotKeyboard extends CpuHardware {
|
||||
|
||||
int a = getCpu().getRegisterSet().getRegister("A").getValue();
|
||||
|
||||
if (a == CLEAR_BUFFER) {
|
||||
if (a == KEYBOARD_CLEAR_BUFFER) {
|
||||
|
||||
cubot.clearKeyboardBuffer();
|
||||
|
||||
} else if (a == FETCH_KEY) {
|
||||
} else if (a == KEYBOARD_FETCH_KEY) {
|
||||
//pop
|
||||
int key = 0;
|
||||
if (cubot.getKeyboardBuffer().size() > 0) {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
33
README.md
33
README.md
@ -7,17 +7,44 @@ In its current state, players can walk around the game universe and collect Biom
|
||||
Wiki: [GitHub](https://github.com/simon987/Much-Assembly-Required/wiki)
|
||||
Chat: [Slack](https://join.slack.com/t/muchassemblyrequired/shared_invite/enQtMjY3Mjc1OTUwNjEwLTkyOTIwOTA5OGY4MDVlMGI4NzM5YzlhMWJiMGY1OWE2NjUxODQ1NWQ1YTcxMTA1NGZkYzNjYzMyM2E1ODdmNzg)
|
||||
|
||||
## Requirements
|
||||
|
||||
# Deploying the server
|
||||
|
||||
Note: You can find the frontend [here](https://github.com/simon987/Much-Assembly-Required)
|
||||
|
||||
|
||||
## Linux (Ubuntu 16.04)
|
||||
```bash
|
||||
# Install tools
|
||||
sudo apt install git maven openjdk-8-jdk
|
||||
|
||||
# Obtain source files
|
||||
git clone https://github.com/simon987/Much-Assembly-Required.git
|
||||
|
||||
# Build
|
||||
cd Much-Assembly-Required
|
||||
mvn package
|
||||
|
||||
# Run
|
||||
cd target
|
||||
java -jar server-1.2a.jar
|
||||
```
|
||||
|
||||
## Windows
|
||||
Coming eventually...
|
||||
|
||||
## Docker
|
||||
### Requirements
|
||||
|
||||
1. [Docker Compose](https://docs.docker.com/compose/install/#install-compose) (and dependencies)
|
||||
|
||||
## Installation
|
||||
### Installation
|
||||
|
||||
Once Docker and Docker Compose are installed, you can build and start
|
||||
this application by running the following command inside this
|
||||
application's directory:
|
||||
|
||||
docker-compose up
|
||||
`docker-compose up`
|
||||
|
||||
This will start MySQL and then build and run this application. It will
|
||||
be available via http://localhost.
|
||||
|
Loading…
x
Reference in New Issue
Block a user