2015-07-19 50 views
-6
# players stats and elements 
player_health = 100 
player_attack.earth = 20 
player_attack.air =10 
player_attack.fire = 15 
player_attack.water = 12 
ogre_health = 75 
ogre_attack = 15 

# main code 
player_name = input('What is your name, Guardian? ') 

print('Hello ' + player_name + ' the Guardian') 

player_element = input('Would you like to be the Guardian of Air, Earth, Fire or Water? ') 

if player_element == 'Air': 
    print('You have been granted the powers of the Air, Guardian.\ 
You now have the powers of the Wind and Sky.') 

if player_element == 'Earth': 
    print('You have been granted the powers of the Earth, Guardian.\ 
You now have the powers of the Earth.') 

if player_element == 'Fire': 
    print('You have been granted the powers of Fire, Guardian.\ 
You now have the powers of Fire. Do not destroy as you wish.') 

if player_element == 'Water': 
    print('You have been granted the powers of Water, Guardian.\ 
You now have the powers to control the oceans and water.') 

print('There is an enemy in the distance! What do you do?') 

player_action = input('What do you do ' + player_name + '? ' + 'Type A to attack ') 
if player_action == 'A': 
    enemy_health = enemy_health - power 

print('The enemy\'s health is at ' + str(enemy_health) + ' Keep attacking!') 

player_action = input('What do you do ' + player_name + '? ' + 'Type A to attack ') 
if player_action == 'A': 

    if player_element == 'Water': 
     ogre_health = ogre_health - player_attack.water 

print('The enemy\'s health is at ' + str(ogre_health) + ' Keep attacking!') 

这是我的代码。 它给我的错误cannot define player_attack.earth 为什么?我定义了它。这里有什么问题? 我正在使用python 3.4.3为什么我的变量没有被定义?

+2

请[编辑]你的问题,包括**全文**追溯的。使用'{}'代码格式化按钮来正确地格式化您的代码。 – MattDMo

+2

什么是“playerAttack”?这是一堂课吗?它是否已经有了“地球”字段? – Carcigenicate

+0

即时通讯新的蟒蛇,所以我不知道太多。这是所有的代码 –

回答

相关问题