2020-11-27 15:33:17 +00:00
|
|
|
|
# Copyright (C) 2020 by ÿnérant, eichhornchen, nicomarg, charlse
|
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
2020-11-10 21:30:55 +00:00
|
|
|
|
import curses
|
2020-11-10 21:04:38 +00:00
|
|
|
|
from typing import Any
|
|
|
|
|
|
|
|
|
|
|
2020-11-06 16:43:30 +00:00
|
|
|
|
class TexturePack:
|
2020-12-13 20:29:25 +00:00
|
|
|
|
"""
|
|
|
|
|
A class to handle displaying several textures.
|
|
|
|
|
"""
|
2020-11-06 16:43:30 +00:00
|
|
|
|
_packs = dict()
|
|
|
|
|
|
|
|
|
|
name: str
|
2020-11-10 21:01:57 +00:00
|
|
|
|
tile_width: int
|
2020-11-10 21:30:55 +00:00
|
|
|
|
tile_fg_color: int
|
|
|
|
|
tile_bg_color: int
|
|
|
|
|
entity_fg_color: int
|
|
|
|
|
entity_bg_color: int
|
2020-12-09 15:50:47 +00:00
|
|
|
|
|
|
|
|
|
BODY_SNATCH_POTION: str
|
|
|
|
|
BOMB: str
|
|
|
|
|
HEART: str
|
|
|
|
|
HEDGEHOG: str
|
2020-11-06 16:43:30 +00:00
|
|
|
|
EMPTY: str
|
|
|
|
|
FLOOR: str
|
2020-12-09 15:54:53 +00:00
|
|
|
|
HAZELNUT: str
|
2020-12-09 15:50:47 +00:00
|
|
|
|
MERCHANT: str
|
2020-11-06 16:43:30 +00:00
|
|
|
|
PLAYER: str
|
2020-12-09 15:50:47 +00:00
|
|
|
|
RABBIT: str
|
|
|
|
|
SUNFLOWER: str
|
|
|
|
|
SWORD: str
|
|
|
|
|
TEDDY_BEAR: str
|
|
|
|
|
TIGER: str
|
2020-12-18 16:29:59 +00:00
|
|
|
|
TRUMPET: str
|
2020-12-09 15:50:47 +00:00
|
|
|
|
WALL: str
|
2020-11-06 16:43:30 +00:00
|
|
|
|
|
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 21:30:55 +00:00
|
|
|
|
def __getitem__(self, item: str) -> Any:
|
2020-11-10 20:47:36 +00:00
|
|
|
|
return self.__dict__[item]
|
|
|
|
|
|
2020-11-06 16:43:30 +00:00
|
|
|
|
@classmethod
|
|
|
|
|
def get_pack(cls, name: str) -> "TexturePack":
|
2020-11-10 17:08:06 +00:00
|
|
|
|
return cls._packs[name.lower()]
|
2020-11-06 16:43:30 +00:00
|
|
|
|
|
2020-11-11 22:09:15 +00:00
|
|
|
|
@classmethod
|
|
|
|
|
def get_next_pack_name(cls, name: str) -> str:
|
|
|
|
|
return "squirrel" if name == "ascii" else "ascii"
|
|
|
|
|
|
2020-11-06 16:43:30 +00:00
|
|
|
|
|
|
|
|
|
TexturePack.ASCII_PACK = TexturePack(
|
|
|
|
|
name="ascii",
|
2020-11-10 21:01:57 +00:00
|
|
|
|
tile_width=1,
|
2020-11-10 21:30:55 +00:00
|
|
|
|
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-12-09 15:50:47 +00:00
|
|
|
|
|
|
|
|
|
BODY_SNATCH_POTION='S',
|
|
|
|
|
BOMB='o',
|
2020-11-06 16:43:30 +00:00
|
|
|
|
EMPTY=' ',
|
2020-12-12 15:50:01 +00:00
|
|
|
|
EXPLOSION='%',
|
2020-11-06 16:43:30 +00:00
|
|
|
|
FLOOR='.',
|
2020-12-25 23:52:47 +00:00
|
|
|
|
LADDER='H',
|
2020-12-11 14:52:36 +00:00
|
|
|
|
HAZELNUT='¤',
|
2020-11-11 15:23:27 +00:00
|
|
|
|
HEART='❤',
|
2020-12-09 15:50:47 +00:00
|
|
|
|
HEDGEHOG='*',
|
2020-11-27 16:54:03 +00:00
|
|
|
|
MERCHANT='M',
|
2020-12-09 15:50:47 +00:00
|
|
|
|
PLAYER='@',
|
|
|
|
|
RABBIT='Y',
|
2020-11-27 17:35:52 +00:00
|
|
|
|
SUNFLOWER='I',
|
2020-12-07 20:13:55 +00:00
|
|
|
|
SWORD='\u2020',
|
2020-12-09 15:50:47 +00:00
|
|
|
|
TEDDY_BEAR='8',
|
|
|
|
|
TIGER='n',
|
2020-12-18 16:29:59 +00:00
|
|
|
|
TRUMPET='/',
|
2020-12-09 15:50:47 +00:00
|
|
|
|
WALL='#',
|
2020-11-06 16:43:30 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
TexturePack.SQUIRREL_PACK = TexturePack(
|
|
|
|
|
name="squirrel",
|
2020-11-10 21:01:57 +00:00
|
|
|
|
tile_width=2,
|
2020-11-10 21:30:55 +00:00
|
|
|
|
tile_fg_color=curses.COLOR_WHITE,
|
|
|
|
|
tile_bg_color=curses.COLOR_BLACK,
|
|
|
|
|
entity_fg_color=curses.COLOR_WHITE,
|
|
|
|
|
entity_bg_color=curses.COLOR_WHITE,
|
2020-12-09 15:50:47 +00:00
|
|
|
|
|
|
|
|
|
BODY_SNATCH_POTION='🔀',
|
|
|
|
|
BOMB='💣',
|
2020-11-10 21:01:57 +00:00
|
|
|
|
EMPTY=' ',
|
2020-12-12 15:50:01 +00:00
|
|
|
|
EXPLOSION='💥',
|
2020-11-10 21:30:55 +00:00
|
|
|
|
FLOOR='██',
|
2020-12-26 13:02:35 +00:00
|
|
|
|
LADDER=('🪜', curses.COLOR_WHITE, curses.COLOR_WHITE),
|
2020-12-09 15:54:53 +00:00
|
|
|
|
HAZELNUT='🌰',
|
2020-11-11 15:23:27 +00:00
|
|
|
|
HEART='💜',
|
2020-12-09 15:50:47 +00:00
|
|
|
|
HEDGEHOG='🦔',
|
|
|
|
|
PLAYER='🐿️ ️',
|
2020-11-27 16:54:03 +00:00
|
|
|
|
MERCHANT='🦜',
|
2020-12-09 15:50:47 +00:00
|
|
|
|
RABBIT='🐇',
|
2020-11-27 17:35:52 +00:00
|
|
|
|
SUNFLOWER='🌻',
|
2020-12-18 00:50:11 +00:00
|
|
|
|
SWORD='🗡️ ',
|
2020-12-09 15:50:47 +00:00
|
|
|
|
TEDDY_BEAR='🧸',
|
|
|
|
|
TIGER='🐅',
|
2020-12-18 16:29:59 +00:00
|
|
|
|
TRUMPET='🎺',
|
2020-12-09 15:50:47 +00:00
|
|
|
|
WALL='🧱',
|
2020-11-06 16:43:30 +00:00
|
|
|
|
)
|