home · contact · privacy
84bc5917d15ec5abc385fd080579088e0c357504
[plomrogue] / server / new_thing.py
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.
4
5
6 def new_Thing(_type, pos=(0, 0)):
7     """Return Thing of type T_TYPE, with fovmap if alive and world active."""
8     from server.config.world_data import thing_defaults, world_db
9     from server.build_fov_map import build_fov_map
10     thing = {}
11     for key in thing_defaults:
12         thing[key] = thing_defaults[key]
13         if type(thing[key]) == list:
14             thing[key] = thing[key][:]
15     thing["T_LIFEPOINTS"] = world_db["ThingTypes"][_type]["TT_LIFEPOINTS"]
16     thing["T_TYPE"] = _type
17     thing["T_POSY"] = pos[0]
18     thing["T_POSX"] = pos[1]
19     if world_db["WORLD_ACTIVE"] and thing["T_LIFEPOINTS"]:
20         build_fov_map(thing)
21     return thing