I2P – Programming Task (F) Adventure Game

Mind map/planning:

unnamed

Pseudo Code:

Drafts:


Final Product:


Final Code:

aGlobalVar = 0
def function_restart():
    global aGlobalVar
    vRestart = input(print("""Would you like to restart again? Yes (1), no (2)"""))
    if vRestart == "1":
        print(funct_game())
    if vRestart == "2":
        aGlobalVar = 1
def function_v3a12():
      v3a12 = input(print("""Do you fight (1) or flee(2)? """));
      if v3a12 == "1":
          print("""You both die trying to kill the wild boar. The End. """);
          print(function_restart())
      if v3a12 == "2":
          print("""You run away, but a herd of pigs corner you, separating you from Piggy. You get gored to death. The End. """)
          print(function_restart())
def function_v3a11():
      v3a11 = input(print("""Do you let Jack share leadership with you (1), or be a dictator (2)?"""))
      if v3a11 == "1":
          print("""You guys split the leadership and he and his choir helps the group hunt, while you and the others help create a signal fire to get rescued. Your leadership seems harmonious and works really well, living long enough to witness a plane see your signal fire and rescue you. You get rescued and return home safely. Congratulations, you’ve survived!""")
      if v3a11 == "2":
          print("""Jack gets jealous and rebels. He and his hunters become more and more uncivilised until they become savages and split from the group. Eventually, out of revenge, Jack and his choir come back and convince your crew that you are a misleading chief. Your group and Jack’s group both set out and rip you apart, until all your remains are washed out into the sea. The End.""");
          print(function_restart())
def function_v3a1():
      v3a1 = input(print("""Accept (1) or decline (2)? """))
      if v3a1 == "1":
          print("""You learn to blow the conch, and when you finally succeed in making a sound, the deep note resonates through the entire island. Over the course of one hour, boys ranging from 6 year olds to 19 year olds stream out of the forest, until eventually an entire choir of boys come out, with a redhead leading the way. All the boys want you to become their leader, but the redhead, Jack, seems to want to be leader too. """);
          print(function_v3a11())
      if v3a1 == "2":
          print("""You and Piggy decide to stay and create a fire, but a wild boar stumbles towards your source of light. """);
          print(function_v3a12())

def funct_game():
   vBeginning= input("You are stuck on a deserted island, "
                      "known to be filled with mysteries of both "
                      "the past and present. You wake up on the beach "
                      "of the island with a chill up your back, and a mysterious "
                      "feeling that you are being followed. You brush yourself off,"
                      " and look around the island. Your stomach is growling, but "
                      "you try to think clearly about your next options. You scratch "
                      "your options into the sand:"
                      "\n" " 1. Go to the faraway abandoned hut"
                      "\n" " 2. Go into the forest "
                      "\n" " 3. Search for people.")
   while vBeginning != "1" or "2" or "3" and aGlobalVar == 0:
       if vBeginning == "1":
           print (" After long contemplation, "
                  " seeing dark clouds hovering over "
                  "the island, bursting to rain, you decide to go "
                  "to the abandoned hut and seek shelter. You enter the "
                  "hut, and notice that it looks empty.")
           vhut= input ("Explore the house (1), or hide in one "
                    "of the rooms and seek refuge just for the night? (2) ")
           if vhut== "2":
               print ("You take refuge in the kitchen and hear a man walk down the "
                       "steps of the hut.")
               vhide= input("Do you greet the man(1), or do you continue to hide.(2)")
               if vhide == "2":
                   print ("You hide, and go to the backyard of his hut. But you walk into a pit of thorns, and bleed to death. You die. The End ")
                   print(function_restart())
                   break
               else:
                   print("The man greets you with a smile and hugs you- a weird embrace especially since you have never met him. However, during the embrace, you still don’t completely trust him, and feel his pocket. A gun shaped indent. ")
                   vgun=input ("Do you take the gun (1), or do you run for your life (2)")
                   if vgun ==("1"):
                       print ("When you take the gun you feel victorious. But as you look around, and see human heads hanging as prizes on the walls, you paralyse. "
                              "You look around, suddenly forgetting that you just stole a gun from a madman. As you look at the room, you realise that the entire room not only has bloody "
                              "human heads but also guns. Not just one gun, but many guns. Too many for your liking. But before you know it, the man shoot you five times. You die. The End.")
                       print(function_restart())
                   elif vgun == "2":
                       print (" You try to run, but realise this was all a dream. The hut had been latched close since you arrived. The man was watching you since you came on the island. "
                              "He chuckles softly, and whispers like the madman he is. Tears streaming down your face, you see him take a knife, and say something about adding you to his pretty collection. "
                              "You stare around the room, and realise all the monuments are dead humans. You have a panic attack, and he kills you when you have fainted. The end, you die.")
                       print(function_restart())
                       break
           else:
               print ("You start to explore the rooms of the house, "
                          "and notice a lot of guns hung up on the walls. "
                          "After exploring all the rooms, and notice that the "
                          "hut is empty, you finally start to relax. You sit in "
                          "one of the lounge chairs in the main part of the hut, "
                          "but the wind blares a chilly breath of air, and you shiver. "
                          "You walk over to the window, and try to close it, but you aren’t "
                          "tall enough. You reach on your tippy-toes and try to close the "
                          "latch. Whilst doing it, you fall out the window, into a pit of "
                          "thorns. The thorns dig deep into your skin, and you bleed to "
                          "death. You die. The End.")
               print(function_restart())
               break
           break
       if vBeginning == "2":
           print("""You get lost. You are scared, and darkness is falling. Suddenly, you fall into a pit with poisonous vipers. You die. The End.""")
           print(function_restart())
           break
       elif vBeginning == "3":
           print("""You pick up a conch shell on the beach. Suddenly, you hear someone calling for you. """)
           v3a = input("""Do you go towards the sound (1), or ignore the call (2)?""")
           while v3a != "1" or "2":
               if v3a == "1":
                   print("""You find a chubby boy with thick spectacles stuck in brambles. You help him out, and discover his name is Piggy. He sees that you have a conch shell, and asks if you know how to blow it. You don’t, and he offers to teach you. """)
                   print(function_v3a1())
                   break
               elif v3a == "2":
                   print("You try to live alone, but you cannot manage to suffice on your own. You eventually die from starvation. ")
                   print(function_restart())
                   break
           break
print (funct_game())

What worked:

– The ‘if’ loops worked well, and the ‘elif’s and ‘else’s worked.

– The idea of putting all the code into one function and then calling up other functions within the main function worked in the end.

What didn’t work:

– At first, the breaks didn’t work and the message that said ‘break outside loop’ kept popping up. This had to do with the issue of indentation and which loop it was stopping.

– Another issue that arose was defining the variables into integers, as the computer would not recognise the integer. We solved this issue by making the integers into strings

– When we added an additional effort of giving an option to restart when the user reached a dead end, we couldn’t figure out how to use functions and variables to do this. In the end, we asked Mr. Lin for help and he taught us how to use the aGlobalVar to define the function for restarting.

– The last issue that we got stuck on was indentation as when we copied and pasted from Google Docs, the indentations kept being messed up.

Who reviewed:

Weilyn, Mr. Lin.