Example #1
0
    def test(self):
        conn = sqlite3.connect('DunSuciRun.sqlite')
        c = conn.cursor()
        d = conn.cursor()
        a = conn.cursor()
        print("Run test")

        d.execute("SELECT * FROM DUNGEONS")
        c.execute("SELECT * FROM BIGSCARIES")
        a.execute("SELECT * FROM CHARACTERS")

        dungeons = d.fetchall()
        bosses = c.fetchall()
        characters = a.fetchall()

        # Make bosses
        for boss in bosses:
            print(boss)
            b = Boss(boss[0], boss[1], boss[2])
            b.talk()

        for dungeon in dungeons:
            print(dungeon)
            d = Dungeon(dungeon[0], dungeon[1], dungeon[2])
            d.sign()

        for character in characters:
            print(character)
            a = Character(character[0], character[1], character[2])
            a.announce()
        conn.close()
Example #2
0
    def dungeon_pick(self, name):

            try:
                self.twtr_manager.printTweet("What level of dungeon would you like? (Easy, Medium or Hard)")
                level = self.twtr_manager.homeTimeline()
                level = level.lower()
                #Changed to text.
                if "easy" in level: #keeps getting stuck in try/catch error
                    self.twtr_manager.printTweet("You selected: Easy")
                    level = 1
                elif "medium" in level:
                    self.twtr_manager.printTweet("You selected: Medium")
                    level = 2
                elif "hard" in level:
                    self.twtr_manager.printTweet("You selected: Hard")
                    level = 3
                else:
                    self.twtr_manager.printTweet('Level not recognized. Please choose Easy, Medium or Hard.')
                    self.dungeon_pick(name)


                if 1 <= level <= 3:
                    conn = sqlite3.connect('DunSuciRun.sqlite')
                    c = conn.cursor()
                    m = conn.cursor()
                    n = conn.cursor()
                    p = conn.cursor()
                    c.execute('SELECT * FROM DUNGEONS WHERE DIFFICULTY =' + str(level))
                    dungeons = c.fetchall()
                    p.execute('SELECT * FROM PLAYERS')
                    getDate = p.fetchall()
                    useName = getDate[0][0]
                    gold = getDate[4][0] #I could have this backwards

                    randomNum= random.randint(0, len(dungeons)-1)
                    newTuple = dungeons[randomNum]
                    dun = Dungeon(newTuple[0],newTuple[1],newTuple[2]) #
                    dun.sign()
                    m.execute('SELECT * FROM BIGSCARIES WHERE THEME =?',(dun.theme,))
                    monsters = m.fetchall()
                    randoMon = random.randint(0, len(monsters)-1)
                    monsterTuple = monsters[randoMon]
                    mob = Boss(monsterTuple[0], monsterTuple[1], int(monsterTuple[2]))
                    horde = random.randint(0,(level*dun.difficulty))
                    #Updates character date with new health and treasure
                    n.execute('UPDATE CHARACTERS SET HEALTH = ?, GOLD = ? WHERE NAME = ?',(str((name.health - (mob.damage*dun.difficulty))), horde, useName))
                    conn.commit()
                    conn.close()

                    self.twtr_manager.printTweet("You slay a " + mob.name + " and collect " + str(horde) + " gold! " "It hurt you for " + str((mob.damage*dun.difficulty)) + " damage.")
                else:
                    self.twtr_manager.printTweet('Level not recognized. Please choose 1, 2, or 3.')
                    self.dungeon_pick(name)

            except StandardError as e:
                self.twtr_manager.printTweet('Level not recognized. Please choose Easy, Medium or Hard.')
                # self.menu_manager.write('Level not recognized. Please choose Easy, Medium or Hard.')
                self.dungeon_pick(name)
Example #3
0
    def dungeon_pick(self, name):

            try:
                self.menu_manager.title(name.name)
                # level = raw_input("What level of dungeon would you like? (Easy, Medium or Hard)\n").lower()
                self.twtr_manager.printTweet("What level of dungeon would you like? (Easy, Medium or Hard)")
                level = self.twtr_manager.homeTimeline()
                level = level.lower()
                print "You selected: " + level
                self.printTweet("You selected: " + level)
                if "easy" in level:
                    level = 1
                elif "medium" in level:
                    level = 2
                elif "hard" in level:
                    level = 3
                else:
                    # self.menu_manager.write('Level not recognized. Please choose Easy, Medium or Hard.')
                    self.printTweet('Level not recognized. Please choose Easy, Medium or Hard.')
                    self.dungeon_pick(name)


                if 1 <= level <= 3:
                    conn = sqlite3.connect('DunSuciRun.sqlite')
                    c = conn.cursor()
                    m = conn.cursor()
                    n = conn.cursor()
                    p = conn.cursor()
                    c.execute('SELECT * FROM DUNGEONS WHERE DIFFICULTY =' + str(level))
                    dungeons = c.fetchall()
                    p.execute('SELECT * FROM PLAYERS')
                    useName = p.fetchall()
                    useName = useName[0][0]

                    randomNum= random.randint(0, len(dungeons)-1)
                    newTuple = dungeons[randomNum]
                    dun = Dungeon(newTuple[0],newTuple[1],newTuple[2]) #
                    dun.sign()
                    m.execute('SELECT * FROM BIGSCARIES WHERE THEME =?',(dun.theme,))
                    monsters = m.fetchall()
                    # print (monsters)
                    randoMon = random.randint(0, len(monsters)-1)
                    monsterTuple = monsters[randoMon]
                    mob = Boss(monsterTuple[0], monsterTuple[1], int(monsterTuple[2]))
                    horde = random.randint(0,(level*dun.difficulty))

                    # n.execute('UPDATE CHARACTERS SET HEALTH = ' + str((name.health - (mob.damage*dun.difficulty)))+ ', GOLD = ' + str(horde)+ ' WHERE NAME ="' + name.name + '"')
                    n.execute('UPDATE CHARACTERS SET HEALTH = ?, GOLD = ? WHERE NAME = ?',(str((name.health - (mob.damage*dun.difficulty))), horde, useName))
                    conn.commit()
                    conn.close()
                    # self.menu_manager.write("You slay a " + mob.name + " and collect " + str(horde) + " gold! " "It hurt you for " + str((mob.damage*dun.difficulty)) + " damage.")
                    self.twtr_manager.printTweet("You slay a " + mob.name + " and collect " + str(horde) + " gold! " "It hurt you for " + str((mob.damage*dun.difficulty)) + " damage.")
                else:
                    # self.menu_manager.write('Level not recognized. Please choose 1, 2, or 3.')
                    self.twtr_manager.printTweet('Level not recognized. Please choose 1, 2, or 3.')
                    self.dungeon_pick(name)

            except:
                self.twtr_manager.printTweet('Level not recognized. Please choose Easy, Medium or Hard.')
                # self.menu_manager.write('Level not recognized. Please choose Easy, Medium or Hard.')
                self.dungeon_pick(name)