1
0
Fork 0

improve next level branch check

This commit is contained in:
Lili (Tlapka) 2021-03-16 14:20:03 +01:00
parent a87d166ac0
commit e424d0d93d
1 changed files with 5 additions and 3 deletions

View File

@ -87,11 +87,13 @@ class Game:
def next_level_branch_check(self, input_text): def next_level_branch_check(self, input_text):
"""Check if `input_text` is really a branch of the next level. """Check if `input_text` is really a branch of the next level.
Accepts both full name "level4a" and just letter "a"""" Accepts both full name, partial name and just branch letter
ex. "level4a", "4a" and "a" are all fine."""
next_level = "level" + str(self.level + 1) if "level" + str(self.level + 1) + input_text in self.level_mapping[next_level]:
if next_level + input_text in self.level_mapping[next_level]:
return input_text return input_text
if "level" + input_text in self.level_mapping[next_level]:
return input_text[1:]
if input_text in self.level_mapping[next_level]: if input_text in self.level_mapping[next_level]:
return input_text[6:] return input_text[6:]
raise NoLevelFoundError("No branch called {} found.".format(input_text)) raise NoLevelFoundError("No branch called {} found.".format(input_text))