我正在尝试制作一个非常简单的 python 脚本,将两个字符放在一起,但是在运行脚本时,它执行脚本用来定义两个字符统计信息的前两个函数,但是当它到达第三个函数时,它只是挂起。
这是代码:
#STAPS: Strength Toughness Agility Perception weapon Skill
#A comparative simulator
import random
#Functions used to define character parameters
#Character 1's parameter function
def char1():
global s1
global t1
global a1
global p1
global dam1
global dt1
global dr1
global ac1
global ws1
s1 = int(input("Char1's Strength? "))
t1 = int(input("Char1's Toughness? "))
a1 = int(input("Char1's Agility? "))
p1 = int(input("Char1's Perception? "))
dam1 = int(input("Char1's Damage? "))
dt1 = int(input("Char1's Damage Threshold? "))
dr1 = int(input("Char1's Damage Resistance? "))
ac1 = int(input("Char1's Armor Class? "))
ws1 = int(input("Char1's Weapon Skill? "))
#Character 2's paramter function
def char2():
global s2
global t2
global a2
global p2
global dam2
global dt2
global dr2
global ac2
global ws2
s2 = int(input("Char2's Strength? "))
t2 = int(input("Char2's Toughness? "))
a2 = int(input("Char2's Agility? "))
p2 = int(input("Char2's Perception? "))
dam2 = int(input("Char2's Damage? "))
dt2 = int(input("Char2's Damage Threshold? "))
dr2 = int(input("Char2's Damage Resistance? "))
ac2 = int(input("Char2's Armor Class? "))
ws2 = int(input("Char2's Weapon Skill? "))
#Main battle function. Ordo Xenos calls this "complex and easy to misuse"
#Jury-rigged way of getting names, why did I include them anyways?
def stapsbatt(c1n,c2n,hp1,hp2):
while hp1 > 0 or hp2 > 0:
#determines original raw acc
char1rawacc = ws1 - ac2
#if statement settles it to minimum 95% acc
if char1rawacc > 95:
char1rawacc = 95
#random int used to determine whether it's a hit or not
char1hitnum = random.randint(0, 100)
if char1rawacc > char1hitnum:
moddam1 = dam1 - dt2
if moddam1 < 0:
moddam1 = 0
rawdam1 = moddam1 * (100 - dr2)
hp2 = hp2 - rawdam1
#Now we move on to doing char2's batt calcs
char2rawacc = ws2 - ac1
if char2rawacc > 95:
char2rawacc = 95
char2hitnum = random.randint(0, 100)
if char2rawacc > char2hitnum:
moddam2 = dam2 - dt1
if moddam2 < 0:
moddam2 = 0
rawdam2 = moddam2 * (100 - dr1)
hp1 = hp1 - rawdam2
if hp1 == 0:
print(c2n, "has won!")
else:
print(c1n, "has won!")
char1()
char2()
stapsbatt("Character 1", "Character 2",400,30)
input("Press enter to exit. ")
是的,这段代码完全未经编辑,我意识到我的评论不是很好。