diff options
author | Viljami Ilola <+@hix.fi> | 2024-04-09 00:43:55 +0300 |
---|---|---|
committer | Viljami Ilola <+@hix.fi> | 2024-04-09 00:43:55 +0300 |
commit | 8710a919afecec802383c8b867ac9c20a6de10ad (patch) | |
tree | e3823a0cc32c85c498ffd7632297d0317eeaa55b /src/sliceitoff | |
parent | b1e18bc5b92826078fc7c480a2662b9208f2edac (diff) |
fix hisghscore file readingv0.3b1
Diffstat (limited to 'src/sliceitoff')
-rw-r--r-- | src/sliceitoff/hiscores/hiscores.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/sliceitoff/hiscores/hiscores.py b/src/sliceitoff/hiscores/hiscores.py index 5ce8ced..4b71c1a 100644 --- a/src/sliceitoff/hiscores/hiscores.py +++ b/src/sliceitoff/hiscores/hiscores.py @@ -21,9 +21,9 @@ class HiScores: return with open(self.config_filename, "r", encoding="utf-8") as config_file: for line in config_file: - option, value = line.split('=') - if option == 'hiscore': - score, name = value.split('!') + option, *value = line.split('=') + if option == 'hiscore' and value: + score, name = value[0].split('!') self.add(int(score.strip()),name.strip()) if len(self.table)<MAX_HIGHSCORES: self.table+=[(0,"") for _ in range(MAX_HIGHSCORES-len(self.table))] @@ -45,14 +45,13 @@ class HiScores: with (open(self.config_filename, "r", encoding="utf-8") as config_file): for line in config_file: - option, _ = line.split('=') + option, *_ = line.split('=') if option != 'hiscore': oldlines.append(line) with open(self.config_filename, 'w', encoding="utf-8") as config_file: 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 = ( |