misc: use xdg-base-dirs

Resolves #26
This commit is contained in:
Marcin Kurczewski
2024-05-04 12:18:07 +02:00
parent 9eaf4397df
commit 07cae1a4e8
7 changed files with 220 additions and 193 deletions
+2 -2
View File
@@ -3,14 +3,14 @@ import sys
import typing as T
from pathlib import Path
import xdg
from xdg_base_dirs import xdg_config_home
from pqcli.mechanic import Player
from pqcli.roster import Roster
from pqcli.ui.basic import BasicUserInterface
from pqcli.ui.curses import CursesUserInterface
SAVE_PATH = Path(xdg.XDG_CONFIG_HOME) / "pqcli" / "save.dat"
SAVE_PATH = Path(xdg_config_home) / "pqcli" / "save.dat"
def parse_args() -> argparse.Namespace:
+3 -3
View File
@@ -347,7 +347,7 @@ class Player(SignalMixin):
self.emit("new_task")
def equip_price(self) -> int:
return 5 * (self.level ** 2) + 10 * self.level + 20
return 5 * (self.level**2) + 10 * self.level + 20
def level_up(self) -> None:
self.level += 1
@@ -373,12 +373,12 @@ class Player(SignalMixin):
chosen_stat = random.choice(list(StatType))
else:
# favor the best stat so it will tend to clump
t = sum(value ** 2 for _stat, value in self.stats)
t = sum(value**2 for _stat, value in self.stats)
t = random.below(t)
chosen_stat = None
for stat, value in self.stats:
chosen_stat = stat
t -= value ** 2
t -= value**2
if t < 0:
break
+5 -3
View File
@@ -54,9 +54,11 @@ class ProgressBar(WindowWrapper):
self._win.chgat(
0,
0,
curses.color_pair(COLOR_PROGRESSBAR)
if has_colors()
else curses.A_REVERSE,
(
curses.color_pair(COLOR_PROGRESSBAR)
if has_colors()
else curses.A_REVERSE
),
)
if x < self.getmaxyx()[1]:
self._win.chgat(0, x, curses.A_NORMAL)
+5 -3
View File
@@ -91,9 +91,11 @@ class Scrollable(WindowWrapper):
self._win.chgat(
win_y,
w - 1,
attr_thumb
if thumb_y1 <= win_y <= thumb_y2
else attr_track,
(
attr_thumb
if thumb_y1 <= win_y <= thumb_y2
else attr_track
),
)
self._win.noutrefresh()