我在python 2.4中尝试过吗?但是它不能正常工作? [英] i tried this in python 2.4? but it is not working properly?

查看:104
本文介绍了我在python 2.4中尝试过吗?但是它不能正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任务3确定相遇的结果当两个角色之间相遇时,结果由以下过程确定:

Task 3 Determining the outcome of an encounter When there is an encounter between two characters the outcome is determined by the following process:

•计算出两个字符的强度属性之间的差异

• The differences between the strength attributes for the two characters is calculated

•此差异除以5,然后四舍五入以创建强度修改器"

• This difference is divided by 5 and then rounded down to create a ‘strength modifier’

•对技能属性重复此过程,以创建技能修改器"

• The process is repeated for the skill attribute to create a ‘skill modifier’

•每个玩家都投掷6面骰子.

• Each player throws a 6 sided dice.

•如果两个骰子的分数相同,则不会进行任何更改

• If the scores on both dice are the same, no changes are made

•如果分数不同,则得分最高的玩家会为其角色的强度值添加强度修改器",并为角色的技能值添加技能修改器"

• If the scores are not the same, the player with the highest score adds the ‘strength modifier’ to the strength value and the ‘skill modifier’ to the skill value for their character

•骰子得分较低的玩家从其角色的力量和技能值中减去这些修饰符

• The player with the lower score on the dice subtracts these modifiers from the strength and skill values for their character

•如果技能值变为负值,则将其存储为零

• If a skill value becomes negative, then it is stored as zero

•如果强度值变为零或负,则角色死亡.

• If a strength value becomes zero or negative, then the character dies.

程序应:

*•允许用户输入两个字符的强度和技能.

*• Allow the user to input the strength and skill for two characters.

import random
strength1 = input("Enter a value for strength")

enter code here print(您已选择:" + str(strength1))

enter code hereprint("you have chosen: "+str (strength1))

skill1=input("Please enter a value of skill, and then press enter")
print("you have chosen: "+str (skill1))      

strength2 = input("Enter a value for strength")
print("you have chosen: "+str (strength2))

skill2=input("Please enter a value of skill, and then press enter")
print("you have chosen: "+str (skill2)) 


Strengthmodifiertoround=strength1
strength1= Strengthmodifiertoround

Skillmodifiertoround = skill1
skill1 = Skillmodifiertoround

Strengthmodifier = strength2
strength2 = Strengthmodifier

Skillmodifier = skill2
skill2 = Skillmodifier

print("character 1 strength is:"+str (strength1))
print("character 1 skill is:"+str (skill1))

print("character 2 strength is:"+str (strength2))
print("character 2 skill is:"+str (skill2))

if (strength1 < strength2):
    strengthmodifiertoround = strength2 - strength1;
    strengthmodifier = strengthmodifiertoround / 5;

if (strength2 < strength1):
    strengthmodifiertoround = strength1 - strength2;
    strengthmodifier = strengthmodifiertoround / 5;

if (skill1 < skill2):
    skillmodifiertoround = skill2 - skill1;
    skillmodifier = skillmodifiertoround / 5; 

if (skill2 < skill1):
    skillmodifiertoround = skill1 - skill2;
    skillmodifier = skillmodifiertoround / 5;

print("character 1 roll a dice")
print("You scored",random.randint(1,6))


print("character 2 roll a dice")
print("You scored",random.randint(1,6))
umar=random.randint(1,6)

if (random.randint < umar):
    char2st = strength2 + strengthmodifier
    char2sk = skill2 + skillmodifier
    print("").char2st
    print("character2strength"+str (char2st))
    print("character2skill"+str (char2sk))

else:
    char1st = strength1 - strengthmodifier
    char1sk = skill1 - skillmodifier
    print("character1strength"+str (char1st))
    print("character1skill"+str (char1sk))


if (umar < random.randint):
    ch2st = strength2 - strengthmodifier
    print("character2strength"+str (ch2st))
    ch2sk = skill2 - skillmodifier
    print("character2skill"+str (ch2sk))

else:
    ch1st = strength1 + strengthmodifier
    print("character1strength"+str (ch1st))
    ch1sk = skill1 + skillmodifier
    print("character1skill"+str (ch1sk)`enter code here`

这不能正常工作.它没有做应做的事情. 请帮忙.

this is not working properly. It is not doing what it should. please help.

推荐答案

random.randint是一个函数.我想你打算用...

random.randint is a function. I think you intended to use...

if(random.randint() < umar):

在许多代码行中都是如此.

And alike in many lines of the code.

这篇关于我在python 2.4中尝试过吗?但是它不能正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆