New scoreboard feature added. Partially implimented.
This commit is contained in:
parent
f2326c628c
commit
7ef11be54c
@ -36,13 +36,48 @@ globalConfig = configparser.ConfigParser()
|
||||
class scoreboard():
|
||||
'Handles scores and top 10'
|
||||
|
||||
def __init__(self):
|
||||
self.oldScores = []
|
||||
for i in range(9):
|
||||
def __init__(self, startingScore = 0):
|
||||
try:
|
||||
self.oldScores[i] = read_config("scoreboard", i)
|
||||
localConfig.add_section("scoreboard")
|
||||
except:
|
||||
self.oldScores[i] = 0
|
||||
pass
|
||||
self.score = startingScore
|
||||
self.oldScores = []
|
||||
for i in range(1, 11):
|
||||
try:
|
||||
self.oldScores.insert(i - 1, read_config("scoreboard", i))
|
||||
except:
|
||||
pass
|
||||
#self.oldScores.insert(i - 1, 0)
|
||||
for i in range(1, 11):
|
||||
if self.oldScores[i - 1] == None:
|
||||
self.oldScores[i - 1] = 0
|
||||
|
||||
def __del__(self):
|
||||
self.Update_Scores()
|
||||
|
||||
def Decrease_Score(self, points = 1):
|
||||
self.score -= points
|
||||
|
||||
def Get_High_Score(self, position = 1):
|
||||
return self.oldScores[position - 1]
|
||||
|
||||
def Get_Score(self):
|
||||
return self.score
|
||||
|
||||
def Increase_Score(self, points = 1):
|
||||
self.score += points
|
||||
|
||||
def Update_Scores(self):
|
||||
newScores = self.oldScores.copy()
|
||||
for i in newScores:
|
||||
if self.score > newScores[newScores.index(i)]:
|
||||
self.oldScores[newScores.index(newScores[i])] = i
|
||||
localConfig.set("scoreboard", str(newScores.index(newScores[i])), str(i))
|
||||
try:
|
||||
write_config()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def write_config(writeGlobal = False):
|
||||
@ -55,11 +90,17 @@ def write_config(writeGlobal = False):
|
||||
|
||||
def read_config(section, value, readGlobal = False):
|
||||
if readGlobal == False:
|
||||
try:
|
||||
with open(gamePath + "config.ini", 'r') as configfile:
|
||||
return localConfig.read(section, value)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
with open(globalPath + "config.ini", 'r') as configfile:
|
||||
return globalConfig.read(section, value)
|
||||
except:
|
||||
pass
|
||||
|
||||
def speak(text, interupt = True):
|
||||
if speechProvider == "speechd":
|
||||
|
Loading…
Reference in New Issue
Block a user