Alright, I'm using the Blessed library to support keyboard input and colors. The game is menu-driven, meaning it's sort-of like a visual novel, but like not one. This is what a segment would look like:
def intro():
state = "start"
#===========
clear()
echo(indent("Aurora Police Department"), delay=ms(30), color="gold1")
sleep(.7)
echo(indent("COTTONWOOD, COLORADO"), delay=ms(30), color="gray30")
wait()
while True: #MAIN GAME LOOP
if state == "start":
################ VERY BEGINNING #########################
state = cmenu(
title = "You are seated at your desk, sipping coffee. It is a monday.",
choices = {
"start_check_computer":"Check computer",
"start_check_papers":"Check papers"
}
)
#########################################################
for i in [1]: #SEGMENT 1
if state == "start_check_computer":
clear()
echo(indent("You check your e-mails."))
wait()
clear
dialogue(
person = "Deputy M. Sherman, CO Police Dept.",
message = "To Chief {name},\n".format(name = player.name) + indent(
"We got a call earlier this morning. Emily Garcia, and her\n") + indent(
"husband Tom were found dead. I think you should take a\n") + indent(
"look at the footage yourself.")
)
clear()
state = cmenu(
title = "There was a video file attached. Play it?",
choices = {
"start_play_footage_of_attack_garcia":"Yes",
"start":"No"
}
)
clear() #Chief checks PC, email
if state == "start_check_papers":
#start_check_papers
clear()
echo(indent(""))
break
break
I'm using the for i in [1] to be able to collapse certain segments in my IDE. Anyway, I'm happy with this setup, since I can use my collapsed for-loop method to organize the if statements, but mccabe would be yelling at me because I would have too many if statements. My question is, is there an alternative, that would keep the "cyclomatic complexity" at a low?
Aucun commentaire:
Enregistrer un commentaire