development #11
@ -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 = {}
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -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)
|
||||||
|
@ -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")
|
||||||
|
Loading…
Reference in New Issue
Block a user