Added chests, they are immortal and contain objects the player can take for free.

This commit is contained in:
eichhornchen
2021-01-08 23:15:48 +01:00
parent 175706b1e4
commit bdbf214d8d
9 changed files with 178 additions and 13 deletions

View File

@ -6,7 +6,7 @@ from typing import Any, Optional
from .display.texturepack import TexturePack
from .entities.player import Player
from .entities.friendly import Merchant
from .entities.friendly import Merchant, Chest
from .enums import GameMode, KeyValues, DisplayActions
from .settings import Settings
from .translations import gettext as _, Translator
@ -158,3 +158,23 @@ class StoreMenu(Menu):
Returns the values of the menu.
"""
return self.merchant.inventory if self.merchant else []
class ChestMenu(Menu):
"""
A special instance of a menu : the menu for the inventory of a chest.
"""
chest: Chest = None
def update_chest(self, chest: Chest) -> None:
"""
Updates the player.
"""
self.chest = chest
@property
def values(self) -> list:
"""
Returns the values of the menu.
"""
return self.chest.inventory if self.chest else []