X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=plomrogue-server.py;h=78cf88c5aa0594a6475c4c96d9bbd94374d01f56;hb=d49987db61d3456bcb623fa795b87e629b819d7f;hp=de1bd420cd2a54650c1b036798e1686081ec5505;hpb=f6a542cec9e972c780eba7ed59ba1c2dc913e06f;p=plomrogue diff --git a/plomrogue-server.py b/plomrogue-server.py index de1bd42..78cf88c 100755 --- a/plomrogue-server.py +++ b/plomrogue-server.py @@ -204,8 +204,10 @@ def save_world(): string = "" for key in world_db: - if dict != type(world_db[key]) and key != "MAP": + if dict != type(world_db[key]) and key != "MAP" and \ + key != "WORLD_ACTIVE" and key != "SEED_MAP": string = string + key + " " + str(world_db[key]) + "\n" + string = string + "SEED_MAP " + str(world_db["SEED_MAP"]) + "\n" string = string + helper("ThingActions", "TA_ID") string = string + helper("ThingTypes", "TT_ID", {"TT_CORPSE_ID": False}) for id in world_db["ThingTypes"]: @@ -572,7 +574,7 @@ def decrement_lifepoints(t): def mv_yx_in_dir_legal(dir, y, x): """Wrapper around libpr.mv_yx_in_dir_legal to simplify its use.""" - dir_c = dir.encode("ascii")[0] + dir_c = chr(dir).encode("ascii")[0] test = libpr.mv_yx_in_dir_legal_wrap(dir_c, y, x) if -1 == test: raise RuntimeError("Too much wrapping in mv_yx_in_dir_legal_wrap()!") @@ -610,7 +612,7 @@ def actor_move(t): decrement_lifepoints(world_db["Things"][hit_id]) return dir = [dir for dir in directions_db - if directions_db[dir] == t["T_ARGUMENT"]][0] + if directions_db[dir] == chr(t["T_ARGUMENT"])][0] if passable: t["T_POSY"] = move_result[1] t["T_POSX"] = move_result[2] @@ -909,13 +911,6 @@ def command_quit(): def command_thingshere(str_y, str_x): """Write to out file list of Things known to player at coordinate y, x.""" - def write_thing_if_here(): - if y == world_db["Things"][id]["T_POSY"] \ - and x == world_db["Things"][id]["T_POSX"] \ - and not world_db["Things"][id]["carried"]: - type = world_db["Things"][id]["T_TYPE"] - name = world_db["ThingTypes"][type]["TT_NAME"] - strong_write(io_db["file_out"], name + "\n") if world_db["WORLD_ACTIVE"]: y = integer_test(str_y, 0, 255) x = integer_test(str_x, 0, 255) @@ -925,10 +920,18 @@ def command_thingshere(str_y, str_x): strong_write(io_db["file_out"], "THINGS_HERE START\n") if "v" == chr(world_db["Things"][0]["fovmap"][pos]): for id in world_db["Things"]: - write_thing_if_here() + # write_thing_if_here() + if y == world_db["Things"][id]["T_POSY"] \ + and x == world_db["Things"][id]["T_POSX"] \ + and not world_db["Things"][id]["carried"]: + type = world_db["Things"][id]["T_TYPE"] + name = world_db["ThingTypes"][type]["TT_NAME"] + strong_write(io_db["file_out"], name + "\n") else: - for id in world_db["Things"][0]["T_MEMTHING"]: - write_thing_if_here() + for mt in world_db["Things"][0]["T_MEMTHING"]: + if y == mt[1] and x == mt[2]: + name = world_db["ThingTypes"][mt[0]]["TT_NAME"] + strong_write(io_db["file_out"], name + "\n") strong_write(io_db["file_out"], "THINGS_HERE END\n") else: print("Ignoring: Invalid map coordinates.") @@ -956,7 +959,7 @@ def play_commander(action, args=False): def set_command_and_argument_movestring(str_arg): if str_arg in directions_db: - world_db["Things"][0]["T_ARGUMENT"] = directions_db[str_arg] + world_db["Things"][0]["T_ARGUMENT"] = ord(directions_db[str_arg]) set_command() else: print("Ignoring: Argument must be valid direction string.") @@ -1387,9 +1390,9 @@ commands_db = { """World state database. With sane default values. (Randomness is in rand.)""" world_db = { "TURN": 0, + "MAP_LENGTH": 64, "SEED_MAP": 0, "PLAYER_TYPE": 0, - "MAP_LENGTH": 64, "WORLD_ACTIVE": 0, "ThingActions": {}, "ThingTypes": {},