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 | |
| parent | b1e18bc5b92826078fc7c480a2662b9208f2edac (diff) | |
fix hisghscore file readingv0.3b1
| -rw-r--r-- | pyproject.toml | 2 | ||||
| -rw-r--r-- | src/sliceitoff/hiscores/hiscores.py | 9 | 
2 files changed, 5 insertions, 6 deletions
| diff --git a/pyproject.toml b/pyproject.toml index bd20970..d2dbd5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@  [tool.poetry]  name = "sliceitoff" -version = "0.3-beta" +version = "0.3-beta.1"  description = "Arcade game where one slices play area off avoiding enemies."  authors = ["Viljami Ilola <+@hix.fi>"]  readme = "README.txt" 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 = ( |