Skip to content

Commit

Permalink
Create inventory.py
Browse files Browse the repository at this point in the history
  • Loading branch information
EmperorPenguin18 authored Jul 28, 2021
1 parent d90eae3 commit 08cef11
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions components/inventory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from __future__ import annotations

from typing import List, TYPE_CHECKING

from components.base_component import BaseComponent

if TYPE_CHECKING:
from entity import Actor, Item


class Inventory(BaseComponent):
parent: Actor

def __init__(self, capacity: int):
self.capacity = capacity
self.items: List[Item] = []

def drop(self, item: Item) -> None:
"""
Removes an item from the inventory and restores it to the game map, at the player's current location.
"""
self.items.remove(item)
item.place(self.parent.x, self.parent.y, self.gamemap)

self.engine.message_log.add_message(f"You dropped the {item.name}.")

0 comments on commit 08cef11

Please sign in to comment.