Files
battle_royale_sim/entities/map.py

58 lines
1.9 KiB
Python

from utils import logs as _logs
class BrSimMap():
def __init__(self, players= None, items= None):
self.players= players or []
self.items= items or []
self.world_width= 15 #seems a reasonable width for smartphones larger maps would go on a new line
self.world_height= 15
self.game_map= []
self.field_sym= '🟩'
self.player_sym= '🟠'
self.item_sym= '📦'
self.init_players_coordinates()
self.init_items_coordinates()
self.init_map_matrix()
def init_map_matrix(self):
# show a matrix representing the game's map
# 🟩 is and empty cell
# (tomorrow we can choose different colors for different locations
# 🟠 this is a player (we could use different colors for different genders)
# 📦 this is an item (weapon or another item)
width= []
for i in range(self.world_width):
width.append(self.field_sym)
for i in range(self.world_height):
self.game_map.append(width)
for player in self.players:
p_coord_x, p_coord_y= players.get_player_coordinates()
self.game_map[p_coord_y][p_coord_x]= self.player_sym
for item in self.items:
i_coord_x, i_coord_y= item.get_item_coordinates()
self.game_map[i_coord_y][i_coord_x]= self.item_sym
_logs.log_debug(f'init_map_matrix: {self.game_map}')
def get_map_matrix(self):
return self.game_map
def get_renderized_map(self):
res= ''
game_map= self.get_map_matrix()
for y in game_map:
for x in y:
res+= x
res+= '\n'
return res
def init_players_coordinates(self):
# XXX init random player.coord_x and player.coord_y (of course not already used coords)
# parse all self.players and define random coordinates (player.coord_x, and player.coord_y)
pass
def init_items_coordinates(self):
# XXX init random item.coord_x and item.coord_y (of course not already used coords)
# parse all self.items and define random coordinates (item.coord_x, and item.coord_y)
pass