samedi 7 octobre 2017

Calling a function inside an if and while statement? [on hold]

partyNames = ['Krogg', 'Glinda', 'Geoffrey']
partyHP = [180, 120, 150]
partyAttack = [20, 5, 15]
partyDefense = [20, 20, 15]
partyDead = [False, False, False]

level = [1, 1, 1]
levelMinXP = [100, 0, 0]
levelAttackGain = [0, 0, 0]
levelDefenseGain = [0, 0, 0]
levelMagicGain = [0, 0, 0]

xpGained = [0, 0, 0]
gainXP = [0, 0, 0 ,0 ,0 ,0, 0]
xp = [0, 0, 0, 0, 0, 0]

#Enemy Stats
enemyNames = ['Spider', 'Skeleton', 'Wolf', 'Bear', 'Gremlin', 'Werewolf', 'The Diamond Dragon', 'The Great One']
enemyHP = [10, 120, 150]
enemyAttack = [5, 5, 15]
enemyDefense = [1, 20, 15]
enemyDead = [False, False, False]
enemylevel = [1, 1, 1]
enemygainXP = [100, 0, 0 ,0 ,0 ,0, 0]


#while condition
battleDecided = False

#Choices
def spider():
    while enemyDead == True:
        print('A', enemyNames[0],' appears!')
        print('Krogg does,', partyAttack[0] - enemyDefense[0], 'points of damage to the', enemyNames[0])
        bossHP = bossHP - (partyAttack[0] - enemyDefense[0])
        print('Geoffrey does,', partyAttack[2] - enemyDefense[0], 'points of damage to the boss')
        bossHP = bossHP - (partyAttack[2] - enemyDefense[0])
        print('Glinda heals 5 hp for Krogg!')
        print('Glinda heals 5 hp for Glinda!')
        print('Glinda heals 5 hp for Glinda!')
        partyHP[0] = partyHP[0] + 5
        partyHP[1] = partyHP[1] + 5
        partyHP[2] = partyHP[2] + 5
        print('Spider does', enemyAttack[0] - partyDefense[0], ' points of damage to Krogg')
        print('Spider does', enemyAttack[0] - partyDefense[1], ' points of damage to Glinda')
        print('Spider does', enemyAttack[0] - partyDefense[2], ' points of damage to Geoffrey')
        partyHP[0] = partyHP[0] - (enemyAttack[0] - partyDefense[0])
        partyHP[1] = partyHP[1] - (enemyAttack[0] - partyDefense[1])
        partyHP[2] = partyHP[2] - (enemyAttack[0] - partyDefense[2])
        if enemyHP[0] <= 0:
            print('The spider was defeated. Your party was victorious!')
            print('Krogg gains', enemygainXP[0], '!')
            print('Glinda gains', enemygainXP[0], '!')
            print('Geoffrey gains', enemygainXP[0], '!')
            gainXP[0] = gainXP[0] + 100
            gainXP[1] = gainXP[1] + 100
            gainXP[2] = gainXP[2] + 100
            xpGained[0] = xpGained[0] + 100
            xpGained[1] = xpGained[1] + 100
            xpGained[2] = xpGained[2] + 100
            print('')
            print('Character Status:' )
            print('Krogg (HP:', partyHP[0])
            print('Glinda HP: ', partyHP[1])
            print('Geoffrey HP: ', partyHP[2])
            print('')






spiderS = 1
skeleTon = 2
wolF = 3
beaR = 4
gremLin = 5
wearWolf = 6
thediamondDragon = 7
thegreatOne = 8


print('Krogg, Glinda, and Geoffrey enter the arena!')
print('Six doorways, each labelled with names of different monsters, spawn in front of the party.')
print('Two gate-like openings, appear above the six doorways, labelled "The Diamond Dragon" and "The Great One".') 
round = 1  

while (partyDead[0] == False) and (partyDead[1] == False) and (partyDead[2] == False):

    print('Which door does the party open?')
    print("Spiders            = 1")
    print("Skeleton           = 2")
    print("Wolf               = 3")
    print("Bear               = 4")
    print("Gremlin            = 5")
    print("The Werewolf       = 6")
    print("The Diamond Dragon = 7")
    print("The Great One      = 8")
    partyChoose = input()

    if partyChoose == 1:
        spider()
        print('Round', round)

When I try to call the function in the if statement it doesn't seem to register? I have tried putting the def function both inside and outside of the if and while statements. It's my first time posting here so if I didn't format my post correctly please let me know. Any help would be appreciated. Thanks

Aucun commentaire:

Enregistrer un commentaire