-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d90eae3
commit 08cef11
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}.") |