X-Git-Url: https://plomlompom.com/repos/test.html?a=blobdiff_plain;f=plomrogue-server.py;h=9e4f008a5198d58d3dc937456532eaf1480a482f;hb=b4e6d1d9288cc3b44c7b524ddd74d2feb0e24b3d;hp=6f51078710609f13bcc7b5067ae391d7fbf0e3d9;hpb=876840711e8e51be461b2b921eac52cdd2faefcb;p=plomrogue
diff --git a/plomrogue-server.py b/plomrogue-server.py
index 6f51078..9e4f008 100755
--- a/plomrogue-server.py
+++ b/plomrogue-server.py
@@ -82,7 +82,7 @@ def obey(command, prefix, replay=False, do_record=False):
else:
print("Reached end of record file.")
else:
- commands_db[tokens[0]][2]()
+ commands_db[tokens[0]][2](*tokens[1:])
if do_record:
record(command)
save_world()
@@ -119,7 +119,7 @@ def record(command):
def save_world():
# Dummy for saving all commands to reconstruct current world state.
# Misses same optimizations as record() from the original record().
- atomic_write(io_db["path_save"], "bla\n")
+ atomic_write(io_db["path_save"], "TURN " + str(world_db["TURN"]) + "\n")
def obey_lines_in_file(path, name, do_record=False):
@@ -234,7 +234,7 @@ def play_game():
obey(read_command(), "in file", do_record=True)
-def command_makeworld():
+def command_makeworld(seed):
"""Mere dummy so far."""
print("I would build a whole world now if only I knew how.")
@@ -250,6 +250,11 @@ def command_quit():
raise SystemExit("received QUIT command")
+def command_turn(turn_string):
+ """Set turn to what's described in turn_string."""
+ world_db["TURN"] = int(turn_string)
+
+
"""Commands database.
Map command start tokens to ([0]) minimum number of expected command arguments,
@@ -260,13 +265,14 @@ function to be called on it.
commands_db = {
"QUIT": (0, True, command_quit),
"PING": (0, True, command_ping),
- "MAKE_WORLD": (1, False, command_makeworld)
+ "MAKE_WORLD": (1, False, command_makeworld),
+ "TURN": (1, False, command_turn)
}
"""World state database,"""
world_db = {
- "turn": 0
+ "TURN": 0
}