get_ending to not be numerically based, but instead enum-based. (#219)

Co-authored-by: san7890 <the@san7890.com>
Reviewed-on: Cavemanon/SnootGame#219
Co-authored-by: san7890 <san7890@noreply.git.cavemanon.xyz>
Co-committed-by: san7890 <san7890@noreply.git.cavemanon.xyz>
This commit is contained in:
2023-05-07 00:44:59 +00:00
committed by Michael Yick
parent 66b289146f
commit ef4764b322
4 changed files with 96 additions and 83 deletions

View File

@ -1,5 +1,15 @@
## Utility functions for game setup, debugging etc.
init python:
from enum import Enum
# Create compile-time macros to more easily track what ending goes to what without the need for magic numbers or strings that can be mistyped
class Endings(Enum):
Shooter = 0
Doomer = 1
Tradwife = 2
Golden = 3
label initstats(anon=0, fang=0, trad=False):
# Sets various game-related global variables
# :param int anon: Anon's score
@ -14,10 +24,10 @@ label get_ending:
# To check what ending we're getting, call this label and then check the value of _return
# Sensible to have this logic defined in only one place for consistency
if anonscore >= 4 and fangscore >= 4 and wingStory:
return(4) # Golden
return(Endings.Golden)
elif anonscore >= 3 and fangscore <=4:
return(3) # Tradwife
return(Endings.Tradwife)
elif anonscore <= 3 and fangscore >=3:
return(2) # Doomer
return(Endings.Doomer)
else:
return(1) # Shooter
return(Endings.Shooter)