2020-11-27 16:33:17 +01:00
|
|
|
|
# Copyright (C) 2020 by ÿnérant, eichhornchen, nicomarg, charlse
|
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2020-11-10 22:30:55 +01:00
|
|
|
|
import curses
|
2020-12-18 17:04:45 +01:00
|
|
|
|
from typing import Any, Union, Tuple
|
2020-11-10 22:04:38 +01:00
|
|
|
|
|
|
|
|
|
|
2020-11-06 17:43:30 +01:00
|
|
|
|
class TexturePack:
|
2020-12-13 21:29:25 +01:00
|
|
|
|
"""
|
|
|
|
|
A class to handle displaying several textures.
|
|
|
|
|
"""
|
2020-11-06 17:43:30 +01:00
|
|
|
|
_packs = dict()
|
|
|
|
|
|
|
|
|
|
name: str
|
2020-11-10 22:01:57 +01:00
|
|
|
|
tile_width: int
|
2020-12-18 17:04:45 +01:00
|
|
|
|
tile_fg_color: Union[int, Tuple[int, int, int]]
|
|
|
|
|
tile_fg_visible_color: Union[int, Tuple[int, int, int]]
|
|
|
|
|
tile_bg_color: Union[int, Tuple[int, int, int]]
|
|
|
|
|
entity_fg_color: Union[int, Tuple[int, int, int]]
|
|
|
|
|
entity_bg_color: Union[int, Tuple[int, int, int]]
|
2020-12-09 16:50:47 +01:00
|
|
|
|
|
|
|
|
|
BODY_SNATCH_POTION: str
|
|
|
|
|
BOMB: str
|
2021-01-06 15:49:54 +01:00
|
|
|
|
CHESTPLATE: str
|
|
|
|
|
EAGLE: str
|
2020-11-06 17:43:30 +01:00
|
|
|
|
EMPTY: str
|
|
|
|
|
FLOOR: str
|
2020-12-09 16:54:53 +01:00
|
|
|
|
HAZELNUT: str
|
2021-01-06 15:49:54 +01:00
|
|
|
|
HEART: str
|
|
|
|
|
HEDGEHOG: str
|
|
|
|
|
HELMET: str
|
2020-12-09 16:50:47 +01:00
|
|
|
|
MERCHANT: str
|
2020-11-06 17:43:30 +01:00
|
|
|
|
PLAYER: str
|
2020-12-09 16:50:47 +01:00
|
|
|
|
RABBIT: str
|
2021-01-06 15:49:54 +01:00
|
|
|
|
RING_OF_CRITICAL_DAMAGE: str
|
|
|
|
|
RING_OF_MORE_EXPERIENCE: str
|
|
|
|
|
SHIELD: str
|
2020-12-09 16:50:47 +01:00
|
|
|
|
SUNFLOWER: str
|
|
|
|
|
SWORD: str
|
|
|
|
|
TEDDY_BEAR: str
|
|
|
|
|
TIGER: str
|
2020-12-18 17:29:59 +01:00
|
|
|
|
TRUMPET: str
|
2020-12-09 16:50:47 +01:00
|
|
|
|
WALL: str
|
2020-11-06 17:43:30 +01:00
|
|
|
|
|
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
|
|
|
|
|
|
2020-11-10 22:30:55 +01:00
|
|
|
|
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":
|
2020-11-10 18:08:06 +01:00
|
|
|
|
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",
|
2020-11-10 22:01:57 +01:00
|
|
|
|
tile_width=1,
|
2020-12-18 17:04:45 +01:00
|
|
|
|
tile_fg_visible_color=(1000, 1000, 1000),
|
2020-11-10 22:30:55 +01:00
|
|
|
|
tile_fg_color=curses.COLOR_WHITE,
|
|
|
|
|
tile_bg_color=curses.COLOR_BLACK,
|
2020-12-18 17:04:45 +01:00
|
|
|
|
entity_fg_color=(1000, 1000, 1000),
|
2020-11-10 22:30:55 +01:00
|
|
|
|
entity_bg_color=curses.COLOR_BLACK,
|
2020-12-09 16:50:47 +01:00
|
|
|
|
|
|
|
|
|
BODY_SNATCH_POTION='S',
|
2021-01-06 11:44:52 +01:00
|
|
|
|
BOMB='ç',
|
2021-01-06 15:49:54 +01:00
|
|
|
|
CHESTPLATE='(',
|
|
|
|
|
EAGLE='µ',
|
2020-11-06 17:43:30 +01:00
|
|
|
|
EMPTY=' ',
|
2020-12-12 16:50:01 +01:00
|
|
|
|
EXPLOSION='%',
|
2020-11-06 17:43:30 +01:00
|
|
|
|
FLOOR='.',
|
2020-12-26 00:52:47 +01:00
|
|
|
|
LADDER='H',
|
2020-12-11 15:52:36 +01:00
|
|
|
|
HAZELNUT='¤',
|
2020-11-11 16:23:27 +01:00
|
|
|
|
HEART='❤',
|
2020-12-09 16:50:47 +01:00
|
|
|
|
HEDGEHOG='*',
|
2021-01-06 15:49:54 +01:00
|
|
|
|
HELMET='0',
|
2020-11-27 17:54:03 +01:00
|
|
|
|
MERCHANT='M',
|
2020-12-09 16:50:47 +01:00
|
|
|
|
PLAYER='@',
|
|
|
|
|
RABBIT='Y',
|
2021-01-06 15:49:54 +01:00
|
|
|
|
RING_OF_CRITICAL_DAMAGE='o',
|
|
|
|
|
RING_OF_MORE_EXPERIENCE='o',
|
2020-12-18 20:01:52 +01:00
|
|
|
|
SHIELD='D',
|
2020-11-27 18:35:52 +01:00
|
|
|
|
SUNFLOWER='I',
|
2020-12-07 21:13:55 +01:00
|
|
|
|
SWORD='\u2020',
|
2020-12-09 16:50:47 +01:00
|
|
|
|
TEDDY_BEAR='8',
|
|
|
|
|
TIGER='n',
|
2020-12-18 17:29:59 +01:00
|
|
|
|
TRUMPET='/',
|
2020-12-09 16:50:47 +01:00
|
|
|
|
WALL='#',
|
2020-11-06 17:43:30 +01:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
TexturePack.SQUIRREL_PACK = TexturePack(
|
|
|
|
|
name="squirrel",
|
2020-11-10 22:01:57 +01:00
|
|
|
|
tile_width=2,
|
2020-12-18 17:04:45 +01:00
|
|
|
|
tile_fg_visible_color=(1000, 1000, 1000),
|
2020-11-10 22:30:55 +01:00
|
|
|
|
tile_fg_color=curses.COLOR_WHITE,
|
|
|
|
|
tile_bg_color=curses.COLOR_BLACK,
|
2020-12-18 17:04:45 +01:00
|
|
|
|
entity_fg_color=(1000, 1000, 1000),
|
|
|
|
|
entity_bg_color=(1000, 1000, 1000),
|
2020-12-09 16:50:47 +01:00
|
|
|
|
|
|
|
|
|
BODY_SNATCH_POTION='🔀',
|
|
|
|
|
BOMB='💣',
|
2021-01-06 15:49:54 +01:00
|
|
|
|
CHESTPLATE='🦺',
|
|
|
|
|
EAGLE='🦅',
|
2020-11-10 22:01:57 +01:00
|
|
|
|
EMPTY=' ',
|
2020-12-12 16:50:01 +01:00
|
|
|
|
EXPLOSION='💥',
|
2020-11-10 22:30:55 +01:00
|
|
|
|
FLOOR='██',
|
2021-01-07 16:49:40 +01:00
|
|
|
|
LADDER=('🪜', curses.COLOR_WHITE, (1000, 1000, 1000),
|
|
|
|
|
curses.COLOR_WHITE, (1000, 1000, 1000)),
|
2020-12-09 16:54:53 +01:00
|
|
|
|
HAZELNUT='🌰',
|
2020-11-11 16:23:27 +01:00
|
|
|
|
HEART='💜',
|
2020-12-09 16:50:47 +01:00
|
|
|
|
HEDGEHOG='🦔',
|
2021-01-06 15:49:54 +01:00
|
|
|
|
HELMET='⛑️',
|
2020-12-09 16:50:47 +01:00
|
|
|
|
PLAYER='🐿️ ️',
|
2020-11-27 17:54:03 +01:00
|
|
|
|
MERCHANT='🦜',
|
2020-12-09 16:50:47 +01:00
|
|
|
|
RABBIT='🐇',
|
2021-01-06 15:49:54 +01:00
|
|
|
|
RING_OF_CRITICAL_DAMAGE='💍',
|
|
|
|
|
RING_OF_MORE_EXPERIENCE='💍',
|
2020-12-18 20:01:52 +01:00
|
|
|
|
SHIELD='🛡️ ',
|
2020-11-27 18:35:52 +01:00
|
|
|
|
SUNFLOWER='🌻',
|
2020-12-18 01:50:11 +01:00
|
|
|
|
SWORD='🗡️ ',
|
2020-12-09 16:50:47 +01:00
|
|
|
|
TEDDY_BEAR='🧸',
|
|
|
|
|
TIGER='🐅',
|
2020-12-18 17:29:59 +01:00
|
|
|
|
TRUMPET='🎺',
|
2020-12-09 16:50:47 +01:00
|
|
|
|
WALL='🧱',
|
2020-11-06 17:43:30 +01:00
|
|
|
|
)
|