1
0

event picket to be tested but im lazy

This commit is contained in:
2025-08-05 21:03:20 +02:00
parent af7f0019ec
commit 13bb11eb8c
3 changed files with 35 additions and 3 deletions

View File

@@ -9,7 +9,7 @@ EVENTS = [
'extreme_fail_percentage' : 1,
'requirements' : {},
'weight' : 1,
'number_of_players' : 1,
'affected_players' : 1,
},
{
'id' : 'BOMB_EXPLOSION'
@@ -22,6 +22,6 @@ EVENTS = [
'requirements' : {
'weapons' : ['BOMB']
},
'number_of_players' : 2,
'affected_players' : [2,3,4],
},
]

5
entities/event.py Normal file
View File

@@ -0,0 +1,5 @@
class Event():
def __init__(self, event_settings, the_player, affected_players = []):
# this will be the class that manage the event, so the result and what ahppens to the players
# will do it later
pass

View File

@@ -13,6 +13,10 @@ class ArenaEventPicker():
self.players = list(filter(lambda x : x.get('id') != the_player_id)
self.already_picked_players.append(the_player)
return the_player
def pick_event(the_player):
player_inventory = the_player.get('inventory') or []
@@ -23,7 +27,7 @@ class ArenaEventPicker():
for event in EVENTS:
requirements = event['requirements']
keys_to_check = ['item', 'weapon', 'status', 'reputation', 'number_of_players']
keys_to_check = ['item', 'weapon', 'status', 'reputation', 'affected_players']
for check in keys_to_check:
if requirements.get(check) and check == 'item':
@@ -49,6 +53,29 @@ class ArenaEventPicker():
elegible_events.append(event)
if '<' in requirements.get(check) and requirements.get(check) < in needed_reputation:
elegible_events.append(event)
if check == 'affected_players':
needed_players = event.get('affected_players')
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)
return list(self.players[0:number_of_targets])
def resolve_event():
playing_player = self.pick_a_player()
assigned_event = self.pick_event(playing_player)
affected_players = assigned_event['affected_players']
if isinstance(affected_players,list):
affected_players = _random.choice(affected_players)
targeted_players = self.pick_targets(affected_players)
event_instance = _event.Event(assigned_event, playing_player)