Esempio n. 1
0
def levelUp():  #levelup!
    os.system('cls')
    music.playSE('Sounds/Levelup.wav')
    dat.characterCurrentHP = dat.characterHP
    dat.characterCurrentMP = dat.characterMP
    print('\n\n\n\n\n\n      You are now Level {}').format(dat.characterLV)
    os.system('pause')
Esempio n. 2
0
def shopProcessing():
    while msvcrt.kbhit():
        msvcrt.getwch()

    dat.PlayerInput = raw_input()

    if dat.PlayerInput.upper() == '1':
        if dat.Gold > 39:
            dat.Gold -= 40
            equipment.changeWep('dagger')  #This string depicts what gets equipped on purchase. See 'equipment.py'
        menu.Refresh(2)
    elif dat.PlayerInput.upper() == '7':
        if dat.Gold > 9 and dat.equipmentPotionCount < 10:  #Max HP potions = 10
            music.playSE('Sounds/Equip.wav')
            dat.Gold -= 10
            dat.equipmentPotionCount += 1
    elif dat.PlayerInput.upper() == '8':
        if dat.Gold > 19 and dat.equipmentManaPotionCount < 3:  #Max MP potions = 3
            music.playSE('Sounds/Equip.wav')
            dat.Gold -= 20
            dat.equipmentManaPotionCount += 1
    elif dat.PlayerInput.upper() == 'GOLD':  #hidden command to get gold
        os.system('cls')
        dat.Gold += 100
        menu.Refresh(2)
    elif dat.PlayerInput.upper() == '2':
        if dat.Gold > 99:
            dat.Gold -= 100
            equipment.changeWep('shortsword')
        menu.Refresh(2)
    elif dat.PlayerInput.upper() == '3':
        if dat.Gold > 299:
            dat.Gold -= 300
            equipment.changeWep('longsword')
        menu.Refresh(2)
    elif dat.PlayerInput.upper() == '4':
        if dat.Gold > 99:
            dat.Gold -= 100
            equipment.changeArmor('leatherarmor')
        menu.Refresh(2)
    elif dat.PlayerInput.upper() == '5':
        if dat.Gold > 399:
            dat.Gold -= 400
            equipment.changeArmor('platearmor')
        menu.Refresh(2)
    elif dat.PlayerInput.upper() == '6':
        if dat.Gold > 49:
            dat.Gold -= 50
            equipment.changeShield('shield')
        menu.Refresh(2)
    elif dat.PlayerInput.upper() == 'A':  #Exit
        dat.sceneTransition = 1
        menu.Refresh(1)
    elif dat.PlayerInput.upper() == 'I':
        menu.Refresh(4)
        dat.characterMenuFlag = 2
        characterProcessing()
        menu.Refresh(2)
    else:
        menu.Refresh(2)
Esempio n. 3
0
def changeArmor(armor):  #Change player's Armor
    music.playSE('Sounds/Equip.wav')
    if armor == 'leatherarmor':
        dat.equipmentArmor = 'Leather Armor'
        dat.equipmentArmorDEF = 4  #Alters armor defense stat based off of the sent 'armor' string
    if armor == 'platearmor':
        dat.equipmentArmor = 'Plate Armor'
        dat.equipmentArmorDEF = 9
Esempio n. 4
0
def changeWep(weapon):  #Change player's Weapon
    music.playSE('Sounds/Equip.wav')
    if weapon == 'dagger':
        dat.equipmentWeapon = 'Dagger'
        dat.equipmentWeaponATT = 3  #Alters weapon attack stat based off of the sent 'weapon' string
    if weapon == 'shortsword':
        dat.equipmentWeapon = 'Shortsword'
        dat.equipmentWeaponATT = 11
    if weapon == 'longsword':
        dat.equipmentWeapon = 'Longsword'
        dat.equipmentWeaponATT = 21
Esempio n. 5
0
def spinSlash():  #Only one skill is in the game currently
    #switches.hitAllEnemies = 1
    music.playSE('Sounds/Skill1.wav')
    os.system('cls' if os.name == 'nt' else 'clear')
    battle.variables.battleMessage = 'Player uses Spinslash!'
    battle.battleWindowRefresh(battle.variables.battleMessage)
    time.sleep(1)

    if battle.variables.enemy1arr[1] > 0:  #First enemy
        result = math.ceil(
            (battle.variables.player[3] - battle.variables.enemy1arr[4]) * 0.9)
        battle.variables.enemy1arr[1] -= int(result)
        os.system('cls' if os.name == 'nt' else 'clear')
        battle.variables.battleMessage = '{} took {} damage!'.format(
            battle.variables.enemy1Type, int(result))
        battle.battleWindowRefresh(battle.variables.battleMessage)
        music.playSE('Sounds/Damage2.wav')
        time.sleep(0.5)

    if battle.variables.enemy2arr[1] > 0:  #Second enemy
        result = math.ceil(
            (battle.variables.player[3] - battle.variables.enemy2arr[4]) * 0.9)
        battle.variables.enemy2arr[1] -= int(result)
        os.system('cls' if os.name == 'nt' else 'clear')
        battle.variables.battleMessage = '{} took {} damage!'.format(
            battle.variables.enemy2Type, int(result))
        battle.battleWindowRefresh(battle.variables.battleMessage)
        music.playSE('Sounds/Damage2.wav')
        time.sleep(0.5)

    if battle.variables.enemy3arr[1] > 0:  #Third enemy
        result = math.ceil(
            (battle.variables.player[3] - battle.variables.enemy3arr[4]) * 0.9)
        battle.variables.enemy3arr[1] -= int(result)
        os.system('cls' if os.name == 'nt' else 'clear')
        battle.variables.battleMessage = '{} took {} damage!'.format(
            battle.variables.enemy3Type, int(result))
        battle.battleWindowRefresh(battle.variables.battleMessage)
        music.playSE('Sounds/Damage2.wav')
        time.sleep(0.5)
Esempio n. 6
0
def changeShield(shield):  #Change player's Shield
    music.playSE('Sounds/Equip.wav')
    if shield == 'shield':
        dat.equipmentShield = 'Shield'
        dat.equipmentArmorBlock = 0.25  #.25 means 25%. This gives the player an additional 25% damage reduction while blocking
        dat.equipmentShieldDEF = 2  #The shield's defense stat
Esempio n. 7
0
def enemyTurn():  #enemy
    if variables.enemy1arr[1] > 0:  #enemy 1
        if variables.playerDefending == 0:
            time.sleep(1)
            music.playSE("Sounds\Damage.wav")
            damage = variables.enemy1arr[3] - variables.player[4]
            if damage < 0:  #Catch so enemy cannot heal player for having negative rolls
                damage = 0
            else:
                variables.player[1] -= damage
            os.system('cls' if os.name == 'nt' else 'clear')
            variables.battleMessage = '{} attacks! Player takes {} damage!!'.format(variables.enemy1Type,damage)
            battleWindowRefresh(variables.battleMessage)
        else:  #Catch if player is defending
            time.sleep(1)
            music.playSE("Sounds\Defense.wav")
            damage = math.ceil((variables.enemy1arr[3] - variables.player[4]) * variables.playerBlock)
            if damage < 0:
                damage = 0
            else:
                variables.player[1] -= int(damage)
            os.system('cls' if os.name == 'nt' else 'clear')
            variables.battleMessage = '{} attacks! Player takes {} damage!!'.format(variables.enemy1Type, int(damage))
            battleWindowRefresh(variables.battleMessage)
        if variables.player[1] < 1:
            return
    if variables.enemy2arr[1] > 0:  #enemy 2
        if variables.playerDefending == 0:
            time.sleep(1)
            music.playSE("Sounds\Damage.wav")
            damage = variables.enemy2arr[3] - variables.player[4]
            if damage < 0:  #Catch so enemy cannot heal player for having negative rolls
                damage = 0
            else:
                variables.player[1] -= damage
            os.system('cls' if os.name == 'nt' else 'clear')
            variables.battleMessage = '{} attacks! Player takes {} damage!!'.format(variables.enemy2Type,damage)
            battleWindowRefresh(variables.battleMessage)
        else:  #Catch if player is defending
            time.sleep(1)
            music.playSE("Sounds\Defense.wav")
            damage = math.ceil((variables.enemy2arr[3] - variables.player[4]) * variables.playerBlock)
            if damage < 0:
                damage = 0
            else:
                variables.player[1] -= int(damage)
            os.system('cls' if os.name == 'nt' else 'clear')
            variables.battleMessage = '{} attacks! Player takes {} damage!!'.format(variables.enemy2Type, int(damage))
            battleWindowRefresh(variables.battleMessage)
    if variables.enemy3arr[1] > 0:  #enemy 3
        if variables.playerDefending == 0:
            time.sleep(1)
            music.playSE("Sounds\Damage.wav")
            damage = variables.enemy3arr[3] - variables.player[4]
            if damage < 0:  #Catch so enemy cannot heal player for having negative rolls
                damage = 0
            else:
                variables.player[1] -= damage
            os.system('cls' if os.name == 'nt' else 'clear')
            variables.battleMessage = '{} attacks! Player takes {} damage!!'.format(variables.enemy3Type, int(damage))
            battleWindowRefresh(variables.battleMessage)
        else:  #Catch if player is defending
            time.sleep(1)
            music.playSE("Sounds\Defense.wav")
            damage = math.ceil((variables.enemy3arr[3] - variables.player[4]) * variables.playerBlock)
            if damage < 0:
                damage = 0
            else:
                variables.player[1] -= int(damage)
            os.system('cls' if os.name == 'nt' else 'clear')
            variables.battleMessage = '{} attacks! Player takes {} damage!!'.format(variables.enemy3Type, damage)
            battleWindowRefresh(variables.battleMessage)

    time.sleep(1)
    variables.playerDefending = 0  #Remove player defending flag
    variables.PlayerTurn = 1  #Flag up for player turn
Esempio n. 8
0
def battleProcessing(input):

    if input.upper() == 'K':  #Use the only skill you have! Spinslash
        os.system('cls' if os.name == 'nt' else 'clear')
        battleWindowRefresh(variables.battleMessage)
        variables.PlayerTurn = 0  #Expends the player's turn here
        if variables.player[2] > 4:
            variables.player[2] -= 5
            skill.spinSlash()
        else:  #Catch for if player doesn't have 5 mp
            os.system('cls' if os.name == 'nt' else 'clear')
            variables.battleMessage = 'Not enough MP!'
            battleWindowRefresh(variables.battleMessage)
    elif input.upper() == 'G':  #Mana recovery potion
        os.system('cls' if os.name == 'nt' else 'clear')
        battleWindowRefresh(variables.battleMessage)
        if dat.equipmentManaPotionCount > 0:  #Check for potions
            if variables.player[2] < dat.characterMP:
                variables.player[2] = dat.characterMP
                dat.equipmentManaPotionCount -= 1  #Remove 1 potion
                music.playSE("Sounds/Recovery.wav")
                time.sleep(0.5)  #Adds delay to text display, allowing the player to read the battle messages
                os.system('cls' if os.name == 'nt' else 'clear')
                variables.PlayerTurn = 0
                variables.battleMessage = 'Player uses a Mana Potion!! MP Recovered!!!'
                battleWindowRefresh(variables.battleMessage)
            else:  #Catch if MP is full
                os.system('cls' if os.name == 'nt' else 'clear')
                variables.battleMessage = 'You are at maximum MP!'
                battleWindowRefresh(variables.battleMessage)
    elif input.upper() == 'H':  #Health potion
        os.system('cls' if os.name == 'nt' else 'clear')
        battleWindowRefresh(variables.battleMessage)
        if dat.equipmentPotionCount > 0:  #Check for potions
            recoveredHP = int(dat.characterHP * .40)
            if recoveredHP + variables.player[1] > dat.characterHP:  #If restored hp makes current HP higher than max, reduces current amount.
                recoveredHP = (recoveredHP + variables.player[1]) - dat.characterHP
                variables.player[1] = dat.characterHP
                dat.equipmentPotionCount -= 1
                music.playSE("Sounds/Recovery.wav")
                time.sleep(0.5)
                os.system('cls' if os.name == 'nt' else 'clear')
                variables.PlayerTurn = 0
                variables.battleMessage = 'Player uses a Potion! Restored {} HP!!'.format(recoveredHP)
                battleWindowRefresh(variables.battleMessage)
            elif variables.player[1] == dat.characterHP:  #Catch if HP is full
                os.system('cls' if os.name == 'nt' else 'clear')
                variables.battleMessage = 'You are at maximum HP!'
                battleWindowRefresh(variables.battleMessage)
            else:  #Normal usage of HP potion, adds recovered amount
                variables.player[1] += recoveredHP
                dat.equipmentPotionCount -= 1
                music.playSE("Sounds/Recovery.wav")
                time.sleep(0.5)
                os.system('cls' if os.name == 'nt' else 'clear')
                variables.PlayerTurn = 0
                variables.battleMessage = 'Player uses a Potion! Restored {} HP!!'.format(recoveredHP)
                battleWindowRefresh(variables.battleMessage)
        else:  #No potions
            os.system('cls' if os.name == 'nt' else 'clear')
            variables.battleMessage = 'No Potions!'
            battleWindowRefresh(variables.battleMessage)
    elif input.upper() == 'R':  #Run Away!!!
        os.system('cls' if os.name == 'nt' else 'clear')
        runRoll = random.randint(1, 100)
        if runRoll > 60:  #40% chance to run away
            variables.run = 1
            dat.sceneTransition = 1
        else:  #Fail
            os.system('cls' if os.name == 'nt' else 'clear')
            variables.PlayerTurn = 0
            variables.battleMessage = 'Unable to run!'
            battleWindowRefresh(variables.battleMessage)
    elif input.upper() == 'D':  #Defend for 1 turn, reducing incoming damage
        os.system('cls' if os.name == 'nt' else 'clear')
        battleWindowRefresh(variables.battleMessage)
        variables.playerDefending = 1  #Set defending flag to 'yes'
        time.sleep(0.5)
        os.system('cls' if os.name == 'nt' else 'clear')
        variables.PlayerTurn = 0
        variables.battleMessage = 'Player defends!'
        battleWindowRefresh(variables.battleMessage)
    elif input.upper() == 'A':  #Attack selected target
        os.system('cls' if os.name == 'nt' else 'clear')
        battleWindowRefresh(variables.battleMessage)
        music.playSE("Sounds/Damage.wav")
        time.sleep(0.5)

        if variables.target == 1:  #Enemy 1
            result = variables.player[3] - variables.enemy1arr[4]
            variables.enemy1arr[1] -= result  #Damage
            if variables.enemy1arr[1] < 0:  #Catch to make enemy hp = 0 if they are negative
                variables.enemy1arr[1] = 0
        if variables.target == 2:  #Enemy 2
            result = variables.player[3] - variables.enemy2arr[4]
            variables.enemy2arr[1] -= result
            if variables.enemy2arr[1] < 0:
                variables.enemy2arr[1] = 0
        if variables.target == 3:  #Enemy 3
            result = variables.player[3] - variables.enemy3arr[4]
            variables.enemy3arr[1] -= result
            if variables.enemy3arr[1] < 0:
                variables.enemy3arr[1] = 0

        os.system('cls' if os.name == 'nt' else 'clear')
        variables.PlayerTurn = 0
        variables.battleMessage = 'Player attacks!! Enemy took {} damage!'.format(result)
        battleWindowRefresh(variables.battleMessage)
    elif input.upper() == 'S':  #Switch targets
        os.system('cls' if os.name == 'nt' else 'clear')
        battleWindowRefresh(variables.battleMessage)
        variables.target += 1
        if variables.target == 4:  #Reset to 1 if the integer is impossible
            variables.target = 1

        if variables.target == 1 and variables.enemy1arr[1] < 1:  #Check if enemy is alive before drawing an arrow
            variables.target = variables.target + 1
        if variables.target == 2 and variables.enemy2arr[1] < 1:
            variables.target += 1
        if variables.target == 3 and variables.enemy3arr[1] < 1:
            variables.target = 1

        if variables.target == 1:  #Draw which variable has the target arrow
            variables.target1 = '>>>'
            variables.target2 = '   '
            variables.target3 = '   '
        if variables.target == 2:
            variables.target1 = '   '
            variables.target2 = '>>>'
            variables.target3 = '   '
        if variables.target == 3:
            variables.target1 = '   '
            variables.target2 = '   '
            variables.target3 = '>>>'

        os.system('cls' if os.name == 'nt' else 'clear')
        variables.battleMessage = "Switched!!!"
        battleWindowRefresh(variables.battleMessage)
    elif input.upper() == "M":  # Magic
        os.system('cls' if os.name == 'nt' else 'clear')
        battleWindowRefresh(variables.battleMessage)
        if variables.player[2] > 24:  # Test Player's MP. If not 25+, cancels action
            music.playSE("Sounds\Spell.wav")
            time.sleep(0.5)

            if variables.target == 1:
                result = (dat.characterMAG - variables.enemy1arr[4]) * 2
                variables.enemy1arr[1] -= int(result)
            if variables.target == 2:
                result = (dat.characterMAG - variables.enemy2arr[4]) * 2
                variables.enemy2arr[1] -= int(result)
            if variables.target == 3:
                result = (dat.characterMAG - variables.enemy3arr[4]) * 2
                variables.enemy3arr[1] -= int(result)

            variables.player[2] = variables.player[2] - 25  # MP cost
            os.system('cls' if os.name == 'nt' else 'clear')
            variables.PlayerTurn = 0
            variables.battleMessage = 'PLAYER casts a spell! ENEMY took {} damage!'.format(result)
            battleWindowRefresh(variables.battleMessage)
        else:  # Not enough MP catch
            os.system('cls' if os.name == 'nt' else 'clear')
            variables.battleMessage = 'Not enough MP!'
            battleWindowRefresh(variables.battleMessage)
    else:
        os.system('cls' if os.name == 'nt' else 'clear')
        battleWindowRefresh(variables.battleMessage)