Ejemplo n.º 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 = monDAO(boss[0], boss[1], boss[2])
            b.talk()

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

        for character in characters:
            print(character)
            a = CharDAO(character[0], character[1], character[2])
            a.announce()
        conn.close()
Ejemplo n.º 2
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 = monDAO(boss[0], boss[1], boss[2])
            b.talk()

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

        for character in characters:
            print(character)
            a = CharDAO(character[0], character[1], character[2])
            a.announce()
        conn.close()
Ejemplo n.º 3
0
    def ruins_monster(self, userName):
        conn = sqlite3.connect('DunSuciRun.sqlite')
        d = conn.cursor()
        c = conn.cursor()
        d.execute('SELECT * FROM BIGSCARIES')
        c.execute('SELECT * FROM CHARACTERS WHERE PLAYER = ?', (userName,))
        monsters = d.fetchall()
        character = c.fetchall()

        dmg = random.randint(1,8)
        randoMon = random.randint(0, len(monsters)-1)
        monsterTuple = monsters[randoMon]
        mob = monDAO(monsterTuple[0], monsterTuple[1], int(monsterTuple[2]))
        try:
            if len(character) == 0:
                text = "You must enter the realm first. Go! Begin your stuggle!"
                # self.twt_print.printTweet(userName,text)
            else:
                charTuple = character[0]
                cha = CharDAO(charTuple[0], charTuple[1],charTuple[2],charTuple[3],charTuple[4], charTuple[5], charTuple[6],
                                              charTuple[7], charTuple[8], charTuple[9], charTuple[10], charTuple[11], charTuple[12], charTuple[13])

                text =  cha.name.split(' ')[0] + " searches the forgotten ruins for ancient texts but finds a " + mob.name+ ". The battle was quick but " + \
                        cha.name.split(' ')[0]+ " took " + str(dmg) + " wound"

            c.execute("UPDATE CHARACTERS SET HEALTH = ? WHERE PLAYER = ?",(str(cha.health-dmg),userName))
            conn.commit()
            conn.close()
            self.twt_print.printTweet(userName,text)
        except Exception as e:
            print('Try/catch error occured: ' + e)
Ejemplo n.º 4
0
    def the_road_monster(self, userName):
        # player|name|job|health|gold|runs|org|weapon|map|RARM|LARM|RLEG|LLEG|HEAD
        conn = sqlite3.connect('DunSuciRun.sqlite')
        d = conn.cursor()
        c = conn.cursor()
        d.execute('SELECT * FROM BIGSCARIES')
        c.execute('SELECT * FROM CHARACTERS WHERE PLAYER = ?', (userName,))
        monsters = d.fetchall()
        character = c.fetchall()
        dmg = random.randint(1,8)
        randoMon = random.randint(0, len(monsters)-1)
        monsterTuple = monsters[randoMon]
        mob = monDAO(monsterTuple[0], monsterTuple[1], int(monsterTuple[2]))
        try:
            if len(character) == 0:
                text = "The End cannot be overcome by those that standby and observe"
                # self.twt_print.printTweet(userName,text)
            else:
                charTuple = character[0]
                cha = CharDAO(charTuple[0], charTuple[1],charTuple[2],charTuple[3],charTuple[4], charTuple[5], charTuple[6],
                                              charTuple[7], charTuple[8], charTuple[9], charTuple[10], charTuple[11], charTuple[12], charTuple[13])

                text = "On the road " + cha.name.split(' ')[0] + " encounters a " + mob.name + ". " + cha.name.split(' ')[0] + " overcame it with their " + cha.weapon.split(' ')[-1] + \
                       " but took " + str(dmg) + " wound. DunSuRu grows safer"

            c.execute("UPDATE CHARACTERS SET HEALTH = ? WHERE PLAYER = ?",(str(cha.health-dmg),userName))
            conn.commit()
            conn.close()
            self.twt_print.printTweet(userName,text)
        except Exception as e:
            print('Try/catch error occured: ' + e)
Ejemplo n.º 5
0
    def dungeon_pick(self, userName):

            try:
                level = 1

                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 CHARACTERS WHERE PLAYER = ?', (userName,))
                    getData = p.fetchall()
                    if len(getData) == 0:
                        text = "To continue, one must begin"
                        # self.twt_print.printTweet(userName,text)
                    else:
                        charTuple = getData[0]
                        cha = CharDAO(charTuple[0], charTuple[1],charTuple[2],charTuple[3],charTuple[4], charTuple[5], charTuple[6],
                                      charTuple[7], charTuple[8], charTuple[9], charTuple[10], charTuple[11], charTuple[12], charTuple[13])
                        randomNum= random.randint(0, len(dungeons)-1)
                        newTuple = dungeons[randomNum]
                        dun = DunDAO(newTuple[0], newTuple[1], newTuple[2], newTuple[3], newTuple[4]) #
                        m.execute('SELECT * FROM BIGSCARIES WHERE THEME =?',(dun.theme,))
                        monsters = m.fetchall()
                        randoMon = random.randint(0, len(monsters)-1)
                        monsterTuple = monsters[randoMon]
                        mob = monDAO(monsterTuple[0], monsterTuple[1], int(monsterTuple[2]))
                        horde = random.randint(0,(level*dun.difficulty)) + cha.gold
                        rns = cha.runs + 1
                        entersAdj= 'runs into,traverses,stalks,enters,charges,assaults'.split(",")
                        flavText = ['cleave','slice','parry','slam']
                        #Updates character date with new health and treasure
                        if cha.health - (mob.damage*dun.difficulty) >= 0:
                            n.execute('UPDATE CHARACTERS SET HEALTH = ?, GOLD = ?, RUNS = ? WHERE PLAYER = ?',(str((cha.health - (mob.damage*dun.difficulty))), horde,rns, userName))
                            if 'a' in mob.name[0] or 'e' in mob.name[0] or 'i' in mob.name[0] or 'o' in mob.name[0] or 'u' in mob.name[0]:
                                text = cha.name.split(' ')[0] + " " + random.choice(entersAdj) + " " + dun.name + " and slew an " + mob.name + \
                               " with a mighty cleave. They find " + str(dun.difficulty*random.randint(1,5)) + " gold but take " + str((mob.damage*dun.difficulty)) + " wound"
                            else:
                                text = cha.name.split(' ')[0] + " " + random.choice(entersAdj) + " " + dun.name + " and slew a " + mob.name + \
                               " with a mighty cleave. They find " + str(dun.difficulty*random.randint(1,5)) + " gold but take " + str((mob.damage*dun.difficulty)) + " wound"
                        else:
                            # PLAYER|NAME|JOB|GOLD||RUNS|MAP|WEAPON|DUNGEON|DLEVEL|MON|LOOTED
                            n.execute('INSERT INTO GRAVEYARD VALUES(?,?,?,?,?,?,?,?,?,?,?)',(cha.user,cha.name,cha.job,cha.gold,cha.runs,cha.map,cha.weapon,dun.name,0,mob.name,"no"))
                            text = cha.name.split(' ')[0] + " " + random.choice(entersAdj) + " " + dun.name + " but fell to a " + mob.name + ". " + cha.name.split(' ')[0]
                            n.execute('DELETE FROM CHARACTERS WHERE NAME = ?',(cha.name))


                    conn.commit()
                    conn.close()

                        # return text
                    self.twt_print.printTweet(userName,text)
                else:
                    print("You shouldn't be able to get here")
                    self.dungeon_pick(userName)

            except Exception as e:
                print('Try/catch error occured: ' + e)
                self.dungeon_pick(userName)