8 Replies - 339 Views - Last Post: 21 October 2013 - 03:26 PM Rate Topic: -----

#1 blakeperkins  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 21-October 13

I have an issue refraining to the beginning of my code (just for fun)

Posted 21 October 2013 - 12:55 PM

print ('You enter a dark room with two doors. Do you want to enter door #1 or door #2?')
door = input('> ')

if door == "1":
    print ('There/s a wizard guarding a statue made solidly of gold')
    print ('what do you want to do?')
    print ('#1 close the door and go back the the room')
    print ('#2 attack the wizard')
    print ('#3 make a run for the statue')
    print ('#4 sneak past the wizard')


    wizard = input('>')

   [ if wizard == "1":}

#how do i start the game over?
        

    
    if wizard == "2":
        print ('the wizard unsheathes his wand and casts a fire spell on you, death comes instantly')
        print ('YOU LOSE')
        exit()
    
    

    elif wizard == "3":
        print ('you grab the statue, but the wizard sees you!')
        print ('what do you want to do?')
        print ('#1 try to kill the wizard')
        print ('#2 jump out the window')
        print ('#3 hide')
        
    

    elif wizard == "4":
        print ('you sneak past the wizard unnoticed')
        print ('what do you want to do?')
        print ('#1 grab the statue while the wizard/s back is turned')
        print ('#2 try to kill the wizard')
        print ('#3 jump out the window')

    sneak = input('>')

    if sneak == "1":
        print ('you grab the statue, but the wizard sees you')
        print ('what do you want to do?')
        print ('#1 try to kill the wizard')
        print ('#2 jump out the window')
        print ('#3 throw the statue at the wizard')

    elif sneak == "2":
        print ('the wizard unsheathes his wand and casts a fire spell on you, death comes instantly')
        print ('YOU LOSE')
        exit()

    elif sneak == "3":
        print ('the wizard easily finds you and kills you')
        print ('YOU LOSE')
        exit()
               
    tim = input('>')

    if tim == "1":
        print ('the wizard unsheathes his wand and casts a fire spell on you, death comes instantly')
        print ('YOU LOSE')
        exit()
    
    

    elif tim == "2":
        print ('you fall out of the castle to your doom')
        print ('YOU LOSE')
        exit()
        

    elif tim == "3":
        print ('the wizard is knocked unconscious!')
        print ('you pick up the statue and run through a nearby corridor')
        print ('a guardsman stands in front of you and screams, "STOP TRESPASSER"')
        print ('what do you want to do?')
        print ('#1 barrel through the guard')
        print ('#2 try to fight the guard')
        print ('#3 run around the guard')

    win = input('>')

    if win == "1":
        print ('the guard knocks you to the ground and sends you to the dungeon')
        print ('YOU LOSE')
        exit()

    if win == "2":
        print ('the guard reveals his gladius and decapitates you')
        print ('YOU LOSE')
        exit()

    if win == "3":
        print ('the guardsman lunges at you but misses, you then trip him and kill him with his own sword')
        print ('slowly you sneak your way through the corridor and make your way out of the castle')
        print ('YOU WIN')
        exit()

This post has been edited by modi123_1: 21 October 2013 - 12:57 PM
Reason for edit:: please use the code tags


Is This A Good Question/Topic? 0
  • +

Replies To: I have an issue refraining to the beginning of my code (just for fun)

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9572
  • View blog
  • Posts: 36,244
  • Joined: 12-June 08

Re: I have an issue refraining to the beginning of my code (just for fun)

Posted 21 October 2013 - 12:57 PM

Is there a question?
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,659
  • Joined: 23-August 08

Re: I have an issue refraining to the beginning of my code (just for fun)

Posted 21 October 2013 - 01:05 PM

I think it's this:

Quote

#how do i start the game over?



The answer is the same as pretty much any time you want to do something repetitive: a loop.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9572
  • View blog
  • Posts: 36,244
  • Joined: 12-June 08

Re: I have an issue refraining to the beginning of my code (just for fun)

Posted 21 October 2013 - 01:06 PM

Ha.. I guess with a dearth of comments I should have paid attention to the only one.
Was This Post Helpful? 0
  • +
  • -

#5 blakeperkins  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 21-October 13

Re: I have an issue refraining to the beginning of my code (just for fun)

Posted 21 October 2013 - 01:15 PM

First of all I'd like to say thank you for the immediate response. Secondly, I'm extremely new to python (you could relate my experience with python to a baby that is still in the womb) and I'm not sure what I would say that would restart the loop. (does that clear up any uncertainties)
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3808
  • View blog
  • Posts: 13,508
  • Joined: 12-December 12

Re: I have an issue refraining to the beginning of my code (just for fun)

Posted 21 October 2013 - 01:20 PM

The wizard seems to hold all the cards. I think I'd pull his hat over his eyes and jump out the window :sorcerer:
Was This Post Helpful? 1
  • +
  • -

#7 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 8001
  • View blog
  • Posts: 13,707
  • Joined: 19-March 11

Re: I have an issue refraining to the beginning of my code (just for fun)

Posted 21 October 2013 - 01:28 PM

To create a loop, you might do something like

play_again = True   # so we play the first time
while (play_again):
  play_again, game_results = play_game()  # from your main game loop, you can return a tuple to tell you 
                                          # how they did, and whether they want to play again


Was This Post Helpful? 0
  • +
  • -

#8 blakeperkins  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 21-October 13

Re: I have an issue refraining to the beginning of my code (just for fun)

Posted 21 October 2013 - 03:19 PM

HAHA I still have no idea what I'm doing:)
Was This Post Helpful? 0
  • +
  • -

#9 blakeperkins  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 21-October 13

Re: I have an issue refraining to the beginning of my code (just for fun)

Posted 21 October 2013 - 03:26 PM

Could someone possibly give me an example of what jon.kiparsky is saying?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1