我在输入问题时遇到了一些问题,该问题应该允许玩家选择 5 场比赛之一。我使用了以下代码。
def racechoice():
players.race = input('After you get a chance to think, you choose to be...') #Here race is chosen
if players.race == "dwarf" or "Dwarf": #Race starting stats
players.race = "Dwarf"
players.level = 1
players.strength = 12
players.agility = 6
players.inteligence = 8
players.vitality = 14
elif players.race == "Orc" or "orc":
players.race = "Orc"
players.level = 1
players.strength = 14
players.agility = 10
players.inteligence = 4
players.vitality = 12
elif players.race == "elf" or "Elf":
players.level = 1
players.race = "Elf"
players.strength = 8
players.agility = 13
players.inteligence = 12
players.vitality = 7
elif players.race == "Human" or "human":
players.level = 1
players.race = "Human"
players.strength = 10
players.agility = 10
players.inteligence = 10
players.vitality = 10
elif players.race == "gnome" or "Gnome":
players.race = "Gnome"
players.strength = 5
players.agility = 11
players.intelligence = 17
players.vitality = 7
当调用显示玩家的统计数据时:
def stats():
print(players.name)
print(players.race)
print("Level: "+ str(players.level) +" Strength: "+ str(players.strength) +" Agility: " + str(players.agility) +" Inteligence: "+ str(players.inteligence) +" Vitality: "+ str(players.vitality))
无论玩家选择什么,它都会以具有 Dwarf 属性的 Dwarf 形式返回。我是 Python 新手,我想知道,我没有正确使用 if/elif 语句吗?ex) 在你有机会思考之后,你选择成为……兽人 Ecep 矮人等级:1 力量:12 敏捷:6 智力:8 活力:14