dimanche 16 avril 2023

Random Number Generator as Dice

Ok I have a question about the Random Number Generator. However, let me explain I know how it works. So there is going to be minimal code. My question is what I call a floating index. This would be used as dice style generator. So I will explain the game example and then a piece of code.

My father is wanting to create a DnD style game. With Attack and defense. The random number generator is the dice. However with each player will have a +Attack bonus and so forth. Kind of like Risk.

My question is when the index of say (1,6) with a attack bonus of (3). The random number generator is (1,6). Can I float that index by the players attack damage on the roll.

So for example one player may have (1,6) and another player could have (1,20). As they level up those numbers will change.

So can I use an int variable in a random number generator as follows.

Val X = 0
Val y = playerAttack.tostring
 
....... (X , y)

So basically if a random number generator is (1,6) then player two with (1,20) will throw an out of index.

So my question is can I float that number to auto change the index based on the player stats.

Think of the game Dungeon and Dragons. Or would I have to do the generator as (1, 100) and the use of else statements to limit the number in the index.

I am needing clarification because I am under the assumption that I would need several random number generators with different indexes.

Any help would be greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire