76 lines
1.6 KiB
Python
Raw Normal View History

import curses
2020-11-10 22:04:38 +01:00
from typing import Any
2020-11-06 17:43:30 +01:00
class TexturePack:
_packs = dict()
name: str
tile_width: int
tile_fg_color: int
tile_bg_color: int
entity_fg_color: int
entity_bg_color: int
2020-11-06 17:43:30 +01:00
EMPTY: str
WALL: str
FLOOR: str
PLAYER: str
2020-11-06 20:18:27 +01:00
ASCII_PACK: "TexturePack"
SQUIRREL_PACK: "TexturePack"
2020-11-06 17:43:30 +01:00
def __init__(self, name: str, **kwargs):
self.name = name
self.__dict__.update(**kwargs)
TexturePack._packs[name] = self
def __getitem__(self, item: str) -> Any:
2020-11-10 21:47:36 +01:00
return self.__dict__[item]
2020-11-06 17:43:30 +01:00
@classmethod
def get_pack(cls, name: str) -> "TexturePack":
return cls._packs[name.lower()]
2020-11-06 17:43:30 +01:00
2020-11-11 23:09:15 +01:00
@classmethod
def get_next_pack_name(cls, name: str) -> str:
return "squirrel" if name == "ascii" else "ascii"
2020-11-06 17:43:30 +01:00
TexturePack.ASCII_PACK = TexturePack(
name="ascii",
tile_width=1,
tile_fg_color=curses.COLOR_WHITE,
tile_bg_color=curses.COLOR_BLACK,
entity_fg_color=curses.COLOR_WHITE,
entity_bg_color=curses.COLOR_BLACK,
2020-11-06 17:43:30 +01:00
EMPTY=' ',
WALL='#',
FLOOR='.',
PLAYER='@',
2020-11-10 21:47:36 +01:00
HEDGEHOG='*',
2020-11-11 16:23:27 +01:00
HEART='',
BOMB='o',
2020-11-11 17:39:48 +01:00
RABBIT='Y',
BEAVER='_',
TEDDY_BEAR='8',
2020-11-06 17:43:30 +01:00
)
TexturePack.SQUIRREL_PACK = TexturePack(
name="squirrel",
tile_width=2,
tile_fg_color=curses.COLOR_WHITE,
tile_bg_color=curses.COLOR_BLACK,
entity_fg_color=curses.COLOR_WHITE,
entity_bg_color=curses.COLOR_WHITE,
EMPTY=' ',
2020-11-11 15:09:28 +01:00
WALL='🧱',
FLOOR='██',
PLAYER='🐿 ',
HEDGEHOG='🦔',
2020-11-11 16:23:27 +01:00
HEART='💜',
BOMB='💣',
2020-11-11 17:39:48 +01:00
RABBIT='🐇',
BEAVER='🦫',
TEDDY_BEAR='🧸',
2020-11-06 17:43:30 +01:00
)