arena as class
This commit is contained in:
64
entities/arena.py
Normal file
64
entities/arena.py
Normal file
@@ -0,0 +1,64 @@
|
||||
from entities import player as _player
|
||||
from entities import weapons as _weapons
|
||||
from entities import weapon_syms as _wsyms
|
||||
|
||||
class BrSimArena():
|
||||
|
||||
# players = [{'name': name, 'inventory': default_inventory, other_stats}]
|
||||
# weapons = [{WEAPON.KNIFE: quantity}, etc...] # this is the whole quantity of the items available on the world
|
||||
|
||||
def __init__(self, players, weapons):
|
||||
self.day= 1
|
||||
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= []
|
||||
for p in self.players:
|
||||
if not p.is_alive(): continue
|
||||
res.append(p)
|
||||
return res
|
||||
|
||||
def get_death_players(self):
|
||||
res= []
|
||||
for p in self.players:
|
||||
if p.is_alive(): continue
|
||||
res.append(p)
|
||||
return res
|
||||
|
||||
def do_random_event(self):
|
||||
#XXX random player does random action according to his inventory health, wounds, available weapons on the world, etc...
|
||||
pass
|
||||
|
||||
def supporter_donation(self):
|
||||
#XXX supporter donate a random item or weapon to a random player
|
||||
#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
|
||||
Reference in New Issue
Block a user