1 # This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
2 # or any later version. For details on its copyright, license, and warranties,
3 # see the file NOTICE in the root directory of the PlomRogue source package.
6 from server.config.world_data import world_db
10 from server.make_map import new_pos, is_neighbor
11 from server.utils import rand
12 world_db["MAP"] = bytearray(b'X' * (world_db["MAP_LENGTH"] ** 2))
13 length = world_db["MAP_LENGTH"]
14 add_half_width = (not (length % 2)) * int(length / 2)
15 world_db["MAP"][int((length ** 2) / 2) + add_half_width] = ord("#")
18 if "X" == chr(world_db["MAP"][pos]) and is_neighbor((y, x), "#"):
19 if y == 0 or y == (length - 1) or x == 0 or x == (length - 1):
21 world_db["MAP"][pos] = ord("#")
22 n_trees = int((length ** 2) / 16)
24 while (i_trees <= n_trees):
25 single_allowed = rand.next() % 32
27 if "#" == chr(world_db["MAP"][pos]) \
28 and ((not single_allowed) or is_neighbor((y, x), ".")):
29 world_db["MAP"][pos] = ord(".")
33 def actor_move_attempts_hook(t, move_result, pos):
34 from server.utils import rand
35 if ord("#") == world_db["MAP"][pos] and 0 == int(rand.next() % 5):
36 world_db["MAP"][pos] = ord(".")
41 def play_move_attempt_hook(t, direction, pos):
42 if ord("#") == world_db["MAP"][pos]:
44 world_db["Things"][0]["T_ARGUMENT"] = direction
50 import server.config.actions
51 server.config.actions.actor_move_attempts_hook = actor_move_attempts_hook
52 import server.config.commands
53 server.config.commands.play_move_attempt_hook = play_move_attempt_hook
54 import server.config.world_data
55 server.config.world_data.symbols_hide += "#"
56 import server.config.make_world_helpers
57 server.config.make_world_helpers.make_map = make_map