debug.py now has a list of 2 actions, attack and move, and every player get a random action from this list

This commit is contained in:
andrea
2025-08-01 21:42:48 +02:00
parent f2c8acb80a
commit 9ad177b459
3 changed files with 53 additions and 11 deletions

View File

@@ -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()