development #11

Merged
s452701 merged 3 commits from development into master 2021-06-03 15:42:55 +02:00
5 changed files with 15 additions and 4 deletions
Showing only changes of commit a82f52d318 - Show all commits

View File

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

View File

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

View File

@ -54,6 +54,6 @@ class ResourceGenerator:
inventory = world.component_for_entity(player, InventoryComponent) inventory = world.component_for_entity(player, InventoryComponent)
answer = decision_tree.predict_answer(resource) answer = decision_tree.predict_answer(resource)
# print(answer) # 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) game_map.remove_entity(pos.grid_position)
world.delete_entity(resource_ent, immediate=True) world.delete_entity(resource_ent, immediate=True)

View File

@ -4,4 +4,15 @@ from enum import Enum
class ResourceType(Enum): class ResourceType(Enum):
FOOD = 1 FOOD = 1
WATER = 2 WATER = 2
WOOD = 3 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")