123 lines
2.6 KiB
Python
123 lines
2.6 KiB
Python
# Copyright (C) 2020 by ÿnérant, eichhornchen, nicomarg, charlse
|
||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||
|
||
import curses
|
||
from typing import Any
|
||
|
||
|
||
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
|
||
|
||
BODY_SNATCH_POTION: str
|
||
BOMB: str
|
||
HEART: str
|
||
HEDGEHOG: str
|
||
EMPTY: str
|
||
FLOOR: str
|
||
HAZELNUT: str
|
||
MERCHANT: str
|
||
PLAYER: str
|
||
RABBIT: str
|
||
SUNFLOWER: str
|
||
SWORD: str
|
||
TEDDY_BEAR: str
|
||
TIGER: str
|
||
WALL: str
|
||
EAGLE: str
|
||
SHIELD: str
|
||
CHESTPLATE: str
|
||
HELMET: str
|
||
RING_OF_MORE_EXPERIENCE: str
|
||
RING_OF_CRITICAL_DAMAGE: 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: str) -> Any:
|
||
return self.__dict__[item]
|
||
|
||
@classmethod
|
||
def get_pack(cls, name: str) -> "TexturePack":
|
||
return cls._packs[name.lower()]
|
||
|
||
@classmethod
|
||
def get_next_pack_name(cls, name: str) -> str:
|
||
return "squirrel" if name == "ascii" else "ascii"
|
||
|
||
|
||
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,
|
||
|
||
BODY_SNATCH_POTION='S',
|
||
BOMB='ç',
|
||
EMPTY=' ',
|
||
EXPLOSION='%',
|
||
FLOOR='.',
|
||
HAZELNUT='¤',
|
||
HEART='❤',
|
||
HEDGEHOG='*',
|
||
MERCHANT='M',
|
||
PLAYER='@',
|
||
RABBIT='Y',
|
||
SHIELD='D',
|
||
SUNFLOWER='I',
|
||
SWORD='\u2020',
|
||
TEDDY_BEAR='8',
|
||
TIGER='n',
|
||
WALL='#',
|
||
EAGLE='µ',
|
||
CHESTPLATE='(',
|
||
HELMET='0',
|
||
RING_OF_MORE_EXPERIENCE='o',
|
||
RING_OF_CRITICAL_DAMAGE='o',
|
||
)
|
||
|
||
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,
|
||
|
||
BODY_SNATCH_POTION='🔀',
|
||
BOMB='💣',
|
||
EMPTY=' ',
|
||
EXPLOSION='💥',
|
||
FLOOR='██',
|
||
HAZELNUT='🌰',
|
||
HEART='💜',
|
||
HEDGEHOG='🦔',
|
||
PLAYER='🐿️ ️',
|
||
MERCHANT='🦜',
|
||
RABBIT='🐇',
|
||
SHIELD='🛡️ ',
|
||
SUNFLOWER='🌻',
|
||
SWORD='🗡️ ',
|
||
TEDDY_BEAR='🧸',
|
||
TIGER='🐅',
|
||
WALL='🧱',
|
||
EAGLE='🦅',
|
||
CHESTPLATE='🦺',
|
||
HELMET='⛑️',
|
||
RING_OF_MORE_EXPERIENCE='💍',
|
||
RING_OF_CRITICAL_DAMAGE='💍',
|
||
)
|