diff --git a/Plugin Cubot/Plugin Cubot.iml b/Plugin Cubot/Plugin Cubot.iml
index c10f299..4feea78 100644
--- a/Plugin Cubot/Plugin Cubot.iml
+++ b/Plugin Cubot/Plugin Cubot.iml
@@ -1,10 +1,5 @@
-
-
-
-
-
diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Cubot.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Cubot.java
index d4bc841..dca9ab0 100644
--- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Cubot.java
+++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/Cubot.java
@@ -19,42 +19,160 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
private static final char MAP_INFO = 0x0080;
public static final int ID = 1;
+ /**
+ * Hologram value that is displayed
+ *
TODO: Move to CubotHologram class
+ */
private int hologram = 0;
+ /**
+ * Hologram string that is displayed
+ *
TODO: Move to CubotHologram class
+ */
private String hologramString = "";
+ /**
+ * Hologram mode that was set during this tick
+ *
TODO: Move to CubotHologram class
+ */
private HologramMode hologramMode = HologramMode.CLEARED;
+ /**
+ * Hologram mode at the end of the last tick
+ *
TODO: Move to CubotHologram class
+ */
private HologramMode lastHologramMode = HologramMode.CLEARED;
+ /**
+ * Hologram color code. Format is handled by the client
+ *
TODO: Move to CubotHologram class
+ */
private int hologramColor = 0;
/**
* Hit points
*/
private int hp;
+ /**
+ * Maximum hit points
+ */
private int maxHp;
+
+ /**
+ * Shield points
+ */
private int shield;
+
+ /**
+ * Maximum shield points
+ */
private int maxShield;
+
+ /**
+ * Item ID of the current 'active' item
+ */
private int heldItem;
+ /**
+ * Action that was set during the current tick. It is set to IDLE by default
+ */
private Action currentAction = Action.IDLE;
+
+ /**
+ * Action at the end of the last tick
+ */
private Action lastAction = Action.IDLE;
+ /**
+ * Status bit field that was set during the current tick. It is set to 0 by default
+ *
See CubotStatus and addStatus() method
+ */
private char currentStatus;
+
+ /**
+ * Status bit field at the end of the last tick
+ */
private char lastStatus;
+ /**
+ * Buffer of keypress codes. It is not changed between ticks and it is reset when
+ * the player uploads their code
+ */
private ArrayList keyboardBuffer = new ArrayList<>();
+ /**
+ * Buffer of console messages (also called 'internal buffer') that was set during the current tick
+ */
private ArrayList consoleMessagesBuffer = new ArrayList<>(CONSOLE_BUFFER_MAX_SIZE);
+ /**
+ * Buffer of console messages (also called 'internal buffer') at the end of the last tick
+ */
private ArrayList lastConsoleMessagesBuffer = new ArrayList<>(CONSOLE_BUFFER_MAX_SIZE);
+ /**
+ * Console mode that was set during the current tick. It is set to NORMAL by default
+ */
private ConsoleMode consoleMode = ConsoleMode.NORMAL;
+ /**
+ * Console mode at the end of the last tick
+ */
private ConsoleMode lastConsoleMode = ConsoleMode.NORMAL;
+ /**
+ * User that controls this Cubot
+ */
private User parent;
+ /**
+ * Energy units in kJ
+ */
private int energy;
+
+ /**
+ * Maximum energy units in kJ
+ */
private int maxEnergy;
+ /**
+ * Solar panel multiplier
+ *
TODO: Set this constant in dimension
+ */
private static final float SOLAR_PANEL_MULTIPLIER = 1;
+ /**
+ * Maximum size of the console buffer (also called 'internal buffer')
+ */
private static final int CONSOLE_BUFFER_MAX_SIZE = 40;
+ /**
+ * Display mode of the hologram hardware
+ *
TODO: move this inside CubotHologram class
+ */
+ public enum HologramMode {
+ /**
+ * Display nothing
+ */
+ CLEARED,
+ /**
+ * Display value as hexadecimal in format 0x0000
+ */
+ HEX,
+ /**
+ * Display string
+ */
+ STRING,
+ /**
+ * Display value as decimal
+ */
+ DEC
+ }
+
+ public enum ConsoleMode {
+ /**
+ * Used by the ComPort hardware - clears the console screen (client-side)
+ */
+ CLEAR,
+ /**
+ * No specific client-side action
+ */
+ NORMAL
+ }
+
+
public Cubot() {
}
@@ -64,6 +182,9 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
return MAP_INFO;
}
+ /**
+ * Called every tick
+ */
@Override
public void update() {
@@ -176,6 +297,52 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
}
+ /**
+ * Reset to 'factory settings', as it were when it was first created
+ */
+ private void reset() {
+ setDead(false);
+ setHp(maxHp);
+ setShield(0);
+ setHeldItem(0);
+ setEnergy(maxEnergy);
+ clearKeyboardBuffer();
+ consoleMessagesBuffer.clear();
+ lastConsoleMessagesBuffer.clear();
+ hologramColor = 0;
+ currentStatus = 0;
+ lastStatus = 0;
+ addStatus(CubotStatus.FACTORY_NEW);
+ }
+
+ @Override
+ public boolean onDeadCallback() {
+ LogManager.LOGGER.info(getParent().getUsername() + "'s Cubot died");
+
+ reset();
+
+ //Teleport to spawn point
+ this.getWorld().removeObject(this);
+ this.getWorld().decUpdatable();
+
+ ServerConfiguration config = GameServer.INSTANCE.getConfig();
+ Random random = new Random();
+
+ int spawnX = config.getInt("new_user_worldX") + random.nextInt(5);
+ int spawnY = config.getInt("new_user_worldY") + random.nextInt(5);
+ String dimension = config.getString("new_user_dimension");
+ this.setWorld(GameServer.INSTANCE.getGameUniverse().getWorld(spawnX, spawnY, true, dimension));
+
+ Point point = this.getWorld().getRandomPassableTile();
+ this.setX(point.x);
+ this.setY(point.y);
+
+ this.getWorld().addObject(this);
+ this.getWorld().incUpdatable();
+
+ return true;
+ }
+
public void setHeldItem(int heldItem) {
this.heldItem = heldItem;
}
@@ -314,18 +481,6 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
this.hologramMode = hologramMode;
}
- public enum HologramMode {
- CLEARED,
- HEX,
- STRING,
- DEC
- }
-
- public enum ConsoleMode {
- CLEAR,
- NORMAL
- }
-
@Override
public void setAction(Action action) {
currentAction = action;
@@ -373,6 +528,9 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
return lastStatus;
}
+ /**
+ * Currently has no effect
+ */
@Override
public void setHealRate(int hp) {
//no op
@@ -398,6 +556,13 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
this.maxHp = hp;
}
+ public int getMaxShield() {
+ return maxShield;
+ }
+
+ public void setMaxShield(int maxShield) {
+ this.maxShield = maxShield;
+ }
@Override
public void heal(int amount) {
hp += amount;
@@ -420,55 +585,4 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit, Pr
setDead(true);
}
}
-
- public void reset() {
- setDead(false);
- setHp(maxHp);
- setShield(0);
- setHeldItem(0);
- setEnergy(maxEnergy);
- clearKeyboardBuffer();
- consoleMessagesBuffer.clear();
- lastConsoleMessagesBuffer.clear();
- hologramColor = 0;
- currentStatus = 0;
- lastStatus = 0;
- addStatus(CubotStatus.FACTORY_NEW);
- }
-
- @Override
- public boolean onDeadCallback() {
- LogManager.LOGGER.info(getParent().getUsername() + "'s Cubot died");
-
- reset();
-
- //Teleport to spawn point
- this.getWorld().removeObject(this);
- this.getWorld().decUpdatable();
-
- ServerConfiguration config = GameServer.INSTANCE.getConfig();
- Random random = new Random();
-
- int spawnX = config.getInt("new_user_worldX") + random.nextInt(5);
- int spawnY = config.getInt("new_user_worldY") + random.nextInt(5);
- String dimension = config.getString("new_user_dimension");
- this.setWorld(GameServer.INSTANCE.getGameUniverse().getWorld(spawnX, spawnY, true, dimension));
-
- Point point = this.getWorld().getRandomPassableTile();
- this.setX(point.x);
- this.setY(point.y);
-
- this.getWorld().addObject(this);
- this.getWorld().incUpdatable();
-
- return true;
- }
-
- public int getMaxShield() {
- return maxShield;
- }
-
- public void setMaxShield(int maxShield) {
- this.maxShield = maxShield;
- }
}
diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/ChargeShieldCommandListener.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/ChargeShieldCommandListener.java
index 4b14f21..877685d 100644
--- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/ChargeShieldCommandListener.java
+++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/ChargeShieldCommandListener.java
@@ -7,6 +7,9 @@ import net.simon987.server.event.GameEvent;
import net.simon987.server.event.GameEventListener;
import net.simon987.server.game.GameObject;
+/**
+ * Debug command to add shield points to a Cubot
+ */
public class ChargeShieldCommandListener implements GameEventListener {
@Override
public Class getListenedEventType() {
diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/CpuInitialisationListener.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/CpuInitialisationListener.java
index efa2428..05135c6 100644
--- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/CpuInitialisationListener.java
+++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/CpuInitialisationListener.java
@@ -15,7 +15,6 @@ public class CpuInitialisationListener implements GameEventListener {
@Override
public void handle(GameEvent event) {
- //LogManager.LOGGER.fine("(Plugin) Handled CPU Initialisation event (Cubot Plugin)");
CPU cpu = (CPU) event.getSource();
User user = ((CpuInitialisationEvent) event).getUser();
diff --git a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/UserCreationListener.java b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/UserCreationListener.java
index 2365d9d..a39f568 100644
--- a/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/UserCreationListener.java
+++ b/Plugin Cubot/src/main/java/net/simon987/cubotplugin/event/UserCreationListener.java
@@ -57,7 +57,5 @@ public class UserCreationListener implements GameEventListener {
user.setControlledUnit(cubot);
LogManager.LOGGER.fine("(Plugin) Handled User creation event (Cubot Plugin)");
-
-
}
}
diff --git a/Plugin Misc HW/Plugin Misc HW.iml b/Plugin Misc HW/Plugin Misc HW.iml
index 2817a50..863545c 100644
--- a/Plugin Misc HW/Plugin Misc HW.iml
+++ b/Plugin Misc HW/Plugin Misc HW.iml
@@ -1,10 +1,5 @@
-
-
-
-
-
diff --git a/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/Clock.java b/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/Clock.java
index c132ca4..886c482 100644
--- a/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/Clock.java
+++ b/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/Clock.java
@@ -6,6 +6,9 @@ import net.simon987.server.assembly.CpuHardware;
import net.simon987.server.assembly.Status;
import net.simon987.server.assembly.Util;
+/**
+ * Hardware to get game time
+ */
public class Clock extends CpuHardware {
public static final char HWID = 0x0008;
diff --git a/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/MiscHWPlugin.java b/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/MiscHWPlugin.java
index 780ed49..099e6b6 100644
--- a/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/MiscHWPlugin.java
+++ b/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/MiscHWPlugin.java
@@ -8,6 +8,9 @@ import net.simon987.server.io.CpuHardwareDeserializer;
import net.simon987.server.logging.LogManager;
import net.simon987.server.plugin.ServerPlugin;
+/**
+ * Plugin that adds miscellaneous hardware to the game
+ */
public class MiscHWPlugin extends ServerPlugin implements CpuHardwareDeserializer {
diff --git a/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/RandomNumberGenerator.java b/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/RandomNumberGenerator.java
index ce4c658..2bceb22 100644
--- a/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/RandomNumberGenerator.java
+++ b/Plugin Misc HW/src/main/java/net/simon987/mischwplugin/RandomNumberGenerator.java
@@ -6,6 +6,9 @@ import net.simon987.server.assembly.Status;
import java.util.Random;
+/**
+ * Hardware to generate random numbers
+ */
public class RandomNumberGenerator extends CpuHardware {
public static final char HWID = 0x0007;
diff --git a/Plugin NPC/Plugin NPC.iml b/Plugin NPC/Plugin NPC.iml
index 2238d89..9aa790c 100644
--- a/Plugin NPC/Plugin NPC.iml
+++ b/Plugin NPC/Plugin NPC.iml
@@ -1,10 +1,5 @@
-
-
-
-
-
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/ElectricBox.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/ElectricBox.java
index f50af38..42f9323 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/ElectricBox.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/ElectricBox.java
@@ -13,24 +13,43 @@ import org.json.simple.JSONObject;
import java.util.ArrayList;
+/**
+ * Game object that deals damage to nearby objects and gives them energy
+ */
public class ElectricBox extends GameObject implements Updatable, Attackable {
public static final int ID = 7;
+ /**
+ * Hit points
+ */
+ private int hp;
+ /**
+ * Maximum hit points
+ */
private static final int maxHp = GameServer.INSTANCE.getConfig().getInt("electric_box_hp");
+ /**
+ * Number of hit points dealt to nearby objects each tick
+ */
private static final int damageDealt = GameServer.INSTANCE.getConfig().getInt("electric_box_damage");
+ /**
+ * Number of energy points given to nearby objects each tick
+ */
private static final int energyGiven = GameServer.INSTANCE.getConfig().getInt("electric_box_energy_given");
- private int hp;
-
+ /**
+ * List of nearby objects. Is updated every tick
+ */
private ArrayList nearObjects = new ArrayList<>();
public ElectricBox() {
this.hp = maxHp;
-
}
+ /**
+ * Currently has no effect
+ */
@Override
public void setHealRate(int hp) {
//no op
@@ -51,11 +70,17 @@ public class ElectricBox extends GameObject implements Updatable, Attackable {
return hp;
}
+ /**
+ * Currently has no effect
+ */
@Override
public void setMaxHp(int hp) {
//No op
}
+ /**
+ * Currently has no effect
+ */
@Override
public void heal(int amount) {
//No op
@@ -77,6 +102,10 @@ public class ElectricBox extends GameObject implements Updatable, Attackable {
return Obstacle.MAP_INFO;
}
+ /**
+ * Updates the current list nearby objects
+ *
An object is considered 'nearby' if its Manhattan distance is {@literal <= @} 1 and is Attackable
+ */
private void updateNearObjects() {
nearObjects.clear();
@@ -89,6 +118,9 @@ public class ElectricBox extends GameObject implements Updatable, Attackable {
}
}
+ /**
+ * Called every tick
+ */
@Override
public void update() {
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/Factory.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/Factory.java
index 1c9cb3a..a76c93d 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/Factory.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/Factory.java
@@ -11,15 +11,27 @@ import org.json.simple.JSONObject;
import java.awt.*;
import java.util.ArrayList;
+/**
+ * Game objects that regularly creates NonPlayerCharacters
+ */
public class Factory extends GameObject implements Updatable {
private static final int MAP_INFO = 0x0200;
static final int ID = 3;
+ /**
+ * Maximum number of NonPlayerCharacters assigned to this Factory
+ */
private static final int MAX_NPC_COUNT = GameServer.INSTANCE.getConfig().getInt("factory_max_npc_count");
+ /**
+ * Number of ticks to wait after creating a NonPlayerCharacter
+ */
private static final int NPC_CREATION_COOLDOWN = NonPlayerCharacter.LIFETIME / MAX_NPC_COUNT;
+ /**
+ * List of associated NonPlayerCharacters
+ */
private ArrayList npcs = new ArrayList<>();
/**
@@ -43,6 +55,10 @@ public class Factory extends GameObject implements Updatable {
return MAP_INFO;
}
+ /**
+ * Called every tick
+ *
The fist time this is called, NPCs retrieved from the database are linked to the Factory
+ */
@Override
public void update() {
@@ -61,6 +77,8 @@ public class Factory extends GameObject implements Updatable {
}
+ tmpNpcArray = null;
+
} else {
if (cooldown == 0) {
@@ -141,7 +159,7 @@ public class Factory extends GameObject implements Updatable {
factory.setX((int) obj.get("x"));
factory.setY((int) obj.get("y"));
- factory.tmpNpcArray = ((BasicDBList) obj.get("n")).toArray();
+ factory.tmpNpcArray = ((BasicDBList) obj.get("tmpNpcArray")).toArray();
return factory;
}
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvestTask.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvestTask.java
index 520a4a1..81e15ef 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvestTask.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvestTask.java
@@ -10,19 +10,31 @@ import net.simon987.server.logging.LogManager;
import java.util.ArrayList;
import java.util.Random;
+/**
+ * Find Biomass, move towards it, collect it, repeat
+ */
public class HarvestTask extends NPCTask {
private Random random;
+ /**
+ * Number of ticks to wait before continuing
+ */
private int pause;
+ /**
+ * Direction of the next world to visit (randomly chosen)
+ */
+ private Direction nextWorldDirection = null;
+
public HarvestTask() {
random = new Random();
pause = 0;
}
- private Direction nextWorldDirection = null;
-
+ /**
+ * This task never finishes
+ */
@Override
public boolean checkCompleted() {
return false;
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvesterNPC.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvesterNPC.java
index 89c58f4..43592f9 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvesterNPC.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/HarvesterNPC.java
@@ -12,6 +12,9 @@ public class HarvesterNPC extends NonPlayerCharacter {
public static final int ID = 10;
+ /**
+ *
+ */
public static final int MAX_HEALTH = GameServer.INSTANCE.getConfig().getInt("harvester_hp_max");
public static final int HEAL_RATE = GameServer.INSTANCE.getConfig().getInt("harvester_regen");
@@ -85,7 +88,6 @@ public class HarvesterNPC extends NonPlayerCharacter {
dbObject.put("y", getY());
dbObject.put("direction", getDirection().ordinal());
dbObject.put("hp", getHp());
- // dbObject.put("energy", energy);
dbObject.put("action", getAction().ordinal());
dbObject.put("t", ID);
@@ -100,8 +102,6 @@ public class HarvesterNPC extends NonPlayerCharacter {
npc.setY((int) obj.get("y"));
npc.setHp((int) obj.get("hp"));
npc.setDirection(Direction.getDirection((int) obj.get("direction")));
- // npc.energy = (int) obj.get("energy");
- // npc.maxEnergy = GameServer.INSTANCE.getConfig().getInt("battery_max_energy");
return npc;
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/NonPlayerCharacter.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/NonPlayerCharacter.java
index 794e2da..028db48 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/NonPlayerCharacter.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/NonPlayerCharacter.java
@@ -9,27 +9,40 @@ import net.simon987.server.logging.LogManager;
import java.util.ArrayList;
+/**
+ * Game object that actively interacts with the game world by doing tasks
+ */
public abstract class NonPlayerCharacter extends GameObject implements Updatable, Attackable {
private static final int MAP_INFO = 0x0040;
+ /**
+ * Maximum distance to travel from its factory, in Worlds
+ */
private static final int MAX_FACTORY_DISTANCE = GameServer.INSTANCE.getConfig().getInt("npc_max_factory_distance");
+ /**
+ * Number of ticks to live
+ */
public static final int LIFETIME = GameServer.INSTANCE.getConfig().getInt("npc_lifetime");
// Set these just in case they aren't overridden in the subclass
public static final int HP_MAX_DEFAULT = 100;
public static final int HP_REGEN_RATE_DEFAULT = 0;
- //Unused
+ /**
+ * Currently unused
+ */
int energy;
- int maxEnergy;
/**
* Current task
*/
private NPCTask task;
+ /**
+ * Action at the end of the last tick
+ */
private Action lastAction = Action.IDLE;
/**
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/NpcPlugin.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/NpcPlugin.java
index 8aa89c5..63526e1 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/NpcPlugin.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/NpcPlugin.java
@@ -4,7 +4,6 @@ import com.mongodb.DBObject;
import net.simon987.npcplugin.event.CpuInitialisationListener;
import net.simon987.npcplugin.event.VaultWorldUpdateListener;
import net.simon987.npcplugin.event.WorldCreationListener;
-import net.simon987.npcplugin.io.StatsDatabaseManager;
import net.simon987.server.ServerConfiguration;
import net.simon987.server.assembly.CpuHardware;
import net.simon987.server.game.GameObject;
@@ -22,8 +21,6 @@ public class NpcPlugin extends ServerPlugin implements GameObjectDeserializer, C
*/
private static ArrayList radioTowers;
- private static StatsDatabaseManager statsDbManager;
-
@Override
public void init(ServerConfiguration configuration) {
@@ -33,8 +30,6 @@ public class NpcPlugin extends ServerPlugin implements GameObjectDeserializer, C
radioTowers = new ArrayList<>(32);
- statsDbManager = new StatsDatabaseManager(configuration);
-
LogManager.LOGGER.info("Initialised NPC plugin");
}
@@ -80,7 +75,4 @@ public class NpcPlugin extends ServerPlugin implements GameObjectDeserializer, C
return radioTowers;
}
- public static StatsDatabaseManager getStatsDbManager() {
- return statsDbManager;
- }
}
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/Obstacle.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/Obstacle.java
index 3dbdc6b..e32ea17 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/Obstacle.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/Obstacle.java
@@ -8,7 +8,6 @@ import org.json.simple.JSONObject;
/**
* Generic game object that blocks the path.
- * Some types of obstacles might have some more interesting features (see ElectricBox)
*/
public class Obstacle extends GameObject implements Attackable {
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/Portal.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/Portal.java
index 06972e7..c4e6ce9 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/Portal.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/Portal.java
@@ -8,16 +8,25 @@ import org.json.simple.JSONObject;
public class Portal extends GameObject implements Enterable {
- private Location dst;
+ /**
+ * Destination location
+ */
+ private Location destination;
public static final int MAP_INFO = 0x0020;
public static final int ID = 8;
+ /**
+ * Called when an object attempts to walk directly into a Enterable object
+ *
+ * @param object The game object that attempted to enter
+ * @return true if successful, false to block the object
+ */
@Override
public boolean enter(GameObject object) {
- World world = GameServer.INSTANCE.getGameUniverse().getWorld(dst.worldX, dst.worldY, false, dst.dimension);
+ World world = GameServer.INSTANCE.getGameUniverse().getWorld(destination.worldX, destination.worldY, false, destination.dimension);
if (object instanceof Updatable) {
object.getWorld().decUpdatable();
@@ -27,8 +36,8 @@ public class Portal extends GameObject implements Enterable {
object.setWorld(world);
world.addObject(object);
- object.setX(dst.x);
- object.setY(dst.y);
+ object.setX(destination.x);
+ object.setY(destination.y);
return true;
}
@@ -46,11 +55,11 @@ public class Portal extends GameObject implements Enterable {
dbObject.put("x", getX());
dbObject.put("y", getY());
dbObject.put("t", ID);
- dbObject.put("dstWorldX", dst.worldX);
- dbObject.put("dstWorldY", dst.worldY);
- dbObject.put("dstX", dst.x);
- dbObject.put("dstY", dst.y);
- dbObject.put("dstDimension", dst.dimension);
+ dbObject.put("dstWorldX", destination.worldX);
+ dbObject.put("dstWorldY", destination.worldY);
+ dbObject.put("dstX", destination.x);
+ dbObject.put("dstY", destination.y);
+ dbObject.put("dstDimension", destination.dimension);
return dbObject;
}
@@ -59,7 +68,7 @@ public class Portal extends GameObject implements Enterable {
Portal portal = new Portal();
- portal.dst = new Location(
+ portal.destination = new Location(
(int) obj.get("dstWorldX"),
(int) obj.get("dstWorldY"),
(String) obj.get("dstDimension"),
@@ -83,11 +92,11 @@ public class Portal extends GameObject implements Enterable {
return json;
}
- public Location getDst() {
- return dst;
+ public Location getDestination() {
+ return destination;
}
- public void setDst(Location dst) {
- this.dst = dst;
+ public void setDestination(Location destination) {
+ this.destination = destination;
}
}
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/RadioTower.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/RadioTower.java
index 8fa2c7c..f278e3b 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/RadioTower.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/RadioTower.java
@@ -24,7 +24,6 @@ public class RadioTower extends GameObject implements Programmable, Updatable {
return MAP_INFO;
}
-
/**
* Messages from the current tick
*/
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/VaultDimension.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/VaultDimension.java
index 8f73fa8..a281b78 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/VaultDimension.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/VaultDimension.java
@@ -141,7 +141,7 @@ public class VaultDimension {
if (exitPortalPt != null) {
VaultExitPortal exitPortal = new VaultExitPortal();
- exitPortal.setDst(exitLocation);
+ exitPortal.setDestination(exitLocation);
exitPortal.setX(exitPortalPt.x);
exitPortal.setY(exitPortalPt.y);
exitPortal.setWorld(objectiveWorld);
@@ -158,7 +158,7 @@ public class VaultDimension {
if (homePortalPt != null) {
Portal homePortal = new Portal();
- homePortal.setDst(exitLocation);
+ homePortal.setDestination(exitLocation);
homePortal.setX(homePortalPt.x);
homePortal.setY(homePortalPt.y);
homePortal.setWorld(homeWorld);
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/VaultExitPortal.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/VaultExitPortal.java
index 341118a..3266b5a 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/VaultExitPortal.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/VaultExitPortal.java
@@ -22,11 +22,11 @@ public class VaultExitPortal extends Portal {
dbObject.put("x", getX());
dbObject.put("y", getY());
dbObject.put("t", ID);
- dbObject.put("dstWorldX", getDst().worldX);
- dbObject.put("dstWorldY", getDst().worldY);
- dbObject.put("dstX", getDst().x);
- dbObject.put("dstY", getDst().y);
- dbObject.put("dstDimension", getDst().dimension);
+ dbObject.put("dstWorldX", getDestination().worldX);
+ dbObject.put("dstWorldY", getDestination().worldY);
+ dbObject.put("dstX", getDestination().x);
+ dbObject.put("dstY", getDestination().y);
+ dbObject.put("dstDimension", getDestination().dimension);
return dbObject;
}
@@ -37,8 +37,7 @@ public class VaultExitPortal extends Portal {
LogManager.LOGGER.info(((ControllableUnit) object).getParent().getUsername() + " Completed vault " +
object.getWorld().getDimension());
- NpcPlugin.getStatsDbManager().saveVaultCompletion((ControllableUnit) object, object.getWorld().getDimension());
-
+ //todo: save vault completion stat
return super.enter(object);
}
@@ -47,7 +46,7 @@ public class VaultExitPortal extends Portal {
VaultExitPortal portal = new VaultExitPortal();
- portal.setDst(new Location(
+ portal.setDestination(new Location(
(int) obj.get("dstWorldX"),
(int) obj.get("dstWorldY"),
(String) obj.get("dstDimension"),
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/event/VaultWorldUpdateListener.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/event/VaultWorldUpdateListener.java
index 1ef06f7..74b7dba 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/event/VaultWorldUpdateListener.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/event/VaultWorldUpdateListener.java
@@ -14,11 +14,26 @@ import java.util.HashMap;
public class VaultWorldUpdateListener implements GameEventListener {
+ /**
+ * Map of worlds and their time to wait until next respawn event
+ */
private HashMap worldWaitMap = new HashMap<>(200);
+ /**
+ * Lower bound of ElectricBox to be created on a respawn event
+ */
private static int minElectricBoxCount;
+ /**
+ * Upper bound of ElectricBox to be created on a respawn event
+ */
private static int maxElectricBoxCount;
+ /**
+ * Number of game ticks to wait after the threshold has been met
+ */
private static int waitTime;
+ /**
+ * Threshold before starting the
+ */
private static int electricBoxThreshold;
public VaultWorldUpdateListener(ServerConfiguration config) {
@@ -37,6 +52,7 @@ public class VaultWorldUpdateListener implements GameEventListener {
@Override
public void handle(GameEvent event) {
+ //TODO: Move this and the Biomass UpdateListener to a 'RespawnManager' kind of deal
World world = ((WorldUpdateEvent) event).getWorld();
if (world.getDimension().startsWith("v")) {
@@ -66,6 +82,5 @@ public class VaultWorldUpdateListener implements GameEventListener {
}
}
}
-
}
}
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/event/WorldCreationListener.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/event/WorldCreationListener.java
index c1b91d4..4f53a19 100644
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/event/WorldCreationListener.java
+++ b/Plugin NPC/src/main/java/net/simon987/npcplugin/event/WorldCreationListener.java
@@ -18,6 +18,7 @@ public class WorldCreationListener implements GameEventListener {
/**
* Spawn rate. Higher = rarer: A factory will be spawn about every FACTORY_SPAWN_RATE generated Worlds
+ *
TODO: Get from config.properties
*/
private static final int FACTORY_SPAWN_RATE = 35;
diff --git a/Plugin NPC/src/main/java/net/simon987/npcplugin/io/StatsDatabaseManager.java b/Plugin NPC/src/main/java/net/simon987/npcplugin/io/StatsDatabaseManager.java
deleted file mode 100644
index 4b62d8e..0000000
--- a/Plugin NPC/src/main/java/net/simon987/npcplugin/io/StatsDatabaseManager.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package net.simon987.npcplugin.io;
-
-import net.simon987.server.ServerConfiguration;
-import net.simon987.server.game.ControllableUnit;
-import net.simon987.server.io.DatabaseManager;
-
-public class StatsDatabaseManager extends DatabaseManager {
-
- public StatsDatabaseManager(ServerConfiguration config) {
- super(config);
- }
-
- public void saveVaultCompletion(ControllableUnit unit, String dimension) {
-
-
-
- }
-}
diff --git a/Plugin Plant/Plugin Plant.iml b/Plugin Plant/Plugin Plant.iml
index 2238d89..9aa790c 100644
--- a/Plugin Plant/Plugin Plant.iml
+++ b/Plugin Plant/Plugin Plant.iml
@@ -1,10 +1,5 @@
-
-
-
-
-
diff --git a/Server/Server.iml b/Server/Server.iml
index b1a9e2c..eb52fc3 100644
--- a/Server/Server.iml
+++ b/Server/Server.iml
@@ -1,10 +1,5 @@
-
-
-
-
-
diff --git a/Server/src/main/java/net/simon987/server/Main.java b/Server/src/main/java/net/simon987/server/Main.java
index d076cc8..a81a075 100644
--- a/Server/src/main/java/net/simon987/server/Main.java
+++ b/Server/src/main/java/net/simon987/server/Main.java
@@ -21,5 +21,4 @@ public class Main {
(new Thread(GameServer.INSTANCE)).start();
}
-
}
diff --git a/Server/src/main/java/net/simon987/server/assembly/Assembler.java b/Server/src/main/java/net/simon987/server/assembly/Assembler.java
index 29e8652..e02a627 100755
--- a/Server/src/main/java/net/simon987/server/assembly/Assembler.java
+++ b/Server/src/main/java/net/simon987/server/assembly/Assembler.java
@@ -61,7 +61,7 @@ public class Assembler {
/**
* Check for and save the origin
*
- * @param line Current line. Assuming that the comments & labels are removed
+ * @param line Current line. Assuming that the comments and labels are removed
* @param result Current line number
*/
private static void checkForORGInstruction(String line, AssemblyResult result, int currentLine)
@@ -121,7 +121,7 @@ public class Assembler {
/**
* Parse the DW instruction (Define word). Handles DUP operator
*
- * @param line Current line. assuming that comments & labels are removed
+ * @param line Current line. assuming that comments and labels are removed
* @param currentLine Current line number
* @param labels Map of labels
* @return Encoded instruction, null if the line is not a DW instruction
@@ -258,7 +258,7 @@ public class Assembler {
/**
* Parse the DW instruction (Define word). Handles DUP operator
*
- * @param line Current line. assuming that comments & labels are removed
+ * @param line Current line. assuming that comments and labels are removed
* @param currentLine Current line number
* @return Encoded instruction, null if the line is not a DW instruction
*/
@@ -267,7 +267,7 @@ public class Assembler {
}
/**
- * Check for and handle section declarations (.text & .data)
+ * Check for and handle section declarations (.text and .data)
*
* @param line Current line
*/
diff --git a/Server/src/main/java/net/simon987/server/assembly/CPU.java b/Server/src/main/java/net/simon987/server/assembly/CPU.java
index 67eeaf8..ba128dd 100755
--- a/Server/src/main/java/net/simon987/server/assembly/CPU.java
+++ b/Server/src/main/java/net/simon987/server/assembly/CPU.java
@@ -17,7 +17,7 @@ import java.util.HashMap;
/**
* CPU: Central Processing Unit. A CPU is capable of reading bytes from
- * a Memory object and execute them. A CPU object holds registers objects &
+ * a Memory object and execute them. A CPU object holds registers objects and
* a Memory object.
*/
public class CPU implements MongoSerialisable {
diff --git a/Server/src/main/java/net/simon987/server/assembly/instruction/AndInstruction.java b/Server/src/main/java/net/simon987/server/assembly/instruction/AndInstruction.java
index 6e8e393..d8ba84a 100755
--- a/Server/src/main/java/net/simon987/server/assembly/instruction/AndInstruction.java
+++ b/Server/src/main/java/net/simon987/server/assembly/instruction/AndInstruction.java
@@ -7,10 +7,11 @@ import net.simon987.server.assembly.Util;
/**
* AND two numbers together, the result is stored in the destination operand
- *
+ *
* AND A, B
- * A = A & B
- *
+ *
+ * {@literal A = A & B @}
+ *
* FLAGS: OF=0 S=* Z=* X=0
*/
public class AndInstruction extends Instruction {
diff --git a/Server/src/main/java/net/simon987/server/assembly/instruction/HwiInstruction.java b/Server/src/main/java/net/simon987/server/assembly/instruction/HwiInstruction.java
index 2fe09b8..f7459d1 100755
--- a/Server/src/main/java/net/simon987/server/assembly/instruction/HwiInstruction.java
+++ b/Server/src/main/java/net/simon987/server/assembly/instruction/HwiInstruction.java
@@ -6,9 +6,9 @@ import net.simon987.server.assembly.Status;
import net.simon987.server.assembly.Target;
/**
- * Send hardware interupt
- * Used to interact with the World using hardware
- *
+ * Send hardware interrupt
+ *
Used to interact with the World using hardware
+ *
*/
public class HwiInstruction extends Instruction {
diff --git a/Server/src/main/java/net/simon987/server/assembly/instruction/RclInstruction.java b/Server/src/main/java/net/simon987/server/assembly/instruction/RclInstruction.java
index 753fe2d..7ff1b36 100644
--- a/Server/src/main/java/net/simon987/server/assembly/instruction/RclInstruction.java
+++ b/Server/src/main/java/net/simon987/server/assembly/instruction/RclInstruction.java
@@ -6,9 +6,9 @@ import net.simon987.server.assembly.Status;
import net.simon987.server.assembly.Target;
/**
- * +---------------------+
- * | |
- * CF < 0<0<0<0<0<0<0<0 <-+
+ *
+---------------------+
+ *
| |
+ *
{@literal CF < 0<0<0<0<0<0<0<0 <-+ @}
*/
public class RclInstruction extends Instruction {
diff --git a/Server/src/main/java/net/simon987/server/assembly/instruction/RcrInstruction.java b/Server/src/main/java/net/simon987/server/assembly/instruction/RcrInstruction.java
index 2e98462..c3e6a74 100644
--- a/Server/src/main/java/net/simon987/server/assembly/instruction/RcrInstruction.java
+++ b/Server/src/main/java/net/simon987/server/assembly/instruction/RcrInstruction.java
@@ -5,9 +5,9 @@ import net.simon987.server.assembly.Status;
import net.simon987.server.assembly.Target;
/**
- * +---------------------+
- * | |
- * CF < 0<0<0<0<0<0<0<0 <-+
+ *
+---------------------+
+ *
| |
+ *
{@literal CF < 0<0<0<0<0<0<0<0 <-+ @}
*/
public class RcrInstruction extends Instruction {
diff --git a/Server/src/main/java/net/simon987/server/assembly/instruction/RolInstruction.java b/Server/src/main/java/net/simon987/server/assembly/instruction/RolInstruction.java
index 3afbf27..8fe1719 100644
--- a/Server/src/main/java/net/simon987/server/assembly/instruction/RolInstruction.java
+++ b/Server/src/main/java/net/simon987/server/assembly/instruction/RolInstruction.java
@@ -5,9 +5,9 @@ import net.simon987.server.assembly.Status;
import net.simon987.server.assembly.Target;
/**
- * +-----------------+
- * | |
- * CF < 0<0<0<0<0<0<0<0 <-+
+ *
+-----------------+
+ *
| |
+ *
{@literal CF < 0<0<0<0<0<0<0<0 <-+ @}
*/
public class RolInstruction extends Instruction {
diff --git a/Server/src/main/java/net/simon987/server/assembly/instruction/RorInstruction.java b/Server/src/main/java/net/simon987/server/assembly/instruction/RorInstruction.java
index 749cfc2..28e1010 100644
--- a/Server/src/main/java/net/simon987/server/assembly/instruction/RorInstruction.java
+++ b/Server/src/main/java/net/simon987/server/assembly/instruction/RorInstruction.java
@@ -5,9 +5,9 @@ import net.simon987.server.assembly.Status;
import net.simon987.server.assembly.Target;
/**
- * +-----------------+
- * | |
- * +-> 0>0>0>0>0>0>0>0 > CF
+ *
+-----------------+
+ *
| |
+ *
{@literal +-> 0>0>0>0>0>0>0>0 > CF @}
*/
public class RorInstruction extends Instruction {
diff --git a/Server/src/main/java/net/simon987/server/game/Enterable.java b/Server/src/main/java/net/simon987/server/game/Enterable.java
index cda8b98..fc0c7ea 100644
--- a/Server/src/main/java/net/simon987/server/game/Enterable.java
+++ b/Server/src/main/java/net/simon987/server/game/Enterable.java
@@ -6,7 +6,7 @@ public interface Enterable {
* Called when an object attempts to walk directly into a Enterable object
*
* @param object The game object that attempted to enter
- * @return true if successful,
+ * @return true if successful, false to block the object
*/
boolean enter(GameObject object);
diff --git a/Server/src/main/java/net/simon987/server/web/WebServer.java b/Server/src/main/java/net/simon987/server/web/WebServer.java
index 8f20e55..c8c2c76 100644
--- a/Server/src/main/java/net/simon987/server/web/WebServer.java
+++ b/Server/src/main/java/net/simon987/server/web/WebServer.java
@@ -37,6 +37,7 @@ public class WebServer {
LogManager.LOGGER.info("(Web) Enabled ssl");
}
+
socketServer = new SocketServer();
Spark.webSocket("/socket", socketServer);
diff --git a/Server/src/main/resources/static/css/mar.css b/Server/src/main/resources/static/css/mar.css
index 1940cc5..0d10035 100644
--- a/Server/src/main/resources/static/css/mar.css
+++ b/Server/src/main/resources/static/css/mar.css
@@ -114,6 +114,7 @@
.bottom-panel {
min-height: 18px;
+ max-height: 100%;
height: 235px;
width: 100%;
position: fixed;
diff --git a/Server/src/main/typescript/GameClient.ts b/Server/src/main/typescript/GameClient.ts
index 7d37817..95b638d 100644
--- a/Server/src/main/typescript/GameClient.ts
+++ b/Server/src/main/typescript/GameClient.ts
@@ -329,7 +329,7 @@ class GameClient {
}
}
- à
+
public requestObjects(): void {
if (DEBUG) {
console.log("[MAR] Requesting game objects");