This commit is contained in:
Kanewersa 2021-05-24 17:35:08 +02:00
parent 551053fd22
commit a82f52d318
5 changed files with 15 additions and 4 deletions

View File

@ -1,5 +1,5 @@
class InventoryComponent:
def __init__(self, maxitems=10):
def __init__(self, maxitems=100):
self.maxitems = maxitems
self.items = {}

View File

@ -21,7 +21,7 @@ class PlayerGenerator:
world.add_component(player, InventoryComponent())
camera_target = CameraTargetComponent(pos)
world.add_component(player, camera_target)
# world.add_component(player, AutomationComponent())
world.add_component(player, AutomationComponent())
game_map.add_entity(player, pos)
sprite = SpriteComponent('stevenson.png')
sprite.set_scale(1)

View File

@ -54,6 +54,6 @@ class ResourceGenerator:
inventory = world.component_for_entity(player, InventoryComponent)
answer = decision_tree.predict_answer(resource)
# print(answer)
inventory.add_item(resource.resource_type, 1)
inventory.add_item(ResourceType.get_from_string(answer), 1)
game_map.remove_entity(pos.grid_position)
world.delete_entity(resource_ent, immediate=True)

View File

@ -5,3 +5,14 @@ class ResourceType(Enum):
FOOD = 1
WATER = 2
WOOD = 3
@staticmethod
def get_from_string(string):
if string == 'food':
return ResourceType.FOOD
elif string == 'water':
return ResourceType.WATER
elif string == 'wood':
return ResourceType.WOOD
else:
raise Exception("Unknown resource type")