forked from Cryz/battle_royale_sim
Arena and Player start populating more basic methods of the object
This commit is contained in:
35
main.py
35
main.py
@@ -9,11 +9,19 @@ class BrSimArena():
|
||||
|
||||
def __init__(self, players, weapons):
|
||||
self.day= 1
|
||||
self.players= players
|
||||
self.weapons= weapons
|
||||
self.players= [_player.BrSimPlayer(p['name'], p.get('inventory')) for p in players]
|
||||
self.weapons= []
|
||||
for weapon in weapons:
|
||||
for wtype, quantity in weapon.items():
|
||||
for i in range(quantity): self.weapons.append(_weapons.BrSimWeapon(wtype))
|
||||
|
||||
def next_day(self):
|
||||
self.day+= 1
|
||||
print(f'Giorno: {self.day}')
|
||||
print(f'Giocatori vivi: {self.get_alive_players()}')
|
||||
death_players= self.get_death_players()
|
||||
if (death_players):
|
||||
print(f'Giocatori morti: {death_players}')
|
||||
|
||||
def get_alive_players(self):
|
||||
res= []
|
||||
@@ -38,11 +46,28 @@ class BrSimArena():
|
||||
#TODO maybe in future a player can have charism stats that can influence the chance to get a donation
|
||||
pass
|
||||
|
||||
def add_player(self, name, inventory= None):
|
||||
player= _player.BrSimPlayer(name, inventory)
|
||||
self.players.append(player)
|
||||
|
||||
def get_players(self):
|
||||
res= []
|
||||
for p in self.players:
|
||||
res.append(p.get_data())
|
||||
return res
|
||||
|
||||
def get_weapons(self):
|
||||
res= []
|
||||
for w in self.weapons:
|
||||
#XXX implement me
|
||||
res.append(w)
|
||||
return res
|
||||
|
||||
def init_arena():
|
||||
players= [{'name': 'Crystal'}, {'name': 'Andrea'}]
|
||||
w= _wsyms.KNIFE
|
||||
weapons= [{_wsyms.WEAPONS[w]['name']: 1}]
|
||||
#weapons= [{_wsyms.WEAPONS[w]['name' ]: 1}]
|
||||
weapons= [{w: 1}]
|
||||
return BrSimArena(players, weapons)
|
||||
|
||||
|
||||
@@ -51,7 +76,7 @@ def run_event(Arena):
|
||||
|
||||
def local_debug():
|
||||
Arena= init_arena()
|
||||
print(Arena.players)
|
||||
print(Arena.weapons)
|
||||
print(f'Players: {Arena.get_players()}')
|
||||
print(f'Weapons: {Arena.get_weapons()}')
|
||||
run_event(Arena)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user