squirrel-battle/dungeonbattle/display/texturepack.py

46 lines
861 B
Python
Raw Normal View History

2020-11-06 16:43:30 +00:00
class TexturePack:
_packs = dict()
name: str
tile_width: int
2020-11-06 16:43:30 +00:00
EMPTY: str
WALL: str
FLOOR: str
PLAYER: str
2020-11-06 19:18:27 +00:00
ASCII_PACK: "TexturePack"
SQUIRREL_PACK: "TexturePack"
2020-11-06 16:43:30 +00:00
def __init__(self, name: str, **kwargs):
self.name = name
self.__dict__.update(**kwargs)
TexturePack._packs[name] = self
2020-11-10 20:47:36 +00:00
def __getitem__(self, item):
return self.__dict__[item]
2020-11-06 16:43:30 +00:00
@classmethod
def get_pack(cls, name: str) -> "TexturePack":
return cls._packs[name.lower()]
2020-11-06 16:43:30 +00:00
TexturePack.ASCII_PACK = TexturePack(
name="ascii",
tile_width=1,
2020-11-06 16:43:30 +00:00
EMPTY=' ',
WALL='#',
FLOOR='.',
PLAYER='@',
2020-11-10 20:47:36 +00:00
HEDGEHOG='*',
2020-11-06 16:43:30 +00:00
)
TexturePack.SQUIRREL_PACK = TexturePack(
name="squirrel",
tile_width=2,
EMPTY=' ',
WALL='██',
FLOOR='..',
PLAYER='🐿️ ',
HEDGEHOG='🦔 ',
2020-11-06 16:43:30 +00:00
)