1 # This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
2 # or any later version. For details on its copyright, license, and warranties,
3 # see the file NOTICE in the root directory of the PlomRogue source package.
6 def decrement_lifepoints(t):
7 """Decrement t's lifepoints by 1; if to zero, corpse it, drop its stuff.
9 If t is the player avatar, only blank its fovmap, so that the client may
10 still display memory data. On non-player things, erase fovmap and memory.
11 On kill, return dying type's TT_LIFEPOINTS, else 0.
13 from server.config.world_data import world_db
14 from server.io import log
15 t["T_LIFEPOINTS"] -= 1
16 if 0 == t["T_LIFEPOINTS"]:
17 live_tid = t["T_TYPE"]
18 for tid in t["T_CARRIES"]:
19 t["T_CARRIES"].remove(tid)
20 world_db["Things"][tid]["carried"] = False
21 t["T_TYPE"] = world_db["ThingTypes"][t["T_TYPE"]]["TT_CORPSE_ID"]
22 if world_db["Things"][0] == t:
23 t["fovmap"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2))
25 log("See README on how to start over.")
29 t["T_MEMDEPTHMAP"] = False
31 return world_db["ThingTypes"][live_tid]["TT_LIFEPOINTS"]