1
0

spawn random items, and try to put on map, but i still need to investigate why items are not correctly rendered on map

This commit is contained in:
andrea
2025-11-14 23:15:14 +01:00
parent f408aee8f8
commit 054522eaf3
5 changed files with 46 additions and 25 deletions

View File

@@ -116,10 +116,10 @@ class BrSimArena():
self.players.append(player)
self.Map.add_player_to_map(player)
def add_item(self, itype):
weapon= _items.BrSimItem(itype)
self.items.append(weapon)
self.Map.add_item_to_map(item)
def add_item(self, item_id):
Item= _items.BrSimItem(item_id)
self.items.append(Item)
self.Map.add_item_to_map(Item)
def get_players(self):
return self.players

View File

@@ -58,14 +58,9 @@ class BrSimMap():
for player in self.players:
p_coord_x, p_coord_y= player.get_coordinates()
self.game_map[p_coord_y][p_coord_x]= player
#if not player.is_alive(): self.game_map[p_coord_y][p_coord_x]= self.dead_player_sym
#elif player.player_gender_is_male(): self.game_map[p_coord_y][p_coord_x]= self.player_male_sym
#elif player.player_gender_is_female(): self.game_map[p_coord_y][p_coord_x]= self.player_female_sym
#else: self.game_map[p_coord_y][p_coord_x]= self.player_nonbinary_sym
for item in self.items:
i_coord_x, i_coord_y= item.get_coordinates()
self.game_map[p_coord_y][p_coord_x]= item
#self.game_map[i_coord_y][i_coord_x]= self.item_sym
def _put_resource_on_map(self, target):
#x= _random.randint(1, self.world_width -2) # from 1 to width-2 because 1 cell is occupied by the mountain

View File

@@ -1,28 +1,35 @@
import random as _random
from entities import resource as _resource
from entities.items import syms as _isyms
class BrSimItem(_resource.BrSimResource):
#XXX i don't know yet if we need to call this clas
# or we need to have subclasses that inherit this one
# for example class Weapon and class Medikit (or something else)
# this decision would change everything from Arena init
# test
def __init__(self, item):
self.coord_x= 0
self.coord_y= 0
self.item= item
def __init__(self, item_id):
self.item= _isyms.ITEMS[item_id]
def is_item(self):
return True
def get_name(self):
return self.name
def get_data(self):
return self.item
def get_item_type(self):
return self.item_type
def get_name(self):
idata= self.get_data()
return idata['name']
def get_weight(self):
return self.weight
idata= self.get_data()
return idata['weight']
def is_weapon(self):
return False
idata= self.get_data()
return idata['is_weapon']
def is_cure(self):
return False
#XXX not sure about it
# maybe we could have more item type, like foods, drink, poison...
return not self.is_weapon()

View File

@@ -35,3 +35,5 @@ ITEMS= {
'range': FAR_RANGE,
},
}
ITEMS_LIST= list(ITEMS.keys())