In [3]:
lives = '0'
while lives not in str(range(1,11)):
    lives = str(raw_input("""
    On a scale from one to ten,\n
    how terrible would you like this game to be?
    \n (10 being really terrible) > """))

In [6]:
import os.path
import sys
import random
from time import sleep

class NewUsr(object):
    
    def __init__(self, name, age, lives):
        self.name = name
        self.age = age
        self.lives = range(1,int(lives))

    def UsrData(self, datafile):
        self.usrdata = datafile
        pass

class AIDict(object):
   def importData(self, filename1, filename2):
       usrtxt = open(filename1)
       usrtxt = usrtxt.read()
       self.usrKeywords = usrtxt.split('\n')
       del(self.usrKeywords[-1])
       aitxt= open(filename2)
       aitxt = aitxt.read()
       self.aiResponse = aitxt.split('\n')
       del(self.aiResponse[-1])

class Scene(object):
    def __init__(self, storytxt, usrtxt, failtxt):
        self.storytxt = storytxt
        self.usrtxt = usrtxt
        self.failtxt = failtxt
    
    def printline(self, textfile, x):
        txt = open(textfile)
        txt = txt.read()
        txt = txt.split('-')
        self.txt = txt
        return self.txt[x]

    def randline(self, textfile):
        lines = open(textfile)
        lines = lines.read()
        lines = lines.split('-')
        line = lines[random.randint(0,len(lines))]
        return line

    def printslow(self, textfile, x, y):
        txt = open(textfile)
        txt = txt.read()
        txt = txt.split('-')
        self.txt = txt
        i = x
        for line in self.txt[x:y]:
            if self.txt[i] != None:
                print self.txt[i]
                i += 1
                sleep(4)
        pass

def ExeScene(scenename):
    scenename.printslow(scenename.storytxt, 0,5)
    usrinput = raw_input('what do you do? > ').lower()
    usrinput = usrinput.split(' ')
    keywords = False
    for word in usrinput:
        for i in range(0,len(usrAction)):
            #print 'in the loop for the %r time' % i
            if word in usrAction[i]:
                keywords = True
                #print 'usrinput in usrAction[%r] True' % i     
                print aiLines[i][random.randint(0,(len(aiLines[i])-1))]
                #print 'broke out of inner loop'
                sleep(3)
                print BUZZER
        if keywords == False:
            print scenename.printline(scenename.storytxt, -1)
            sleep(2)
            print scenename.randline(scenename.usrtxt)
            sleep(2)
            scenename.printslow(scenename.failtxt, 0, -1)

#lives = [1,2,3]
#usr = NewUsr('Laura Kraft', 30)

runAway = AIDict()
runAway.importData('usrRun.txt','aiRunresponse.txt')
attack = AIDict()
attack.importData('usrAttack.txt', 'aiAttackresponse.txt')
love = AIDict()
love.importData('usrLove.txt', 'aiLoveResponse.txt')

usrAction = [attack.usrKeywords, runAway.usrKeywords, love.usrKeywords]
aiLines = [attack.aiResponse, runAway.aiResponse, love.aiResponse]

start = Scene('mainentry.txt','','')
date = Scene('dateEntry.txt', 'quotes.txt','datefail.txt')
job = Scene('','','')
fridge = Scene('','','')

BUZZER = '\n\n*******bbbbzzzzzzzzzz*******\n\n'

def gameloop(usr, lives):
    for spawn in lives:
        print BUZZER
        start.printslow(start.storytxt,0,-1)
        choice1 = ''
        while choice1 not in ['1', '2', '3']:
            choice1 = str(raw_input("Pick a number 1 to 3\n> "))
        if choice1 == '1':
            ExeScene(date)
        elif choice1 == '2':
            ExeScene(job)
        else:
            ExeScene(fridge)

    print """
    You soar into a seething maelstrom of particles...
    hit a wall of fire...
    your legs get stretched out like a mile of spaggetti...
    your shoulders crush your chest as they are forced inwards...
    and you are burned to a crisp in an instant.
    Ouch.
    """

In [8]:
ExeScene(date)


Yes! You'd been trying to make inroads with Nikola all semester,
and then they asked you to study for this exam together!


And that hair...


You groaned a little bit on the inside just thinking of Nikola's
wavy perfect hair.


You wouldn't mind being trapped in a wormhole with them.
This study date was the perfect auspices
under which you could lay down some serious moves.


Nikola, of course, looked perfect. Something about the wind
and the sun hitting them made them look to glow like an angel.
Nikola smiles at you and asks, "How are you?"

what do you do? > poop on their face
You try to move but you feel as though you are tied down.


*******bbbbzzzzzzzzzz*******



In [3]:
usrAction


Out[3]:
[['aggression',
  'attack',
  'barrage',
  'charge',
  'incursion',
  'intervention',
  'intrusion',
  'invade',
  'poop',
  'punch',
  'kill',
  'offensive',
  'onslaught',
  'outbreak',
  'raid',
  'skirmish',
  'strike',
  'violate',
  'advance',
  'assail',
  'blitz',
  'blitzkrieg',
  'defile',
  'drive',
  'encounter',
  'encroach',
  'foray',
  'initiative',
  'inroad',
  'irruption',
  'mugging',
  'offense',
  'onrush',
  'pushrush',
  'storm',
  'thrust',
  'volley',
  'assail',
  'dirtydeed',
  'gouge'],
 ['run',
  'escape',
  'out',
  'exit',
  'sneak',
  'hide',
  'slink',
  'bury ',
  'camouflage ',
  'cover ',
  'disguise ',
  'hole up ',
  'mask ',
  'obscure ',
  'plant ',
  'protect ',
  'shelter ',
  'shield ',
  'smuggle ',
  'stash  ',
  'suppress ',
  'tuck away ',
  'withhold ',
  'adumbrate ',
  'cache ',
  'cloak ',
  'curtain ',
  'dissemble ',
  'ditch ',
  'duck ',
  'eclipse ',
  'ensconce ',
  'harbor  ',
  'reserve ',
  'screen ',
  'secrete ',
  'shadow ',
  'shroud ',
  'squirrel ',
  'stifle ',
  'veil ',
  'blot out ',
  'go into hiding ',
  'go underground ',
  'hold back ',
  'hush up  ',
  'keep from ',
  'keep secret ',
  'lie low ',
  'lock up ',
  'not give away ',
  'not tell ',
  'put out of the way ',
  'salt away ',
  'stow away ',
  'take cover  ',
  '',
  ''],
 ['love',
  'kiss',
  'hug',
  'squeeze',
  'bone',
  'caress',
  'fondle',
  'stroke',
  'canoodle',
  'snuggle',
  'shnuggle',
  'cuddle',
  'kiss',
  'lick',
  'smooch',
  'date',
  'hump',
  'seduce',
  'flirt',
  'pet',
  'rub',
  'care',
  'i like you',
  'i want you',
  'give me a kiss',
  '']]

In [5]:
usrAction


Out[5]:
[['aggression',
  'attack',
  'barrage',
  'charge',
  'incursion',
  'intervention',
  'intrusion',
  'invade',
  'poop',
  'punch',
  'kill',
  'offensive',
  'onslaught',
  'outbreak',
  'raid',
  'skirmish',
  'strike',
  'violate',
  'advance',
  'assail',
  'blitz',
  'blitzkrieg',
  'defile',
  'drive',
  'encounter',
  'encroach',
  'foray',
  'initiative',
  'inroad',
  'irruption',
  'mugging',
  'offense',
  'onrush',
  'pushrush',
  'storm',
  'thrust',
  'volley',
  'assail',
  'dirtydeed',
  'gouge'],
 ['run',
  'escape',
  'out',
  'exit',
  'sneak',
  'hide',
  'slink',
  'bury ',
  'camouflage ',
  'cover ',
  'disguise ',
  'hole up ',
  'mask ',
  'obscure ',
  'plant ',
  'protect ',
  'shelter ',
  'shield ',
  'smuggle ',
  'stash  ',
  'suppress ',
  'tuck away ',
  'withhold ',
  'adumbrate ',
  'cache ',
  'cloak ',
  'curtain ',
  'dissemble ',
  'ditch ',
  'duck ',
  'eclipse ',
  'ensconce ',
  'harbor  ',
  'reserve ',
  'screen ',
  'secrete ',
  'shadow ',
  'shroud ',
  'squirrel ',
  'stifle ',
  'veil ',
  'blot out ',
  'go into hiding ',
  'go underground ',
  'hold back ',
  'hush up  ',
  'keep from ',
  'keep secret ',
  'lie low ',
  'lock up ',
  'not give away ',
  'not tell ',
  'put out of the way ',
  'salt away ',
  'stow away ',
  'take cover  ',
  '',
  ''],
 ['love',
  'kiss',
  'hug',
  'squeeze',
  'bone',
  'caress',
  'fondle',
  'stroke',
  'canoodle',
  'snuggle',
  'shnuggle',
  'cuddle',
  'kiss',
  'lick',
  'smooch',
  'date',
  'hump',
  'seduce',
  'flirt',
  'pet',
  'rub',
  'care',
  'i like you',
  'i want you',
  'give me a kiss',
  '']]

In [22]:
print aiLines[0][(len(aiLines[0])-2)]


You try to move but you feel as though you are tied down.

In [ ]: