Compare commits

...

4 Commits

Author SHA256 Message Date
andrea
4c2864634b additional debug functions 2025-09-04 21:12:12 +02:00
andrea
b4c8d94c8c initialize random_event action on Arena 2025-09-04 21:11:24 +02:00
andrea
a56d931304 fix event_picker errors that cause bot crash 2025-09-04 21:10:32 +02:00
andrea
b001c9312a fix event_pickers errors that make the bot crash 2025-09-04 21:09:15 +02:00
4 changed files with 39 additions and 19 deletions

View File

@@ -9,7 +9,7 @@ EVENTS = [
'extreme_fail_percentage' : 1,
'requirements' : {},
'weight' : 1,
'affected_players' : 1,
'affected_players' : 1, #NOTE, what is it? to why it could be integer or list?
},
{
'id' : 'BOMB_EXPLOSION',

View File

@@ -91,7 +91,7 @@ def init_debug_simulation():
_logs.log_debug('#################')
_time.sleep(0.3)
def init_debug_loop():
def init_debug_attack_loop():
Arena= _debug_data()
while (len(Arena.get_alive_players()) > 1):
alive_players= Arena.get_alive_players()
@@ -104,6 +104,18 @@ def init_debug_loop():
Arena.next_day()
_time.sleep(0.3)
#End of day
Map= Arena.get_map()
_logs.log_debug(Map.get_renderized_map())
last_player= Arena.get_alive_players()[0]
_logs.log_debug(f'{last_player.get_name()} sopravvive e vince dopo {Arena.day} lunghi Giorni, conquistando l\'amore eterno di Guarino')
def init_debug_event_loop():
Arena= _debug_data()
while (len(Arena.get_alive_players()) > 1):
Arena.do_random_event()
_time.sleep(0.3)
#End of day
last_player= Arena.get_alive_players()[0]
_logs.log_debug(f'{last_player.get_name()} sopravvive e vince dopo {Arena.day} lunghi Giorni, conquistando l\'amore eterno di Guarino')
@@ -116,4 +128,6 @@ def debug_random_map():
_logs.log_debug(res)
if __name__ == '__main__':
init_debug()
init_debug_simulation()
#init_debug_attack_loop()
#init_debug_event_loop()

View File

@@ -103,7 +103,8 @@ class BrSimArena():
def do_random_event(self):
#XXX random player does random action according to his inventory health, wounds, available weapons on the world, etc...
pass
self.eventClass.resolve_event()
self.next_day()
def supporter_donation(self):
#XXX supporter donate a random item or weapon to a random player

View File

@@ -7,21 +7,21 @@ class ArenaEventPicker():
self.event_list = EVENTS
self.already_picked_players = []
def pick_a_player():
def pick_a_player(self):
the_player = _random.choice(self.players)
the_player_id = the_player.get('id')
the_player_id = the_player.get_id()
self.players = list(filter(lambda x : x.get('id') != the_player_id))
self.players = list(filter(lambda x : x.get_id() != the_player_id, self.players))
self.already_picked_players.append(the_player)
return the_player
def pick_event(the_player):
def pick_event(self, the_player):
player_inventory = the_player.get('inventory') or []
status = the_player['health']
reputation = the_player['reputation']
player_inventory = the_player.get_inventory()
status = the_player.get_health()
reputation = the_player.get_reputation()
elegible_events = []
for event in EVENTS:
@@ -56,17 +56,23 @@ class ArenaEventPicker():
if check == 'affected_players':
needed_players = event.get('affected_players')
#NOTE: this is only to compensate a double type of needed_players
# check NOTE on assets/events.py
if isinstance(needed_players, list):
if len(needed_players) < len(self.players):
elegible_events.append(event)
else:
if needed_players < len(self.players):
elegible_events.append(event)
the_event = _random.choice(elegible_events)
return the_event
def pick_targets(number_of_targets):
random.shuffle(self.players)
def pick_targets(self, number_of_targets):
_random.shuffle(self.players)
return list(self.players[0:number_of_targets])
def resolve_event():
def resolve_event(self):
playing_player = self.pick_a_player()
assigned_event = self.pick_event(playing_player)
@@ -76,6 +82,5 @@ class ArenaEventPicker():
targeted_players = self.pick_targets(affected_players)
event_instance = _event.Event(assigned_event, playing_player)
# FIXME this is not implemented
#event_instance = _event.Event(assigned_event, playing_player)