"It glows in wondrous colors, and emits a sound as if from a d"
"ying cat. The Island God laughs.\n")
t["T_LIFEPOINTS"] = 1
- from server.config.misc import decrement_lifepoints_func
- decrement_lifepoints_func(t)
+ from server.config.misc import decrement_lifepoints
+ decrement_lifepoints(t)
elif (world_db["ThingTypes"][ty]["TT_TOOL"] == "carpentry"):
pos = t["T_POSY"] * world_db["MAP_LENGTH"] + t["T_POSX"]
if (world_db["MAP"][pos] == ord("X")
return False
def decrement_lifepoints(t):
- t["T_LIFEPOINTS"] -= 1
+ from server.decrement_lifepoints import decrement_lifepoints
live_tid = t["T_TYPE"]
- _id = [_id for _id in world_db["Things"] if world_db["Things"][_id] == t][0]
- if 0 == t["T_LIFEPOINTS"]:
- for id in t["T_CARRIES"]:
- t["T_CARRIES"].remove(id)
- world_db["Things"][id]["T_POSY"] = t["T_POSY"]
- world_db["Things"][id]["T_POSX"] = t["T_POSX"]
- world_db["Things"][id]["carried"] = False
- t["T_TYPE"] = world_db["ThingTypes"][t["T_TYPE"]]["TT_CORPSE_ID"]
- if world_db["Things"][0] == t:
- t["fovmap"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2))
- log("You die.")
- log("See README on how to start over.")
- else:
- t["fovmap"] = False
- t["T_MEMMAP"] = False
- t["T_MEMDEPTHMAP"] = False
- t["T_MEMTHING"] = []
- n_species = len([id for id in world_db["Things"]
- if world_db["Things"][id]["T_TYPE"] == live_tid])
- if 0 == n_species:
- from server.new_thing import new_Thing
- if world_db["FAVOR_STAGE"] >= 3 and \
+ test = decrement_lifepoints(t)
+ if test > 0 and t != world_db["Things"][0]:
+ n_species = len([tid for tid in world_db["Things"]
+ if world_db["Things"][tid]["T_TYPE"] == live_tid])
+ if 0 == n_species:
+ from server.new_thing import new_Thing
+ if world_db["FAVOR_STAGE"] >= 3 and \
live_tid == world_db["ANIMAL_0"]:
- world_db["GOD_FAVOR"] += 3000
- log("CONGRATULATIONS! The "
- + world_db["ThingTypes"][live_tid]["TT_NAME"]
- + " species has died out. The Island God is pleased.")
- else:
- id = id_setter(-1, "Things")
- world_db["Things"][id] = new_Thing(live_tid,
- world_db["altar"])
- log("The "
- + world_db["ThingTypes"][live_tid]["TT_NAME"]
- + " species has temporarily died out. "
- + "One new-born is spawned at the altar.")
- return world_db["ThingTypes"][live_tid]["TT_LIFEPOINTS"]
- return 0
+ world_db["GOD_FAVOR"] += 3000
+ log("CONGRATULATIONS! The "
+ + world_db["ThingTypes"][live_tid]["TT_NAME"]
+ + " species has died out. The Island God is pleased.")
+ else:
+ tid = id_setter(-1, "Things")
+ world_db["Things"][tid] = new_Thing(live_tid,
+ world_db["altar"])
+ log("The " + world_db["ThingTypes"][live_tid]["TT_NAME"] + " s"
+ "pecies has temporarily died out. One new-born is spawned "
+ "at the altar.")
+ return test
def command_ttid(id_string):
id = id_setter(id_string, "ThingTypes", command_ttid)
import server.config.misc
server.config.misc.make_map_func = make_map
-server.config.misc.decrement_lifepoints_func = decrement_lifepoints
+server.config.misc.decrement_lifepoints = decrement_lifepoints
server.config.misc.calc_effort_func = calc_effort
import server.config.make_world_helpers
plus type id of attacked Thing. On move, return mv_yx_in_dir_legal result.
"""
from server.build_fov_map import build_fov_map
- from server.config.misc import decrement_lifepoints_func
+ from server.config.misc import decrement_lifepoints
from server.utils import mv_yx_in_dir_legal
from server.config.world_data import directions_db, symbols_passable
passable = False
elif 0 == hit_id:
hitter_name = world_db["ThingTypes"][t["T_TYPE"]]["TT_NAME"]
log(hitter_name +" WOUNDS you.")
- decr_test = decrement_lifepoints_func(world_db["Things"][hit_id])
+ decr_test = decrement_lifepoints(world_db["Things"][hit_id])
if decr_test > 0 and t == world_db["Things"][0]:
log(hitted_name + " dies.")
return decr_test, hitted_tid
--- /dev/null
+# This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
+# or any later version. For details on its copyright, license, and warranties,
+# see the file NOTICE in the root directory of the PlomRogue source package.
+
+
+def calc_effort(thing_action, thing):
+ return thing_action["TA_EFFORT"]
--- /dev/null
+# This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
+# or any later version. For details on its copyright, license, and warranties,
+# see the file NOTICE in the root directory of the PlomRogue source package.
+
+
+ai_hook_pickup_test = lambda x: True
from server.decrement_lifepoints import decrement_lifepoints
from server.calc_effort import calc_effort
-decrement_lifepoints_func = decrement_lifepoints
+decrement_lifepoints = decrement_lifepoints
calc_effort_func = calc_effort
def decrement_lifepoints(t):
- """Decrement t's lifepoints by 1, and if to zero, corpse it.
+ """Decrement t's lifepoints by 1; if to zero, corpse it, drop its stuff.
If t is the player avatar, only blank its fovmap, so that the client may
still display memory data. On non-player things, erase fovmap and memory.
- Dying actors drop all their things.
+ On kill, return dying type's TT_LIFEPOINTS, else 0.
"""
from server.config.world_data import world_db
from server.io import log
t["T_LIFEPOINTS"] -= 1
if 0 == t["T_LIFEPOINTS"]:
live_tid = t["T_TYPE"]
- for id in t["T_CARRIES"]:
- t["T_CARRIES"].remove(id)
- world_db["Things"][id]["T_POSY"] = t["T_POSY"]
- world_db["Things"][id]["T_POSX"] = t["T_POSX"]
- world_db["Things"][id]["carried"] = False
+ for tid in t["T_CARRIES"]:
+ t["T_CARRIES"].remove(tid)
+ world_db["Things"][tid]["T_POSY"] = t["T_POSY"]
+ world_db["Things"][tid]["T_POSX"] = t["T_POSX"]
+ world_db["Things"][tid]["carried"] = False
t["T_TYPE"] = world_db["ThingTypes"][t["T_TYPE"]]["TT_CORPSE_ID"]
if world_db["Things"][0] == t:
t["fovmap"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2))
def hunger(t):
"""Decrement t's satiation,dependent on it trigger lifepoint dec chance."""
- from server.config.misc import decrement_lifepoints_func
+ from server.config.misc import decrement_lifepoints
if t["T_SATIATION"] > -32768:
t["T_SATIATION"] -= hunger_per_turn(t["T_TYPE"])
if 0 != t["T_SATIATION"] and 0 == int(rand.next() / abs(t["T_SATIATION"])):
log("You SUFFER from hunger.")
else:
log("You SUFFER from over-eating.")
- decrement_lifepoints_func(t)
+ decrement_lifepoints(t)
def set_world_inactive():