forked from Cryz/battle_royale_sim
fix conflicts
This commit is contained in:
12
bot.py
12
bot.py
@@ -38,8 +38,18 @@ async def bot_start(update, context):
|
|||||||
async def bot_commands(update, context):
|
async def bot_commands(update, context):
|
||||||
text= update.message.text
|
text= update.message.text
|
||||||
chat_id = update.effective_chat.id
|
chat_id = update.effective_chat.id
|
||||||
|
username= update.effective_chat.username
|
||||||
|
first_name= update.effective_chat.first_name
|
||||||
|
last_name= update.effective_chat.last_name
|
||||||
|
chat_type= update.effective_chat.type.name # PRIVAT|BOT|ETC..
|
||||||
|
|
||||||
_log.log_info(f'bot_command: {chat_id} - text received: {text}')
|
|
||||||
|
_log.log_info(f'bot_command: \
|
||||||
|
user id="{chat_id}" \
|
||||||
|
username="{username}" \
|
||||||
|
first_name="{first_name}" \
|
||||||
|
last_name="{last_name}" \
|
||||||
|
chat_type="{chat_type}"')
|
||||||
|
|
||||||
# init or restart the game
|
# init or restart the game
|
||||||
if text == 'Init/Restart':
|
if text == 'Init/Restart':
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ MAP_IMAGE_PLAYER_NONBINARY= (255, 255, 0) # yellow
|
|||||||
MAP_IMAGE_DEATH_PLAYER= (160, 160, 160) # grey
|
MAP_IMAGE_DEATH_PLAYER= (160, 160, 160) # grey
|
||||||
MAP_IMAGE_ITEM= (255, 255, 255) # white
|
MAP_IMAGE_ITEM= (255, 255, 255) # white
|
||||||
|
|
||||||
MAP_IMAGE_LEGEND= """*Legenda*:
|
MAP_IMAGE_LEGEND= r"""*Legenda*:
|
||||||
\- *Verde*: Cella *libera* per muoversi
|
\- *Verde*: Cella *libera* per muoversi
|
||||||
\- *Nero*: Bordo della mappa, *non raggiungibile*
|
\- *Nero*: Bordo della mappa, *non raggiungibile*
|
||||||
\- *Blue*: Posizione di un *giocatore Maschio*
|
\- *Blue*: Posizione di un *giocatore Maschio*
|
||||||
|
|||||||
40
debug.py
40
debug.py
@@ -36,6 +36,33 @@ def _end_game_debug(alive_players, day):
|
|||||||
print(msg)
|
print(msg)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
def _random_action(Arena, Player_one):
|
||||||
|
_RANDOM_ACTIONS= {
|
||||||
|
1: 'attack',
|
||||||
|
2: 'move',
|
||||||
|
}
|
||||||
|
action= _rand.randint(1, len(_RANDOM_ACTIONS))
|
||||||
|
msg= ''
|
||||||
|
if action == 1:
|
||||||
|
# XXX maybe in future this action is available only if you are near to another player
|
||||||
|
# so Player_two is no more random, but will be a random near player
|
||||||
|
Player_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
||||||
|
while Player_one.get_id() == Player_two.get_id():
|
||||||
|
Player_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
||||||
|
_dmg, msg= Player_one.attack(Player_two)
|
||||||
|
elif action == 2:
|
||||||
|
Map= Arena.get_map()
|
||||||
|
available_movements= Map.get_player_available_directions(Player_one)
|
||||||
|
if not available_movements: return f'{Player_one.get_name()} Pensa a Guarino tutto il giorno' # XXX probably should skip this action and look for another action
|
||||||
|
_rand.shuffle(available_movements)
|
||||||
|
x, y, direction= available_movements[0]
|
||||||
|
Player_one.move(x, y)
|
||||||
|
Map.init_map_matrix()
|
||||||
|
print(Map.get_renderized_map())
|
||||||
|
msg= f'{Player_one.get_name()} Si muove a: {direction}'
|
||||||
|
|
||||||
|
return msg
|
||||||
|
|
||||||
def play_one_day_debug(Arena):
|
def play_one_day_debug(Arena):
|
||||||
if not Arena.get_players(): return
|
if not Arena.get_players(): return
|
||||||
print(f'Giorno #{Arena.day}')
|
print(f'Giorno #{Arena.day}')
|
||||||
@@ -46,12 +73,13 @@ def play_one_day_debug(Arena):
|
|||||||
|
|
||||||
daily_events= []
|
daily_events= []
|
||||||
_rand.shuffle(alive_players)
|
_rand.shuffle(alive_players)
|
||||||
for p_one in alive_players:
|
for Player_one in alive_players:
|
||||||
if not p_one.is_alive(): continue # he could be dead during this day cycle
|
if not Player_one.is_alive(): continue # he could be dead during this day cycle
|
||||||
p_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
msg= _random_action(Arena, Player_one)
|
||||||
while p_one.get_id() == p_two.get_id():
|
#p_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
||||||
p_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
#while Player_one.get_id() == p_two.get_id():
|
||||||
_dmg, msg= p_one.attack(p_two)
|
#p_two= _rand.sample(Arena.get_alive_players(), 1)[0]
|
||||||
|
#_dmg, msg= Player_one.attack(p_two)
|
||||||
daily_events.append(msg)
|
daily_events.append(msg)
|
||||||
|
|
||||||
Arena.next_day()
|
Arena.next_day()
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class BrSimMap():
|
|||||||
# 📦 this is an item (weapon or another item)
|
# 📦 this is an item (weapon or another item)
|
||||||
# 💀 this is icon when the player is dead
|
# 💀 this is icon when the player is dead
|
||||||
# ⛰️ this is icon for the mountain (We can prevent players from passing through the mountains and thus use them for map boundaries.)
|
# ⛰️ this is icon for the mountain (We can prevent players from passing through the mountains and thus use them for map boundaries.)
|
||||||
|
self.game_map= []
|
||||||
|
|
||||||
width= []
|
width= []
|
||||||
#mon = []
|
#mon = []
|
||||||
@@ -94,6 +95,19 @@ class BrSimMap():
|
|||||||
|
|
||||||
def get_map_matrix(self):
|
def get_map_matrix(self):
|
||||||
return self.game_map
|
return self.game_map
|
||||||
|
|
||||||
|
def get_player_available_directions(self, Player):
|
||||||
|
coord_x, coord_y= Player.get_player_coordinates()
|
||||||
|
avail_directions= []
|
||||||
|
if self.get_map_matrix()[coord_x - 1][coord_y] not in [self.mountain_sym]:
|
||||||
|
avail_directions.append((-1, 0, 'left'))
|
||||||
|
if self.get_map_matrix()[coord_x + 1][coord_y] not in [self.mountain_sym]:
|
||||||
|
avail_directions.append((1, 0, 'right'))
|
||||||
|
if self.get_map_matrix()[coord_x][coord_y - 1] not in [self.mountain_sym]:
|
||||||
|
avail_directions.append((0, -1, 'up'))
|
||||||
|
if self.get_map_matrix()[coord_x][coord_y + 1] not in [self.mountain_sym]:
|
||||||
|
avail_directions.append((0, 1, 'bottom'))
|
||||||
|
return avail_directions
|
||||||
|
|
||||||
def get_renderized_map(self):
|
def get_renderized_map(self):
|
||||||
res= ''
|
res= ''
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ from entities import resource as _resource
|
|||||||
|
|
||||||
class BrSimItem(_resource.BrSimResource):
|
class BrSimItem(_resource.BrSimResource):
|
||||||
|
|
||||||
|
# test
|
||||||
|
def __init__(self):
|
||||||
|
self.coord_x= 0
|
||||||
|
self.coord_y= 0
|
||||||
|
|
||||||
def is_item(self):
|
def is_item(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -174,6 +174,28 @@ class BrSimPlayer(_resource.BrSimResource):
|
|||||||
return False
|
return False
|
||||||
self.inventory.append(item)
|
self.inventory.append(item)
|
||||||
|
|
||||||
|
def move(self, delta_x, delta_y):
|
||||||
|
# XXX maps limits:
|
||||||
|
# probably this isn't player's business
|
||||||
|
# game orchestror should manage it
|
||||||
|
# to avoid that the player can go out from the map
|
||||||
|
# or can reach unaccessible points
|
||||||
|
# also because the player doens't know the Map (entities/gamemap.py)
|
||||||
|
self.coord_x += delta_x
|
||||||
|
self.coord_y += delta_y
|
||||||
|
|
||||||
|
def move_right(self):
|
||||||
|
self._move(1, 0)
|
||||||
|
|
||||||
|
def move_left(self):
|
||||||
|
self._move(-1, 0)
|
||||||
|
|
||||||
|
def move_top(self):
|
||||||
|
self._move(0, -1)
|
||||||
|
|
||||||
|
def move_bottom(self):
|
||||||
|
self._move(0, 1)
|
||||||
|
|
||||||
def escape(self):
|
def escape(self):
|
||||||
# TODO It can run away from the fighting
|
# TODO It can run away from the fighting
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user