mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Delete game statistics when deleting a game
This commit is contained in:
parent
148f189a74
commit
4a3d6e7383
3 changed files with 16 additions and 2 deletions
|
@ -72,6 +72,19 @@ class Statistics:
|
||||||
else:
|
else:
|
||||||
games[player] = [g for g in games[player] if g[0] != gameid]
|
games[player] = [g for g in games[player] if g[0] != gameid]
|
||||||
|
|
||||||
|
def deleteGameStats(self, gameid):
|
||||||
|
for player in self.games_stats:
|
||||||
|
try:
|
||||||
|
del self.games_stats[player][gameid]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
for player in self.prev_games:
|
||||||
|
self.prev_games[player] = \
|
||||||
|
[g for g in self.prev_games[player] if g[0] != gameid]
|
||||||
|
for player in self.session_games:
|
||||||
|
self.session_games[player] = \
|
||||||
|
[g for g in self.session_games[player] if g[0] != gameid]
|
||||||
|
|
||||||
def getStats(self, player, gameid):
|
def getStats(self, player, gameid):
|
||||||
# returned (won, lost)
|
# returned (won, lost)
|
||||||
return self.getFullStats(player, gameid)[:2]
|
return self.getFullStats(player, gameid)[:2]
|
||||||
|
|
|
@ -2190,7 +2190,7 @@ Error while saving game.
|
||||||
% self.game.gameinfo.name):
|
% self.game.gameinfo.name):
|
||||||
return
|
return
|
||||||
from pysollib.wizardutil import delete_game
|
from pysollib.wizardutil import delete_game
|
||||||
delete_game(self.game)
|
delete_game(self.app, self.game)
|
||||||
self.game.endGame()
|
self.game.endGame()
|
||||||
self.game.quitGame(2)
|
self.game.quitGame(2)
|
||||||
|
|
||||||
|
|
|
@ -471,8 +471,9 @@ registerCustomGame(MyCustomGame)
|
||||||
return gameid
|
return gameid
|
||||||
|
|
||||||
|
|
||||||
def delete_game(game):
|
def delete_game(app, game):
|
||||||
hideGame(game)
|
hideGame(game)
|
||||||
|
app.stats.deleteGameStats(game.id)
|
||||||
fn = game.MODULE_FILENAME
|
fn = game.MODULE_FILENAME
|
||||||
os.remove(fn)
|
os.remove(fn)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue