squirrel-battle/dungeonbattle/display/texturepack.py

46 lines
861 B
Python

class TexturePack:
_packs = dict()
name: str
tile_width: int
EMPTY: str
WALL: str
FLOOR: str
PLAYER: str
ASCII_PACK: "TexturePack"
SQUIRREL_PACK: "TexturePack"
def __init__(self, name: str, **kwargs):
self.name = name
self.__dict__.update(**kwargs)
TexturePack._packs[name] = self
def __getitem__(self, item):
return self.__dict__[item]
@classmethod
def get_pack(cls, name: str) -> "TexturePack":
return cls._packs[name.lower()]
TexturePack.ASCII_PACK = TexturePack(
name="ascii",
tile_width=1,
EMPTY=' ',
WALL='#',
FLOOR='.',
PLAYER='@',
HEDGEHOG='*',
)
TexturePack.SQUIRREL_PACK = TexturePack(
name="squirrel",
tile_width=2,
EMPTY=' ',
WALL='██',
FLOOR='..',
PLAYER='🐿️ ',
HEDGEHOG='🦔 ',
)