X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/balance?a=blobdiff_plain;f=plugins%2Fserver%2FPleaseTheIslandGod.py;h=40fa6937a491c5d48f9ef67d54e1d85321fcc0a0;hb=27797029a3f0619dbe0cc64ed3322a1610a4fec1;hp=09672b227c0f325ed25616a5581bb34cebe64a4c;hpb=22508813dc1bc6a53652349253f9ee19b1ac4a0f;p=plomrogue diff --git a/plugins/server/PleaseTheIslandGod.py b/plugins/server/PleaseTheIslandGod.py index 09672b2..40fa693 100644 --- a/plugins/server/PleaseTheIslandGod.py +++ b/plugins/server/PleaseTheIslandGod.py @@ -5,13 +5,9 @@ from server.config.io import io_db from server.new_thing import new_Thing def make_world(seed): - from server.config.world_data import world_db, symbols_passable - from server.config.misc import make_map_func - from server.config.io import io_db - from server.utils import rand, libpr, id_setter - from server.new_thing import new_Thing - from server.io import strong_write from server.update_map_memory import update_map_memory + from server.config.misc import make_map_func + from server.utils import libpr def free_pos(plant=False): i = 0 @@ -83,10 +79,8 @@ def make_world(seed): strong_write(io_db["file_out"], "NEW_WORLD\n") def thingproliferation(t, prol_map): - from server.config.world_data import directions_db, symbols_passable,\ - world_db - from server.utils import mv_yx_in_dir_legal, rand from server.new_thing import new_Thing + global directions_db, mv_yx_in_dir_legal prolscore = world_db["ThingTypes"][t["T_TYPE"]]["TT_PROLIFERATE"] if prolscore and \ (world_db["ThingTypes"][t["T_TYPE"]]["TT_LIFEPOINTS"] == 0 or @@ -119,8 +113,7 @@ def thingproliferation(t, prol_map): # world_db["GOD_FAVOR"] += 750 def make_map(): - from server.config.world_data import world_db - from server.utils import rand + global rand def is_neighbor(coordinates, type): y = coordinates[0] @@ -179,17 +172,17 @@ def make_map(): and ((not single_allowed) or is_neighbor((y, x), ":"))): world_db["MAP"][pos] = ord(":") i_colons += 1 - #altar_placed = False - #while not altar_placed: - # y = rand.next() % length - # x = rand.next() % length - # pos = (y * length) + x - # if (("." == chr(world_db["MAP"][pos] - # or ":" == chr(world_db["MAP"][pos])) - # and not is_neighbor((y, x), "X"))): - # world_db["MAP"][pos] = ord("_") - # world_db["altar"] = (y, x) - # altar_placed = True + altar_placed = False + while not altar_placed: + y = rand.next() % length + x = rand.next() % length + pos = (y * length) + x + if (("." == chr(world_db["MAP"][pos] + or ":" == chr(world_db["MAP"][pos])) + and not is_neighbor((y, x), "X"))): + world_db["MAP"][pos] = ord("_") + world_db["altar"] = (y, x) + altar_placed = True def ai(t): from server.ai import get_dir_to_target, get_inventory_slot_to_consume, \ @@ -269,9 +262,12 @@ def actor_drop(t): def actor_move(t): - from server.utils import mv_yx_in_dir_legal + + def enter_altar(): + log("YOU ENTER SACRED GROUND.") + + from server.config.world_data import symbols_passable from server.build_fov_map import build_fov_map - from server.config.world_data import directions_db, symbols_passable def decrement_lifepoints(t): t["T_LIFEPOINTS"] -= 1 _id = [_id for _id in world_db["Things"] if world_db["Things"][_id] == t][0] @@ -331,6 +327,9 @@ def actor_move(t): build_fov_map(t) if t == world_db["Things"][0]: log("You MOVE " + dir + ".") + if (move_result[1] == world_db["altar"][0] and + move_result[2] == world_db["altar"][1]): + enter_altar() def command_ttid(id_string): id = id_setter(id_string, "ThingTypes", command_ttid) @@ -347,6 +346,47 @@ def command_ttid(id_string): "TT_TOOL": "" } +def command_worldactive(worldactive_string): + val = integer_test(worldactive_string, 0, 1) + if None != val: + if 0 != world_db["WORLD_ACTIVE"]: + if 0 == val: + set_world_inactive() + else: + print("World already active.") + elif 0 == world_db["WORLD_ACTIVE"]: + wait_exists = False + for ThingAction in world_db["ThingActions"]: + if "wait" == world_db["ThingActions"][ThingAction]["TA_NAME"]: + wait_exists = True + break + player_exists = False + for Thing in world_db["Things"]: + if 0 == Thing: + player_exists = True + break + altar_found = False + if world_db["MAP"]: + pos = world_db["MAP"].find(b'_') + if pos > 0: + y = int(pos / world_db["MAP_LENGTH"]) + x = pos % world_db["MAP_LENGTH"] + world_db["altar"] = (y, x) + altar_found = True + if altar_found and wait_exists and player_exists and \ + world_db["MAP"]: + for id in world_db["Things"]: + if world_db["Things"][id]["T_LIFEPOINTS"]: + build_fov_map(world_db["Things"][id]) + if 0 == id: + update_map_memory(world_db["Things"][id], False) + if not world_db["Things"][0]["T_LIFEPOINTS"]: + empty_fovmap = bytearray(b" " * world_db["MAP_LENGTH"] ** 2) + world_db["Things"][0]["fovmap"] = empty_fovmap + world_db["WORLD_ACTIVE"] = 1 + else: + print("Ignoring: Not all conditions for world activation met.") + strong_write(io_db["file_out"], "PLUGIN PleaseTheIslandGod\n") if not "GOD_FAVOR" in world_db: @@ -354,7 +394,7 @@ if not "GOD_FAVOR" in world_db: io_db["worldstate_write_order"] += [["GOD_FAVOR", "world_int"]] import server.config.world_data -server.config.world_data.symbols_passable += ":" +server.config.world_data.symbols_passable += ":_" from server.config.world_data import thing_defaults thing_defaults["T_PLAYERDROP"] = 0 @@ -370,6 +410,7 @@ commands_db["TT_ID"] = (1, False, command_ttid) commands_db["GOD_FAVOR"] = (1, False, setter(None, "GOD_FAVOR", -32768, 32767)) commands_db["TT_STORAGE"] = (1, False, setter("ThingType", "TT_STORAGE", 0, 255)) commands_db["T_PLAYERDROP"] = (1, False, setter("Thing", "T_PLAYERDROP", 0, 1)) +commands_db["WORLD_ACTIVE"] = (1, False, command_worldactive) import server.config.misc server.config.misc.make_map_func = make_map