mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-13 22:59:02 +00:00
Added structure class #145 and moved many constants to config.properties
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.simon987.server.assembly;
|
||||
|
||||
import net.simon987.server.GameServer;
|
||||
import net.simon987.server.ServerConfiguration;
|
||||
import net.simon987.server.assembly.exception.*;
|
||||
import net.simon987.server.logging.LogManager;
|
||||
@@ -24,7 +25,7 @@ public class Assembler {
|
||||
|
||||
private RegisterSet registerSet;
|
||||
|
||||
private static final int MEM_SIZE = 0x10000; // Size in words todo load from config
|
||||
private static final int MEM_SIZE = GameServer.INSTANCE.getConfig().getInt("memory_size");
|
||||
|
||||
public Assembler(InstructionSet instructionSet, RegisterSet registerSet, ServerConfiguration config) {
|
||||
this.instructionSet = instructionSet;
|
||||
|
||||
@@ -274,7 +274,7 @@ public class GameUniverse {
|
||||
public String getGuestUsername() {
|
||||
int i = 1;
|
||||
|
||||
while (i < 10000) { //todo get Max guest user cap from config
|
||||
while (i < 50000) {
|
||||
if (getUser("guest" + String.valueOf(i)) != null) {
|
||||
i++;
|
||||
continue;
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package net.simon987.server.game.objects;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Game object that is stationary.
|
||||
*/
|
||||
public abstract class Structure extends GameObject {
|
||||
|
||||
/**
|
||||
* Length of the structure in tiles for the x axis
|
||||
*/
|
||||
private int width;
|
||||
|
||||
/**
|
||||
* Lenght of the structure in tiles for the y axis
|
||||
*/
|
||||
private int height;
|
||||
|
||||
public Structure(Document document, int width, int height) {
|
||||
super(document);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public Structure(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first non-blocked tile that is directly adjacent to the factory
|
||||
*
|
||||
* @return The coordinates of the first non-blocked tile found, null if none is found.
|
||||
*/
|
||||
public Point getAdjacentTile() {
|
||||
|
||||
//Top
|
||||
for (int x = getX() - 1; x < getX() + width; x++) {
|
||||
if (!getWorld().isTileBlocked(x, getY() - 1)) {
|
||||
return new Point(x, getY() - 1);
|
||||
}
|
||||
}
|
||||
//Right
|
||||
for (int y = getY() + width; y < getY() + height; y++) {
|
||||
if (!getWorld().isTileBlocked(getX() + width, y)) {
|
||||
return new Point(getX() + width, y);
|
||||
}
|
||||
}
|
||||
//Bottom
|
||||
for (int x = getX() - 1; x < getX() + width; x++) {
|
||||
if (!getWorld().isTileBlocked(x, getY() + height)) {
|
||||
return new Point(x, getY() + height);
|
||||
}
|
||||
}
|
||||
//Left
|
||||
for (int y = getY() - 1; y < getY() + height; y++) {
|
||||
if (!getWorld().isTileBlocked(getX() - 1, y)) {
|
||||
return new Point(getX() - 1, y);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAt(int x, int y) {
|
||||
|
||||
/*
|
||||
* Object is width x height tiles, the (x,y) coordinates of the object being
|
||||
* at top-left.
|
||||
* # .
|
||||
* . .
|
||||
*/
|
||||
return x >= getX() && x < getX() + width && y >= getY() && y < getY() + height;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -456,24 +456,6 @@ public class World implements MongoSerializable {
|
||||
return res;
|
||||
}
|
||||
|
||||
public Point getAdjacentTile(int x, int y) {
|
||||
|
||||
if (!isTileBlocked(x + 1, y)) {
|
||||
return new Point(x + 1, y);
|
||||
|
||||
} else if (!isTileBlocked(x, y + 1)) {
|
||||
return new Point(x, getY() + 1);
|
||||
|
||||
} else if (!isTileBlocked(x - 1, y)) {
|
||||
return new Point(x - 1, getY());
|
||||
|
||||
} else if (!isTileBlocked(x, y - 1)) {
|
||||
return new Point(x, y - 1);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<GameObject> getGameObjects() {
|
||||
return gameObjects.values();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.simon987.server.web;
|
||||
|
||||
import net.simon987.server.GameServer;
|
||||
import spark.ModelAndView;
|
||||
import spark.Request;
|
||||
import spark.Response;
|
||||
@@ -14,6 +15,7 @@ public class PlayPage implements TemplateViewRoute {
|
||||
public ModelAndView handle(Request request, Response response) {
|
||||
Map<String, Object> model = new HashMap<>(1);
|
||||
model.put("session", request.session());
|
||||
model.put("gamePageTitle", GameServer.INSTANCE.getConfig().getString("server_name"));
|
||||
|
||||
return new ModelAndView(model, "play.vm");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.simon987.server.websocket;
|
||||
|
||||
import net.simon987.server.GameServer;
|
||||
import net.simon987.server.logging.LogManager;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
@@ -18,7 +19,7 @@ public class CodeRequestHandler implements MessageHandler {
|
||||
JSONObject response = new JSONObject();
|
||||
|
||||
response.put("t", "code");
|
||||
response.put("code", "; Create a free account to control your own Cubot with assembly language!"); //todo load from config
|
||||
response.put("code", GameServer.INSTANCE.getConfig().getString("guest_user_code"));
|
||||
|
||||
user.getWebSocket().getRemote().sendString(response.toJSONString());
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ keyStore_password=
|
||||
#Server
|
||||
mar_port=4567
|
||||
mar_address=localhost
|
||||
server_name=Official MAR server
|
||||
server_name=MAR dev
|
||||
|
||||
#Database
|
||||
mongo_dbname=mar_beta
|
||||
@@ -51,6 +51,7 @@ new_user_code=; Welcome to Much Assembly required!\n\
|
||||
\t; Write code here\n\
|
||||
\tbrk
|
||||
new_user_item=0
|
||||
guest_user_code=; Create a free account to control your own Cubot with assembly language!
|
||||
#Cubot
|
||||
battery_max_energy=60000
|
||||
cubot_max_shield=100
|
||||
@@ -60,14 +61,22 @@ shield_energy_cost=50
|
||||
npc_lifetime=1024
|
||||
npc_max_factory_distance=3
|
||||
factory_max_npc_count=16
|
||||
factory_spawn_rate=2
|
||||
harvester_hp_max=100
|
||||
harvester_regen=5
|
||||
harvester_biomass_drop_count=8
|
||||
radio_tower_range=3
|
||||
#Vaults
|
||||
vault_door_open_time=4
|
||||
min_electric_box_count=1
|
||||
min_electric_box_respawn_count=1
|
||||
max_electric_box_respawn_count=4
|
||||
vault_wg_min_layer_count=4
|
||||
vault_wg_max_layer_count=6
|
||||
vault_wg_min_attached_world=0
|
||||
vault_wg_max_attached_world=4
|
||||
vault_wg_min_electric_box_count=2
|
||||
vault_wg_max_electric_box_count=4
|
||||
#ElectricBox
|
||||
electric_box_hp=250
|
||||
electric_box_respawnTime=256
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
#set ($title = "Official game server") ## TODO get from config
|
||||
#set ($title = $gamePageTitle)
|
||||
#set ($cur_page = "play")
|
||||
#parse("head.vm")
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user