22 lines
594 B
Python
22 lines
594 B
Python
|
|
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[:3]
|
|
|
|
def add_point(self, value):
|
|
self.points += value |