From 51e3367a1c58bd500916061cfbb02d68de1b0d73b2961dc90e02916f16900861 Mon Sep 17 00:00:00 2001 From: frostbite Date: Tue, 29 Jul 2025 14:25:28 +0200 Subject: [PATCH 1/5] fixed SyntaxWarning backslash for python 3.13.0 --- bot_libs/syms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot_libs/syms.py b/bot_libs/syms.py index e301cfb..5b8f15d 100644 --- a/bot_libs/syms.py +++ b/bot_libs/syms.py @@ -103,7 +103,7 @@ MAP_IMAGE_PLAYER_NONBINARY= (255, 255, 0) # yellow MAP_IMAGE_DEATH_PLAYER= (160, 160, 160) # grey MAP_IMAGE_ITEM= (255, 255, 255) # white -MAP_IMAGE_LEGEND= """*Legenda*: +MAP_IMAGE_LEGEND= r"""*Legenda*: \- *Verde*: Cella *libera* per muoversi \- *Nero*: Bordo della mappa, *non raggiungibile* \- *Blue*: Posizione di un *giocatore Maschio* From c30c46e20f4f7eaaa76b4ee7bf923ed52563d726336606e9a11271043db6c1d8 Mon Sep 17 00:00:00 2001 From: cyan Date: Wed, 30 Jul 2025 22:51:10 +0200 Subject: [PATCH 2/5] test push --- entities/items/item.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entities/items/item.py b/entities/items/item.py index 8e8d055..90fb489 100644 --- a/entities/items/item.py +++ b/entities/items/item.py @@ -1,7 +1,8 @@ import random as _random class BrSimItem(): - + + # test def __init__(self): self.coord_x= 0 self.coord_y= 0 From 47729ceeb9bd4975a2b15f6dabcad0d6d22f01f8a0fe1b54b1c0f70c4efd7d9f Mon Sep 17 00:00:00 2001 From: andrea Date: Fri, 1 Aug 2025 19:20:23 +0200 Subject: [PATCH 3/5] bot log more user info --- bot.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 38ebbf1..b075eb3 100644 --- a/bot.py +++ b/bot.py @@ -38,8 +38,18 @@ async def bot_start(update, context): async def bot_commands(update, context): text= update.message.text 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 if text == 'Init/Restart': From f2c8acb80a601cd57af9fcb3444bfbe3c52619f9fce66ee32f9a4d48a5bdbe05 Mon Sep 17 00:00:00 2001 From: andrea Date: Fri, 1 Aug 2025 19:25:36 +0200 Subject: [PATCH 4/5] player movements --- entities/player.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/entities/player.py b/entities/player.py index 9bdfbf5..ee8e523 100644 --- a/entities/player.py +++ b/entities/player.py @@ -178,6 +178,28 @@ class BrSimPlayer(): return False 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 += x + self.coord_y += 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): # TODO It can run away from the fighting return From 9ad177b459a9f3ceb88e5fd2775dce70cdd240ec37aa8e73f64f502d16230966 Mon Sep 17 00:00:00 2001 From: andrea Date: Fri, 1 Aug 2025 21:42:48 +0200 Subject: [PATCH 5/5] debug.py now has a list of 2 actions, attack and move, and every player get a random action from this list --- debug.py | 40 ++++++++++++++++++++++++++++++++++------ entities/gamemap.py | 14 ++++++++++++++ entities/player.py | 10 +++++----- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/debug.py b/debug.py index 07dd7dd..c7d8572 100644 --- a/debug.py +++ b/debug.py @@ -36,6 +36,33 @@ def _end_game_debug(alive_players, day): print(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): if not Arena.get_players(): return print(f'Giorno #{Arena.day}') @@ -46,12 +73,13 @@ def play_one_day_debug(Arena): daily_events= [] _rand.shuffle(alive_players) - for p_one in alive_players: - if not p_one.is_alive(): continue # he could be dead during this day cycle - p_two= _rand.sample(Arena.get_alive_players(), 1)[0] - while p_one.get_id() == p_two.get_id(): - p_two= _rand.sample(Arena.get_alive_players(), 1)[0] - _dmg, msg= p_one.attack(p_two) + for Player_one in alive_players: + if not Player_one.is_alive(): continue # he could be dead during this day cycle + msg= _random_action(Arena, Player_one) + #p_two= _rand.sample(Arena.get_alive_players(), 1)[0] + #while Player_one.get_id() == p_two.get_id(): + #p_two= _rand.sample(Arena.get_alive_players(), 1)[0] + #_dmg, msg= Player_one.attack(p_two) daily_events.append(msg) Arena.next_day() diff --git a/entities/gamemap.py b/entities/gamemap.py index 8a76451..fbf4aba 100644 --- a/entities/gamemap.py +++ b/entities/gamemap.py @@ -35,6 +35,7 @@ class BrSimMap(): # 📦 this is an item (weapon or another item) # 💀 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.) + self.game_map= [] width= [] #mon = [] @@ -88,6 +89,19 @@ class BrSimMap(): def get_map_matrix(self): 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): res= '' diff --git a/entities/player.py b/entities/player.py index ee8e523..2743bbb 100644 --- a/entities/player.py +++ b/entities/player.py @@ -178,15 +178,15 @@ class BrSimPlayer(): return False self.inventory.append(item) - def _move(self, delta_x, delta_y): + 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 += x - self.coord_y += y + self.coord_x += delta_x + self.coord_y += delta_y def move_right(self): self._move(1, 0) @@ -195,10 +195,10 @@ class BrSimPlayer(): self._move(-1, 0) def move_top(self): - self._move(0, 1) + self._move(0, -1) def move_bottom(self): - self._move(0, -1) + self._move(0, 1) def escape(self): # TODO It can run away from the fighting