Python中文
首页
教程
问答
标签
搜索
登录
注册
python3.2脚本挂起第三个函数
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我试图创建一个非常简单的python脚本,它将两个字符放在一起,但是在运行脚本时,它执行脚本用来定义两个字符统计信息的前两个函数,但是当它到达第三个函数时,它就挂起了。在</p> <p>代码如下:</p> <pre><code>#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. ") </code></pre> <p>是的,这段代码是完全未经编辑的,我知道我的评论不是很好。在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>首先,注释必须与代码处于相同的缩进级别。在</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在python中从数据帧列中删除分类值?
5 回答
如何在python中从数据帧列表中删除引号
10 回答
如何在python中从数据帧创建列表
7 回答
如何在Python中从数据帧创建嵌套的JSON
10 回答
如何在Python中从数据帧显示wordcloud
4 回答
如何在Python中从数据帧的时间戳中删除字符
9 回答
如何在Python中从数据帧绘制简单绘图?
10 回答
如何在python中从数据帧行提取具有特定长度的范围?
6 回答
如何在python中从数据帧设置dict中的值
7 回答
如何在Python中从数据库中获得一个结果
4 回答
如何在python中从数据框中绘制分类条形图
3 回答
如何在Python中从数据框中选择特定细节?
6 回答
如何在python中从数据集中删除unicode
5 回答
如何在python中从数据集中删除某些数值?
1 回答
如何在python中从数据集中选择行
7 回答
如何在Python中从数组中删除元素
9 回答
如何在python中从数组中删除单个倒逗号?
6 回答
如何在python中从数组中删除对象?
2 回答
如何在python中从数组中删除引号
7 回答
如何在python中从数组中删除所有最小值
6 回答