}
}
-extern uint8_t set_cells_passable_on_memmap_to_65534_on_scoremap(char * mem_map)
+extern uint8_t set_cells_passable_on_memmap_to_65534_on_scoremap(char * mem_map,
+ const char * symbols_passable)
{
if (!score_map)
{
uint16_t pos;
for (pos = 0; pos < map_size; pos++)
{
- if ('.' == mem_map[pos])
+ if (NULL != strchr(symbols_passable, mem_map[pos]))
{
score_map[pos] = 65534;
}
"""If passable, move/collide(=attack) thing into T_ARGUMENT's direction."""
from server.world import build_fov_map, decrement_lifepoints
from server.utils import mv_yx_in_dir_legal
- from server.config.world_data import directions_db
+ 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"])
log(hitter_name +" WOUNDS you.")
decrement_lifepoints(world_db["Things"][hit_id])
return
- passable = "." == chr(world_db["MAP"][pos])
+ 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:
"s": memory map cell with greatest-reachable degree of unexploredness
"""
from server.utils import rand, libpr, c_pointer_to_bytearray
+ from server.config.world_data import symbols_passable
def zero_score_map_where_char_on_memdepthmap(c):
# OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
def set_cells_passable_on_memmap_to_65534_on_scoremap():
# OUTSOURCED FOR PERFORMANCE REASONS TO libplomrogue.so:
- # ord_dot = ord(".")
# memmap = t["T_MEMMAP"]
# for i in [i for i in range(world_db["MAP_LENGTH"] ** 2)
- # if ord_dot == memmap[i]]:
+ # if memmap[i] in symbols_passable]:
# set_map_score(i, 65534) # i.e. 65535-1
map = c_pointer_to_bytearray(t["T_MEMMAP"])
- if libpr.set_cells_passable_on_memmap_to_65534_on_scoremap(map):
+ if libpr.set_cells_passable_on_memmap_to_65534_on_scoremap(map,
+ symbols_passable):
raise RuntimeError("No score map allocated for set_cells_passable"
"_on_memmap_to_65534_on_scoremap().")
"T_MEMDEPTHMAP": False,
"fovmap": False
}
+
+symbols_passable = "."
"""To chance of 1/TT_PROLIFERATE, create t offspring in open neighbor cell.
Naturally only works with TT_PROLIFERATE > 0. The neighbor cell must be be
- marked '.' in prol_map. If there are several map cell candidates, one is
+ marked "." in prol_map. If there are several map cell candidates, one is
selected randomly.
"""
from server.config.world_data import directions_db
candidates = []
for dir in [directions_db[key] for key in sorted(directions_db.keys())]:
mv_result = mv_yx_in_dir_legal(dir, t["T_POSY"], t["T_POSX"])
- if mv_result[0] and ord('.') == prol_map[mv_result[1]
+ if mv_result[0] and ord(".") == prol_map[mv_result[1]
* world_db["MAP_LENGTH"]
+ mv_result[2]]:
candidates.append((mv_result[1], mv_result[2]))
of ID = world["PLAYER_TYPE"]. Place Things randomly, and actors not on each
other. Init player's memory map. Write "NEW_WORLD" line to out file.
"""
+ from server.config.world_data import symbols_passable
def free_pos():
i = 0
while 1:
y = rand.next() % world_db["MAP_LENGTH"]
x = rand.next() % world_db["MAP_LENGTH"]
- if "." == chr(world_db["MAP"][y * world_db["MAP_LENGTH"] + x]):
+ if chr(world_db["MAP"][y * world_db["MAP_LENGTH"] + x]) in \
+ symbols_passable:
break
i += 1
if i == 65535: