我是一名编程初学者,用python制作基于文本的rpg。我有一场老板之战要开始了。我为老板和所有球员创造了进攻的功能。我在这段代码中遇到的问题是,我已经创建了一个布尔值,用于判断老板是否已经轮流攻击过一次。该值以true开头,然后在函数末尾变为false。我已经设置了代码,玩家可以按照他们的速度进行攻击。老板是第一位的。现在战斗继续下去的条件是老板的健康值在0以上。由于某种原因,当我第一次开始战斗时,老板一直在攻击,即使在她的攻击功能结束时,她是否可以攻击的值应该更改为false。如果她不能攻击,代码应该转移到玩家的攻击功能。下面是战斗的代码,boss和player的攻击函数,以及试图更改底部的布尔值
def AriaMove():
target = Player.NocturneEnemy
if Player.Aria.hp > 0:
print("What will Aria do?")
choice = input()
if choice == "attack":
Player.Aria.NormalAttack
if Player.Aria.attack <= target.defense:
damage = 0
target.hp = target.hp - damage
print("Nocturne's health is:")
print(target.hp)
if choice == "healing song: Sereana":
Player.Sereana.hp + 100
print("Sereana's health is:")
print(Player.Sereana.hp)
if choice == "healing song: Lupin":
Player.Lupin.hp + 100
print("Lupin's health is:")
print(Player.Lupin.hp)
if choice == "healing song: Aria":
Player.Aria.hp + 100
print("Aria's health is:")
print(Player.Aria.hp)
if choice == "healing song: Anges":
Player.Anges.hp + 100
print("Anges's health is:")
print(Player.Anges.hp)
if choice == "healing song: Sylph":
Player.Sylph.hp + 100
print("Sylph's health is:")
print(Player.Sylph.hp)
def AngesMove():
target = Player.NocturneEnemy
if Player.Anges.hp > 0:
print("What will Anges do?")
choice = input()
if choice == "attack":
damage = Player.Anges.attack - target.defense
target.hp = target.hp - damage
print("Nocturne's health is:")
print(target.hp)
if choice == "pirouette":
damage = Player.Anges.Pirouette - target.defense
target.hp = target.hp - damage
print("Nocturne's health is:")
print(target.hp)
def SylphMove():
target = Player.NocturneEnemy
if Player.Sylph.hp > 0:
print("What will Sylph do?")
choice = input()
if choice == "attack":
damage = Player.Sylph.attack - target.defense
if Player.Sylph.attack <= target.defense:
damage = 0
target.hp = target.hp - damage
print("Nocturne's health is:")
print(target.hp)
if choice == "health drain":
damage = (Player.Sylph.attack + 20) - target.defense
target.hp = target.hp - damage
Player.Sylph.hp = Player.Sylph.hp + 40
print("Sylph's health is:")
print(Player.Sylph.hp)
print("Nocturne's health is:")
print(target.hp)
def SereanaMove():
target = Player.NocturneEnemy
if Player.Sereana.hp > 0:
print("What will Sereana do?")
choice = input()
if choice == "attack":
damage = Player.Sereana.attack - target.defense
target.hp = target.hp - damage
print(target.hp)
if choice == "paintbrush spear":
damage = (Player.Sereana.attack + 30) - target.defense
target.hp = target.hp - damage
print("Nocturne's health is:")
print(target.hp)
def LupinMove():
target = Player.NocturneEnemy
if Player.Lupin.hp > 0:
print("What will Lupin do?")
choice = input()
if choice == "attack":
damage = Player.Lupin.attack - target.defense
target.hp = target.hp - damage
print("nocturne's health is:")
print(target.hp)
def NocturneAttack():
attackID = random.randint(1, 2)
targetID = random.randint(1, 5)
if attackID == 1:
if targetID == 1 and Player.Sereana.hp > 0:
target = Player.Sereana
Nocturnedamage = Player.NocturneEnemy.attack - target.defense
Player.Sereana.hp = Player.Sereana.hp - Nocturnedamage
print("Sereana's health is:")
print(Player.Sereana.hp)
elif Player.Sereana.hp < 0:
targetID = random.randint(2, 5)
if targetID == 2 and Player.Lupin.hp > 0:
target = Player.Lupin
Nocturnedamage = Player.NocturneEnemy.attack - target.defense
Player.Lupin.hp = Player.Lupin.hp - Nocturnedamage
print("Lupin's health is:")
print(Player.Lupin.hp)
elif Player.Lupin.hp < 0:
targetID = random.randint(1, 5)
if targetID == 3 and Player.Aria.hp > 0:
target = Player.Aria
Nocturnedamage = Player.NocturneEnemy.attack - target.defense
Player.Aria.hp = Player.Aria.hp - Nocturnedamage
print("Aria's health is:")
print(Player.Aria.hp)
elif Player.Aria.hp < 0:
targetID = random.randint(1, 5)
if targetID == 4 and Player.Anges.hp > 0:
target = Player.Anges
Nocturnedamage = Player.NocturneEnemy.attack - target.defense
Player.Anges.hp = Player.Anges.hp - Nocturnedamage
print("Anges's health is:")
print(Player.Anges.hp)
elif Player.Anges.hp < 0:
targetID = random.randint(1, 5)
if targetID == 5 and Player.Sylph.hp > 0:
target = Player.Sylph
Nocturnedamage = Player.NocturneEnemy.attack - target.defense
Player.Sylph.hp = Player.Sylph.hp - Nocturnedamage
print("Sylph's health is:")
print(Player.Sylph.hp)
elif Player.Sylph.hp < 0:
targetID = random.randint(1, 4)
Nocturnedamage = Player.NocturneEnemy.attack - target.defense
if attackID == 2:
if targetID == 1 and Player.Sereana.hp > 0:
target = Player.Sereana
Nocturnedamage = (Player.NocturneEnemy.attack + 30) - target.defense
Player.Sereana.hp = Player.Sereana.hp - Nocturnedamage
print("Sereana's health is:")
print(Player.Sereana.hp)
elif Player.Sereana.hp < 0:
targetID = random.randint(2, 5)
if targetID == 2 and Player.Lupin.hp > 0:
target = Player.Lupin
Nocturnedamage = (Player.NocturneEnemy.attack + 30) - target.defense
Player.Lupin.hp = Player.Lupin.hp - Nocturnedamage
print("Lupin's health is:")
print(Player.Lupin.hp)
elif Player.Lupin.hp < 0:
targetID = random.randint(1, 5)
if targetID == 3 and Player.Aria.hp > 0:
target = Player.Aria
Nocturnedamage = (Player.NocturneEnemy.attack + 30) - target.defense
Player.Aria.hp = Player.Aria.hp - Nocturnedamage
print("Aria's health is:")
print(Player.Aria.hp)
elif Player.Aria.hp < 0:
targetID = random.randint(1, 5)
if targetID == 4 and Player.Anges.hp > 0:
target = Player.Anges
Nocturnedamage = (Player.NocturneEnemy.attack + 30) - target.defense
Player.Anges.hp = Player.Anges.hp - Nocturnedamage
print("Anges's health is:")
print(Player.Anges.hp)
elif Player.Anges.hp < 0:
targetID = random.randint(1, 5)
if targetID == 5 and Player.Sylph.hp > 0:
target = Player.Sylph
Nocturnedamage = (Player.NocturneEnemy.attack + 30) - target.defense
Player.Sylph.hp = Player.Sylph.hp - Nocturnedamage
print("Sylph's health is:")
print(Player.Sylph.hp)
elif Player.Sylph.hp < 0:
targetID = random.randint(1, 4)
Nocturnedamage = (Player.NocturneEnemy.attack + 30) - target.defense
if targetID == 1:
Player.Sereana.hp = Player.Sereana.hp - Nocturnedamage
print("Sereana's health is:")
print(Player.Sereana.hp)
if targetID == 2:
Player.Lupin.hp = Player.Lupin.hp - Nocturnedamage
print("Lupin's health is:")
print(Player.Lupin.hp)
if targetID == 3:
Player.Aria.hp = Player.Aria.hp - Nocturnedamage
print("Aria's health is:")
print(Player.Aria.hp)
if targetID == 4:
Player.Anges.hp = Player.Anges.hp - Nocturnedamage
print("Anges's health is:")
print(Player.Anges.hp)
if targetID == 5:
Player.Sylph.hp = Player.Sylph.hp - Nocturnedamage
print("Sylph's health is:")
print(Player.Sylph.hp)
CanNocturneAttack = True
while Player.NocturneEnemy.hp > 0:
while Player.Sereana.hp > 0 or Player.Lupin.hp > 0 or Player.Aria.hp > 0 or Player.Anges.hp > 0 or Player.Sylph.hp > 0:
if CanNocturneAttack:
NocturneAttack()
CanNocturneAttack = False
while Player.NocturneEnemy.hp > 0:
NocturneAttack()
AriaMove()
AngesMove()
SylphMove()
SereanaMove()
LupinMove()
目前没有回答
相关问题 更多 >
编程相关推荐