Merge branch 'master' into 'moreitems'
# Conflicts: # squirrelbattle/entities/items.py # squirrelbattle/interfaces.py # squirrelbattle/tests/game_test.py
This commit is contained in:
@ -92,6 +92,6 @@ class CreditsDisplay(Display):
|
||||
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, game: Game) -> None:
|
||||
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
|
||||
|
@ -190,12 +190,11 @@ class Display:
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def handle_click(self, y: int, x: int, game: Game) -> None:
|
||||
def handle_click(self, y: int, x: int, attr: int, game: Game) -> None:
|
||||
"""
|
||||
A mouse click was performed on the coordinates (y, x) of the pad.
|
||||
Maybe it should do something.
|
||||
"""
|
||||
pass
|
||||
|
||||
@property
|
||||
def rows(self) -> int:
|
||||
|
@ -66,7 +66,7 @@ class DisplayManager:
|
||||
d.pack = TexturePack.get_pack(self.game.settings.TEXTURE_PACK)
|
||||
d.update(self.game)
|
||||
|
||||
def handle_mouse_click(self, y: int, x: int) -> None:
|
||||
def handle_mouse_click(self, y: int, x: int, attr: int) -> None:
|
||||
"""
|
||||
Handles the mouse clicks.
|
||||
"""
|
||||
@ -79,7 +79,7 @@ class DisplayManager:
|
||||
# of that display
|
||||
display = d
|
||||
if display:
|
||||
display.handle_click(y - display.y, x - display.x, self.game)
|
||||
display.handle_click(y - display.y, x - display.x, attr, self.game)
|
||||
|
||||
def refresh(self) -> List[Display]:
|
||||
"""
|
||||
|
@ -51,7 +51,7 @@ class MenuDisplay(Display):
|
||||
self.height - 2 + self.y,
|
||||
self.width - 2 + self.x)
|
||||
|
||||
def handle_click(self, y: int, x: int, game: Game) -> None:
|
||||
def handle_click(self, y: int, x: int, attr: int, game: Game) -> None:
|
||||
"""
|
||||
We can select a menu item with the mouse.
|
||||
"""
|
||||
@ -135,13 +135,13 @@ class MainMenuDisplay(Display):
|
||||
def update(self, game: Game) -> None:
|
||||
self.menudisplay.update_menu(game.main_menu)
|
||||
|
||||
def handle_click(self, y: int, x: int, game: Game) -> None:
|
||||
def handle_click(self, y: int, x: int, attr: int, game: Game) -> None:
|
||||
menuwidth = min(self.menudisplay.preferred_width, self.width)
|
||||
menuy, menux = len(self.title) + 8, self.width // 2 - menuwidth // 2 - 1
|
||||
menuheight = min(self.menudisplay.preferred_height, self.height - menuy)
|
||||
|
||||
if menuy <= y < menuy + menuheight and menux <= x < menux + menuwidth:
|
||||
self.menudisplay.handle_click(y - menuy, x - menux, game)
|
||||
self.menudisplay.handle_click(y - menuy, x - menux, attr, game)
|
||||
|
||||
if y <= len(self.title):
|
||||
self.fg_color = randint(0, 1000), randint(0, 1000), randint(0, 1000)
|
||||
@ -176,6 +176,7 @@ class PlayerInventoryDisplay(MenuDisplay):
|
||||
and self.selected else f" {rep} "
|
||||
self.addstr(self.pad, i + 1, 0, selection
|
||||
+ " " + item.translated_name.capitalize()
|
||||
+ (f" ({item.description})" if item.description else "")
|
||||
+ (": " + str(item.price) + " Hazels"
|
||||
if self.store_mode else ""))
|
||||
|
||||
@ -193,7 +194,7 @@ class PlayerInventoryDisplay(MenuDisplay):
|
||||
def trueheight(self) -> int:
|
||||
return 2 + super().trueheight
|
||||
|
||||
def handle_click(self, y: int, x: int, game: Game) -> None:
|
||||
def handle_click(self, y: int, x: int, attr: int, game: Game) -> None:
|
||||
"""
|
||||
We can select a menu item with the mouse.
|
||||
"""
|
||||
@ -221,6 +222,7 @@ class StoreInventoryDisplay(MenuDisplay):
|
||||
and self.selected else f" {rep} "
|
||||
self.addstr(self.pad, i + 1, 0, selection
|
||||
+ " " + item.translated_name.capitalize()
|
||||
+ (f" ({item.description})" if item.description else "")
|
||||
+ ": " + str(item.price) + " Hazels")
|
||||
|
||||
price = f"{self.pack.HAZELNUT} {self.menu.merchant.hazel} Hazels"
|
||||
@ -236,7 +238,7 @@ class StoreInventoryDisplay(MenuDisplay):
|
||||
def trueheight(self) -> int:
|
||||
return 2 + super().trueheight
|
||||
|
||||
def handle_click(self, y: int, x: int, game: Game) -> None:
|
||||
def handle_click(self, y: int, x: int, attr: int, game: Game) -> None:
|
||||
"""
|
||||
We can select a menu item with the mouse.
|
||||
"""
|
||||
|
@ -3,8 +3,10 @@
|
||||
|
||||
import curses
|
||||
|
||||
from ..entities.items import Monocle
|
||||
from ..entities.player import Player
|
||||
from ..game import Game
|
||||
from ..interfaces import FightingEntity
|
||||
from ..translations import gettext as _
|
||||
from .display import Display
|
||||
|
||||
@ -13,6 +15,7 @@ class StatsDisplay(Display):
|
||||
"""
|
||||
A class to handle the display of the stats of the player.
|
||||
"""
|
||||
game: Game
|
||||
player: Player
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -20,6 +23,7 @@ class StatsDisplay(Display):
|
||||
self.pad = self.newpad(self.rows, self.cols)
|
||||
|
||||
def update(self, game: Game) -> None:
|
||||
self.game = game
|
||||
self.player = game.player
|
||||
|
||||
def update_pad(self) -> None:
|
||||
@ -77,6 +81,47 @@ class StatsDisplay(Display):
|
||||
self.addstr(self.pad, 15, 0, _("YOU ARE DEAD"), curses.COLOR_RED,
|
||||
bold=True, blink=True, standout=True)
|
||||
|
||||
if self.player.map.tiles[self.player.y][self.player.x].is_ladder():
|
||||
msg = _("Use {key} to use the ladder") \
|
||||
.format(key=self.game.settings.KEY_LADDER.upper())
|
||||
self.addstr(self.pad, self.height - 2, 0, msg,
|
||||
italic=True, reverse=True)
|
||||
|
||||
self.update_entities_stats()
|
||||
|
||||
def update_entities_stats(self) -> None:
|
||||
"""
|
||||
Display information about a near entity if we have a monocle.
|
||||
"""
|
||||
for dy, dx in [(-1, 0), (0, -1), (0, 1), (1, 0)]:
|
||||
for entity in self.player.map.find_entities(FightingEntity):
|
||||
if entity == self.player:
|
||||
continue
|
||||
|
||||
if entity.y == self.player.y + dy \
|
||||
and entity.x == self.player.x + dx:
|
||||
if entity.is_friendly():
|
||||
msg = _("Move to the friendly entity to talk to it") \
|
||||
if self.game.waiting_for_friendly_key else \
|
||||
_("Use {key} then move to talk to the entity") \
|
||||
.format(key=self.game.settings.KEY_CHAT.upper())
|
||||
self.addstr(self.pad, self.height - 1, 0, msg,
|
||||
italic=True, reverse=True)
|
||||
|
||||
if isinstance(self.player.equipped_secondary, Monocle):
|
||||
# Truth monocle
|
||||
message = f"{entity.translated_name.capitalize()} " \
|
||||
f"{self.pack[entity.name.upper()]}\n" \
|
||||
f"STR {entity.strength}\n" \
|
||||
f"INT {entity.intelligence}\n" \
|
||||
f"CHR {entity.charisma}\n" \
|
||||
f"DEX {entity.dexterity}\n" \
|
||||
f"CON {entity.constitution}\n" \
|
||||
f"CRI {entity.critical}%"
|
||||
self.addstr(self.pad, 17, 0, message)
|
||||
# Only display one entity
|
||||
break
|
||||
|
||||
def display(self) -> None:
|
||||
self.pad.erase()
|
||||
self.update_pad()
|
||||
|
@ -93,6 +93,7 @@ TexturePack.ASCII_PACK = TexturePack(
|
||||
HEDGEHOG='*',
|
||||
HELMET='0',
|
||||
MERCHANT='M',
|
||||
MONOCLE='ô',
|
||||
PLAYER='@',
|
||||
RABBIT='Y',
|
||||
RING_OF_CRITICAL_DAMAGE='o',
|
||||
@ -133,9 +134,10 @@ TexturePack.SQUIRREL_PACK = TexturePack(
|
||||
HAZELNUT='🌰',
|
||||
HEART='💜',
|
||||
HEDGEHOG='🦔',
|
||||
HELMET='⛑️',
|
||||
HELMET='⛑️ ',
|
||||
PLAYER='🐿️ ️',
|
||||
MERCHANT='🦜',
|
||||
MONOCLE='🧐',
|
||||
RABBIT='🐇',
|
||||
RING_OF_CRITICAL_DAMAGE='💍',
|
||||
RING_OF_MORE_EXPERIENCE='💍',
|
||||
|
Reference in New Issue
Block a user