Merge branch 'clean' into 'master'
Clean See merge request ynerant/squirrel-battle!64
This commit is contained in:
commit
e56fc502cb
58
README.md
58
README.md
@ -9,8 +9,62 @@
|
||||
|
||||
# Squirrel Battle
|
||||
|
||||
Attention aux couteaux des écureuils !
|
||||
Squirrel Battle is an infinite rogue-like game with randomly generated levels, in which the player controls a squirrel in its quest down in a dungeon, using diverse items to defeat monsters, and trying not to die.
|
||||
|
||||
##Installation
|
||||
|
||||
####Via PyPI :
|
||||
``` pip install --user squirrel-battle
|
||||
``` to install
|
||||
|
||||
``` pip install --user --upgrade squirrel-battle
|
||||
``` to upgrade
|
||||
|
||||
####Via ArchLinux package :
|
||||
Download one of these two packages on the AUR :
|
||||
|
||||
* python-squirrel-battle
|
||||
* python-squirrel-battle-git
|
||||
|
||||
####Via Debian package :
|
||||
Available on our git repository, has a dependency on fonts-noto-color-emoji (to be found in the official Debian repositories).
|
||||
|
||||
Run ```
|
||||
dpkg -i python3-squirrelbattle_3.14.1_all.deb
|
||||
``` after downloading
|
||||
|
||||
In all cases, execute via command line : ```squirrel-battle```
|
||||
|
||||
##For first-time players
|
||||
|
||||
The game is played in a terminal only, preferably one that supports color, markdown and emojis, but it can be played with only grey levels and relatively classic unicode characters.
|
||||
|
||||
Upon starting, the game will display the main menu. To navigate in menus, use zqsd or the keyboard arrows. To validate one of the options, use the Enter key. Mouse click is also supported in most menus, **but not in game**.
|
||||
|
||||
The game in itself can have two types of display : using ascii and simple unicode characters, or using emojis. To activate emoji mode, go to the settings menu and select the squirrel texture pack. Emojis will not work if the terminal does not support them, so do tests before to ensure the terminal can display them.
|
||||
|
||||
The game is translated (almost entirely) in English, French, German and Spanish. To change the language, go to the settings menu.
|
||||
|
||||
Controls in-game are pretty basic : use zqsd or the keyboard arrows to move. To hit an ennemy, simply go in its direction if it is in an adjacent tile.
|
||||
|
||||
There are several special control keys, they can be changed in the settings menu :
|
||||
|
||||
* To close a store menu or go back to the main menu, use Space
|
||||
* To open/close the inventory, use i
|
||||
* To use an object in the inventory, use u
|
||||
* To equip an object in the inventory, use e
|
||||
* To use a long range weapon after it has been equipped, use l and then select the direction to shoot in
|
||||
* To drop an object from the inventory, use r (to pick up an object, simply go on its tile, its automatic)
|
||||
* To talk to certains entities (or open a chest), use t and then select the direction of the entity
|
||||
* To wait a turn (rather than moving), use w
|
||||
* To use a ladder, use <
|
||||
|
||||
The dungeon consists in empty tiles (you can not go there), walls (which you can not cross) and floor ( :) ). Entities that move are usually monsters, but if you see a trumpet (or a '/'), do not kill it ! It is a familiar that will help you defeat monsters. Entities that do not move are either entities to which you can talk, like merchants and ... chests for some reason, or objects. Differentiating the two is not difficult, trying to go on the same tile as a living entity (or a chest) is impossible. Objects have pretty clear names, so it should not be too difficult determining what they do (if you still don't know, you can either read the docs, or test for yourself (beware of surprises though))
|
||||
|
||||
And that is all you need to get started! You can now start your adventure and don't worry, floors are randomly generated, so it won't always be the same boring level.
|
||||
|
||||
## Documentation
|
||||
|
||||
La documentation du projet est présente sur [squirrel-battle.readthedocs.io](https://squirrel-battle.readthedocs.io).
|
||||
The documentation for the project cen be found at [squirrel-battle.readthedocs.io](https://squirrel-battle.readthedocs.io). It is unfortunately only written in French.
|
||||
|
||||
Anyone interested in understanding how the code works can find a few explanations in the documentation.
|
||||
|
@ -1,97 +0,0 @@
|
||||
# Copyright (C) 2020-2021 by ÿnérant, eichhornchen, nicomarg, charlse
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import curses
|
||||
|
||||
from ..display.display import Box, Display
|
||||
from ..game import Game
|
||||
from ..resources import ResourceManager
|
||||
from ..translations import gettext as _
|
||||
|
||||
|
||||
class CreditsDisplay(Display):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.box = Box(*args, **kwargs)
|
||||
self.pad = self.newpad(1, 1)
|
||||
self.ascii_art_displayed = False
|
||||
|
||||
def update(self, game: Game) -> None:
|
||||
return
|
||||
|
||||
def display(self) -> None:
|
||||
self.box.refresh(self.y, self.x, self.height, self.width)
|
||||
self.box.display()
|
||||
self.pad.erase()
|
||||
|
||||
messages = [
|
||||
_("Credits"),
|
||||
"",
|
||||
"Squirrel Battle",
|
||||
"",
|
||||
_("Developers:"),
|
||||
"Yohann \"ÿnérant\" D'ANELLO",
|
||||
"Mathilde \"eichhornchen\" DÉPRÉS",
|
||||
"Nicolas \"nicomarg\" MARGULIES",
|
||||
"Charles \"charsle\" PEYRAT",
|
||||
"",
|
||||
_("Translators:"),
|
||||
"Hugo \"ifugao\" JACOB (español)",
|
||||
]
|
||||
|
||||
for i, msg in enumerate(messages):
|
||||
self.addstr(self.pad, i + (self.height - len(messages)) // 2,
|
||||
(self.width - len(msg)) // 2, msg,
|
||||
bold=(i == 0), italic=(":" in msg))
|
||||
|
||||
if self.ascii_art_displayed:
|
||||
self.display_ascii_art()
|
||||
|
||||
self.refresh_pad(self.pad, 0, 0, self.y + 1, self.x + 1,
|
||||
self.height + self.y - 2,
|
||||
self.width + self.x - 2)
|
||||
|
||||
def display_ascii_art(self) -> None:
|
||||
with open(ResourceManager.get_asset_path("ascii-art-ecureuil.txt"))\
|
||||
as f:
|
||||
ascii_art = f.read().split("\n")
|
||||
|
||||
height, width = len(ascii_art), len(ascii_art[0])
|
||||
y_offset, x_offset = (self.height - height) // 2,\
|
||||
(self.width - width) // 2
|
||||
|
||||
for i, line in enumerate(ascii_art):
|
||||
for j, c in enumerate(line):
|
||||
bg_color = curses.COLOR_WHITE
|
||||
fg_color = curses.COLOR_BLACK
|
||||
bold = False
|
||||
if c == ' ':
|
||||
bg_color = curses.COLOR_BLACK
|
||||
elif c == '━' or c == '┃' or c == '⋀':
|
||||
bold = True
|
||||
fg_color = curses.COLOR_WHITE
|
||||
bg_color = curses.COLOR_BLACK
|
||||
elif c == '|':
|
||||
bold = True # c = '┃'
|
||||
fg_color = (100, 700, 1000)
|
||||
bg_color = curses.COLOR_BLACK
|
||||
elif c == '▓':
|
||||
fg_color = (700, 300, 0)
|
||||
elif c == '▒':
|
||||
fg_color = (700, 300, 0)
|
||||
bg_color = curses.COLOR_BLACK
|
||||
elif c == '░':
|
||||
fg_color = (350, 150, 0)
|
||||
elif c == '█':
|
||||
fg_color = (0, 0, 0)
|
||||
bg_color = curses.COLOR_BLACK
|
||||
elif c == '▬':
|
||||
c = '█'
|
||||
fg_color = (1000, 1000, 1000)
|
||||
bg_color = curses.COLOR_BLACK
|
||||
self.addstr(self.pad, y_offset + i, x_offset + j, c,
|
||||
fg_color, bg_color, bold=bold)
|
||||
|
||||
def handle_click(self, y: int, x: int, attr: int, game: Game) -> None:
|
||||
if self.pad.inch(y - 1, x - 1) != ord(" "):
|
||||
self.ascii_art_displayed = True
|
@ -290,3 +290,29 @@ class Box(Display):
|
||||
|
||||
self.refresh_pad(self.pad, 0, 0, self.y, self.x,
|
||||
self.y + self.height - 1, self.x + self.width - 1)
|
||||
|
||||
|
||||
class MessageDisplay(Display):
|
||||
"""
|
||||
A class to handle the display of popup messages.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.box = Box(fg_border_color=curses.COLOR_RED, *args, **kwargs)
|
||||
self.message = ""
|
||||
self.pad = self.newpad(1, 1)
|
||||
|
||||
def update(self, game: Game) -> None:
|
||||
self.message = game.message
|
||||
|
||||
def display(self) -> None:
|
||||
self.box.refresh(self.y - 1, self.x - 2,
|
||||
self.height + 2, self.width + 4)
|
||||
self.box.display()
|
||||
self.pad.erase()
|
||||
self.addstr(self.pad, 0, 0, self.message, bold=True)
|
||||
self.refresh_pad(self.pad, 0, 0, self.y, self.x,
|
||||
self.height + self.y - 1,
|
||||
self.width + self.x - 1)
|
||||
|
@ -4,14 +4,11 @@
|
||||
import curses
|
||||
from typing import Any, List
|
||||
|
||||
from .creditsdisplay import CreditsDisplay
|
||||
from .display import Display, HorizontalSplit, VerticalSplit
|
||||
from .logsdisplay import LogsDisplay
|
||||
from .mapdisplay import MapDisplay
|
||||
from .menudisplay import ChestInventoryDisplay, MainMenuDisplay, \
|
||||
PlayerInventoryDisplay, SettingsMenuDisplay, StoreInventoryDisplay
|
||||
from .messagedisplay import MessageDisplay
|
||||
from .statsdisplay import StatsDisplay
|
||||
from .display import Display, HorizontalSplit, MessageDisplay, VerticalSplit
|
||||
from .gamedisplay import LogsDisplay, MapDisplay, StatsDisplay
|
||||
from .menudisplay import ChestInventoryDisplay, CreditsDisplay, \
|
||||
MainMenuDisplay, PlayerInventoryDisplay, \
|
||||
SettingsMenuDisplay, StoreInventoryDisplay
|
||||
from .texturepack import TexturePack
|
||||
from ..enums import DisplayActions
|
||||
from ..game import Game, GameMode
|
||||
|
@ -7,10 +7,116 @@ from .display import Display
|
||||
from ..entities.items import Monocle
|
||||
from ..entities.player import Player
|
||||
from ..game import Game
|
||||
from ..interfaces import FightingEntity
|
||||
from ..interfaces import FightingEntity, Logs, Map
|
||||
from ..translations import gettext as _
|
||||
|
||||
|
||||
class LogsDisplay(Display):
|
||||
"""
|
||||
A class to handle the display of the logs.
|
||||
"""
|
||||
|
||||
logs: Logs
|
||||
|
||||
def __init__(self, *args) -> None:
|
||||
super().__init__(*args)
|
||||
self.pad = self.newpad(self.rows, self.cols)
|
||||
|
||||
def update(self, game: Game) -> None:
|
||||
self.logs = game.logs
|
||||
|
||||
def display(self) -> None:
|
||||
messages = self.logs.messages[-self.height:]
|
||||
messages = messages[::-1]
|
||||
self.pad.erase()
|
||||
for i in range(min(self.height, len(messages))):
|
||||
self.addstr(self.pad, self.height - i - 1, self.x,
|
||||
messages[i][:self.width])
|
||||
self.refresh_pad(self.pad, 0, 0, self.y, self.x,
|
||||
self.y + self.height - 1, self.x + self.width - 1)
|
||||
|
||||
|
||||
class MapDisplay(Display):
|
||||
"""
|
||||
A class to handle the display of the map.
|
||||
"""
|
||||
|
||||
map: Map
|
||||
|
||||
def __init__(self, *args):
|
||||
super().__init__(*args)
|
||||
|
||||
def update(self, game: Game) -> None:
|
||||
self.map = game.map
|
||||
self.pad = self.newpad(self.map.height,
|
||||
self.pack.tile_width * self.map.width + 1)
|
||||
|
||||
def update_pad(self) -> None:
|
||||
for j in range(len(self.map.tiles)):
|
||||
for i in range(len(self.map.tiles[j])):
|
||||
if not self.map.seen_tiles[j][i]:
|
||||
continue
|
||||
fg, bg = self.map.tiles[j][i].visible_color(self.pack) if \
|
||||
self.map.visibility[j][i] else \
|
||||
self.map.tiles[j][i].hidden_color(self.pack)
|
||||
self.addstr(self.pad, j, self.pack.tile_width * i,
|
||||
self.map.tiles[j][i].char(self.pack), fg, bg)
|
||||
for e in self.map.entities:
|
||||
if self.map.visibility[e.y][e.x]:
|
||||
self.addstr(self.pad, e.y, self.pack.tile_width * e.x,
|
||||
self.pack[e.name.upper()],
|
||||
self.pack.entity_fg_color,
|
||||
self.pack.entity_bg_color)
|
||||
|
||||
# Display Path map for debug purposes
|
||||
# from squirrelbattle.entities.player import Player
|
||||
# players = [ p for p in self.map.entities if isinstance(p,Player) ]
|
||||
# player = players[0] if len(players) > 0 else None
|
||||
# if player:
|
||||
# for x in range(self.map.width):
|
||||
# for y in range(self.map.height):
|
||||
# if (y,x) in player.paths:
|
||||
# deltay, deltax = (y - player.paths[(y, x)][0],
|
||||
# x - player.paths[(y, x)][1])
|
||||
# if (deltay, deltax) == (-1, 0):
|
||||
# character = '↓'
|
||||
# elif (deltay, deltax) == (1, 0):
|
||||
# character = '↑'
|
||||
# elif (deltay, deltax) == (0, -1):
|
||||
# character = '→'
|
||||
# else:
|
||||
# character = '←'
|
||||
# self.addstr(self.pad, y, self.pack.tile_width * x,
|
||||
# character, self.pack.tile_fg_color,
|
||||
# self.pack.tile_bg_color)
|
||||
|
||||
def display(self) -> None:
|
||||
y, x = self.map.currenty, self.pack.tile_width * self.map.currentx
|
||||
deltay, deltax = (self.height // 2) + 1, (self.width // 2) + 1
|
||||
pminrow, pmincol = y - deltay, x - deltax
|
||||
sminrow, smincol = max(-pminrow, 0), max(-pmincol, 0)
|
||||
deltay, deltax = self.height - deltay, self.width - deltax
|
||||
smaxrow = self.map.height - (y + deltay) + self.height - 1
|
||||
smaxrow = min(smaxrow, self.height - 1)
|
||||
smaxcol = self.pack.tile_width * self.map.width - \
|
||||
(x + deltax) + self.width - 1
|
||||
|
||||
# Wrap perfectly the map according to the width of the tiles
|
||||
pmincol = self.pack.tile_width * (pmincol // self.pack.tile_width)
|
||||
smincol = self.pack.tile_width * (smincol // self.pack.tile_width)
|
||||
smaxcol = self.pack.tile_width \
|
||||
* (smaxcol // self.pack.tile_width + 1) - 1
|
||||
|
||||
smaxcol = min(smaxcol, self.width - 1)
|
||||
pminrow = max(0, min(self.map.height, pminrow))
|
||||
pmincol = max(0, min(self.pack.tile_width * self.map.width, pmincol))
|
||||
|
||||
self.pad.erase()
|
||||
self.update_pad()
|
||||
self.refresh_pad(self.pad, pminrow, pmincol, sminrow, smincol, smaxrow,
|
||||
smaxcol)
|
||||
|
||||
|
||||
class StatsDisplay(Display):
|
||||
"""
|
||||
A class to handle the display of the stats of the player.
|
@ -1,31 +0,0 @@
|
||||
# Copyright (C) 2020-2021 by ÿnérant, eichhornchen, nicomarg, charlse
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from squirrelbattle.display.display import Display
|
||||
from squirrelbattle.game import Game
|
||||
from squirrelbattle.interfaces import Logs
|
||||
|
||||
|
||||
class LogsDisplay(Display):
|
||||
"""
|
||||
A class to handle the display of the logs.
|
||||
"""
|
||||
|
||||
logs: Logs
|
||||
|
||||
def __init__(self, *args) -> None:
|
||||
super().__init__(*args)
|
||||
self.pad = self.newpad(self.rows, self.cols)
|
||||
|
||||
def update(self, game: Game) -> None:
|
||||
self.logs = game.logs
|
||||
|
||||
def display(self) -> None:
|
||||
messages = self.logs.messages[-self.height:]
|
||||
messages = messages[::-1]
|
||||
self.pad.erase()
|
||||
for i in range(min(self.height, len(messages))):
|
||||
self.addstr(self.pad, self.height - i - 1, self.x,
|
||||
messages[i][:self.width])
|
||||
self.refresh_pad(self.pad, 0, 0, self.y, self.x,
|
||||
self.y + self.height - 1, self.x + self.width - 1)
|
@ -1,87 +0,0 @@
|
||||
# Copyright (C) 2020-2021 by ÿnérant, eichhornchen, nicomarg, charlse
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from .display import Display
|
||||
from ..game import Game
|
||||
from ..interfaces import Map
|
||||
|
||||
|
||||
class MapDisplay(Display):
|
||||
"""
|
||||
A class to handle the display of the map.
|
||||
"""
|
||||
|
||||
map: Map
|
||||
|
||||
def __init__(self, *args):
|
||||
super().__init__(*args)
|
||||
|
||||
def update(self, game: Game) -> None:
|
||||
self.map = game.map
|
||||
self.pad = self.newpad(self.map.height,
|
||||
self.pack.tile_width * self.map.width + 1)
|
||||
|
||||
def update_pad(self) -> None:
|
||||
for j in range(len(self.map.tiles)):
|
||||
for i in range(len(self.map.tiles[j])):
|
||||
if not self.map.seen_tiles[j][i]:
|
||||
continue
|
||||
fg, bg = self.map.tiles[j][i].visible_color(self.pack) if \
|
||||
self.map.visibility[j][i] else \
|
||||
self.map.tiles[j][i].hidden_color(self.pack)
|
||||
self.addstr(self.pad, j, self.pack.tile_width * i,
|
||||
self.map.tiles[j][i].char(self.pack), fg, bg)
|
||||
for e in self.map.entities:
|
||||
if self.map.visibility[e.y][e.x]:
|
||||
self.addstr(self.pad, e.y, self.pack.tile_width * e.x,
|
||||
self.pack[e.name.upper()],
|
||||
self.pack.entity_fg_color,
|
||||
self.pack.entity_bg_color)
|
||||
|
||||
# Display Path map for debug purposes
|
||||
# from squirrelbattle.entities.player import Player
|
||||
# players = [ p for p in self.map.entities if isinstance(p,Player) ]
|
||||
# player = players[0] if len(players) > 0 else None
|
||||
# if player:
|
||||
# for x in range(self.map.width):
|
||||
# for y in range(self.map.height):
|
||||
# if (y,x) in player.paths:
|
||||
# deltay, deltax = (y - player.paths[(y, x)][0],
|
||||
# x - player.paths[(y, x)][1])
|
||||
# if (deltay, deltax) == (-1, 0):
|
||||
# character = '↓'
|
||||
# elif (deltay, deltax) == (1, 0):
|
||||
# character = '↑'
|
||||
# elif (deltay, deltax) == (0, -1):
|
||||
# character = '→'
|
||||
# else:
|
||||
# character = '←'
|
||||
# self.addstr(self.pad, y, self.pack.tile_width * x,
|
||||
# character, self.pack.tile_fg_color,
|
||||
# self.pack.tile_bg_color)
|
||||
|
||||
def display(self) -> None:
|
||||
y, x = self.map.currenty, self.pack.tile_width * self.map.currentx
|
||||
deltay, deltax = (self.height // 2) + 1, (self.width // 2) + 1
|
||||
pminrow, pmincol = y - deltay, x - deltax
|
||||
sminrow, smincol = max(-pminrow, 0), max(-pmincol, 0)
|
||||
deltay, deltax = self.height - deltay, self.width - deltax
|
||||
smaxrow = self.map.height - (y + deltay) + self.height - 1
|
||||
smaxrow = min(smaxrow, self.height - 1)
|
||||
smaxcol = self.pack.tile_width * self.map.width - \
|
||||
(x + deltax) + self.width - 1
|
||||
|
||||
# Wrap perfectly the map according to the width of the tiles
|
||||
pmincol = self.pack.tile_width * (pmincol // self.pack.tile_width)
|
||||
smincol = self.pack.tile_width * (smincol // self.pack.tile_width)
|
||||
smaxcol = self.pack.tile_width \
|
||||
* (smaxcol // self.pack.tile_width + 1) - 1
|
||||
|
||||
smaxcol = min(smaxcol, self.width - 1)
|
||||
pminrow = max(0, min(self.map.height, pminrow))
|
||||
pmincol = max(0, min(self.pack.tile_width * self.map.width, pmincol))
|
||||
|
||||
self.pad.erase()
|
||||
self.update_pad()
|
||||
self.refresh_pad(self.pad, pminrow, pmincol, sminrow, smincol, smaxrow,
|
||||
smaxcol)
|
@ -104,7 +104,8 @@ class MainMenuDisplay(Display):
|
||||
super().__init__(*args)
|
||||
self.menu = menu
|
||||
|
||||
with open(ResourceManager.get_asset_path("ascii_art.txt"), "r") as file:
|
||||
with open(ResourceManager.get_asset_path("ascii_art-title.txt"), "r")\
|
||||
as file:
|
||||
self.title = file.read().split("\n")
|
||||
|
||||
self.pad = self.newpad(max(self.rows, len(self.title) + 30),
|
||||
@ -281,3 +282,91 @@ class ChestInventoryDisplay(MenuDisplay):
|
||||
self.menu.position = max(0, min(len(self.menu.values) - 1, y - 2))
|
||||
game.is_in_chest_menu = True
|
||||
game.handle_key_pressed(KeyValues.ENTER)
|
||||
|
||||
|
||||
class CreditsDisplay(Display):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.box = Box(*args, **kwargs)
|
||||
self.pad = self.newpad(1, 1)
|
||||
self.ascii_art_displayed = False
|
||||
|
||||
def update(self, game: Game) -> None:
|
||||
return
|
||||
|
||||
def display(self) -> None:
|
||||
self.box.refresh(self.y, self.x, self.height, self.width)
|
||||
self.box.display()
|
||||
self.pad.erase()
|
||||
|
||||
messages = [
|
||||
_("Credits"),
|
||||
"",
|
||||
"Squirrel Battle",
|
||||
"",
|
||||
_("Developers:"),
|
||||
"Yohann \"ÿnérant\" D'ANELLO",
|
||||
"Mathilde \"eichhornchen\" DÉPRÉS",
|
||||
"Nicolas \"nicomarg\" MARGULIES",
|
||||
"Charles \"charsle\" PEYRAT",
|
||||
"",
|
||||
_("Translators:"),
|
||||
"Hugo \"ifugao\" JACOB (español)",
|
||||
]
|
||||
|
||||
for i, msg in enumerate(messages):
|
||||
self.addstr(self.pad, i + (self.height - len(messages)) // 2,
|
||||
(self.width - len(msg)) // 2, msg,
|
||||
bold=(i == 0), italic=(":" in msg))
|
||||
|
||||
if self.ascii_art_displayed:
|
||||
self.display_ascii_art()
|
||||
|
||||
self.refresh_pad(self.pad, 0, 0, self.y + 1, self.x + 1,
|
||||
self.height + self.y - 2,
|
||||
self.width + self.x - 2)
|
||||
|
||||
def display_ascii_art(self) -> None:
|
||||
with open(ResourceManager.get_asset_path("ascii-art-ecureuil.txt"))\
|
||||
as f:
|
||||
ascii_art = f.read().split("\n")
|
||||
|
||||
height, width = len(ascii_art), len(ascii_art[0])
|
||||
y_offset, x_offset = (self.height - height) // 2,\
|
||||
(self.width - width) // 2
|
||||
|
||||
for i, line in enumerate(ascii_art):
|
||||
for j, c in enumerate(line):
|
||||
bg_color = curses.COLOR_WHITE
|
||||
fg_color = curses.COLOR_BLACK
|
||||
bold = False
|
||||
if c == ' ':
|
||||
bg_color = curses.COLOR_BLACK
|
||||
elif c == '━' or c == '┃' or c == '⋀':
|
||||
bold = True
|
||||
fg_color = curses.COLOR_WHITE
|
||||
bg_color = curses.COLOR_BLACK
|
||||
elif c == '|':
|
||||
bold = True # c = '┃'
|
||||
fg_color = (100, 700, 1000)
|
||||
bg_color = curses.COLOR_BLACK
|
||||
elif c == '▓':
|
||||
fg_color = (700, 300, 0)
|
||||
elif c == '▒':
|
||||
fg_color = (700, 300, 0)
|
||||
bg_color = curses.COLOR_BLACK
|
||||
elif c == '░':
|
||||
fg_color = (350, 150, 0)
|
||||
elif c == '█':
|
||||
fg_color = (0, 0, 0)
|
||||
bg_color = curses.COLOR_BLACK
|
||||
elif c == '▬':
|
||||
c = '█'
|
||||
fg_color = (1000, 1000, 1000)
|
||||
bg_color = curses.COLOR_BLACK
|
||||
self.addstr(self.pad, y_offset + i, x_offset + j, c,
|
||||
fg_color, bg_color, bold=bold)
|
||||
|
||||
def handle_click(self, y: int, x: int, attr: int, game: Game) -> None:
|
||||
if self.pad.inch(y - 1, x - 1) != ord(" "):
|
||||
self.ascii_art_displayed = True
|
||||
|
@ -1,32 +0,0 @@
|
||||
# Copyright (C) 2020-2021 by ÿnérant, eichhornchen, nicomarg, charlse
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
import curses
|
||||
|
||||
from squirrelbattle.display.display import Box, Display
|
||||
from squirrelbattle.game import Game
|
||||
|
||||
|
||||
class MessageDisplay(Display):
|
||||
"""
|
||||
A class to handle the display of popup messages.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.box = Box(fg_border_color=curses.COLOR_RED, *args, **kwargs)
|
||||
self.message = ""
|
||||
self.pad = self.newpad(1, 1)
|
||||
|
||||
def update(self, game: Game) -> None:
|
||||
self.message = game.message
|
||||
|
||||
def display(self) -> None:
|
||||
self.box.refresh(self.y - 1, self.x - 2,
|
||||
self.height + 2, self.width + 4)
|
||||
self.box.display()
|
||||
self.pad.erase()
|
||||
self.addstr(self.pad, 0, 0, self.message, bold=True)
|
||||
self.refresh_pad(self.pad, 0, 0, self.y, self.x,
|
||||
self.height + self.y - 1,
|
||||
self.width + self.x - 1)
|
Loading…
Reference in New Issue
Block a user