Linting
This commit is contained in:
parent
2e667cdebe
commit
0bd26a1bd0
@ -1,21 +1,25 @@
|
||||
import curses
|
||||
from typing import Any
|
||||
|
||||
from .mapdisplay import MapDisplay
|
||||
from .texturepack import TexturePack
|
||||
from ..game import Game
|
||||
|
||||
|
||||
class Display:
|
||||
def __init__(self, game, screen):
|
||||
def __init__(self, game: Game, screen: Any):
|
||||
self.screen = screen
|
||||
self.game = game
|
||||
lines = curses.LINES if screen else 4
|
||||
cols = curses.COLS * 4 // 5 if screen else 4
|
||||
self.map_display = MapDisplay(game.m,
|
||||
TexturePack.get_pack(
|
||||
game.settings.TEXTURE_PACK),
|
||||
game.settings.TEXTURE_PACK
|
||||
),
|
||||
lines, cols, screen is not None)
|
||||
|
||||
def refresh(self):
|
||||
def refresh(self) -> None:
|
||||
self.map_display.update_pad()
|
||||
|
||||
def display(self, y, x):
|
||||
def display(self, y: int, x: int) -> None:
|
||||
self.map_display.display(y, x)
|
||||
|
@ -16,21 +16,21 @@ class MapDisplay:
|
||||
if init_pad:
|
||||
self.pad = curses.newpad(m.height, m.width + 1)
|
||||
|
||||
def update_pad(self):
|
||||
def update_pad(self) -> None:
|
||||
self.pad.addstr(0, 0, self.map.draw_string(self.pack))
|
||||
for e in self.map.entities:
|
||||
self.pad.addstr(e.y, e.x, self.pack.PLAYER)
|
||||
|
||||
def display(self, y, x):
|
||||
deltay, deltax = (self.height // 2) + 1, (self.width //2) + 1
|
||||
pminrow, pmincol = y-deltay, x-deltax
|
||||
def display(self, y: int, x: int) -> None:
|
||||
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.map.width - (x + deltax) + self.width -1
|
||||
smaxcol = min(smaxcol, self.width-1)
|
||||
pminrow = max(0, min(self.map.height, pminrow))
|
||||
smaxrow = self.map.height - (y + deltay) + self.height - 1
|
||||
smaxrow = min(smaxrow, self.height - 1)
|
||||
smaxcol = self.map.width - (x + deltax) + self.width - 1
|
||||
smaxcol = min(smaxcol, self.width - 1)
|
||||
pminrow = max(0, min(self.map.height, pminrow))
|
||||
pmincol = max(0, min(self.map.width, pmincol))
|
||||
self.pad.clear()
|
||||
self.update_pad()
|
||||
|
@ -1,15 +1,31 @@
|
||||
import curses
|
||||
|
||||
from dungeonbattle.entities.player import Player
|
||||
|
||||
|
||||
class StatsDisplay:
|
||||
def __init__(self, player, height, width, topleftx, toplefty) :
|
||||
def __init__(self, player: Player, height: int, width: int,
|
||||
topleftx: int, toplefty: int):
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.topleftx = topleftx
|
||||
self.toplefty = toplefty
|
||||
self.player = player
|
||||
self.pad = curses.newpad(height, width)
|
||||
def update_pad(self) :
|
||||
string = "Player -- LVL {} EXP {}/{} HP {}/{}\nStats : STR {} INT {} CHR {} DEX {} CON {}".format(player.level, player.currentXP, player.maxXP, player.health, player.maxhealth, player.strength, player.intelligence, player.charisma, player.dexterity, player.constitution)
|
||||
|
||||
def update_pad(self) -> None:
|
||||
string = "Player -- LVL {} EXP {}/{} HP {}/{}\n" \
|
||||
"Stats : STR {} INT {} CHR {} DEX {} CON {}"\
|
||||
.format(self.player.level, self.player.current_xp,
|
||||
self.player.max_xp, self.player.health,
|
||||
self.player.maxhealth, self.player.strength,
|
||||
self.player.intelligence, self.player.charisma,
|
||||
self.player.dexterity, self.player.constitution)
|
||||
self.pad.addstr(0, 0, string)
|
||||
def refresh(self) :
|
||||
|
||||
def refresh(self) -> None:
|
||||
self.pad.clear()
|
||||
self.update_pad()
|
||||
self.pad.refresh(0, 0, toplefty, topleftx, heigth+toplefty, width+topleftx)
|
||||
|
||||
self.pad.refresh(0, 0, self.toplefty, self.topleftx,
|
||||
self.heigth + self.toplefty,
|
||||
self.width + self.topleftx)
|
||||
|
@ -17,14 +17,15 @@ class Player(FightingEntity):
|
||||
def move_right(self) -> bool:
|
||||
return self.check_move(self.y, self.x + 1, True)
|
||||
|
||||
currentXP: int
|
||||
maxXP: int
|
||||
current_xp: int
|
||||
max_xp: int
|
||||
|
||||
def level_up(self):
|
||||
if currentXP>maxXP :
|
||||
self.level+=1
|
||||
currentXP = 0
|
||||
maxXP = self.level*10
|
||||
def addXP(self, xp) :
|
||||
currentXP+=xp
|
||||
def level_up(self) -> None:
|
||||
if self.current_xp > self.max_xp:
|
||||
self.level += 1
|
||||
self.current_xp = 0
|
||||
self.max_xp = self.level * 10
|
||||
|
||||
def add_xp(self, xp: int) -> None:
|
||||
self.current_xp += xp
|
||||
self.level_up()
|
||||
|
@ -12,8 +12,10 @@ class Map:
|
||||
width: int
|
||||
height: int
|
||||
tiles: list
|
||||
currentx : int #coordinates of the point that should be on the topleft corner of the screen
|
||||
currenty : int
|
||||
# coordinates of the point that should be
|
||||
# on the topleft corner of the screen
|
||||
currentx: int
|
||||
currenty: int
|
||||
|
||||
def __init__(self, width: int, height: int, tiles: list):
|
||||
self.width = width
|
||||
@ -88,7 +90,7 @@ class Tile(Enum):
|
||||
class Entity:
|
||||
y: int
|
||||
x: int
|
||||
name : str
|
||||
name: str
|
||||
map: Map
|
||||
|
||||
def __init__(self):
|
||||
|
Loading…
Reference in New Issue
Block a user