-def make_world(seed):
- 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
- while 1:
- err = "Space to put thing on too hard to find. Map too small?"
- while 1:
- y = rand.next() % world_db["MAP_LENGTH"]
- x = rand.next() % world_db["MAP_LENGTH"]
- pos = y * world_db["MAP_LENGTH"] + x;
- if (not plant
- and "." == chr(world_db["MAP"][pos])) \
- or ":" == chr(world_db["MAP"][pos]):
- break
- i += 1
- if i == 65535:
- raise SystemExit(err)
- pos_clear = (0 == len([id for id in world_db["Things"]
- if world_db["Things"][id]["T_LIFEPOINTS"]
- if world_db["Things"][id]["T_POSY"] == y
- if world_db["Things"][id]["T_POSX"] == x]))
- if pos_clear:
- break
- return (y, x)
-
- rand.seed = seed
- if world_db["MAP_LENGTH"] < 1:
- print("Ignoring: No map length >= 1 defined.")
- return
- libpr.set_maplength(world_db["MAP_LENGTH"])
- player_will_be_generated = False
- playertype = world_db["PLAYER_TYPE"]
- for ThingType in world_db["ThingTypes"]:
- if playertype == ThingType:
- if 0 < world_db["ThingTypes"][ThingType]["TT_START_NUMBER"]:
- player_will_be_generated = True
- break
- if not player_will_be_generated:
- print("Ignoring: No player type with start number >0 defined.")
- return
- wait_action = False
- for ThingAction in world_db["ThingActions"]:
- if "wait" == world_db["ThingActions"][ThingAction]["TA_NAME"]:
- wait_action = True
- if not wait_action:
- print("Ignoring beyond SEED_MAP: " +
- "No thing action with name 'wait' defined.")
- return
+def pos_test(type, y, x):
+ pos = y * world_db["MAP_LENGTH"] + x;
+ plant = world_db["ThingTypes"][type]["TT_PROLIFERATE"]
+ return (not plant or ":" == chr(world_db["MAP"][pos]))
+
+def world_makable():
+ from server.world_makable import world_makable
+ playertype = world_makable()