X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=roguelike-server;h=a70b590356eae8f20f2868e38b45bea2a6859333;hb=d5c3c09f3cfdc5e00128b1fc630a641a4e6d48d4;hp=7ccfafe8b828db833d5b4262e155f67446cd35d4;hpb=33baba1ba773b1472015bb7568e5ff15f5e82452;p=plomrogue diff --git a/roguelike-server b/roguelike-server index 7ccfafe..a70b590 100755 --- a/roguelike-server +++ b/roguelike-server @@ -333,12 +333,12 @@ def try_worldstate_update(): str(world_db["Things"][0]["T_POSX"]) + "\n" + \ str(world_db["MAP_LENGTH"]) + "\n" length = world_db["MAP_LENGTH"] + fov = bytearray(b' ' * (length ** 2)) ord_v = ord("v") for pos in [pos for pos in range(length ** 2) if ord_v == world_db["Things"][0]["fovmap"][pos]]: fov[pos] = world_db["MAP"][pos] - length = world_db["MAP_LENGTH"] for id in [id for tid in reversed(sorted(list(world_db["ThingTypes"]))) for id in world_db["Things"] if not world_db["Things"][id]["carried"] @@ -351,6 +351,7 @@ def try_worldstate_update(): fov[world_db["Things"][id]["T_POSY"] * length + world_db["Things"][id]["T_POSX"]] = c string = write_map(string, fov) + mem = world_db["Things"][0]["T_MEMMAP"][:] for mt in [mt for tid in reversed(sorted(list(world_db["ThingTypes"]))) for mt in world_db["Things"][0]["T_MEMTHING"] @@ -358,6 +359,35 @@ def try_worldstate_update(): c = world_db["ThingTypes"][mt[0]]["TT_SYMBOL"] mem[(mt[1] * length) + mt[2]] = ord(c) string = write_map(string, mem) + + stacksmap = bytearray(b'0' * (length ** 2)) # # + for id in [id for id in world_db["Things"] # # + if not world_db["Things"][id]["carried"] # # + if world_db["Things"][id]["T_LIFEPOINTS"] # # + if world_db["Things"][0]["fovmap"][ # # + world_db["Things"][id]["T_POSY"] * length # # + + world_db["Things"][id]["T_POSX"]] == ord_v]: # # + pos = (world_db["Things"][id]["T_POSY"] * length # # + + world_db["Things"][id]["T_POSX"]) # # + if id == 0 or world_db["EMPATHY"]: # # + type = world_db["Things"][id]["T_TYPE"] # # + max_hp = world_db["ThingTypes"][type]["TT_LIFEPOINTS"] # # + third_of_hp = max_hp / 3 # # + hp = world_db["Things"][id]["T_LIFEPOINTS"] # # + add = 0 # # + if hp > 2 * third_of_hp: # # + add = 2 # # + elif hp > third_of_hp: # # + add = 1 # # + stacksmap[pos] = ord('a') + add # # + else: # # + stacksmap[pos] = ord('X') # # + for mt in world_db["Things"][0]["T_MEMTHING"]: # # + pos = mt[1] * length + mt[2] # # + if stacksmap[pos] < ord('2'): # # + stacksmap[pos] += 1 # # + string = write_map(string, stacksmap) # # + atomic_write(io_db["path_worldstate"], string, delete=False) strong_write(io_db["file_out"], "WORLD_UPDATED\n") io_db["worldstate_updateable"] = False @@ -1957,6 +1987,7 @@ commands_db = { "PLANT_1": (1, False, specialtypesetter("PLANT_1")), # # "LUMBER": (1, False, specialtypesetter("LUMBER")), # # "TOOL_0": (1, False, specialtypesetter("TOOL_0")), # # + "EMPATHY": (1, False, setter(None, "EMPATHY", 0, 1)), # # "TA_ID": (1, False, command_taid), "TA_EFFORT": (1, False, setter("ThingAction", "TA_EFFORT", 0, 255)), "TA_NAME": (1, False, command_taname), @@ -2011,6 +2042,7 @@ world_db = { "PLANT_1": 0, # # "LUMBER": 0, # # "TOOL_0": 0, # # + "EMPATHY": 0, # # "ThingActions": {}, "ThingTypes": {}, "Things": {}