From 84ff2a453f20fa04844328c6df22a57e1c948729 Mon Sep 17 00:00:00 2001 From: Luke Gebbink <48702026+PersonGuyGit@users.noreply.github.com> Date: Sun, 16 Jan 2022 11:45:37 -0700 Subject: [PATCH] Added Die roller to Die.gd --- Godot/MainMenu/GodotUserInterface_Luke/Die.gd | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Godot/MainMenu/GodotUserInterface_Luke/Die.gd b/Godot/MainMenu/GodotUserInterface_Luke/Die.gd index a2e047a..34eaa09 100644 --- a/Godot/MainMenu/GodotUserInterface_Luke/Die.gd +++ b/Godot/MainMenu/GodotUserInterface_Luke/Die.gd @@ -24,22 +24,26 @@ func RollDie(InputDie): var DieFaceResult = 0; var LowestPossibleNumberOnDie = 0 var rng = RandomNumberGenerator.new() + rng.randomize() var NoOfSides = NumberOfFaces match NoOfSides: 100: - LowestPossibleNumberOnDie = 0 - #Will need to come up with a solution just for 00 Dice. - + LowestPossibleNumberOnDie = 1 + DieFaceResult = rng.randi_range(LowestPossibleNumberOnDie, 10) + DieFaceResult *= 10 + _: LowestPossibleNumberOnDie = 1 DieFaceResult = rng.randi_range(LowestPossibleNumberOnDie, NumberOfFaces) - var DieSuccessPercentage = DieFaceResult/NumberOfFaces + var DieSuccessPercentage = (float(DieFaceResult)/float(NumberOfFaces)) print("DieFace:") print(DieFaceResult) + print("Die Success Rate") + print(DieSuccessPercentage) func SetNumberOfSides(): @@ -72,7 +76,7 @@ func SetNumberOfSides(): # Called when the node enters the scene tree for the first time. func _ready(): - DieType = DieCategory.D20 + DieType = DieCategory.D00 SetNumberOfSides() RollDie(NumberOfFaces) # Replace with function body.