-
Notifications
You must be signed in to change notification settings - Fork 8
/
gameResult.py
67 lines (55 loc) · 2.47 KB
/
gameResult.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
# Screaming Strike game results class
# Copyright (C) 2019 Yukio Nozawa <[email protected]>
# License: GPL V2.0 (See copying.txt for details)
"""This module contains GameResult class."""
class GameResult:
"""This class stores a gameplay's result. """
def __init__(self):
self.aborted = False
def initialize(self, field):
"""
Populates the game results from the given field instance.
:param field: Field instance from which the game results are loaded.
:type field: gameField.GameField
"""
self.score = field.player.score
self.score_validator = field.player.score_validator
self.hitPercentage = field.player.hitPercentage
self.hits = field.player.hits
self.punches = field.player.punches
self.level = field.level
self.mode = field.modeHandler.getName()
self.unlockedCollection = field.collectionCounter.getLog()
self.highscore = field.player.getNewHighscore()
self.previousHighscore = field.player.getPreviousHighscore()
self.modeSpecificResults = field.modeHandler.getModeSpecificResults()
self.modeSpecificResultsForScoreboard = field.modeHandler.getModeSpecificResultsForScoreboard()
self.log = field.getLog()
ms = field.gameTimer.elapsed
self.lastedMinute = int(ms / 60000)
self.lastedSecond = int((ms % 60000) / 1000)
m = _("minute") if self.lastedMinute == 1 else _("minutes")
s = _("second") if self.lastedSecond == 1 else _("seconds")
self.lastedString = _("%(min)d %(minunit)s and %(sec)d %(secunit)s") % {
"min": self.lastedMinute, "minunit": m, "sec": self.lastedSecond, "secunit": s}
# end initialize
def getaborted(self):
"""Retrieves if this game was ended by abort (ESC)."""
return self.aborted
# end aborted
def setaborted(self, abt):
"""Set the abort status of this result.
:param abt: aborted?
:type abt: bool
"""
self.aborted = abt
def validateScore(self):
"""Returns if the score is valid (not modified by memory hacking).
:rtype: bool
"""
return self.score == sum(self.score_validator)
def getModeSpecificResults(self):
return self.modeSpecificResults
def getModeSpecificResultsForScoreboard(self):
return self.modeSpecificResultsForScoreboard