def actor_move_attempts_hook(t, move_result, pos): if (ord("X") == world_db["MAP"][pos] or ord("|") == world_db["MAP"][pos]): for tid in t["T_CARRIES"]: ty = world_db["Things"][tid]["T_TYPE"] if world_db["ThingTypes"][ty]["TT_TOOL"] == "axe": axe_name = world_db["ThingTypes"][ty]["TT_NAME"] if t == world_db["Things"][0]: log("With your " + axe_name + ", you chop!") if ord("X") == world_db["MAP"][pos]: world_db["GOD_FAVOR"] -= 1 chop_power = world_db["ThingTypes"][ty]["TT_TOOLPOWER"] case_X = world_db["MAP"][pos] == ord("X") if (chop_power > 0 and ((case_X and 0 == int(rand.next() / chop_power)) or (not case_X and 0 == int(rand.next() / (3 * chop_power))))): if t == world_db["Things"][0]: log("You chop it DOWN.") if ord("X") == world_db["MAP"][pos]: world_db["GOD_FAVOR"] -= 10 world_db["MAP"][pos] = ord(".") i = 3 if case_X else 1 from server.new_thing import new_Thing for i in range(i): tid = id_setter(-1, "Things") world_db["Things"][tid] = new_Thing( world_db["LUMBER"], (move_result[1], move_result[2])) build_fov_map(t) return True return False
def decrement_lifepoints(t): """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. 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 tid in t["T_CARRIES"]: t["T_CARRIES"].remove(tid) 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)) 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"] = [] return world_db["ThingTypes"][live_tid]["TT_LIFEPOINTS"] return 0
def decrement_lifepoints(t): from server.decrement_lifepoints import decrement_lifepoints live_tid = t["T_TYPE"] 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: 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 decrement_lifepoints(t): """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. 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 tid in t["T_CARRIES"]: t["T_CARRIES"].remove(tid) 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)) 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"] = [] return world_db["ThingTypes"][live_tid]["TT_LIFEPOINTS"] return 0
def actor_move_attempts_hook(t, move_result, pos): if (ord("X") == world_db["MAP"][pos] or ord("|") == world_db["MAP"][pos]): for tid in t["T_CARRIES"]: ty = world_db["Things"][tid]["T_TYPE"] if world_db["ThingTypes"][ty]["TT_TOOL"] == "axe": axe_name = world_db["ThingTypes"][ty]["TT_NAME"] if t == world_db["Things"][0]: log("With your " + axe_name + ", you chop!") if ord("X") == world_db["MAP"][pos]: world_db["GOD_FAVOR"] -= 1 chop_power = world_db["ThingTypes"][ty]["TT_TOOLPOWER"] case_X = world_db["MAP"][pos] == ord("X") if (chop_power > 0 and ((case_X and 0 == int(rand.next() / chop_power)) or (not case_X and 0 == int(rand.next() / (3 * chop_power))))): if t == world_db["Things"][0]: log("You chop it DOWN.") if ord("X") == world_db["MAP"][pos]: world_db["GOD_FAVOR"] -= 10 world_db["MAP"][pos] = ord(".") i = 3 if case_X else 1 from server.new_thing import new_Thing for i in range(i): tid = id_setter(-1, "Things") world_db["Things"][tid] = new_Thing(world_db["LUMBER"], (move_result[1], move_result[2])) build_fov_map(t) return True return False
def thingprol_post_create(t): tt = world_db["ThingTypes"][t["T_TYPE"]] if (world_db["FAVOR_STAGE"] > 0 and t["T_TYPE"] == world_db["PLANT_0"]): world_db["GOD_FAVOR"] += 5 elif t["T_TYPE"] == world_db["PLANT_1"]: world_db["GOD_FAVOR"] += 25 elif world_db["FAVOR_STAGE"] >= 4 and t["T_TYPE"] == world_db["ANIMAL_1"]: log("The Island God SMILES upon a new-born bear baby.") world_db["GOD_FAVOR"] += 750
def actor_drop(t): """Drop to ground from t's inventory, return T_ARGUMENT-indexed Thing.""" # TODO: Handle case where T_ARGUMENT matches nothing. if len(t["T_CARRIES"]): id = t["T_CARRIES"][t["T_ARGUMENT"]] t["T_CARRIES"].remove(id) world_db["Things"][id]["carried"] = False if t == world_db["Things"][0]: log("You DROP an object.") return world_db["Things"][id]
def hunger(t): """Decrement t's satiation,dependent on it trigger lifepoint dec chance.""" 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"])): if t == world_db["Things"][0]: if t["T_SATIATION"] < 0: log("You SUFFER from hunger.") else: log("You SUFFER from over-eating.") decrement_lifepoints(t)
def play_pickup(): """Try "pickup" as player's T_COMMAND".""" if action_exists("pickup") and world_db["WORLD_ACTIVE"]: t = world_db["Things"][0] ids = [tid for tid in world_db["Things"] if tid if not world_db["Things"][tid]["carried"] if world_db["Things"][tid]["pos"] == t["pos"]] from server.config.commands import play_pickup_attempt_hook if not len(ids): log("NOTHING to pick up.") elif play_pickup_attempt_hook(t): set_command("pickup")
def try_healing(t): """If t's HP < max, increment them if well-nourished, maybe waiting.""" if t["T_LIFEPOINTS"] < \ world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"]: wait_id = [id for id in world_db["ThingActions"] if world_db["ThingActions"][id]["TA_NAME"] == "wait"][0] wait_divider = 8 if t["T_COMMAND"] == wait_id else 1 testval = int(abs(t["T_SATIATION"]) / wait_divider) if (testval <= 1 or 1 == (rand.next() % testval)): t["T_LIFEPOINTS"] += 1 if t == world_db["Things"][0]: log("You HEAL.")
def play_drop(str_arg): """Try "drop" as player's T_COMMAND, int(str_arg) as T_ARGUMENT / slot.""" if action_exists("drop") and world_db["WORLD_ACTIVE"]: t = world_db["Things"][0] if 0 == len(t["T_CARRIES"]): log("You have NOTHING to drop in your inventory.") else: val = integer_test(str_arg, 0, 255) if None != val and val < len(t["T_CARRIES"]): world_db["Things"][0]["T_ARGUMENT"] = val set_command("drop") else: print("Illegal inventory index.")
def actor_pickup(t): used_slots = len(t["T_CARRIES"]) if used_slots < world_db["ThingTypes"][t["T_TYPE"]]["TT_STORAGE"]: from server.actions import actor_pickup t_picked = actor_pickup(t) if t_picked != None: ty = world_db["ThingTypes"][t_picked["T_TYPE"]] if t != world_db["Things"][0] and t_picked["T_PLAYERDROP"] \ and ty["TT_TOOL"] == "food": score = int(ty["TT_TOOLPOWER"] / 32) world_db["GOD_FAVOR"] += score t_picked["T_PLAYERDROP"] = 0 elif t == world_db["Things"][0]: log("CAN'T pick up object: No storage room to carry more.")
def play_pickup(): """Try "pickup" as player's T_COMMAND".""" if action_exists("pickup") and world_db["WORLD_ACTIVE"]: t = world_db["Things"][0] ids = [ tid for tid in world_db["Things"] if tid if not world_db["Things"][tid]["carried"] if world_db["Things"][tid]["pos"] == t["pos"] ] from server.config.commands import play_pickup_attempt_hook if not len(ids): log("NOTHING to pick up.") elif play_pickup_attempt_hook(t): set_command("pickup")
def try_healing(t): """If t's HP < max, increment them if well-nourished, maybe waiting.""" if t["T_LIFEPOINTS"] < \ world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"]: wait_id = [ id for id in world_db["ThingActions"] if world_db["ThingActions"][id]["TA_NAME"] == "wait" ][0] wait_divider = 8 if t["T_COMMAND"] == wait_id else 1 testval = int(abs(t["T_SATIATION"]) / wait_divider) if (testval <= 1 or 1 == (rand.next() % testval)): t["T_LIFEPOINTS"] += 1 if t == world_db["Things"][0]: log("You HEAL.")
def actor_use(t): """Make t use (for now: consume) T_ARGUMENT-indexed Thing in inventory.""" # TODO: Handle case where T_ARGUMENT matches nothing. if len(t["T_CARRIES"]): id = t["T_CARRIES"][t["T_ARGUMENT"]] type = world_db["Things"][id]["T_TYPE"] if world_db["ThingTypes"][type]["TT_TOOL"] == "food": t["T_CARRIES"].remove(id) del world_db["Things"][id] t["T_SATIATION"] += world_db["ThingTypes"][type]["TT_TOOLPOWER"] if t == world_db["Things"][0]: log("You CONSUME this thing.") else: from server.config.actions import actor_use_attempts_hook actor_use_attempts_hook(t, type)
def actor_move(t): """If passable, move/collide(=attack) thing into T_ARGUMENT's direction. On attack, return 0 on non-kill and TT_LIFEPOINTS of killed type on kill, 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 from server.utils import mv_yx_in_dir_legal from server.config.world_data import directions_db, symbols_passable passable = False move_result = mv_yx_in_dir_legal(chr(t["T_ARGUMENT"]), t["T_POSY"], t["T_POSX"]) if 1 == move_result[0]: pos = (move_result[1] * world_db["MAP_LENGTH"]) + move_result[2] hitted = [ id for id in world_db["Things"] if world_db["Things"][id] != t if world_db["Things"][id]["T_LIFEPOINTS"] if world_db["Things"][id]["T_POSY"] == move_result[1] if world_db["Things"][id]["T_POSX"] == move_result[2] ] if len(hitted): hit_id = hitted[0] hitted_tid = world_db["Things"][hit_id]["T_TYPE"] if t == world_db["Things"][0]: hitted_name = world_db["ThingTypes"][hitted_tid]["TT_NAME"] log("You WOUND " + hitted_name + ".") elif 0 == hit_id: hitter_name = world_db["ThingTypes"][t["T_TYPE"]]["TT_NAME"] log(hitter_name + " WOUNDS you.") 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 from server.config.actions import actor_move_attempts_hook if actor_move_attempts_hook(t, move_result, pos): return passable = chr(world_db["MAP"][pos]) in symbols_passable dir = [ dir for dir in directions_db if directions_db[dir] == chr(t["T_ARGUMENT"]) ][0] if passable: t["T_POSY"] = move_result[1] t["T_POSX"] = move_result[2] t["pos"] = move_result[1] * world_db["MAP_LENGTH"] + move_result[2] for id in t["T_CARRIES"]: world_db["Things"][id]["T_POSY"] = move_result[1] world_db["Things"][id]["T_POSX"] = move_result[2] world_db["Things"][id]["pos"] = t["pos"] build_fov_map(t) if t == world_db["Things"][0]: log("You MOVE " + dir + ".") return move_result
def actor_move(t): """If passable, move/collide(=attack) thing into T_ARGUMENT's direction. On attack, return 0 on non-kill and TT_LIFEPOINTS of killed type on kill, 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 from server.utils import mv_yx_in_dir_legal from server.config.world_data import directions_db, symbols_passable passable = False move_result = mv_yx_in_dir_legal(chr(t["T_ARGUMENT"]), t["T_POSY"], t["T_POSX"]) if 1 == move_result[0]: pos = (move_result[1] * world_db["MAP_LENGTH"]) + move_result[2] hitted = [id for id in world_db["Things"] if world_db["Things"][id] != t if world_db["Things"][id]["T_LIFEPOINTS"] if world_db["Things"][id]["T_POSY"] == move_result[1] if world_db["Things"][id]["T_POSX"] == move_result[2]] if len(hitted): hit_id = hitted[0] hitted_tid = world_db["Things"][hit_id]["T_TYPE"] if t == world_db["Things"][0]: hitted_name = world_db["ThingTypes"][hitted_tid]["TT_NAME"] log("You WOUND " + hitted_name + ".") elif 0 == hit_id: hitter_name = world_db["ThingTypes"][t["T_TYPE"]]["TT_NAME"] log(hitter_name +" WOUNDS you.") 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 from server.config.actions import actor_move_attempts_hook if actor_move_attempts_hook(t, move_result, pos): return passable = chr(world_db["MAP"][pos]) in symbols_passable dir = [dir for dir in directions_db if directions_db[dir] == chr(t["T_ARGUMENT"])][0] if passable: t["T_POSY"] = move_result[1] t["T_POSX"] = move_result[2] t["pos"] = move_result[1] * world_db["MAP_LENGTH"] + move_result[2] for id in t["T_CARRIES"]: world_db["Things"][id]["T_POSY"] = move_result[1] world_db["Things"][id]["T_POSX"] = move_result[2] world_db["Things"][id]["pos"] = t["pos"] build_fov_map(t) if t == world_db["Things"][0]: log("You MOVE " + dir + ".") return move_result
def play_use(str_arg): """Try "use" as player's T_COMMAND, int(str_arg) as T_ARGUMENT / slot.""" if action_exists("use") and world_db["WORLD_ACTIVE"]: t = world_db["Things"][0] if 0 == len(t["T_CARRIES"]): log("You have NOTHING to use in your inventory.") else: val = integer_test(str_arg, 0, 255) if None != val and val < len(t["T_CARRIES"]): tid = t["T_CARRIES"][val] tt = world_db["ThingTypes"][world_db["Things"][tid]["T_TYPE"]] from server.config.commands import play_use_attempt_hook hook_test = play_use_attempt_hook(t, tt) if not (tt["TT_TOOL"] == "food" or hook_test): if hook_test != False: log("You CAN'T use this thing.") return world_db["Things"][0]["T_ARGUMENT"] = val set_command("use") else: print("Illegal inventory index.")
def actor_pickup(t): """Make t pick up (topmost?) Thing from ground into inventory. Return it. Define topmostness by how low the thing's type ID is. """ ids = [id for id in world_db["Things"] if world_db["Things"][id] != t if not world_db["Things"][id]["carried"] if world_db["Things"][id]["pos"] == t["pos"]] if len(ids): lowest_tid = -1 for iid in ids: tid = world_db["Things"][iid]["T_TYPE"] from server.config.actions import actor_pickup_test_hook if (lowest_tid == -1 or tid < lowest_tid) and \ actor_pickup_test_hook(t, tid): id = iid lowest_tid = tid world_db["Things"][id]["carried"] = True t["T_CARRIES"].append(id) if t == world_db["Things"][0]: log("You PICK UP an object.") return world_db["Things"][id]
def decrement_lifepoints(t): from server.decrement_lifepoints import decrement_lifepoints live_tid = t["T_TYPE"] 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: 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 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 ord("~") == world_db["MAP"][pos]: log("You can't SWIM.") return from server.config.commands import play_move_attempt_hook if play_move_attempt_hook(t, d, pos): return if chr(world_db["MAP"][pos]) in symbols_passable: world_db["Things"][0]["T_ARGUMENT"] = d set_command("move") return log("You CAN'T move there.")
def actor_pickup(t): """Make t pick up (topmost?) Thing from ground into inventory. Return it. Define topmostness by how low the thing's type ID is. """ ids = [ id for id in world_db["Things"] if world_db["Things"][id] != t if not world_db["Things"][id]["carried"] if world_db["Things"][id]["pos"] == t["pos"] ] if len(ids): lowest_tid = -1 for iid in ids: tid = world_db["Things"][iid]["T_TYPE"] from server.config.actions import actor_pickup_test_hook if (lowest_tid == -1 or tid < lowest_tid) and \ actor_pickup_test_hook(t, tid): id = iid lowest_tid = tid world_db["Things"][id]["carried"] = True t["T_CARRIES"].append(id) if t == world_db["Things"][0]: log("You PICK UP an object.") return world_db["Things"][id]
def actor_use_attempts_hook(t, ty): if ty == world_db["SLIPPERS"]: if t == world_db["Things"][0]: log("You use the " + world_db["ThingTypes"][ty]["TT_NAME"] + ". " \ "It glows in wondrous colors, and emits a sound as if from a d" "ying cat. The Island God laughs.") t["T_LIFEPOINTS"] = 1 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") or world_db["MAP"][pos] == ord("|")): return for t_id in [ t_id for t_id in world_db["Things"] if not world_db["Things"][t_id] == t if not world_db["Things"][t_id]["carried"] if world_db["Things"][t_id]["T_POSY"] == t["T_POSY"] if world_db["Things"][t_id]["T_POSX"] == t["T_POSX"] ]: return wood_id = None for t_id in t["T_CARRIES"]: type_material = world_db["Things"][t_id]["T_TYPE"] if (world_db["ThingTypes"][type_material]["TT_TOOL"] == "wood"): wood_id = t_id break if wood_id != None: t["T_CARRIES"].remove(wood_id) del world_db["Things"][wood_id] world_db["MAP"][pos] = ord("|") log("With your " + world_db["ThingTypes"][ty]["TT_NAME"] + " you" \ " build a WOODEN BARRIER from your " + world_db["ThingTypes"][type_material]["TT_NAME"] + ".") elif world_db["ThingTypes"][ty]["TT_TOOL"] == "fertilizer": pos = t["T_POSY"] * world_db["MAP_LENGTH"] + t["T_POSX"] if world_db["MAP"][pos] == ord("."): log("You create SOIL.") world_db["MAP"][pos] = ord(":")
def actor_use_attempts_hook(t, ty): if ty == world_db["SLIPPERS"]: if t == world_db["Things"][0]: log("You use the " + world_db["ThingTypes"][ty]["TT_NAME"] + ". " \ "It glows in wondrous colors, and emits a sound as if from a d" "ying cat. The Island God laughs.") t["T_LIFEPOINTS"] = 1 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") or world_db["MAP"][pos] == ord("|")): return for t_id in [t_id for t_id in world_db["Things"] if not world_db["Things"][t_id] == t if not world_db["Things"][t_id]["carried"] if world_db["Things"][t_id]["T_POSY"] == t["T_POSY"] if world_db["Things"][t_id]["T_POSX"] == t["T_POSX"]]: return wood_id = None for t_id in t["T_CARRIES"]: type_material = world_db["Things"][t_id]["T_TYPE"] if (world_db["ThingTypes"][type_material]["TT_TOOL"] == "wood"): wood_id = t_id break if wood_id != None: t["T_CARRIES"].remove(wood_id) del world_db["Things"][wood_id] world_db["MAP"][pos] = ord("|") log("With your " + world_db["ThingTypes"][ty]["TT_NAME"] + " you" \ " build a WOODEN BARRIER from your " + world_db["ThingTypes"][type_material]["TT_NAME"] + ".") elif world_db["ThingTypes"][ty]["TT_TOOL"] == "fertilizer": pos = t["T_POSY"] * world_db["MAP_LENGTH"] + t["T_POSX"] if world_db["MAP"][pos] == ord("."): log("You create SOIL.") world_db["MAP"][pos] = ord(":")
def actor_wait(t): """Make t do nothing (but loudly, if player avatar).""" if t == world_db["Things"][0]: log("You wait")
def altar_msg_wait(limit): log("The Island God will talk again when it favors you to >=" + str(limit) + " points.")
def enter_altar(): from server.new_thing import new_Thing if world_db["FAVOR_STAGE"] > 9000: log("You step on a soul-less slab of stone.") return log("YOU ENTER SACRED GROUND.") if world_db["FAVOR_STAGE"] == 0: world_db["FAVOR_STAGE"] = 1 log(altar_msg_0) elif world_db["FAVOR_STAGE"] == 1 and world_db["GOD_FAVOR"] < 100: altar_msg_wait(100) elif world_db["FAVOR_STAGE"] == 1 and world_db["GOD_FAVOR"] >= 100: world_db["FAVOR_STAGE"] = 2 log(altar_msg_1) id = id_setter(-1, "Things") world_db["Things"][id] = new_Thing(world_db["PLANT_1"], world_db["altar"]) id = id_setter(-1, "Things") world_db["Things"][id] = new_Thing(world_db["TOOL_0"], world_db["altar"]) elif world_db["FAVOR_STAGE"] == 2 and \ 0 == len([id for id in world_db["Things"] if world_db["Things"][id]["T_TYPE"] == world_db["PLANT_1"]]): log(altar_msg_2) id = id_setter(-1, "Things") world_db["Things"][id] = new_Thing(world_db["PLANT_1"], world_db["altar"]) world_db["GOD_FAVOR"] -= 250 elif world_db["FAVOR_STAGE"] == 2 and world_db["GOD_FAVOR"] < 500: altar_msg_wait(500) elif world_db["FAVOR_STAGE"] == 2 and world_db["GOD_FAVOR"] >= 500: world_db["FAVOR_STAGE"] = 3 log(altar_msg_3) log(altar_msg_4) world_db["EMPATHY"] = 1 elif world_db["FAVOR_STAGE"] == 3 and world_db["GOD_FAVOR"] < 5000: altar_msg_wait(5000) elif world_db["FAVOR_STAGE"] == 3 and world_db["GOD_FAVOR"] >= 5000: world_db["FAVOR_STAGE"] = 4 log(altar_msg_5) id = id_setter(-1, "Things") world_db["Things"][id] = new_Thing(world_db["TOOL_1"], world_db["altar"]) elif world_db["GOD_FAVOR"] < 20000: altar_msg_wait(20000) elif world_db["GOD_FAVOR"] > 20000: world_db["FAVOR_STAGE"] = 9001 log(altar_msg_6) id = id_setter(-1, "Things") world_db["Things"][id] = new_Thing(world_db["SLIPPERS"], world_db["altar"])
def play_use_attempt_hook(t, tt): pos = t["T_POSY"] * world_db["MAP_LENGTH"] + t["T_POSX"] if tt["TT_TOOL"] == "axe": log("To use this item for chopping, MOVE towards a tree while carrying" " it in your inventory.") return False elif tt["TT_TOOL"] == "carpentry": if (world_db["MAP"][pos] == ord("X") or world_db["MAP"][pos] == ord("|")): log("CAN'T build when standing on barrier.") return False for tid in [tid for tid in world_db["Things"] if not world_db["Things"][tid] == t if not world_db["Things"][tid]["carried"] if world_db["Things"][tid]["T_POSY"] == t["T_POSY"] if world_db["Things"][tid]["T_POSX"] == t["T_POSX"]]: log("CAN'T build when standing objects.") return False wood_id = None for tid in t["T_CARRIES"]: type_material = world_db["Things"][tid]["T_TYPE"] if world_db["ThingTypes"][type_material]["TT_TOOL"] == "wood": wood_id = tid break if wood_id == None: log("You CAN'T use a " + tt["TT_NAME"] + " without some wood in your inventory.") return False return True elif tt["TT_TOOL"] == "fertilizer": if not world_db["MAP"][pos] == ord("."): log("Can only make soil out of NON-SOIL earth.") return False return True elif tt["TT_TOOL"] == "wood": log("To use wood, you NEED a carpentry tool.") return False elif tt == world_db["ThingTypes"][world_db["SLIPPERS"]]: return True
def play_pickup_attempt_hook(t): if len(t["T_CARRIES"]) >= world_db["ThingTypes"][t["T_TYPE"]]["TT_STORAGE"]: log("CAN'T pick up: No storage room to carry anything more.") return False return True
def play_pickup_attempt_hook(t): if len(t["T_CARRIES"]) >= world_db["ThingTypes"][ t["T_TYPE"]]["TT_STORAGE"]: log("CAN'T pick up: No storage room to carry anything more.") return False return True
def play_use_attempt_hook(t, tt): pos = t["T_POSY"] * world_db["MAP_LENGTH"] + t["T_POSX"] if tt["TT_TOOL"] == "axe": log("To use this item for chopping, MOVE towards a tree while carrying" " it in your inventory.") return False elif tt["TT_TOOL"] == "carpentry": if (world_db["MAP"][pos] == ord("X") or world_db["MAP"][pos] == ord("|")): log("CAN'T build when standing on barrier.") return False for tid in [ tid for tid in world_db["Things"] if not world_db["Things"][tid] == t if not world_db["Things"][tid]["carried"] if world_db["Things"][tid]["T_POSY"] == t["T_POSY"] if world_db["Things"][tid]["T_POSX"] == t["T_POSX"] ]: log("CAN'T build when standing objects.") return False wood_id = None for tid in t["T_CARRIES"]: type_material = world_db["Things"][tid]["T_TYPE"] if world_db["ThingTypes"][type_material]["TT_TOOL"] == "wood": wood_id = tid break if wood_id == None: log("You CAN'T use a " + tt["TT_NAME"] + " without some wood in your inventory.") return False return True elif tt["TT_TOOL"] == "fertilizer": if not world_db["MAP"][pos] == ord("."): log("Can only make soil out of NON-SOIL earth.") return False return True elif tt["TT_TOOL"] == "wood": log("To use wood, you NEED a carpentry tool.") return False elif tt == world_db["ThingTypes"][world_db["SLIPPERS"]]: return True