+def play_drink():
+ if action_exists("drink") and world_db["WORLD_ACTIVE"]:
+ if not chr(world_db["MAP"][world_db["Things"][0]["pos"]]) in "~LO":
+ log("NOTHING to drink here.")
+ return
+ elif world_db["Things"][0]["T_BLADDER"] >= 32:
+ log("You're too FULL to drink more.")
+ return
+ world_db["set_command"]("drink")
+
+
+def actor_drink(t):
+ pos = world_db["Things"][0]["pos"]
+ if chr(world_db["MAP"][pos]) in "~LO" and \
+ t["T_BLADDER"] < 32:
+ log("You DRINK.")
+ t["T_BLADDER"] += 1
+ if chr(world_db["MAP"][pos]) == "~":
+ world_db["MAP"][pos] = ord("_")
+ elif chr(world_db["MAP"][pos]) == "L":
+ world_db["MAP"][pos] = ord("~")
+ elif chr(world_db["MAP"][pos]) == "O":
+ world_db["MAP"][pos] = ord("L")
+
+
+def play_pee():
+ if action_exists("pee") and world_db["WORLD_ACTIVE"]:
+ if world_db["Things"][0]["T_BLADDER"] < 1:
+ log("Nothing to drop from empty bladder.")
+ return
+ world_db["set_command"]("pee")
+
+
+def actor_pee(t):
+ if t["T_BLADDER"] < 1:
+ return
+ if t == world_db["Things"][0]:
+ log("You LOSE fluid.")
+ t["T_BLADDER"] -= 1
+ terrain = world_db["MAP"][t["pos"]]
+ if terrain == ord("_"):
+ world_db["MAP"][t["pos"]] = ord("~")
+ elif terrain == ord("~"):
+ world_db["MAP"][t["pos"]] = ord("L")
+ elif terrain == ord("L"):
+ world_db["MAP"][t["pos"]] = ord("L") + 3
+ elif terrain == ord("."):
+ world_db["MAP"][t["pos"]] = ord("J")
+ elif terrain == ord("J"):
+ world_db["MAP"][t["pos"]] = ord("J") + 3
+ elif terrain == ord("J") + 3:
+ world_db["MAP"][t["pos"]] = ord("J") + 6
+ elif terrain == ord(":"):
+ world_db["MAP"][t["pos"]] = ord("K")
+ elif terrain == ord("K"):
+ world_db["MAP"][t["pos"]] = ord("K") + 3
+ elif terrain == ord("K") + 3:
+ world_db["MAP"][t["pos"]] = ord("K") + 6
+ elif terrain == ord("%"):
+ world_db["MAP"][t["pos"]] = ord("A")
+ elif terrain == ord("A"):
+ world_db["MAP"][t["pos"]] = ord("A") + 3
+ elif terrain == ord("A") + 3:
+ world_db["MAP"][t["pos"]] = ord("A") + 6
+ elif terrain == ord("#"):
+ world_db["MAP"][t["pos"]] = ord("B")
+ elif terrain == ord("B"):
+ world_db["MAP"][t["pos"]] = ord("B") + 3
+ elif terrain == ord("B") + 3:
+ world_db["MAP"][t["pos"]] = ord("B") + 6
+ elif terrain == ord("X"):
+ world_db["MAP"][t["pos"]] = ord("C")
+ elif terrain == ord("C"):
+ world_db["MAP"][t["pos"]] = ord("C") + 3
+ elif terrain == ord("C") + 3:
+ world_db["MAP"][t["pos"]] = ord("C") + 6
+ elif chr(terrain) in "GHIOPQ":
+ t["T_LIFEPOINTS"] = 0
+ if t == world_db["Things"][0]:
+ t["fovmap"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2))
+ log("You DROWN.")
+
+
+def play_drop():
+ if action_exists("drop") and world_db["WORLD_ACTIVE"]:
+ if world_db["Things"][0]["T_BOWEL"] < 1:
+ log("Nothing to drop from empty bowel.")
+ return
+ world_db["set_command"]("drop")
+
+
+def actor_drop(t):
+ if t["T_BOWEL"] < 1:
+ return
+ if t == world_db["Things"][0]:
+ log("You DROP waste.")
+ terrain = world_db["MAP"][t["pos"]]
+ t["T_BOWEL"] -= 1
+ if terrain == ord("_"):
+ world_db["MAP"][t["pos"]] = ord(".")
+ elif terrain == ord("~"):
+ world_db["MAP"][t["pos"]] = ord("J")
+ elif terrain == ord("L") :
+ world_db["MAP"][t["pos"]] = ord("J") + 3
+ elif terrain == ord("L") + 3:
+ world_db["MAP"][t["pos"]] = ord("J") + 6
+ elif terrain == ord("."):
+ world_db["MAP"][t["pos"]] = ord(":")
+ elif terrain == ord("J"):
+ world_db["MAP"][t["pos"]] = ord("K")
+ elif terrain == ord("J") + 3:
+ world_db["MAP"][t["pos"]] = ord("K") + 3
+ elif terrain == ord("J") + 6:
+ world_db["MAP"][t["pos"]] = ord("K") + 6
+ elif terrain == ord(":"):
+ world_db["MAP"][t["pos"]] = ord("%")
+ elif terrain == ord("K"):
+ world_db["MAP"][t["pos"]] = ord("A")
+ elif terrain == ord("K") + 3:
+ world_db["MAP"][t["pos"]] = ord("A") + 3
+ elif terrain == ord("K") + 6:
+ world_db["MAP"][t["pos"]] = ord("A") + 6
+ elif terrain == ord("%"):
+ world_db["MAP"][t["pos"]] = ord("#")
+ elif terrain == ord("A"):
+ world_db["MAP"][t["pos"]] = ord("B")
+ elif terrain == ord("A") + 3:
+ world_db["MAP"][t["pos"]] = ord("B") + 3
+ elif terrain == ord("A") + 6:
+ world_db["MAP"][t["pos"]] = ord("B") + 6
+ elif terrain == ord("#"):
+ world_db["MAP"][t["pos"]] = ord("X")
+ elif terrain == ord("B"):
+ world_db["MAP"][t["pos"]] = ord("C")
+ elif terrain == ord("B") + 3:
+ world_db["MAP"][t["pos"]] = ord("C") + 3
+ elif terrain == ord("B") + 6:
+ world_db["MAP"][t["pos"]] = ord("C") + 6
+ elif chr(terrain) in "XCFI":
+ t["T_LIFEPOINTS"] = 0
+ if t == world_db["Things"][0]:
+ t["fovmap"] = bytearray(b' ' * (world_db["MAP_LENGTH"] ** 2))
+ log("You SUFFOCATE.")
+
+
+def play_move(str_arg):
+ """Try "move" as player's T_COMMAND, str_arg as T_ARGUMENT / direction."""
+ if action_exists("move") and world_db["WORLD_ACTIVE"]:
+ from server.config.world_data import directions_db, symbols_passable
+ t = world_db["Things"][0]
+ if not str_arg in directions_db:
+ print("Illegal move direction string.")
+ return
+ d = ord(directions_db[str_arg])
+ from server.utils import mv_yx_in_dir_legal
+ move_result = mv_yx_in_dir_legal(chr(d), t["T_POSY"], t["T_POSX"])
+ if 1 == move_result[0]:
+ pos = (move_result[1] * world_db["MAP_LENGTH"]) + move_result[2]
+ if chr(world_db["MAP"][pos]) in "%#ABDEGH":
+ if t["T_BOWEL"] >= 32:
+ if t == world_db["Things"][0]:
+ log("You're too FULL to eat.")
+ return
+ world_db["Things"][0]["T_ARGUMENT"] = d
+ world_db["set_command"]("move")
+ return
+ if chr(world_db["MAP"][pos]) in symbols_passable:
+ world_db["Things"][0]["T_ARGUMENT"] = d
+ world_db["set_command"]("move")
+ return
+ log("You CAN'T eat your way through there.")