diff options
author | Viljami Ilola <+@hix.fi> | 2024-04-08 23:50:29 +0300 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-04-08 23:50:29 +0300 |
commit | b1e18bc5b92826078fc7c480a2662b9208f2edac (patch) | |
tree | df9d91a26357e8af7c94e15b899914057bf94808 /src/sliceitoff/hiscores | |
parent | a433d57a893d3605db5fe1eb501e5ae25d547ac1 (diff) |
nt compatibility
Diffstat (limited to 'src/sliceitoff/hiscores')
-rw-r--r-- | src/sliceitoff/hiscores/hiscores.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/sliceitoff/hiscores/hiscores.py b/src/sliceitoff/hiscores/hiscores.py index a6c2bf0..5ce8ced 100644 --- a/src/sliceitoff/hiscores/hiscores.py +++ b/src/sliceitoff/hiscores/hiscores.py @@ -1,5 +1,6 @@ -""" hiscores.hiscores - high socres: loading, saving, converting to string""" +""" hiscores.hiscores - high socres: loading, saving, converting to string """ import os +from pathlib import Path from .static import INITIAL_HIGHSCORES, MAX_HIGHSCORES @@ -8,10 +9,13 @@ class HiScores: def __init__(self): """ On creation load high scores from config file """ self.table=[] - self.config_filename = os.path.join( - os.getenv('HOME'), - ".config", - "sliceitoffrc") + if os.name == 'nt': + self.config_filename = os.path.join(Path.home(), "sliceitoff.cfg") + else: + self.config_filename = os.path.join( + Path.home(), + ".config", + "sliceitoffrc") if not os.path.isfile(self.config_filename): self.table=INITIAL_HIGHSCORES[:] return @@ -48,13 +52,14 @@ class HiScores: config_file.writelines(oldlines) for score, name in self.table: config_file.write(f"hiscore={score}!{name}\n") + config_file.write("\n") def __str__(self): text = ( " " "\xeeH\xecI\xedG\xe9H " "\xeaS\xedC\xeeO\xebR\xe9E\xecS\xeb!\xed!\n\n") - half = len(self.table)//2 + half = len(self.table) // 2 for i in range(half): text += ( f"\xed{self.table[i][1]:<3s} " |