You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
590 B
22 lines
590 B
|
|
import datetime |
|
|
|
|
|
class Scoring: |
|
# ==================== SCORING ==================== |
|
|
|
def save_score(self): |
|
with open("scores.txt", "a") as f: |
|
f.write(f"{datetime.datetime.now()} - {self.points}\n") |
|
|
|
def read_score(self): |
|
table = [] |
|
with open("scores.txt") as f: |
|
rows = f.read().splitlines() |
|
for row in rows: |
|
table.append(row.split(" - ")) |
|
table.sort(key=lambda x: int(x[1]), reverse=True) |
|
return table |
|
|
|
def add_point(self, value): |
|
self.points += value |