add start time, total time elapsed
This commit is contained in:
parent
c73679bff3
commit
d1e54caf1b
|
@ -45,6 +45,7 @@ class Game:
|
||||||
self.load_times = []
|
self.load_times = []
|
||||||
self.solving_times = []
|
self.solving_times = []
|
||||||
self.level_log = []
|
self.level_log = []
|
||||||
|
self.game_start_time = 0
|
||||||
self.level_start_time = 0
|
self.level_start_time = 0
|
||||||
self.level = level_number
|
self.level = level_number
|
||||||
self.branch = ''
|
self.branch = ''
|
||||||
|
@ -68,6 +69,7 @@ class Game:
|
||||||
load_time = int(end_time - start_time)
|
load_time = int(end_time - start_time)
|
||||||
self.load_times.append(load_time)
|
self.load_times.append(load_time)
|
||||||
self.level_start_time = time.time()
|
self.level_start_time = time.time()
|
||||||
|
self.game_start_time = time.time()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def next_level_exists(self):
|
def next_level_exists(self):
|
||||||
|
@ -86,10 +88,10 @@ class Game:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def next_level_branch_check(self, input_text):
|
def next_level_branch_check(self, input_text):
|
||||||
"""Check if `input_text` corresponds to a branch of next level, return next level branch name.
|
"""Check if `input_text` is a branch of next level, return next level branch name.
|
||||||
|
|
||||||
`input_text` can be a full level name, partial level name or just
|
`input_text` can be a full level name, partial level name or just
|
||||||
a branch letter ex. "level4a", "4a" and "a" are all fine."""
|
a branch letter. Ex. "level4a", "4a" and "a" are all fine."""
|
||||||
next_level = "level" + str(self.level + 1)
|
next_level = "level" + str(self.level + 1)
|
||||||
if "level" + str(self.level + 1) + input_text in self.level_mapping[next_level]:
|
if "level" + str(self.level + 1) + input_text in self.level_mapping[next_level]:
|
||||||
return input_text
|
return input_text
|
||||||
|
@ -178,6 +180,8 @@ class Game:
|
||||||
print("Game is not in progress.")
|
print("Game is not in progress.")
|
||||||
else:
|
else:
|
||||||
print("Game in progress. Level:{} Branch:{}".format(self.level, self.branch))
|
print("Game in progress. Level:{} Branch:{}".format(self.level, self.branch))
|
||||||
|
print("Total time elapsed: ", end="")
|
||||||
|
self.print_time(int(time.time() - self.game_start_time), True)
|
||||||
if self.level_log:
|
if self.level_log:
|
||||||
print("Levels traversed so far:")
|
print("Levels traversed so far:")
|
||||||
for level in self.level_log:
|
for level in self.level_log:
|
||||||
|
|
Reference in New Issue