mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
Added Die roller to Die.gd
This commit is contained in:
parent
de708954cf
commit
84ff2a453f
@ -24,22 +24,26 @@ func RollDie(InputDie):
|
|||||||
var DieFaceResult = 0;
|
var DieFaceResult = 0;
|
||||||
var LowestPossibleNumberOnDie = 0
|
var LowestPossibleNumberOnDie = 0
|
||||||
var rng = RandomNumberGenerator.new()
|
var rng = RandomNumberGenerator.new()
|
||||||
|
rng.randomize()
|
||||||
|
|
||||||
var NoOfSides = NumberOfFaces
|
var NoOfSides = NumberOfFaces
|
||||||
|
|
||||||
match NoOfSides:
|
match NoOfSides:
|
||||||
100:
|
100:
|
||||||
LowestPossibleNumberOnDie = 0
|
LowestPossibleNumberOnDie = 1
|
||||||
#Will need to come up with a solution just for 00 Dice.
|
DieFaceResult = rng.randi_range(LowestPossibleNumberOnDie, 10)
|
||||||
|
DieFaceResult *= 10
|
||||||
|
|
||||||
_:
|
_:
|
||||||
LowestPossibleNumberOnDie = 1
|
LowestPossibleNumberOnDie = 1
|
||||||
DieFaceResult = rng.randi_range(LowestPossibleNumberOnDie, NumberOfFaces)
|
DieFaceResult = rng.randi_range(LowestPossibleNumberOnDie, NumberOfFaces)
|
||||||
|
|
||||||
var DieSuccessPercentage = DieFaceResult/NumberOfFaces
|
var DieSuccessPercentage = (float(DieFaceResult)/float(NumberOfFaces))
|
||||||
|
|
||||||
print("DieFace:")
|
print("DieFace:")
|
||||||
print(DieFaceResult)
|
print(DieFaceResult)
|
||||||
|
print("Die Success Rate")
|
||||||
|
print(DieSuccessPercentage)
|
||||||
|
|
||||||
|
|
||||||
func SetNumberOfSides():
|
func SetNumberOfSides():
|
||||||
@ -72,7 +76,7 @@ func SetNumberOfSides():
|
|||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
DieType = DieCategory.D20
|
DieType = DieCategory.D00
|
||||||
SetNumberOfSides()
|
SetNumberOfSides()
|
||||||
RollDie(NumberOfFaces)
|
RollDie(NumberOfFaces)
|
||||||
# Replace with function body.
|
# Replace with function body.
|
||||||
|
Loading…
Reference in New Issue
Block a user