I'm very new to coding and trying to write a simple program to roll dice for the TTRPG game Daggerheart (I play solo on paper, so something to help track both Fear and Hope seemed useful). In the game mechanic, two special dice (both d12) are defined, and if one rolls higher then the other (re: hope > fear) the player gets a resource ('hope'), or if the other way around, the GM gets a 'fear' resource. Now, the game allows these resources up to, but not exceeding 6.
So far, I can't figure out how to set this maximum for my 'hope' and 'fear' variables. The examples I've found on stackOverflow are either in another language (Java) or I don't know how to translate the solution to my situation.
This is my program so far. A snippet to increase hope to illustrate:
# Roll the dice
if playerMove == 'r':
hopeDice = int(random.randint(1, 12))
fearDice = int(random.randint(1, 12))
roll = int(hopeDice) + int(fearDice)
print('You rolled {} with ...'.format(roll))
if hopeDice > fearDice:
print('... hope')
hope += 1
if hope <= 6: .... That's all.+=to ensure that the increment is allowed. There's ways that you could abstract away the check (using a class for example), but you still need to do the check yourself at some point.hope==6andhopeDice > fearDice? Nothing?