Linting
This commit is contained in:
parent
e0366b4719
commit
933385e79d
|
@ -2,46 +2,49 @@ from dungeonbattle.menus import Menu
|
|||
from typing import Any
|
||||
import curses
|
||||
|
||||
|
||||
class MenuDisplay:
|
||||
def __init__(self, menu : Menu, screen: Any, height : int, width : int, topleftx: int, toplefty: int) :
|
||||
def __init__(self, menu: Menu, screen: Any, height: int, width: int,
|
||||
topleftx: int, toplefty: int):
|
||||
self.screen = screen
|
||||
self.position = menu.position
|
||||
self.values = menu.values
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.trueheight = len(menu.values)
|
||||
self.truewidth = max(map(len,self.values))
|
||||
self.truewidth = max(map(len, self.values))
|
||||
self.topleftx = topleftx
|
||||
self.toplefty = toplefty
|
||||
|
||||
#Menu values are printed in pad
|
||||
self.pad = curses.newpad(self.trueheight,self.truewidth+1)
|
||||
for i in range(self.trueheight-1) :
|
||||
self.pad.addstr(i,0," " + self.values[i])
|
||||
# Menu values are printed in pad
|
||||
self.pad = curses.newpad(self.trueheight, self.truewidth + 1)
|
||||
for i in range(self.trueheight - 1):
|
||||
self.pad.addstr(i, 0, " " + self.values[i])
|
||||
|
||||
#Menu box
|
||||
self.menubox = curses.newpad(self.height,self.width)
|
||||
self.menubox.addstr(0,0,"┏"+"━"*(self.width-2)+"┓")
|
||||
for i in range(1,self.height-2) :
|
||||
self.menubox.addstr(i,0,"┃"+" "*(self.width-2)+"┃")
|
||||
self.menubox.addstr(self.height-2, 0, "┗"+"━"*(self.width-2)+"┛")
|
||||
|
||||
def update_pad(self, position : int) -> None:
|
||||
for i in range(self.trueheight) :
|
||||
self.pad.addstr(i,0," ")
|
||||
self.pad.addstr(position,0,">") #set a marker in front of the selected line
|
||||
# Menu box
|
||||
self.menubox = curses.newpad(self.height, self.width)
|
||||
self.menubox.addstr(0, 0, "┏" + "━" * (self.width - 2) + "┓")
|
||||
for i in range(1, self.height - 2):
|
||||
self.menubox.addstr(i, 0, "┃" + " " * (self.width - 2) + "┃")
|
||||
self.menubox.addstr(self.height - 2, 0,
|
||||
"┗" + "━" * (self.width - 2) + "┛")
|
||||
|
||||
def refresh(self, position : int) -> None:
|
||||
if self.height-2>=position-1 :
|
||||
def update_pad(self, position: int) -> None:
|
||||
for i in range(self.trueheight):
|
||||
self.pad.addstr(i, 0, " ")
|
||||
# set a marker in front of the selected line
|
||||
self.pad.addstr(position, 0, ">")
|
||||
|
||||
def refresh(self, position: int) -> None:
|
||||
if self.height - 2 >= position - 1:
|
||||
cornery = 0
|
||||
elif self.height-2 >= self.trueheight-position :
|
||||
cornery = self.trueheight-self.height+2
|
||||
|
||||
elif self.height - 2 >= self.trueheight - position:
|
||||
cornery = self.trueheight - self.height + 2
|
||||
|
||||
self.menubox.refresh(0, 0, self.toplefty, self.topleftx,
|
||||
self.height + self.toplefty,
|
||||
self.width + self.topleftx)
|
||||
self.height + self.toplefty,
|
||||
self.width + self.topleftx)
|
||||
self.update_pad(position)
|
||||
self.pad.refresh(cornery, 0, self.toplefty+1, self.topleftx+1,
|
||||
self.height-2 + self.toplefty,
|
||||
self.width-2 + self.topleftx)
|
||||
|
||||
self.pad.refresh(cornery, 0, self.toplefty + 1, self.topleftx + 1,
|
||||
self.height - 2 + self.toplefty,
|
||||
self.width - 2 + self.topleftx)
|
||||
|
|
|
@ -15,7 +15,7 @@ class StatsDisplay:
|
|||
|
||||
def update_pad(self) -> None:
|
||||
string = ""
|
||||
for i in range(self.width-1) :
|
||||
for i in range(self.width - 1):
|
||||
string = string + "-"
|
||||
string = string
|
||||
self.pad.addstr(0, 0, string)
|
||||
|
@ -23,20 +23,20 @@ class StatsDisplay:
|
|||
.format(self.player.level, self.player.current_xp,
|
||||
self.player.max_xp, self.player.health,
|
||||
self.player.maxhealth)
|
||||
for i in range(self.width-len(string2)-1) :
|
||||
for i in range(self.width - len(string2) - 1):
|
||||
string2 = string2 + " "
|
||||
self.pad.addstr(1, 0, string2)
|
||||
string3 = "Stats : STR {} INT {} CHR {} DEX {} CON {}"\
|
||||
.format(self.player.strength,
|
||||
self.player.intelligence, self.player.charisma,
|
||||
self.player.dexterity, self.player.constitution)
|
||||
for i in range(self.width-len(string3)-1) :
|
||||
for i in range(self.width - len(string3) - 1):
|
||||
string3 = string3 + " "
|
||||
self.pad.addstr(2, 0, string3)
|
||||
self.pad.addstr(2, 0, string3)
|
||||
|
||||
def refresh(self) -> None:
|
||||
self.pad.clear()
|
||||
self.update_pad()
|
||||
self.pad.refresh(0, 0, self.toplefty, self.topleftx,
|
||||
2+ self.toplefty,
|
||||
self.width+ self.topleftx)
|
||||
2 + self.toplefty,
|
||||
self.width + self.topleftx)
|
||||
|
|
Loading…
Reference in New Issue