예제 #1
0
def scanner():
    global monster, player
    if player.hp < 1:
        print("You Died!")
        t.sleep(1)
        ter=input(c.yellow+"Do you want to keep playing, or quit? (1), (2)"+c.reset+" >>>"+c.violet).strip()
        if ter == '1':
            tower.tower()
        elif ter == '2':
            exit()
        else:
            tower.tower()
    elif monster.hp < 1:
        print(c.yellow+"You won!")                                                                                                                                  
        cl.Player.gold+=100000                                                                                                                                      
        save.save_game()                                                                                                                                            
        t.sleep(1)                                                                                                                                                  
        print("Blinding light begins too engulf you.")                                                                                                              
        t.sleep(1.25)                                                                                                                                               
        print(c.clear)                                                                                                                                              
        print(c.reset+".")                                                                                                                                                  
        t.sleep(1)                                                                                                                                                  
        print(c.clear)                                                                                                                                              
        print("..")                                                                                                                                                 
        t.sleep(1)                                                                                                                                                  
        print(c.clear)                                                                                                                                              
        print("...")                                                                                                                                                
        t.sleep(1)                                                                                                                                                  
        print(c.clear)                                                                                                                                              
        print("You awake.")                                                                                                                                         
        t.sleep(1.5)                                                                                                                                                
        print(c.clear)                                                                                                                                              
        credits.roll()                                                                                                                                              
        exit() 
예제 #2
0
파일: snow.py 프로젝트: jajaio/kingsarmy
def explore():
        print(c.yellow+"You decide to explore the mountain for a bit.")
        d.normal()
        if cl.Player.wname=='Wooden Bow':
            print(c.yellow+'You find a bow, placed nicely at a shrine of Adari.')
            t.sleep(1)
            sword=input('Do you want to take the bow? (Y/N)'+c.reset+" >>>"+c.violet).strip().lower()
            if sword == 'y':
                print(c.yellow+"You picked up the bow, and it's arrows.")
                t.sleep(1)
                print("You received Adari's personal Bow, the Sun Bow!")
                cl.Player.wname="Sun Bow"
                cl.Player.att+=3
                save.save_game()
                cl.show_player()
                input('[Game saved! Press enter to continue.]')
                mountain()
            elif sword == 'n':
                print(c.yellow+'You hike back to the main part of the mountain.')
                t.sleep(1)
                input('[Press enter to continue.]')
                mountain()
            else:
                print(c.yellow+"I don't understand...")
                t.sleep(1.25)
                explore()
        else:
            print(c.yellow+'You arrive at the shrine of Adari.')
            t.sleep(1)
            print('Nothing to see here!')
            input('[Press enter to continue.]')
            mountain()
예제 #3
0
def staminaTrain():
    c()
    input(co.c + '---Press Enter to start---')
    c()
    s(random.randint(1, 10))
    input('START')
    then = time.time()
    input()
    reactionTime = time.time() - then
    thenTwo = time.time()
    input()
    reactionTimeTwo = time.time() - thenTwo
    reactionTime -= 1
    reactionTimeTwo -= 1
    xpGain = 0
    staGain = 0
    print(colorDef())
    anim.staminaAnim()
    if abs(reactionTime) < abs(reactionTimeTwo):
        breactionTime = reactionTime
    else:
        breactionTime = reactionTimeTwo
    breactionTime = abs(breactionTime)
    print(co.g + f"Your best reaction time was {breactionTime*1000:.0f} ms")
    s(2)
    if round(breactionTime * 10) == 0:
        cl.Dragon.sta += 5
        staGain += 5
        cl.Dragon.xp += 50
        xpGain += 50
    else:
        if round(breactionTime * 1000) < cl.highScores.stamina:
            cl.highScores.stamina = round(breactionTime * 1000)
        if cl.Dragon.hap >= 30:
            cl.Dragon.xp += 15 - round(breactionTime * 10)
            xpGain += 15 - round(breactionTime * 10)
            if cl.Dragon.hap >= 80:
                cl.Dragon.xp += 5
                xpGain += 5
        if round(breactionTime * 10) < 5 and cl.Dragon.hap >= 30:
            if 4 - math.floor(reactionTime * 10) > 3:
                cl.Dragon.sta += 3
                staGain += 3
            else:
                cl.Dragon.sta += 4 - math.floor(reactionTime * 10)
                staGain += 4 - math.floor(reactionTime * 10)
        if cl.Dragon.hap >= 80:
            cl.Dragon.sta += 1
            staGain += 1
    gain(xpGain, staGain, 'stamina')
    if cl.Dragon.hap >= 70:
        cl.Dragon.hap -= round((110 - cl.Dragon.hap) * .25)
    elif cl.Dragon.hap < 70 and cl.Dragon.hap >= 40:
        cl.Dragon.hap -= round((90 - cl.Dragon.hap) * .25)
    else:
        cl.Dragon.hap -= round((80 - cl.Dragon.hap) * .25)
    if cl.Dragon.hap < 0:
        cl.Dragon.hap = 0
    sav.save_game()
    sav.save_scores()
def main_menu():
    """ Display the main menu and wait for input """
    render.animate_background('main_menu', 0.5)

    while not libtcod.console_is_window_closed():
        #show the background image, at twice the regular console resolution

        choice = render.menu('', ['New game', 'Continue', 'Quit'],
                             24,
                             center=True,
                             alpha=0,
                             xOffset=18,
                             yOffset=12)

        if choice == 0:
            new_game()
        elif choice == 1:
            try:
                save.load_game()
            except:
                render.menu('Couldnt load savegame.', ["ok"], 24)
                continue
            play_game()
        elif choice == 2:
            save.save_game()
            raise SystemExit
예제 #5
0
파일: town.py 프로젝트: jajaio/alphaquest
def inn():
    print(c.clear)
    innq=input(c.yellow+"Welcome to the inn. Would you like to rest here? Or leave? (1), (2)"+c.reset+">>>"+c.violet).strip()
    if innq=="1":
        print(c.yellow+"You shut your eyes and rest for a bit.")
        t.sleep(.5)
        cl.show_player()
        print("[Game saved!]")
        save.save_game()
        qu=input('[Would you like to keep playing?] (Y/N)'+c.reset+' >>>'+c.violet).strip().lower()
        if qu=='y':
            print(c.yellow+'[Resuming game]')
        elif qu=='n':
            print(c.yellow+'[Exiting game...]')
            exit()
        else:
            print(c.yellow+'[Resuming game]')
        print(c.yellow+"You wake up feeling rested...")
        t.sleep(1.5)
        hub()
    elif innq=="2":
        print(c.yellow+"You return to the town.")
        t.sleep(1)
        hub()
    else:
        print(c.yellow+"I don't understand...")
        t.sleep(1)
        inn()
예제 #6
0
파일: town.py 프로젝트: jajaio/kingsarmy
def shrine():
    print(c.clear)
    print(c.yellow+"You are at the magical shrine.")
    t.sleep(1)
    shr=input("You currently have "+str(cl.Player.xp)+" XP. You need at least "+str(cl.Player.xpreq)+" to level up. Would you like to level up? (Y/N) "+c.reset+">>>"+c.violet).strip().lower()
    if shr == 'y':
        if int(cl.Player.xp) >= int(cl.Player.xpreq):
            cl.Player.lvl += 1
            cl.Player.hp += 1
            cl.Player.att += 1
            cl.Player.agi +=1
            cl.Player.xp -= cl.Player.xpreq
            cl.Player.xpreq +=10
            print(c.yellow+"You are now level "+str(cl.Player.lvl)+"!")
            cl.show_player()
            save.save_game()
            input('[Game Saved! Press enter to continue]')
            shrine()
        elif int(cl.Player.xp) <= cl.Player.xpreq:
            print(c.yellow+"You do not have enough XP!")
            t.sleep(1.5)
            hub()
    elif shr == 'n':
        print(c.yellow+'You leave the shrine.')
        t.sleep(1)
        hub()
    else:
        print(c.yellow+"I don't know what you mean...")
        t.sleep(1)
        shrine()
예제 #7
0
def hub():
    save.save_game()
    print(c.clear)
    print(c.yellow + "Welcome to the Pines!")
    hubquestion = input(
        "Would you like to go to the field, shop, inn, or the old tower? (1), (2), (3), (4)"
        + c.reset + " >>>" + c.violet)
    if hubquestion == "1":
        print(c.yellow + "You decide to go to the field.")
        t.sleep(1.3)
        f.field()
    elif hubquestion == "2":
        print(c.yellow + "You decide to go to the shop.")
        t.sleep(1.3)
        shop()
    elif hubquestion == "3":
        print(c.yellow + "You decide to go to the inn.")
        t.sleep(1.3)
        inn()
    elif hubquestion == "4":
        print(c.yellow + "You take a lantern and travel to the old tower.")
        t.sleep(1.25)
        tower.tower()
    else:
        print("I don't understand...")
        t.sleep(1)
        hub()
예제 #8
0
def inn():
    print(c.clear)
    innq = input(
        c.yellow +
        "Welcome to the inn. Would you like to rest here? Or leave? (1), (2)" +
        c.reset + ">>>" + c.violet).strip()
    if innq == "1":
        print(c.yellow + "You shut your eyes and rest for a bit.")
        t.sleep(.5)
        cl.show_player()
        print("[Game saved!]")
        save.save_game()
        qu = input('[Would you like to keep playing?] (Y/N)' + c.reset +
                   ' >>>' + c.violet).strip().lower()
        if qu == 'y':
            print(c.yellow + '[Resuming game]')
        elif qu == 'n':
            print(c.yellow + '[Exiting game...]')
            exit()
        else:
            print(c.yellow + '[Resuming game]')
        print(c.yellow + "You wake up feeling rested...")
        t.sleep(1.5)
        hub()
    elif innq == "2":
        print(c.yellow + "You return to the town.")
        t.sleep(1)
        hub()
    else:
        print(c.yellow + "I don't understand...")
        t.sleep(1)
        inn()
예제 #9
0
파일: pyramid.py 프로젝트: jajaio/kingsarmy
def shrine():
    print(c.clear)
    print(c.yellow+'You find a a broken down shrine of Adari.')
    t.sleep(1)
    pray=input("Do you wish to pray here? (Y/N)"+c.reset+' >>>'+c.violet).strip().lower()
    if pray == 'y':
        d.normal()
        if cl.Player.wname == 'Flameblade':
            cl.Player.att+=5
            cl.Player.wname='Divine Flameblade'
            print(c.yellow+'You got the Blessing of the god of flame, Adari!')
            t.sleep(1)
            print('Flameblade burns even brighter now!')
            t.sleep(1)
            save.save_game()
            input('[Game saved! Press enter to continue.]')
            main()
        else:
            print(c.yellow+'You take your stuff and leave.')
            t.sleep(1)
            input('[Press enter to continue.]')
            main()
    elif pray == 'n':
        print(c.yellow+'You decide to leave.')
        t.sleep(1)
        main()
    else:
        print("I don't understand...")
        t.sleep(1.25)
        shrine()
예제 #10
0
파일: town.py 프로젝트: jajaio/alphaquest
def hub():
    save.save_game()
    print(c.clear)
    print(c.yellow+"Welcome to the Pines!")
    hubquestion=input("Would you like to go to the field, shop, inn, or the old tower? (1), (2), (3), (4)"+c.reset+" >>>"+c.violet)
    if hubquestion=="1":
        print(c.yellow+"You decide to go to the field.")
        t.sleep(1.3)
        f.field()
    elif hubquestion=="2":
        print(c.yellow+"You decide to go to the shop.")
        t.sleep(1.3)
        shop()
    elif hubquestion=="3":
        print(c.yellow+"You decide to go to the inn.")
        t.sleep(1.3)
        inn()
    elif hubquestion=="4":
        print(c.yellow+"You take a lantern and travel to the old tower.")
        t.sleep(1.25)
        tower.tower()
    else:
        print("I don't understand...")
        t.sleep(1)
        hub()
예제 #11
0
def lvlUp():
    cl.Dragon.xp -= math.floor(50 + cl.Dragon.lvl * 5.25)
    cl.Dragon.lvl += 1
    print(co.g + cl.Dragon.name + ' leveled up!')
    s(2)
    print(training.colorDef())
    anim.lvlUpAnim()
    sav.save_game()
    def test_save_game(self):
        character.set_hp(6)
        character.set_coordinates(21, 21)
        save.save_game()

        with open('character.json') as file_object:
            current_character = json.load(file_object)

        self.assertEqual({"hp": 6, "column": 21, "row": 21}, current_character)
예제 #13
0
def fight():
    global q, player, monster
    load.load_game()
    player = cl.Player()
    monster = cl.Dragon()
    while True:
        if player.hp < 1:
            print(c.yellow + "You Died!")
            t.sleep(1)
            ter = input("Do you want to keep playing, or quit? (1), (2)" +
                        c.reset + " >>>" + c.violet).strip()
            if ter == '1':
                break
            elif ter == '2':
                exit()
            else:
                break
        elif monster.hp < 1:
            print(c.yellow + "You won!")
            cl.Player.gold += 100000
            save.save_game()
            t.sleep(1)
            print("Blinding light begins too engulf you.")
            t.sleep(1.25)
            print(c.clear)
            print(".")
            t.sleep(1)
            print(c.clear)
            print("..")
            t.sleep(1)
            print(c.clear)
            print("...")
            t.sleep(1)
            print(c.clear)
            print("You awaken.")
            t.sleep(1.5)
            print(c.clear)
            credits.roll()
            exit()
        else:
            print(c.clear)
            print(c.blue + player.name + str(" HP = ") + str(player.hp) +
                  str(": ") + player.name + str(" MP = ") + str(player.mp))
            print(c.red + monster.mname +
                  str(" HP = " + str(monster.hp) + str(": ") + monster.mname +
                      str(" MP = ") + str(monster.mp)))
            q = input(c.reset + "Attack(1) or Heal(2)? >>>" +
                      c.violet).strip().lower()
            if player.agi >= monster.agi:
                pmove()
                scanner()
                ai()
            elif monster.agi > player.agi:
                ai()
                scanner()
                pmove()
예제 #14
0
def dodgeTrain():
    c()
    input(co.c + '---Press Enter to start---')
    c()
    x = random.randint(2, 7)
    s(random.randint(3, 8))
    print(co.g + 'There is an obstacle ' + str(x) + ' seconds away!')
    print()
    then = time.time()
    input()
    reactionTime = abs(time.time() - then - x)
    print(co.g + f"Your dodge time was {reactionTime*1000:.0f} ms")
    s(2)
    xpGain = 0
    dogGain = 0
    print(colorDef())
    anim.dodgeAnim()
    if round(reactionTime * 1000) < cl.highScores.dodge:
        cl.highScores.dodge = round(reactionTime * 1000)
    if round(reactionTime * 10) == 0:
        cl.Dragon.dog += 5
        dogGain += 5
        cl.Dragon.xp += 50
        xpGain += 50
    elif round(reactionTime * 10) == 1:
        cl.Dragon.dog += 4
        dogGain += 4
        cl.Dragon.xp += 45
        xpGain += 45
    else:
        if cl.Dragon.hap >= 30:
            cl.Dragon.xp += 20 - round(reactionTime * 10)
            xpGain += 20 - round(reactionTime * 10)
            if cl.Dragon.hap >= 80:
                cl.Dragon.xp += 5
                xpGain += 5
        if round(reactionTime * 10) < 6 and cl.Dragon.hap >= 30:
            cl.Dragon.dog += 5 - math.floor(reactionTime * 10)
            dogGain += 4 - math.floor(reactionTime * 10)
            if cl.Dragon.hap >= 80:
                cl.Dragon.dog += 1
                dogGain += 1
    gain(xpGain, dogGain, 'dodge')
    if cl.Dragon.hap >= 70:
        cl.Dragon.hap -= round((110 - cl.Dragon.hap) * .25)
    elif cl.Dragon.hap < 70 and cl.Dragon.hap >= 40:
        cl.Dragon.hap -= round((90 - cl.Dragon.hap) * .25)
    else:
        cl.Dragon.hap -= round((80 - cl.Dragon.hap) * .25)
    if cl.Dragon.hap < 0:
        cl.Dragon.hap = 0
    sav.save_game()
    sav.save_scores()
예제 #15
0
def quit_game():
    """
    Quit and save the game.

    POST-CONDITION game is saved
    POST-CONDITION game saved message is printed
    POST-CONDITION program terminates
    """

    save.save_game()
    print("GAME SAVED")
    quit()
예제 #16
0
def main():
    load.load_game()
    print(co.g + 'You play with ' + cl.Dragon.name + '.')
    print(b.playerColorDef())
    s(1.5)
    anim.playAnim()
    cl.Dragon.hap += 45
    cl.Dragon.hap += cl.Dragon.lvl * 2
    cl.Dragon.hap += r.randint(1, 10)
    if cl.Dragon.hap > 100:
        cl.Dragon.hap = 100
    save.save_game()
    c()
예제 #17
0
def fight():
    global q, player, monster
    load.load_game()
    player=cl.Player()
    monster=cl.Dragon()
    while True:
        if player.hp < 1: 
            print(c.yellow+"You Died!")                                                                                                                                                                       
            t.sleep(1)                                                                                                                                                                               
            ter=input("Do you want to keep playing, or quit? (1), (2)"+c.reset+" >>>"+c.violet).strip()                                                                                                                              
            if ter == '1':                                                                                                                                                                           
                break                                                                                                                                                                                
            elif ter == '2':                                                                                                                                                                         
                exit()                                                                                                                                                                               
            else:                                                                                                                                                                                    
                break                                                                                                                                                                                
        elif monster.hp < 1:                                                                                                                                                                         
            print(c.yellow+"You won!")                                                                                                                                                               
            cl.Player.gold+=100000
            save.save_game()
            t.sleep(1)                                                                                                                                                                               
            print("Blinding light begins too engulf you.")
            t.sleep(1.25)
            print(c.clear)
            print(".")
            t.sleep(1)
            print(c.clear)
            print("..")
            t.sleep(1)
            print(c.clear)
            print("...")
            t.sleep(1)
            print(c.clear)
            print("You awaken.")
            t.sleep(1.5)
            print(c.clear)
            credits.roll()
            exit()
        else:
            print(c.clear)
            print(c.blue+player.name+str(" HP = ")+str(player.hp)+str(": ")+player.name+str(" MP = ")+str(player.mp))
            print(c.red+monster.mname+str(" HP = "+str(monster.hp)+str(": ")+monster.mname+str(" MP = ")+str(monster.mp)))
            q=input(c.reset+"Attack(1) or Heal(2)? >>>"+c.violet).strip().lower()
            if player.agi >= monster.agi:
                pmove()
                scanner()
                ai()
            elif monster.agi > player.agi:
                ai()
                scanner()
                pmove()
예제 #18
0
def attackTrain():
    c()
    input(co.c + '---Press Enter to start---')
    c()
    s(random.randint(1, 10))
    then = time.time()
    react = input('ATTACK')
    print()
    reactionTime = time.time() - then
    s(2)
    if reactionTime <= 0.01:
        c()
        print(co.r + 'You failed! Try again next time.')
        s(2)
    else:
        print(colorDef())
        anim.attackAnim()
        xpGain = 0
        attGain = 0
        print(co.g + f"Your reaction time was {reactionTime*1000:.0f} ms")
        s(2)
        if round(reactionTime * 1000) < cl.highScores.attack:
            cl.highScores.attack = round(reactionTime * 1000)
        if cl.Dragon.hap >= 30:
            cl.Dragon.xp += 20 - round(reactionTime * 10)
            xpGain += 20 - round(reactionTime * 10)
            if cl.Dragon.hap >= 80:
                cl.Dragon.xp += random.randint(1, 5)
                xpGain += 20 - round(reactionTime * 10)
        if round(reactionTime * 10) < 5 and cl.Dragon.hap >= 30:
            cl.Dragon.att += 4 - math.floor(reactionTime * 10)
            attGain += 5 - math.floor(reactionTime * 10)
            if cl.Dragon.hap >= 90:
                cl.Dragon.att += 1
                attGain += 1
        if cl.Dragon.hap >= 70:
            cl.Dragon.hap -= round((110 - cl.Dragon.hap) * .25)
        elif cl.Dragon.hap < 70 and cl.Dragon.hap >= 40:
            cl.Dragon.hap -= round((90 - cl.Dragon.hap) * .25)
        else:
            cl.Dragon.hap -= round((80 - cl.Dragon.hap) * .25)
        if cl.Dragon.hap < 0:
            cl.Dragon.hap = 0
        gain(xpGain, attGain, 'attack')
    sav.save_game()
    sav.save_scores()
예제 #19
0
def speedTrain():
    c()
    input(co.c + '---Press Enter to start---')
    c()
    s(random.randint(1, 10))
    input('START')
    then = time.time()
    input()
    reactionTime = time.time() - then
    if reactionTime < 0.001:
        c()
        print(co.r + 'You failed! Try again next time.')
        s(2)
    else:
        print(co.g + f"Your speed time was {reactionTime*1000:.0f} ms")
        s(2)
        xpGain = 0
        spdGain = 0
        print(colorDef())
        anim.speedAnim()
        if round(reactionTime * 1000) < cl.highScores.speed:
            cl.highScores.speed = round(reactionTime * 1000)
        if cl.Dragon.hap >= 30:
            cl.Dragon.xp += 20 - round(reactionTime * 10)
            xpGain += 20 - round(reactionTime * 10)
            if cl.Dragon.hap >= 80:
                cl.Dragon.xp += 5
                xpGain += 5
        if round(reactionTime * 10) < 3 and cl.Dragon.hap >= 30:
            cl.Dragon.spd += 2 - math.floor(reactionTime * 10)
            spdGain += 2 - math.floor(reactionTime * 10)
            if cl.Dragon.hap >= 80:
                cl.Dragon.spd += 1
                spdGain += 1
            gain(xpGain, spdGain, 'speed')
    if cl.Dragon.hap >= 70:
        cl.Dragon.hap -= round((110 - cl.Dragon.hap) * .25)
    elif cl.Dragon.hap < 70 and cl.Dragon.hap >= 40:
        cl.Dragon.hap -= round((90 - cl.Dragon.hap) * .25)
    else:
        cl.Dragon.hap -= round((80 - cl.Dragon.hap) * .25)
    if cl.Dragon.hap < 0:
        cl.Dragon.hap = 0
    sav.save_game()
    sav.save_scores()
def play_game():
    """ Main Loop """
    player_action = None

    #Main Loop
    while not libtcod.console_is_window_closed():
        render.render_all()
        libtcod.console_flush()
        map = gvar.game.player.currentmap()
        for object in map.objects:
            object.clear()
            if object.fighter is not None and libtcod.map_is_in_fov(
                    gvar.foh_map, object.x,
                    object.y) and not gvar.game.ticks.contains(object):
                object.fighter.join_battle()

        #handle death state
        if gvar.game.game_state == 'dead':
            player_action = input.handle_keys()
            if player_action == 'exit':
                save.save_game()
                break
            else:
                continue

        else:
            actor = gvar.game.ticks.getWithPriority()
            if actor[1] == gvar.game.player:
                #handle keys and exit game if needed
                player_action = input.handle_keys()
                if player_action == 'exit':
                    save.save_game()
                    main_menu()
                    break
                gvar.game.ticks.put(actor[1], int(player_action + actor[0]))

            else:
                #let mobs take their turn
                if gvar.game.game_state == 'playing':
                    if actor[1].ai:
                        speed = actor[1].ai.take_turn()
                        gvar.game.ticks.put(actor[1], int(speed + actor[0]))
예제 #21
0
def finish():        
    print(c.yellow+"You won!")
    t.sleep(1)
    print("You got 125 XP!")
    cl.Player.xp+=125
    t.sleep(1)
    print("You pry the skull off Elyn's head.")
    t.sleep(2)
    print("Dark energy flies everywhere.")
    t.sleep(2)
    print("You got an ancient skull!")
    cl.Player.skulls+=1
    t.sleep(2)
    print('Your Magic Power and Defense stat went up by 1!')
    cl.Player.mp +=1
    cl.Player.deff +=1
    cl.Player.ecomp +=1
    save.save_game()
    t.sleep(2)
    input('[Game Saved! Press enter to continue.]')
    skull.woods()
예제 #22
0
def scanner():
    if player.hp < 1:
        print(c.yellow+ "You Died!")
        t.sleep(1)
        ter=input("Do you want to keep playing, or quit? (1), (2)"+c.reset+" >>>"+c.violet).strip()
        if ter == '1':
            ancient.dunes()
        elif ter == '2':
            exit()
        else:
            ancient.dunes()
    elif monster.hp < 1:
        print(c.yellow+"You won!")
        t.sleep(1)
        gain=random.randint(40, 55)
        print("You got "+str(gain)+" XP!")
        cl.Player.xp+=int(gain)
        t.sleep(1)
        save.save_game()
        input('[Game Saved! Press enter to continue.]')
        ancient.dunes()
예제 #23
0
def finish():        
    print(c.yellow+"You won!")
    t.sleep(1)
    print("You got 75 XP!")
    cl.Player.xp+=75
    t.sleep(1)
    print("You pry the mask off of Blarney's head.")
    t.sleep(2)
    print("Dark energy flies everywhere.")
    t.sleep(2)
    print("You got an ancient skull!")
    cl.Player.skulls+=1
    t.sleep(2)
    print('Your Magic and Defense stat went up by 1!')
    cl.Player.mp +=1
    cl.Player.deff +=1
    cl.Player.bcomp +=1
    save.save_game()
    t.sleep(2)
    input('[Game Saved! Press enter to continue.]')
    snow.mountain()
예제 #24
0
def main_menu():
	""" Display the main menu and wait for input """
	render.animate_background('main_menu', 0.5)

	while not libtcod.console_is_window_closed():
		#show the background image, at twice the regular console resolution

		choice = render.menu('', ['New game', 'Continue', 'Quit'], 24, center=True, alpha=0, xOffset=18, yOffset=12)

		if choice == 0:
			new_game()
		elif choice == 1:
			try:
				save.load_game()
			except:
				render.menu('Couldnt load savegame.', ["ok"], 24)
				continue
			play_game()
		elif choice == 2:
			save.save_game()
			raise SystemExit
예제 #25
0
def scanner():
    if player.hp < 1:
        print("You Died!")
        t.sleep(1)
        ter=input(c.yellow+"Do you want to keep playing, or quit? (1), (2)"+c.reset+" >>>"+c.violet).strip()
        if ter == '1':
            f.field()
        elif ter == '2':
            exit()
        else:
            f.field()
    elif monster.hp < 1:
        print(c.yellow+"You won!")
        t.sleep(1)
        curr=random.randint(10,25)
        print("You got "+str(curr)+" Gold!")
        cl.Player.gold+=int(curr)
        t.sleep(1)
        save.save_game()
        input('[Game Saved! Press enter to continue.]')
        f.field()
예제 #26
0
def fight():
    global q, player, monster
    load.load_game()
    player=cl.Player()
    monster=cl.Foe()
    while True:
        if player.hp < 1:                                                                                                                                                                            
            print(c.yellow+"You Died!")                                                                                                                                                                       
            t.sleep(1)                                                                                                                                                                               
            ter=input("Do you want to keep playing, or quit? (1), (2)"+c.reset+" >>>"+c.violet).strip()                                                                                          
            if ter == '1':                                                                                                                                                                           
                break                                                                                                                                                             
            elif ter == '2':                                                                                                                                                                         
                print('[Exiting game...]')
                exit()                                                                                                                                                                               
            else:                                                                                                                                                                                    
                break                                                                                                                                                                                
        elif monster.hp < 1:                                                                                                                                                                         
            print(c.yellow+"You won!")                                                                                                                                                               
            t.sleep(1)                                                                                                                                                                               
            gain=random.randint(20, 35)                                                                                                                                                               
            print("You got "+str(gain)+" XP!")                                                                                                                                                     
            cl.Player.xp+=int(gain)                                                                                                                                                                
            t.sleep(1)
            save.save_game()                                                                                                                                                                         
            input('[Game Saved! Press enter to continue.]')                                                                                                                                          
            break     
        else:
            print(c.clear)
            print(c.blue+player.name+str(" HP = ")+str(player.hp)+str(": ")+player.name+str(" MP = ")+str(player.mp))
            print(c.red+monster.mname+str(" HP = "+str(monster.hp)+str(": ")+monster.mname+str(" MP = ")+str(monster.mp)))
            q=input(c.reset+"Attack(1) or Heal(2)? >>>"+c.violet).strip().lower()
            if player.agi >= monster.agi:
                pmove()
                scanner()
                ai()
            elif monster.agi > player.agi:
                ai()
                scanner()
                pmove()
예제 #27
0
def play_game():
	""" Main Loop """
	player_action = None

	#Main Loop
	while not libtcod.console_is_window_closed():
		render.render_all()
		libtcod.console_flush()
		map = gvar.game.player.currentmap()
		for object in  map.objects:
			object.clear()
			if object.fighter is not None and libtcod.map_is_in_fov(gvar.foh_map, object.x, object.y) and not gvar.game.ticks.contains(object):
				object.fighter.join_battle()

		#handle death state
		if gvar.game.game_state == 'dead':
			player_action = input.handle_keys()
			if player_action == 'exit':
				save.save_game()
				break
			else:
				continue

		else:
			actor = gvar.game.ticks.getWithPriority()
			if actor[1] == gvar.game.player:
				#handle keys and exit game if needed
				player_action = input.handle_keys()
				if player_action == 'exit':
					save.save_game()
					main_menu()
					break
				gvar.game.ticks.put(actor[1], int(player_action + actor[0]))

			else:
				#let mobs take their turn
				if gvar.game.game_state == 'playing':
					if actor[1].ai:
						speed = actor[1].ai.take_turn()
						gvar.game.ticks.put(actor[1], int(speed + actor[0]))
예제 #28
0
    def run(self):
        while not tcod.console_is_window_closed():
            self.render_engine.render_scene(self.current_scene)
            if self.current_scene.data is not None:
                input_return = self.current_scene.manage_input(None)
            else:
                game_input = self.input_manager.get_input()
                input_return = self.current_scene.manage_input(game_input)
            if input_return is None:
                continue
            if input_return['action']:
                if input_return['action'] == 'confirm':
                    input_return = self.current_scene.need_confirm
                if input_return['action'] == 'cancel' or input_return['action'] == 'cancel_with_action':
                    if self.current_scene.previous_scene is not None:
                        current = self.current_scene
                        self.current_scene = self.current_scene.previous_scene
                        current.previous_scene = None
                        if input_return['action'] == 'cancel_with_action' and isinstance(self.current_scene, MapScene):
                            self.current_scene.player_took_action = True
                        self.current_scene.render_next = True
                        del current
                    else:
                        if self.current_scene.need_confirm is not None:
                            return True
                        self.current_scene.need_confirm = input_return
                        add_log_message(
                            LogMessage(
                                get_message("quit_game.confirm"),
                                tcod.light_cyan
                            )
                        )
                        self.current_scene.render_next = True
                elif input_return['action'] == 'change_scene':
                    self.current_scene = input_return['scene']
                    self.current_scene.render_next = True

        if not self.player.entity.dead:
            save_game(self.player)
예제 #29
0
def scanner():
    global monster, player
    if player.hp < 1:
        print("You Died!")
        t.sleep(1)
        ter = input(c.yellow +
                    "Do you want to keep playing, or quit? (1), (2)" +
                    c.reset + " >>>" + c.violet).strip()
        if ter == '1':
            tower.tower()
        elif ter == '2':
            exit()
        else:
            tower.tower()
    elif monster.hp < 1:
        print(c.yellow + "You won!")
        cl.Player.gold += 100000
        save.save_game()
        t.sleep(1)
        print("Blinding light begins too engulf you.")
        t.sleep(1.25)
        print(c.clear)
        print(c.reset + ".")
        t.sleep(1)
        print(c.clear)
        print("..")
        t.sleep(1)
        print(c.clear)
        print("...")
        t.sleep(1)
        print(c.clear)
        print("You awake.")
        t.sleep(1.5)
        print(c.clear)
        credits.roll()
        exit()
예제 #30
0
def askLoad():
    load = input(
        co.b +
        'Would you like to make a new game or load an old save?\nNew - 1\nOld - 2\n >>> '
    ).strip().lower()
    if load == '1':
        cl.Dragon = cl.Base
        c()
        askColor()
        askName()
        saves.save_game()
        saves.save_scores()
        game.welcome()
        game.main()
    elif load == '2':
        loads.load_game()
        loads.load_scores()
        c()
        game.main()
    else:
        print(co.y + "Please respond with a 1 or a 2.")
        s(1.5)
        c()
        askLoad()
예제 #31
0
    def main(self):
        # Game Loop
        while self.game_running:
            # Check input streams for an event
            libtcod.sys_check_for_event(
                libtcod.EVENT_KEY_PRESS | libtcod.EVENT_MOUSE, self.key,
                self.mouse)

            # If we need to recompute fov, do so
            if self.fov_recompute:
                recompute_fov(self.fov_map, self.player.x, self.player.y)

            # Render the game world according to current FOV, mark FOV recompute as complete, and flush to console
            render_all(self.con, self.panel, self.entities, self.player,
                       self.game_map, self.fov_map, self.fov_recompute,
                       self.message_log, self.mouse, self.game_state,
                       self.player_target)
            self.fov_recompute = False
            libtcod.console_flush()

            # Interpret the input into a game action
            input = handle_keys(self.key, self.game_state)
            action = input.get('action')

            inventory_item = input.get(
                'inventory_item') if 'inventory_item' in input else None
            dialogue_option = input.get(
                'dialogue_option') if 'dialogue_option' in input else None
            shop_option = input.get(
                'shop_option') if 'shop_option' in input else None
            unequip_item = input.get('slot') if 'slot' in input else None

            # If players turned and it's their turn to move
            if action == 'move' and self.game_state == GameStates.PLAYERS_TURN:
                # Calculate where they should move
                dx, dy = input.get('move')
                destination_x = self.player.x + dx
                destination_y = self.player.y + dy

                # TODO: This is where you hid the noclip check. Fix this for release
                #if not self.game_map.is_blocked(destination_x, destination_y):
                if True:
                    # If they're not about to walk into a wall, check for enemies at the destination
                    potential_collision_list = self.entities.get_sublist(
                        lambda ent: ent.x == destination_x and ent.y ==
                        destination_y and ent.blocks)
                    target = potential_collision_list[
                        0] if potential_collision_list else None
                    if target and target.state == AIStates.HOSTILE:
                        # If there are enemies, attack them
                        self.player.get_component("Fighter").attack(target)
                        self.game_state = GameStates.ENEMY_TURN
                    elif target and target.state == AIStates.FRIENDLY:
                        self.previous_game_state = self.game_state
                        self.player_target = target
                        self.game_state = GameStates.DIALOGUE
                    else:
                        # If there are not enemies, move and mark FOV for recomputation
                        self.player.move(dx, dy, self.game_map)
                        self.fov_recompute = True
                        self.game_map.compute_dijkstra_map([self.player],
                                                           'player', True)
                        self.game_state = GameStates.ENEMY_TURN

            # If the player grabs something, check if there is an object at their feet, and either have them pick it up (if it's an Item) or add it to their wallet (if it's money)
            elif action == 'grab' and self.game_state == GameStates.PLAYERS_TURN:
                for item in self.entities.get_sublist(
                        lambda entity: (entity.has_component("Item") or entity.
                                        has_component("Money")) and entity.x ==
                        self.player.x and entity.y == self.player.y):
                    if item.has_component("Money"):
                        self.player.get_component("Fighter").pick_up_money(
                            item)
                    else:
                        self.player.get_component("Inventory").add_item(item)
                    self.entities.remove_entity(item)
                    self.game_state = GameStates.ENEMY_TURN

            # Open up the inventory menu
            elif action == 'inventory' and inventory_item is None:
                self.previous_game_state = self.game_state
                self.game_state = GameStates.INVENTORY_OPEN

            # Open up the equipped menu
            elif action == 'equipped':
                self.previous_game_state = self.game_state
                self.game_state = GameStates.EQUIPPED_OPEN

            elif action == 'unequip' and self.game_state == GameStates.EQUIPPED_OPEN:
                self.player.get_component("Inventory").unequip_slot(
                    unequip_item)

            # if the player has selected an inventory item to use, get the item object, and equip it if it's vgear, or use it if it's a consumable (like a potion)
            elif inventory_item is not None and self.previous_game_state != GameStates.PLAYER_DEAD and inventory_item < len(
                    self.player.get_component("Inventory").items):
                item_entity = self.player.get_component(
                    "Inventory").items[inventory_item]
                if ItemType(item_entity.get_component(
                        "Item").item_type) != ItemType.NONE:
                    self.player.get_component("Inventory").equip_item(
                        item_entity)
                else:
                    print("In the else")
                    if item_entity.get_component("Item").use(self.player):
                        self.player.get_component("Inventory").remove_item(
                            item_entity)

            # if the player is in dialogue, provide the dialogue option to the target's Character object
            elif dialogue_option is not None:
                dialogue_response = self.player_target.get_component(
                    "Character").talk(dialogue_option)
                if dialogue_response.shop:
                    self.game_state = GameStates.SHOPPING

            # if the player attempts to go down some stairs, make sure they're on stairs, then build a new map and clear the console
            elif action == 'go_down' and self.game_state == GameStates.PLAYERS_TURN:
                stairs_candidates = self.entities.get_sublist(
                    lambda entity: entity.x == self.player.x and entity.y ==
                    self.player.y and entity.has_component("Stairs"))
                if stairs_candidates:
                    self.build_map(
                        stairs_candidates[0].get_component("Stairs").floor)
                    libtcod.console_clear(self.con)

            # Save the game
            elif action == 'save':
                save_game(self.player, self.entities, self.game_map,
                          self.message_log, self.game_state)

            # if the player draws their gun, change to a player shoot state and await gunfire
            elif self.game_state == GameStates.PLAYERS_TURN and action == 'gun':
                if (self.player.get_component("Inventory").slot_filled(
                        "RANGED")):
                    self.previous_game_state = self.game_state
                    self.game_state = GameStates.PLAYER_SHOOT
                    self.message_log.add_message(
                        Message(
                            "Taking aim. Click on your target, or e to holster"
                        ))
                else:
                    self.message_log.add_message(
                        Message("No ranged weapon equipped!"))

            # if the player already has their gun drawn and presses the draw button, holster it instead
            elif self.game_state == GameStates.PLAYER_SHOOT and action == 'holster':
                self.game_state = self.previous_game_state
                self.message_log.add_message(Message("Holstered your weapon"))

            # if the player has their gun drawn and clicks on a target, check if there is line of sight
            # and if so, shoot the target. This sets the AI to hostile if it isn't already (this should be handled by Fighter)
            elif self.game_state == GameStates.PLAYER_SHOOT and self.mouse.lbutton_pressed:
                target = get_shoot_target(self.mouse, self.entities,
                                          self.fov_map)
                if (target):
                    line_of_sight = draw_line((self.player.x, self.player.y),
                                              (target.x, target.y))
                    if not [
                            space for space in line_of_sight
                            if self.game_map.is_blocked(space[0], space[1])
                    ]:
                        self.player.get_component("Fighter").ranged_attack(
                            target)
                        target.state = AIStates.HOSTILE
                        self.game_state = GameStates.ENEMY_TURN
                    else:
                        self.message_log.add_message(
                            Message("You don't have a clear line of sight!"))

            # if the player right clicks something, get open up the inspect menu for that target
            elif self.mouse.rbutton_pressed and self.game_state != GameStates.INSPECT_OPEN:
                target = get_shoot_target(self.mouse, self.entities,
                                          self.fov_map, False)
                if (target):
                    self.player_target = target
                    self.previous_game_state = self.game_state
                    self.game_state = GameStates.INSPECT_OPEN

            # If the player is buying something, they make the purchase
            elif action == 'buy' and shop_option is not None:
                target.get_component("Shop").purchase(shop_option, self.player)

            elif action == 'status':
                self.previous_game_state = self.game_state
                self.game_state = GameStates.STATUS

            # Exit the game
            if action == 'exit' and (self.game_state in [
                    GameStates.INVENTORY_OPEN, GameStates.DIALOGUE,
                    GameStates.EQUIPPED_OPEN, GameStates.SHOPPING,
                    GameStates.INSPECT_OPEN, GameStates.STATUS
            ]):
                self.game_state = self.previous_game_state
            elif action == 'exit':
                return True

            # Set the game to fullscreen
            if action == 'fullscreen':
                libtcod.console_set_fullscreen(
                    not libtcod.console_is_fullscreen())

            # cull_dead returns true if the player is dead, so this conditional calls it to cull the dead, and then
            # checks if the game is over
            if self.cull_dead():
                self.game_state = GameStates.PLAYER_DEAD

            # when it's the AI's turn, find every entity that has AI and move it (if it's hostile)
            if self.game_state == GameStates.ENEMY_TURN:
                for entity in self.entities.get_entity_set():
                    if entity.has_component(
                            "AI") and entity.state == AIStates.HOSTILE:
                        entity.get_component("AI").take_turn(
                            self.player, self.fov_map, self.game_map,
                            self.entities)
                        if self.cull_dead():
                            self.game_state = GameStates.PLAYER_DEAD
                    if entity.has_component("StatusContainer"):
                        entity.get_component("StatusContainer").tick_clocks()
                        for status in entity.get_component(
                                "StatusContainer").get_statuses():
                            status_mapping[status](entity, self.entities,
                                                   self.game_map)

                if self.game_state != GameStates.PLAYER_DEAD:
                    self.player.get_component("StatusContainer").tick_clocks()
                    for status in self.player.get_component(
                            "StatusContainer").get_statuses():
                        status_mapping[status](self.player, self.entities,
                                               self.game_map)
                    self.game_map.compute_dijkstra_map(
                        self.entities.get_sublist(
                            lambda x: x.name != "Ascetic"), "enemies")
                    self.game_state = GameStates.PLAYERS_TURN

            # TODO: need a check somewhere around here to tick condition clocks, and then to apply conditions

            if action == 'restart':
                libtcod.console_clear(self.con)
                self.initialize_game()
예제 #32
0
파일: town.py 프로젝트: jajaio/alphaquest
def shop():
    print(c.clear)
    while True:
        question=input(c.yellow+"Welcome to the shop! Would you like to see our professions, masteries, or would you like to leave? (1), (2), (3)"+c.reset+" >>>"+c.violet).strip()
        if question=="1":
            question_one=input(c.yellow+"Okay, would you like to see the the Rogue, Cleric, or Sellsword? (1),(2),(3)"+c.reset+" >>>"+c.violet).strip()
            if question_one=="1":
                cl.show_rogue()
                buyr=input(c.yellow+"You currently have "+str(cl.Player.gold)+" gold. Would you like to purchase the Rogue class for 100 gold? (Y/N)"+c.reset+" >>>"+c.violet).strip().lower()
                if buyr=="y":
                    if int(cl.Player.gold) >= 100:
                        cl.Player.hp=cl.Rogue.hp
                        cl.Player.att=cl.Rogue.att
                        cl.Player.agi=cl.Rogue.agi
                        cl.Player.deff=cl.Rogue.deff
                        cl.Player.mp=cl.Rogue.mp
                        cl.Player.gold-=100
                        print(c.yellow+"You are now a Rogue!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input("[Game saved! Press enter to continue.]")
                        hub()
                    if int(cl.Player.gold) < 100:
                        print(c.yellow+"You need more money! You currently have "+str(cl.Player.gold)+" and you need 100!")
                        input("[Press enter to continue.]")
                        hub()
                elif buyr=="n":
                    print(c.yellow+"Oh, okay.")
                    t.sleep(1)
                    shop()
            elif question_one=="2":
                cl.show_cleric()
                buyd=input(c.yellow+"You currently have "+str(cl.Player.gold)+" gold. Would you like to purchase the Cleric class for 100 gold? (Y/N)"+c.reset+" >>>"+c.violet).strip().lower()
                if buyd=="y":
                    if int(cl.Player.gold) >= 100:
                        cl.Player.hp=cl.Cleric.hp
                        cl.Player.att=cl.Cleric.att
                        cl.Player.agi=cl.Cleric.agi
                        cl.Player.deff=cl.Cleric.deff
                        cl.Player.mp=cl.Cleric.mp
                        cl.Player.gold-=100
                        print(c.yellow+"You are now a Cleric!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input("[Press enter to continue.]")
                        hub()
                    elif int(cl.Player.gold) <= 100:
                        print(c.yellow+"You need more money! You currently have "+str(cl.Player.gold)+" and you need 100!")
                        hub()
                elif buyd=="n":
                    print(c.yellow+"Oh, okay.")
                    t.sleep(1)
                    shop()
            elif question_one=="3":
                cl.show_sellsword()
                buyf=input(c.yellow+"You currently have "+str(cl.Player.gold)+" gold. Would you like to purchase the Sellsword class for 100 gold? (Y/N)"+c.reset+" >>>"+c.violet).strip().lower()
                if buyf=="y":
                    if int(cl.Player.gold) >= 100:
                        cl.Player.hp=cl.Sellsword.hp
                        cl.Player.att=cl.Sellsword.att
                        cl.Player.agi=cl.Sellsword.agi
                        cl.Player.deff=cl.Sellsword.deff
                        cl.Player.mp=cl.Sellsword.mp
                        cl.Player.gold-=100
                        print(c.yellow+"You are now a Sellsword!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input("[Game saved! Press enter to continue.]")
                        hub()
                    elif int(cl.Player.gold) <= 100:
                        print(c.yellow+"You need more money! You currently have "+str(cl.Player.gold)+" and you need 100!")
                        input("[Press enter to continue]")
                        hub()
                elif buyf=="n":
                    print(c.yellow+"Oh, okay.")
                    t.sleep(1)
                    shop()
                else:
                    print(c.yellow+"I'm not sure if I understand...")
                    t.sleep(1.25)
                    shop()
        elif question=="2":
            question_q=input(c.yellow+"Our masteries are the Assassin, Wizard, Paladin. What would you like to see? (1), (2), (3)"+c.reset+" >>>"+c.violet).strip()
            if question_q=="1":
                cl.show_assassin()
                buyg=input(c.yellow+"You currently have "+str(cl.Player.gold)+" gold. Would you like to purchase the Assassin class for 200 gold? (Y/N)"+c.reset+" >>>"+c.violet).strip().lower()
                if buyg=='y':
                    if int(cl.Player.gold) >= 200:
                        cl.Player.hp=cl.Assassin.hp
                        cl.Player.att=cl.Assassin.att
                        cl.Player.agi=cl.Assassin.agi
                        cl.Player.deff=cl.Assassin.deff
                        cl.Player.mp=cl.Assassin.mp
                        cl.Player.gold-=200
                        print(c.yellow+"You are now an Assassin!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input("[Game saved! Press enter to continue.]")
                        hub()
                    elif int(cl.Player.gold) <= 200:
                        print(c.yellow+"You need more money! You currently have "+str(cl.Player.gold)+" and you need 200!")
                        input("[Press enter to continue.]")
                        hub()
                elif buyg=='n':
                    print(c.yellow+"Oh, okay.")
                    t.sleep(1)
                    shop()
                else:
                    print("I'm not sure if I understand...")
                    t.sleep(1.25)
                    shop()
            elif question_q=="2":
                cl.show_wizard()
                buyh=input(c.yellow+"You currently have "+str(cl.Player.gold)+" gold. Would you like to purchase the Wizard class for 200 gold? (Y/N)"+c.reset+" >>>"+c.violet).strip().lower()
                if buyh=="y":
                    if int(cl.Player.gold) >= 200:
                        cl.Player.hp=cl.Wizard.hp
                        cl.Player.att=cl.Wizard.att
                        cl.Player.agi=cl.Wizard.agi
                        cl.Player.deff=cl.Wizard.deff
                        cl.Player.mp=cl.Wizard.mp
                        cl.Player.gold-=200
                        print(c.yellow+"You are now a Wizard!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input("[Game saved! Press enter to continue.]")
                        hub()
                    elif int(cl.Player.gold) <= 200:
                        print(c.yellow+"You need more money! You currently have "+str(cl.Player.gold)+" and you need 200!")
                        input("[Press enter to continue.]")
                        hub()
                elif buyh=="n":
                    print("Oh, Okay.")
                    t.sleep(1)
                    shop()
                else:
                    print("I'm not sure if I understand...")
                    t.sleep(1.25)
            elif question_q=="3":
                cl.show_paladin()
                buyj=input(c.yellow+"You currently have "+str(cl.Player.gold)+" gold. Would you like to purchase the Paladin class for 200 gold? (Y/N)"+c.reset+" >>>"+c.violet).strip().lower()
                if buyj=="y":
                    if int(cl.Player.gold) >= 200:
                        cl.Player.hphp=cl.Paladin.hp
                        cl.Player.att=cl.Paladin.att
                        cl.Player.agi=cl.Paladin.agi
                        cl.Player.deff=cl.Paladin.deff
                        cl.Player.mp=cl.Paladin.mp
                        cl.Player.gold -= 200
                        print("You are now a Paladin!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input('[Game saved! Press enter to continue.]')
                        hub()
                    elif int(cl.Player.gold) <= 200:
                        print(c.yellow+"You need more money! You currently have "+str(cl.Player.gold)+" and you need 200!")
                        input('[Press enter to continue.]')
                        hub()
                elif buyj=="n":
                    print("Oh, Okay.")
                    t.sleep(1)
                    shop()
            else:
                print(c.yellow+"I'm not sure if I understand...")
                t.sleep(1.25)
                shop()
        elif question=="3":
            print(c.yellow+"You decide to go back to the town.")
            t.sleep(1.25)
            hub()
        else:
            print(c.yellow+"I'm not sure if I understand...")
            t.sleep(1.25)
            shop()
예제 #33
0
def handle_escape_menu():
    choices = ["Save and exit to main menu", "Back"]
    choice = menu("Escape Menu", choices, 30)
    if choice == 0:
        save.save_game()
        game.alive = False
예제 #34
0
 def manage_input_field(self, game_input):
     if game_input.type == InputType.KEY:
         if game_input.value == tcod.KEY_UP \
                 or game_input.value == tcod.KEY_LEFT \
                 or game_input.value == tcod.KEY_DOWN \
                 or game_input.value == tcod.KEY_RIGHT \
                 or game_input.value == tcod.KEY_KP1 \
                 or game_input.value == tcod.KEY_KP2 \
                 or game_input.value == tcod.KEY_KP3 \
                 or game_input.value == tcod.KEY_KP4 \
                 or game_input.value == tcod.KEY_KP6 \
                 or game_input.value == tcod.KEY_KP7 \
                 or game_input.value == tcod.KEY_KP8 \
                 or game_input.value == tcod.KEY_KP9:
             coordinates = (0, 0)
             if game_input.value == tcod.KEY_UP or game_input.value == tcod.KEY_KP8:
                 coordinates = (0, -1)
             elif game_input.value == tcod.KEY_KP7:
                 coordinates = (-1, -1)
             elif game_input.value == tcod.KEY_LEFT or game_input.value == tcod.KEY_KP4:
                 coordinates = (-1, 0)
             elif game_input.value == tcod.KEY_KP1:
                 coordinates = (-1, 1)
             elif game_input.value == tcod.KEY_DOWN or game_input.value == tcod.KEY_KP2:
                 coordinates = (0, 1)
             elif game_input.value == tcod.KEY_KP3:
                 coordinates = (1, 1)
             elif game_input.value == tcod.KEY_RIGHT or game_input.value == tcod.KEY_KP6:
                 coordinates = (1, 0)
             elif game_input.value == tcod.KEY_KP9:
                 coordinates = (1, -1)
             attacked = self.game_map.move_monster(self.player.entity,
                                                   coordinates)
             if attacked:
                 BattleAbilityAttackPlayer.reset_turn(self.player.entity)
             else:
                 BattleAbilityMoveToTarget.reset_turn(self.player.entity)
             self.fov_recompute = True
             self.player_took_action = True
     elif game_input.type == InputType.CHAR:
         if game_input.value == 's' and game_input.key.lctrl:
             save_game(self.player)
             self.need_confirm = {'action': 'save'}
             return {'action': 'cancel'}
         elif game_input.value == '>':
             if self.game_map.field[self.player.entity.x][
                     self.player.entity.y].stairs:
                 self.go_downstairs()
         elif game_input.value == 's':
             self.player.entity.reset_turn(100)
             self.player_took_action = True
         elif game_input.value == '5':
             if self.data is None:
                 self.data = {'long_rest': 100}
         elif game_input.value == ',':
             BattleAbilityPickItemUp.use_ability(self.player.entity)
             self.player_took_action = True
         elif game_input.value == 'i':
             inventory_scene = InventoryScene(self.player,
                                              self,
                                              mode=InventoryMode.USE)
             return {'action': 'change_scene', 'scene': inventory_scene}
         elif game_input.value == 'd':
             inventory_scene = InventoryScene(self.player,
                                              self,
                                              mode=InventoryMode.DROP)
             return {'action': 'change_scene', 'scene': inventory_scene}
         elif game_input.value == 'a':
             ability_scene = AbilityScene(self.player, self)
             return {'action': 'change_scene', 'scene': ability_scene}
예제 #35
0
def defenseTrain():
    c()
    input(co.c + '---Press Enter to start---')
    c()
    numbers = ['1', '2', '3']
    game = random.choice(numbers)
    if game == '1':
        s(random.randint(1, 5))
        print('ATTACK')
        print()
        s(2)
        s(random.randint(1, 5))
        print('ATTACK')
        print()
        s(2)
        s(random.randint(1, 5))
        then = time.time()
        input('DEFEND')
        breactionTime = time.time() - then
        s(2)
        c()
    elif game == '2':
        s(random.randint(1, 5))
        then = time.time()
        input('DEFEND')
        reactionTime = time.time() - then
        print()
        s(2)
        s(random.randint(1, 5))
        print('ATTACK')
        print()
        s(2)
        s(random.randint(1, 5))
        then = time.time()
        input('DEFEND')
        reactionTimeTwo = time.time() - then
        print()
        s(2)
        c()
        if reactionTime <= reactionTimeTwo:
            breactionTime = reactionTime
        else:
            breactionTime = reactionTimeTwo
    elif game == '3':
        s(random.randint(1, 5))
        print('ATTACK')
        print()
        s(2)
        s(random.randint(1, 5))
        then = time.time()
        input('DEFEND')
        reactionTime = time.time() - then
        print()
        s(random.randint(1, 5))
        then = time.time()
        input('DEFEND')
        reactionTimeTwo = time.time() - then
        s(2)
        c()
        if reactionTime <= reactionTimeTwo:
            breactionTime = reactionTime
        elif reactionTime >= reactionTimeTwo:
            breactionTime = reactionTimeTwo
    if int(round(breactionTime * 1000)) <= 0.01:
        print(co.r + 'You failed! Try again next time.')
        s(2)
    else:
        print(colorDef())
        anim.defenseAnim()
        xpGain = 0
        dfcGain = 0
        print(co.g +
              f"Your best reaction time was {breactionTime*1000:.0f} ms")
        s(2)
        if round(breactionTime * 1000) < cl.highScores.defense:
            cl.highScores.defense = round(breactionTime * 1000)
        if cl.Dragon.hap >= 30:
            cl.Dragon.xp += 20 - round(breactionTime * 10)
            xpGain += 20 - round(breactionTime * 10)
            if cl.Dragon.hap >= 80:
                cl.Dragon.xp += 5
                xpGain += 5
        if round(breactionTime * 10) < 6 and cl.Dragon.hap >= 30:
            cl.Dragon.dfc += 5 - math.floor(breactionTime * 10)
            dfcGain += 5 - math.floor(breactionTime * 10)
            if cl.Dragon.hap >= 90:
                cl.Dragon.dfc += 1
                dfcGain += 1
        gain(xpGain, dfcGain, 'defense')
    if cl.Dragon.hap >= 70:
        cl.Dragon.hap -= round((110 - cl.Dragon.hap) * .25)
    elif cl.Dragon.hap < 70 and cl.Dragon.hap >= 40:
        cl.Dragon.hap -= round((90 - cl.Dragon.hap) * .25)
    else:
        cl.Dragon.hap -= round((80 - cl.Dragon.hap) * .25)
    if cl.Dragon.hap < 0:
        cl.Dragon.hap = 0
    sav.save_game()
    sav.save_scores()
예제 #36
0
def shop():
    print(c.clear)
    while True:
        question = input(
            c.yellow +
            "Welcome to the shop! Would you like to see our professions, masteries, or would you like to leave? (1), (2), (3)"
            + c.reset + " >>>" + c.violet).strip()
        if question == "1":
            question_one = input(
                c.yellow +
                "Okay, would you like to see the the Rogue, Cleric, or Sellsword? (1),(2),(3)"
                + c.reset + " >>>" + c.violet).strip()
            if question_one == "1":
                cl.show_rogue()
                buyr = input(
                    c.yellow + "You currently have " + str(cl.Player.gold) +
                    " gold. Would you like to purchase the Rogue class for 100 gold? (Y/N)"
                    + c.reset + " >>>" + c.violet).strip().lower()
                if buyr == "y":
                    if int(cl.Player.gold) >= 100:
                        cl.Player.hp = cl.Rogue.hp
                        cl.Player.att = cl.Rogue.att
                        cl.Player.agi = cl.Rogue.agi
                        cl.Player.deff = cl.Rogue.deff
                        cl.Player.mp = cl.Rogue.mp
                        cl.Player.gold -= 100
                        print(c.yellow + "You are now a Rogue!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input("[Game saved! Press enter to continue.]")
                        hub()
                    if int(cl.Player.gold) < 100:
                        print(c.yellow +
                              "You need more money! You currently have " +
                              str(cl.Player.gold) + " and you need 100!")
                        input("[Press enter to continue.]")
                        hub()
                elif buyr == "n":
                    print(c.yellow + "Oh, okay.")
                    t.sleep(1)
                    shop()
            elif question_one == "2":
                cl.show_cleric()
                buyd = input(
                    c.yellow + "You currently have " + str(cl.Player.gold) +
                    " gold. Would you like to purchase the Cleric class for 100 gold? (Y/N)"
                    + c.reset + " >>>" + c.violet).strip().lower()
                if buyd == "y":
                    if int(cl.Player.gold) >= 100:
                        cl.Player.hp = cl.Cleric.hp
                        cl.Player.att = cl.Cleric.att
                        cl.Player.agi = cl.Cleric.agi
                        cl.Player.deff = cl.Cleric.deff
                        cl.Player.mp = cl.Cleric.mp
                        cl.Player.gold -= 100
                        print(c.yellow + "You are now a Cleric!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input("[Press enter to continue.]")
                        hub()
                    elif int(cl.Player.gold) <= 100:
                        print(c.yellow +
                              "You need more money! You currently have " +
                              str(cl.Player.gold) + " and you need 100!")
                        hub()
                elif buyd == "n":
                    print(c.yellow + "Oh, okay.")
                    t.sleep(1)
                    shop()
            elif question_one == "3":
                cl.show_sellsword()
                buyf = input(
                    c.yellow + "You currently have " + str(cl.Player.gold) +
                    " gold. Would you like to purchase the Sellsword class for 100 gold? (Y/N)"
                    + c.reset + " >>>" + c.violet).strip().lower()
                if buyf == "y":
                    if int(cl.Player.gold) >= 100:
                        cl.Player.hp = cl.Sellsword.hp
                        cl.Player.att = cl.Sellsword.att
                        cl.Player.agi = cl.Sellsword.agi
                        cl.Player.deff = cl.Sellsword.deff
                        cl.Player.mp = cl.Sellsword.mp
                        cl.Player.gold -= 100
                        print(c.yellow + "You are now a Sellsword!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input("[Game saved! Press enter to continue.]")
                        hub()
                    elif int(cl.Player.gold) <= 100:
                        print(c.yellow +
                              "You need more money! You currently have " +
                              str(cl.Player.gold) + " and you need 100!")
                        input("[Press enter to continue]")
                        hub()
                elif buyf == "n":
                    print(c.yellow + "Oh, okay.")
                    t.sleep(1)
                    shop()
                else:
                    print(c.yellow + "I'm not sure if I understand...")
                    t.sleep(1.25)
                    shop()
        elif question == "2":
            question_q = input(
                c.yellow +
                "Our masteries are the Assassin, Wizard, Paladin. What would you like to see? (1), (2), (3)"
                + c.reset + " >>>" + c.violet).strip()
            if question_q == "1":
                cl.show_assassin()
                buyg = input(
                    c.yellow + "You currently have " + str(cl.Player.gold) +
                    " gold. Would you like to purchase the Assassin class for 200 gold? (Y/N)"
                    + c.reset + " >>>" + c.violet).strip().lower()
                if buyg == 'y':
                    if int(cl.Player.gold) >= 200:
                        cl.Player.hp = cl.Assassin.hp
                        cl.Player.att = cl.Assassin.att
                        cl.Player.agi = cl.Assassin.agi
                        cl.Player.deff = cl.Assassin.deff
                        cl.Player.mp = cl.Assassin.mp
                        cl.Player.gold -= 200
                        print(c.yellow + "You are now an Assassin!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input("[Game saved! Press enter to continue.]")
                        hub()
                    elif int(cl.Player.gold) <= 200:
                        print(c.yellow +
                              "You need more money! You currently have " +
                              str(cl.Player.gold) + " and you need 200!")
                        input("[Press enter to continue.]")
                        hub()
                elif buyg == 'n':
                    print(c.yellow + "Oh, okay.")
                    t.sleep(1)
                    shop()
                else:
                    print("I'm not sure if I understand...")
                    t.sleep(1.25)
                    shop()
            elif question_q == "2":
                cl.show_wizard()
                buyh = input(
                    c.yellow + "You currently have " + str(cl.Player.gold) +
                    " gold. Would you like to purchase the Wizard class for 200 gold? (Y/N)"
                    + c.reset + " >>>" + c.violet).strip().lower()
                if buyh == "y":
                    if int(cl.Player.gold) >= 200:
                        cl.Player.hp = cl.Wizard.hp
                        cl.Player.att = cl.Wizard.att
                        cl.Player.agi = cl.Wizard.agi
                        cl.Player.deff = cl.Wizard.deff
                        cl.Player.mp = cl.Wizard.mp
                        cl.Player.gold -= 200
                        print(c.yellow + "You are now a Wizard!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input("[Game saved! Press enter to continue.]")
                        hub()
                    elif int(cl.Player.gold) <= 200:
                        print(c.yellow +
                              "You need more money! You currently have " +
                              str(cl.Player.gold) + " and you need 200!")
                        input("[Press enter to continue.]")
                        hub()
                elif buyh == "n":
                    print("Oh, Okay.")
                    t.sleep(1)
                    shop()
                else:
                    print("I'm not sure if I understand...")
                    t.sleep(1.25)
            elif question_q == "3":
                cl.show_paladin()
                buyj = input(
                    c.yellow + "You currently have " + str(cl.Player.gold) +
                    " gold. Would you like to purchase the Paladin class for 200 gold? (Y/N)"
                    + c.reset + " >>>" + c.violet).strip().lower()
                if buyj == "y":
                    if int(cl.Player.gold) >= 200:
                        cl.Player.hphp = cl.Paladin.hp
                        cl.Player.att = cl.Paladin.att
                        cl.Player.agi = cl.Paladin.agi
                        cl.Player.deff = cl.Paladin.deff
                        cl.Player.mp = cl.Paladin.mp
                        cl.Player.gold -= 200
                        print("You are now a Paladin!")
                        t.sleep(1)
                        cl.show_player()
                        print()
                        save.save_game()
                        input('[Game saved! Press enter to continue.]')
                        hub()
                    elif int(cl.Player.gold) <= 200:
                        print(c.yellow +
                              "You need more money! You currently have " +
                              str(cl.Player.gold) + " and you need 200!")
                        input('[Press enter to continue.]')
                        hub()
                elif buyj == "n":
                    print("Oh, Okay.")
                    t.sleep(1)
                    shop()
            else:
                print(c.yellow + "I'm not sure if I understand...")
                t.sleep(1.25)
                shop()
        elif question == "3":
            print(c.yellow + "You decide to go back to the town.")
            t.sleep(1.25)
            hub()
        else:
            print(c.yellow + "I'm not sure if I understand...")
            t.sleep(1.25)
            shop()