このタスクは、ゲームのキャラクターから、強さとスキルの 2 つの属性の違いを判断することです。このプロセスは次のとおりです。
- 強さの属性の違いを決定します。
- 差を 5 で割り、切り捨てて「強度修正」を作成します。
- 同じプロセスがスキル属性と名前付きの「スキル修飾子」に対して実行されます。
- その後、ゲームが始まります:
- 両方のプレイヤーが 6 面ダイスを投げます。
- 値が同じ場合、変更は発生しません。
- 値が異なる場合は、値が最も高いプレイヤーが以前に計算された強さとスキルを獲得し、合計に追加されます。最も低い値を持つプレーヤーは、合計から取り除かれた強さとスキルを持っています。
これは、strength 属性が 0 以下になるまで繰り返さなければなりませんが、この部分はできません。ループする方法は知っていますが、これは常に、ユーザーに再度実行するかどうかを尋ねることによって行われます。
c1sc=random.randint(1,6)
c2sc=random.randint(1,6)
if c1sc > c2sc:
c1st=c1st+strengthmodifier
c2st=c2st-strengthmodifier
c1sk=c1sk+skillmodifier
c2sk=c2sk-skillmodifier
print('Character 1, your strength attribute is: '+(str(c1st))+' and your skill attribute is: '+(str(c1sk)))
print('Character 2, your strength attribute is: '+(str(c2st))+' and your skill attribute is: '+(str(c2sk)))
elif c2sc > c1sc:
c1st=c1st-strengthmodifier
c2st=c2st+strengthmodifier
c1sk=c1sk-skillmodifier
c2sk=c2sk+skillmodifier
print('Character 1, your strength attribute is: '+(str(c1st))+' and your skill attribute is: '+(str(c1sk)))
print('Character 2, your strength attribute is: '+(str(c2st))+' and your skill attribute is: '+(str(c2sk)))
else:
print('It\'s a draw, no changes were made.')
if c1sk < 0:
c1sk=0
elif c2sk < 0:
c2sk=0
if c1st < 0:
print('Character 1 died. Game over.')
elif c2st < 0:
print('Character 2 died. Game over.')
助けてください!