A python questionaire game

It's a silly game I made a while back,  Totally rebuilt it.  The old version was when I tried Zed's book the first time and was completely on my own( back when it was a free download).  The orginal had no class's, a crap ton of 'if's'  and honestly... I'm not sure how it ran.  It did, I remember having my friends play it.

Next project setting up my webpage under nelliesdoodles.com!

My new Psychillogical.py game:

from sys import exit

class Psychillogical(object):

      def __init__(self, question):
          self.question = question
          self.responses = {}
          self.answers = []

      def respond(self, answer):
          result = self.responses.get(answer, None)
          print(result)
      def add_responses(self, responses):
          self.responses.update(responses)
      def set_answers(self, alist):
          self.answers = alist
      def show_question(self):
          print(self.question)
      def show_answers(self):
          for i in self.answers:
              print(i)




class Game(object):


    def __init__(self):
        self.anger = 0
        self.passive = 0
        self.chill = 0
        self.aggressive = 0
        self.batshit = 0
        self.uncooperative = 0
    # intro:
    def intro(self):
        print ("""
           Welcome to the completely unethical and unscientific psychological test.
           Explore your basic emotional skill set with these randomly unprofessional
           questions that have no real life application.
           """)
         # ask to begin:
        print(" If you would like to begin, please type y or yes. ")
        print(" Type quit, or exit to leave.")
        begin = input(">")
        if begin in ['y', 'yes']:
            self.run_questions()
        elif begin in ['Y', 'YES']:
            print("All-righty then, come along shouty pants.")
            self.run_questions()
        else:
            print("Goodbye.")
            exit(0)

    def run_questions(self):
        self.ask_questions('first')

    def ask_questions(self, which):

        x = questions.get_it(which)
        x.show_question()
        print("\n")
        x.show_answers()
        answer = input(" > a b c d (e-other)  ? ")
        if answer in ['quit', 'exit']:
            print("Doorknob. Later!")
            exit(0)
        else:
            print("\n")
            x.respond(answer)
            print("\n")
            if which in ['number1', 'number2', 'number3', 'number4']:
                self.scoring1(answer)
            else:
                self.scoring2(answer)
            #self.show_score()
            new = self.next_question(which)
            if new == None:
                print("\n\t Totally fake test complete! \n")
                self.show_score()
            else:
                print("\n\t next question: \n")
                self.ask_questions(new)




    def scoring1(self, answer):
        if answer == 'a':
            self.anger += 2
            self.aggressive += 1
        elif answer == 'b':
            self.passive += 2
            self.chill += 1
        elif answer == 'c':
            self.chill += 2
        elif answer == 'd':
            self.batshit += 0.25
            self.aggressive += 2
        elif answer == 'e':
            self.batshit += 2
            self.uncooperative += 1
        else:
            self.uncooperative += 2
            self.passive += 1

    def scoring2(self, answer):
        if answer == 'a':
            # impulsive
            self.aggressive += 1
            self.passive -= 1
        elif answer == 'b':
            #batshit
            self.batshit += 2
        elif answer == 'c':
            #angry
            self.anger += 2
        elif answer == 'd':
            #chill
            self.chill += 2
        elif answer == 'e':
            #balance
            self.passive += 1
            self.aggressive -= 1
        else:
            self.uncooperative += 2


    def show_score(self):
        print("You're scores after testing:")
        print(f" Hulk Smash = {self.aggressive + self.anger} ")
        print(f" Hang with scooby level = {self.chill + self.passive}")
        print(f" Refuse to take a stupid test = {self.uncooperative}")
        print(f" 51/50 level = {self.batshit} ")
        pos = (self.chill + self.passive)  // 2
        neg = (self.aggressive + self.anger) // 2
        balance = pos - neg
        print(f" (- 0 +) balance level = {balance}")
        print("\n\t Do it again?")
        choice = input(" y or quit >")
        if choice in ['y', 'yes', 'Y', 'YES']:
            self.anger = 0
            self.passive = 0
            self.chill = 0
            self.aggressive = 0
            self.batshit = 0
            self.uncooperative = 0
            self.ask_questions('first')
        else:
            print('verifing ssh key ......')
            print('updating FBI database......')
            exit(0)

    def next_question(self, current):
        if current == 'first':
            return 'number1'
        elif current == 'number1':
            return 'number2'
        elif current == 'number2':
            return 'number3'
        elif current == 'number3':
            return 'number4'
        elif current == 'number4':
            return 'number5'
        elif current == 'number5':
            return 'number6'
        elif current == 'number6':
            return 'number7'
        elif current == 'number7':
            return 'number8'
        elif current == 'number8':
            return 'number9'
        elif current == 'number9':
            return 'number10'
        elif current == 'number10':
            return 'number11'
        elif current == 'number11':
            return None
        else:
            return None





class Questionaire(object):
    question_list = [" 1. You have stepped on bee, and it died stinging you. ",
      "2. An elderly lady is in the way at the liquor store, and can't hear you asking her to move.",
      "3. A stranger's child has knocked over your morning coffee with his large bouncy ball.",
      "4. Someone is trying to dramatically tell you a story about thier trip to a zoo.",
      "5. A clicking noise is getting louder as you try to rest.",
      "6. Someone has defiled a church and placed thier landmark cross upside down.",
      "7. You have awakened in a field of cotton candy blossoms whose neon filimants light up the sky.",
      "8. The bicyclist in front of you refuses to get off the road and continues to ride in the middle of the lane as you honk.",
      "9. The narrator said what? ",
      "10. A woman has sneezed and blood splatters on the floor in front of you.",
      "11. A mysterious and dangerous looking individual is approaching you rapidly.",
      "12. Are you tired of questions? "]



    number1 = Psychillogical(question_list[0])
    number2 = Psychillogical(question_list[1])
    number3 = Psychillogical(question_list[2])
    number4 = Psychillogical(question_list[3])
    number5 = Psychillogical(question_list[4])
    number6 = Psychillogical(question_list[5])
    number7 = Psychillogical(question_list[6])
    number8 = Psychillogical(question_list[7])
    number9 = Psychillogical(question_list[8])
    number10 = Psychillogical(question_list[9])
    number11 = Psychillogical(question_list[10])
    number12 = Psychillogical(question_list[11])
    #  number 1  set up "Bee sting"
    # anger, passive, chill, aggressive, batshit, uncooperative Game.score1()

    onelist = ['a: Stomp on it!',
               'b: Flick it\'s corpse away.',
               'c: Just glad no ones allergic, and no one got hurt.',
               'd: Find the hive and kill them all!']
    number1.set_answers(onelist)


    number1.add_responses({'a': 'Yes, crunch crunch.',
                           'b': 'No one will notice.',
                           'c': 'The bee got hurt.',
                           'd': 'Let me just get my big notebook.'
                            })
    #  number 2  set up "getting beer"
    # Game.score1()

    twolist = ['a: Shout and push through to the Vodka.',
               'b: Walk around to a different isle but give her the finger.',
               'c: Get closer and ask if she needs help.',
               'd: Go tell the manager an old lady is having a stroke in the whisky isle.' ]
    number2.set_answers(twolist)
    number2.add_responses({'a': 'Vegetables are important.',
                           'b': 'You don\'t drink anyways right?',
                           'c': 'How sweet... psycho.',
                           'd': 'You can drink your beer outside and watch. I see. <going out for more paper>' })

    #  number 3  set up "the kid spilled my coffee"
    # Game.score1()

    threelist = ['a: Be very loud about how much coffee means to you.',
                 'b: Get a towel to clean the coffee, and flip off the kids parents.',
                 'c: Laugh it off and get some tea.',
                 'd: Take the ball and rip it apart with your bare hands.',
                 'e: Follow the parents home so you can send them hate mail later.']
    number3.set_answers(threelist)
    number3.add_responses({'a': 'Coffee is life.',
                           'b': 'I have a feeling that finger might get tired.',
                           'c': 'Tea sounds delicious.',
                           'd': 'That ball deserved what it got.',
                           'e': 'Traffic can be tricky.' })

    #  number 4  set up  "zoo story"
    # Game.score1()

    fourlist = ['a: Tell them you hate zoos and have somewhere to be.',
                'b: Stop them to tell them how long giraffe\'s necks are.',
                'c: Show interest and engage in the conversation.',
                'd: Rage about the captivity of endangered species and suggest breaking them free.',
                'e: Fantasize about being a part of an orangutan worshipping cult.']
    number4.set_answers(fourlist)
    number4.add_responses({'a': 'Zoo SHMOO. Right?',
                           'b': 'Yes, everyone needs to know what you know.',
                           'c': 'How very social. It\'s ok to answer honestly.',
                           'd': 'Too right! <slowly hiding the zoo contributions certificate>',
                           'e': 'They are amazing apes.'})

    #  number 5  set up  "clicking noise"
    # impulsive, batshit, angry, chill, balance Game.score2()

    fivelist = ['a: Wake up your partner for some nookie.',
                'b: Start making your own louder noise to scare the gremlin away.',
                'c: Go tear apart whatever is making the sound.',
                'd: Play some techno and meditate.',
                'e: Find the noise and try to fix it.']
    number5.set_answers(fivelist)
    number5.add_responses({'a': 'That, well there is that.',
                           'b': 'I didn\'t know they could be scared, tell me more.',
                           'c': 'With tools, or with your words?',
                           'd': 'What\'s in that tea?',
                           'e': 'And that\'s how the horror movie begins?'})
    #  number 6  set up  "religion"
    # impulsive, batshit, angry, chill, balance Game.score2()

    sixlist = ['a: Start a facebook post to find the person(s) involved.',
               'b: Go prepare for the apocolypse.',
               'c: Punch the first person who laughs about it',
               'd: Go have some Tea.',
               'e: Offer to help the church fix it.']
    number6.set_answers(sixlist)
    number6.add_responses({'a': 'To congratulate them, or turn them in?',
                           'b': 'Did you say you have a bomb shelter?',
                           'c': 'Sacred objects, yes, I see.',
                           'd': 'I\'d sure like to try that Tea.',
                           'e': 'How very charitable. <making notes>'})
    #  number 7 set up  "dream or not a dream "
    # impulsive, batshit, angry, chill, balance Game.score2()

    sevenlist = ['a: Go taste the cotton candy.',
                 'b: Enjoy it, it\'ll disappear soon.',
                 'c: Start looking for something to kick.',
                 'd: This is a dream, explore.',
                 'e: Establish what is reality and what is not.']
    number7.set_answers(sevenlist)
    number7.add_responses({'a': 'I guess it would be tempting.',
                           'b': 'So, this is normal for you?',
                           'c': 'Disorientation can be frightening.',
                           'd': 'Ever seen the movie, \'The Cell\'?',
                           'e': 'Does it need established at that point?'})
    #  number 8 set up  "share the road"
    # impulsive, batshit, angry, chill, balance Game.score2()

    eightlist = ['a: Honk and speed around the person.',
                 'b: Pull up next to them so you can memorize the face.',
                 'c: Honk and Yell and speed around them, then slam the brakes.',
                 'd: Put on some music and enjoy a slow ride.',
                 'e: Wait for a chance to safely pass.']
    number8.set_answers(eightlist)
    number8.add_responses({'a': 'Do you drive like that often?',
                           'b': 'Random citizen\'s faces a hobby collection?',
                           'c': 'Reaction time is important. <flip to a new sheet of paper>',
                           'd': 'What kind of bowl do you have for breakfast?',
                           'e': 'oh yeah, I\'d do that too.'})
    #  number 9 set up  "narrator"
    # impulsive, batshit, angry, chill, balance Game.score2()

    ninelist = ['a: Do something random to see if the narrator notices',
                'b: Get more supplies for the bomb shelter.',
                'c: Break stuff until it shuts up.',
                'd: Offer the narrator Tea.',
                'e: Investigate as to where the voice is comming from.']
    number9.set_answers(ninelist)
    number9.add_responses({'a': 'Are you flipping me off?',
                           'b': 'Spam is definitely under-rated.',
                           'c': 'Not the computer though, right?',
                           'd': 'Yes, please.',
                           'e': 'Interesting.'})
    #  number 10 set up  "germs and blood"
    # impulsive, batshit, angry, chill, balance Game.score2()

    tenlist = ['a: Run home and prepare a bath of luke warm bleach water.',
               'b: Kill her before she begins the mass extinction of mankind.',
               'c: Throw Pine-Sol at her, and tell her to cover her face if she\'s sick.',
               'd: Calmly exit and find some hand sanitizer and burritos.',
               'e: Ask her if she needs to be taken to a doctor.']
    number10.set_answers(tenlist)
    number10.add_responses({'a': 'Is that your natural hair color?',
                            'b': 'I see..........................',
                            'c': 'Love the smell of Pine-Sol in the morning.',
                            'd': 'Now I\'m hungry. Thanks.',
                            'e': 'You\'re right, Maybe 911.'})
    #  number 11 set up  "perception danger"
    # impulsive, batshit, angry, chill, balance Game.score2()

    elevenlist = ['a: Wink at them.',
                  'b: Approach them to tell them the benefits of floppy trout storage.',
                  'c: Put on your most intimidating face and get ready for a fight.',
                  'd: It has nothing to do with you, smile and move on.',
                  'e: Put your hand up, and firmly state, "What is the meaning of this?"']
    number11.set_answers(elevenlist)
    number11.add_responses({'a': 'Wink wink, nudge nudge.',
                            'b': 'Do tell me about this floppy trout storage.',
                            'c': 'Fisticuffs, too right chap.',
                            'd': 'What a wonderful place to be.',
                            'e': 'What if they just got stung by a bee?'})

    # number 12  final question
    twelvelist = ['a: YES! NO! Maybe!',
                  'b: I quite like questions.',
                  'c: Another God Damned question and I\'ll kick something!',
                  'd: Got any brownies?',
                  'e: Just looking for something to do.']
    number12.set_answers(twelvelist)
    number12.add_responses({'a': 'I don\'t have any more available yet.',
                            'b': 'Maybe I\'ll make some more.'
                            'c': 'We are done, let me gather the score.',
                            'd': 'Do you have brownies?',
                            'e': 'Me too.  Me too. '})
    lookup_next = {'first': number1, 'number1': number2, 'number2': number3,
    'number3': number4, 'number4': number5,
    'number5': number6, 'number6': number7, 'number7': number8,
    'number8': number9, 'number9': number10,
     'number10': number11, 'number11': number12}

    def get_it(self, number):
        return self.lookup_next.get(number)

#############  Initiate and run ###########
questions = Questionaire()
newtest = Game()
newtest.intro()

Comments

Popular posts from this blog

playing with color in powershell python

JavaScript Ascii animation with while loops and console.log

playing with trigonometry sin in pygame