arena replace weapons with more generic items

This commit is contained in:
andrea
2025-11-14 21:49:49 +01:00
parent f80edfff83
commit 9c2b6b026b
3 changed files with 21 additions and 20 deletions

View File

@@ -1,33 +1,33 @@
from entities import player as _player
from entities import event_picker as _events
from entities import gamemap as _map
from entities.items import weapons as _weapons
from entities.items import item as _items
from utils import logs as _logs
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
# items = [{WEAPON.KNIFE: quantity}, etc...] # this is the whole quantity of the items available on the world
def __init__(self, players= None, weapons= None):
def __init__(self, players= None, items= None):
self.day= 1
self.players= []
self.weapons= []
self.items= []
self.eventClass = _events.ArenaEventPicker(self.players)
self.init_players(players)
self.init_weapons(weapons)
self.Map= _map.BrSimMap(self.players, self.weapons)
self.init_items(items)
self.Map= _map.BrSimMap(self.players, self.items)
def init_players(self, players):
if not players: return
for player in players:
self.add_player(player['name'], player.get('inventory'))
def init_weapons(self, weapons):
if not weapons: return
for weapon in weapons:
for wtype, quantity in weapon.items():
for i in range(quantity): self.weapons.append(_weapons.BrSimWeapon(wtype))
def init_items(self, items):
if not items: return
for item in items:
for itype, quantity in item.items():
for i in range(quantity): self.items.append(_items.BrSimItem(wrype))
def next_day(self):
self.day+= 1
@@ -116,19 +116,19 @@ class BrSimArena():
self.players.append(player)
self.Map.add_player_to_map(player)
def add_weapon(self, weapon_type):
weapon= _weapons.BrSimWeapon(weapon_type)
self.weapons.append(weapon)
def add_item(self, itype):
weapon= _items.BrSimItem(itype)
self.items.append(weapon)
self.Map.add_item_to_map(item)
def get_players(self):
return self.players
def get_weapons(self):
def get_items(self):
res= []
for w in self.weapons:
for i in self.items:
#XXX implement me
res.append(w)
res.append(i)
return res
def get_map(self):

View File

@@ -4,9 +4,10 @@ from entities import resource as _resource
class BrSimItem(_resource.BrSimResource):
# test
def __init__(self):
def __init__(self, item):
self.coord_x= 0
self.coord_y= 0
self.item= item
def is_item(self):
return True