mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-19 18:46:43 +00:00
Support for color in hologram. Renamed classes: fixes #72
This commit is contained in:
parent
1ed9e9e4db
commit
83f05efff6
@ -17,6 +17,7 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
|||||||
private String hologramString = "";
|
private String hologramString = "";
|
||||||
private HologramMode hologramMode = HologramMode.CLEARED;
|
private HologramMode hologramMode = HologramMode.CLEARED;
|
||||||
private HologramMode lastHologramMode = HologramMode.CLEARED;
|
private HologramMode lastHologramMode = HologramMode.CLEARED;
|
||||||
|
private int hologramColor = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hit points
|
* Hit points
|
||||||
@ -34,8 +35,6 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
|||||||
private ConsoleMode consoleMode = ConsoleMode.NORMAL;
|
private ConsoleMode consoleMode = ConsoleMode.NORMAL;
|
||||||
private ConsoleMode lastConsoleMode = ConsoleMode.NORMAL;
|
private ConsoleMode lastConsoleMode = ConsoleMode.NORMAL;
|
||||||
|
|
||||||
private FloppyDisk floppyDisk;
|
|
||||||
|
|
||||||
private User parent;
|
private User parent;
|
||||||
|
|
||||||
private int energy;
|
private int energy;
|
||||||
@ -103,6 +102,7 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
|||||||
json.put("holo", hologram);
|
json.put("holo", hologram);
|
||||||
json.put("holoStr", hologramString);
|
json.put("holoStr", hologramString);
|
||||||
json.put("holoMode", lastHologramMode.ordinal());
|
json.put("holoMode", lastHologramMode.ordinal());
|
||||||
|
json.put("holoC", hologramColor);
|
||||||
json.put("energy", energy);
|
json.put("energy", energy);
|
||||||
|
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
@ -236,8 +236,7 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
|||||||
CLEARED,
|
CLEARED,
|
||||||
HEX,
|
HEX,
|
||||||
STRING,
|
STRING,
|
||||||
DEC,
|
DEC
|
||||||
COLOR
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ConsoleMode {
|
public enum ConsoleMode {
|
||||||
@ -270,4 +269,8 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
|
|||||||
public void setConsoleMode(ConsoleMode consoleMode) {
|
public void setConsoleMode(ConsoleMode consoleMode) {
|
||||||
this.consoleMode = consoleMode;
|
this.consoleMode = consoleMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHologramColor(int hologramColor) {
|
||||||
|
this.hologramColor = hologramColor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import org.json.simple.JSONObject;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ComPort extends CpuHardware {
|
public class CubotComPort extends CpuHardware {
|
||||||
|
|
||||||
public static final char HWID = 0xD;
|
public static final char HWID = 0xD;
|
||||||
public static final int DEFAULT_ADDRESS = 0xD;
|
public static final int DEFAULT_ADDRESS = 0xD;
|
||||||
@ -22,7 +22,7 @@ public class ComPort extends CpuHardware {
|
|||||||
private static final int FRONT_PORT_OUT = 2;
|
private static final int FRONT_PORT_OUT = 2;
|
||||||
private static final int SELF_OUT = 3;
|
private static final int SELF_OUT = 3;
|
||||||
|
|
||||||
public ComPort(Cubot cubot) {
|
public CubotComPort(Cubot cubot) {
|
||||||
this.cubot = cubot;
|
this.cubot = cubot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ public class ComPort extends CpuHardware {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ComPort deserialize(JSONObject json) {
|
public static CubotComPort deserialize(JSONObject json) {
|
||||||
return new ComPort((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) json.get("cubot")));
|
return new CubotComPort((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) json.get("cubot")));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -71,8 +71,7 @@ public class CubotHologram extends CpuHardware {
|
|||||||
int b = getCpu().getRegisterSet().getRegister("B").getValue();
|
int b = getCpu().getRegisterSet().getRegister("B").getValue();
|
||||||
int c = getCpu().getRegisterSet().getRegister("C").getValue();
|
int c = getCpu().getRegisterSet().getRegister("C").getValue();
|
||||||
|
|
||||||
cubot.setHologramMode(Cubot.HologramMode.COLOR);
|
cubot.setHologramColor((c | (b << 16))); //B:C
|
||||||
cubot.setHologram((c | (b << 16)) & 0x00FFFFFF); //B:C, ignore first byte
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import net.simon987.server.assembly.CpuHardware;
|
|||||||
import net.simon987.server.assembly.Status;
|
import net.simon987.server.assembly.Status;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
public class Keyboard extends CpuHardware {
|
public class CubotKeyboard extends CpuHardware {
|
||||||
|
|
||||||
public static final int DEFAULT_ADDRESS = 4;
|
public static final int DEFAULT_ADDRESS = 4;
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ public class Keyboard extends CpuHardware {
|
|||||||
|
|
||||||
private Cubot cubot;
|
private Cubot cubot;
|
||||||
|
|
||||||
public Keyboard(Cubot cubot) {
|
public CubotKeyboard(Cubot cubot) {
|
||||||
this.cubot = cubot;
|
this.cubot = cubot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ public class Keyboard extends CpuHardware {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Keyboard deserialize(JSONObject hwJSON) {
|
public static CubotKeyboard deserialize(JSONObject hwJSON) {
|
||||||
return new Keyboard((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) hwJSON.get("cubot")));
|
return new CubotKeyboard((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) hwJSON.get("cubot")));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -50,16 +50,16 @@ public class CubotPlugin extends ServerPlugin implements GameObjectDeserializer,
|
|||||||
return CubotDrill.deserialize(hwJson);
|
return CubotDrill.deserialize(hwJson);
|
||||||
case CubotInventory.HWID:
|
case CubotInventory.HWID:
|
||||||
return CubotInventory.deserialize(hwJson);
|
return CubotInventory.deserialize(hwJson);
|
||||||
case Keyboard.HWID:
|
case CubotKeyboard.HWID:
|
||||||
return Keyboard.deserialize(hwJson);
|
return CubotKeyboard.deserialize(hwJson);
|
||||||
case CubotHologram.HWID:
|
case CubotHologram.HWID:
|
||||||
return CubotHologram.deserialize(hwJson);
|
return CubotHologram.deserialize(hwJson);
|
||||||
case CubotBattery.HWID:
|
case CubotBattery.HWID:
|
||||||
return CubotBattery.deserialize(hwJson);
|
return CubotBattery.deserialize(hwJson);
|
||||||
case CubotFloppyDrive.HWID:
|
case CubotFloppyDrive.HWID:
|
||||||
return CubotFloppyDrive.deserialize(hwJson);
|
return CubotFloppyDrive.deserialize(hwJson);
|
||||||
case ComPort.HWID:
|
case CubotComPort.HWID:
|
||||||
return ComPort.deserialize(hwJson);
|
return CubotComPort.deserialize(hwJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -26,7 +26,7 @@ public class CpuInitialisationListener implements GameEventListener {
|
|||||||
laserHw.setCpu(cpu);
|
laserHw.setCpu(cpu);
|
||||||
CubotLidar radarHw = new CubotLidar((Cubot) user.getControlledUnit());
|
CubotLidar radarHw = new CubotLidar((Cubot) user.getControlledUnit());
|
||||||
radarHw.setCpu(cpu);
|
radarHw.setCpu(cpu);
|
||||||
Keyboard keyboard = new Keyboard((Cubot) user.getControlledUnit());
|
CubotKeyboard keyboard = new CubotKeyboard((Cubot) user.getControlledUnit());
|
||||||
keyboard.setCpu(cpu);
|
keyboard.setCpu(cpu);
|
||||||
CubotDrill drillHw = new CubotDrill((Cubot) user.getControlledUnit());
|
CubotDrill drillHw = new CubotDrill((Cubot) user.getControlledUnit());
|
||||||
drillHw.setCpu(cpu);
|
drillHw.setCpu(cpu);
|
||||||
@ -38,19 +38,19 @@ public class CpuInitialisationListener implements GameEventListener {
|
|||||||
batteryHw.setCpu(cpu);
|
batteryHw.setCpu(cpu);
|
||||||
CubotFloppyDrive floppyHw = new CubotFloppyDrive((Cubot) user.getControlledUnit());
|
CubotFloppyDrive floppyHw = new CubotFloppyDrive((Cubot) user.getControlledUnit());
|
||||||
floppyHw.setCpu(cpu);
|
floppyHw.setCpu(cpu);
|
||||||
ComPort comPortHw = new ComPort((Cubot) user.getControlledUnit());
|
CubotComPort comPortHw = new CubotComPort((Cubot) user.getControlledUnit());
|
||||||
comPortHw.setCpu(cpu);
|
comPortHw.setCpu(cpu);
|
||||||
|
|
||||||
cpu.attachHardware(legHw, CubotLeg.DEFAULT_ADDRESS);
|
cpu.attachHardware(legHw, CubotLeg.DEFAULT_ADDRESS);
|
||||||
cpu.attachHardware(laserHw, CubotLaser.DEFAULT_ADDRESS);
|
cpu.attachHardware(laserHw, CubotLaser.DEFAULT_ADDRESS);
|
||||||
cpu.attachHardware(radarHw, CubotLidar.DEFAULT_ADDRESS);
|
cpu.attachHardware(radarHw, CubotLidar.DEFAULT_ADDRESS);
|
||||||
cpu.attachHardware(keyboard, Keyboard.DEFAULT_ADDRESS);
|
cpu.attachHardware(keyboard, CubotKeyboard.DEFAULT_ADDRESS);
|
||||||
cpu.attachHardware(drillHw, CubotDrill.DEFAULT_ADDRESS);
|
cpu.attachHardware(drillHw, CubotDrill.DEFAULT_ADDRESS);
|
||||||
cpu.attachHardware(invHw, CubotInventory.DEFAULT_ADDRESS);
|
cpu.attachHardware(invHw, CubotInventory.DEFAULT_ADDRESS);
|
||||||
cpu.attachHardware(invHw, CubotInventory.DEFAULT_ADDRESS);
|
cpu.attachHardware(invHw, CubotInventory.DEFAULT_ADDRESS);
|
||||||
cpu.attachHardware(emoteHw, CubotHologram.DEFAULT_ADDRESS);
|
cpu.attachHardware(emoteHw, CubotHologram.DEFAULT_ADDRESS);
|
||||||
cpu.attachHardware(batteryHw, CubotBattery.DEFAULT_ADDRESS);
|
cpu.attachHardware(batteryHw, CubotBattery.DEFAULT_ADDRESS);
|
||||||
cpu.attachHardware(floppyHw, CubotFloppyDrive.DEFAULT_ADDRESS);
|
cpu.attachHardware(floppyHw, CubotFloppyDrive.DEFAULT_ADDRESS);
|
||||||
cpu.attachHardware(comPortHw, ComPort.DEFAULT_ADDRESS);
|
cpu.attachHardware(comPortHw, CubotComPort.DEFAULT_ADDRESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
@ -15,5 +16,7 @@
|
|||||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.42" level="project" />
|
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.42" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.commons:commons-text:1.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.7" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -22,6 +22,7 @@ public class Main {
|
|||||||
|
|
||||||
GameServer.INSTANCE.setSocketServer(socketServer);
|
GameServer.INSTANCE.setSocketServer(socketServer);
|
||||||
|
|
||||||
|
System.out.println(GameServer.INSTANCE.getGameUniverse().getWorld(0x7fff, 0x7fff));
|
||||||
|
|
||||||
(new Thread(socketServer)).start();
|
(new Thread(socketServer)).start();
|
||||||
(new Thread(GameServer.INSTANCE)).start();
|
(new Thread(GameServer.INSTANCE)).start();
|
||||||
|
@ -28,8 +28,8 @@ public class DivInstruction extends Instruction {
|
|||||||
public Status execute(Target src, int srcIndex, Status status) {
|
public Status execute(Target src, int srcIndex, Status status) {
|
||||||
|
|
||||||
//Source = Y:A
|
//Source = Y:A
|
||||||
int source = ((((char) cpu.getRegisterSet().getRegister("Y").getValue() & 0xFFFF) << 16)) |
|
int source = (((cpu.getRegisterSet().getRegister("Y").getValue() & 0xFFFF) << 16)) |
|
||||||
((char) cpu.getRegisterSet().getRegister("A").getValue() & 0xFFFF);
|
(cpu.getRegisterSet().getRegister("A").getValue() & 0xFFFF);
|
||||||
|
|
||||||
if (src.get(srcIndex) == 0) {
|
if (src.get(srcIndex) == 0) {
|
||||||
//Division by 0
|
//Division by 0
|
||||||
@ -48,8 +48,8 @@ public class DivInstruction extends Instruction {
|
|||||||
|
|
||||||
|
|
||||||
//Source = Y:A
|
//Source = Y:A
|
||||||
int source = ((((char) cpu.getRegisterSet().getRegister("Y").getValue() & 0xFFFF) << 16)) |
|
int source = (((cpu.getRegisterSet().getRegister("Y").getValue() & 0xFFFF) << 16)) |
|
||||||
((char) cpu.getRegisterSet().getRegister("A").getValue() & 0xFFFF);
|
(cpu.getRegisterSet().getRegister("A").getValue() & 0xFFFF);
|
||||||
|
|
||||||
if (src == 0) {
|
if (src == 0) {
|
||||||
//Division by 0
|
//Division by 0
|
||||||
|
@ -180,8 +180,6 @@ public class SocketServer extends WebSocketServer {
|
|||||||
try {
|
try {
|
||||||
ControllableUnit unit = user.getUser().getControlledUnit();
|
ControllableUnit unit = user.getUser().getControlledUnit();
|
||||||
|
|
||||||
System.out.println("Sent " + unit.getConsoleMessagesBuffer().size() + " messages to " + user.getUser().getUsername());
|
|
||||||
|
|
||||||
//Send keyboard updated buffer
|
//Send keyboard updated buffer
|
||||||
ArrayList<Integer> kbBuffer = unit.getKeyboardBuffer();
|
ArrayList<Integer> kbBuffer = unit.getKeyboardBuffer();
|
||||||
JSONArray keys = new JSONArray();
|
JSONArray keys = new JSONArray();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user