fix merge regression and exlude death player from attackable players

This commit is contained in:
andrea
2025-08-02 09:33:06 +02:00
parent 62c7c7f2c2
commit 3cc6966d86
2 changed files with 11 additions and 8 deletions

View File

@@ -23,16 +23,19 @@ def _random_action(Arena, Player_one):
1: 'attack',
2: 'move',
}
action= _rand.randint(1, len(_RANDOM_ACTIONS))
Map= Arena.get_map()
avail_actions= Map.get_player_available_actions(Player_one)
print(f'{Player_one.get_name()}:{Player_one.get_coordinates()}, avail_actions: {avail_actions}')
msg= ''
if action == 1:
if 1 in avail_actions:
# 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]
preys= avail_actions[1]
Player_two= _rand.sample(preys, 1)[0]
while Player_one.get_id() == Player_two.get_id() and not Player_two.is_alive():
Player_two= _rand.sample(preys, 1)[0]
_dmg, msg= Player_one.attack(Player_two)
elif action == 2:
elif 2 in avail_actions:
Map= Arena.get_map()
available_movements= Map.get_player_available_directions(Player_one)
if not available_movements: