2022-06-26 17:40:01 +00:00
|
|
|
#Die class
|
2022-07-10 17:16:34 +00:00
|
|
|
extends Node2D
|
2022-06-26 17:40:01 +00:00
|
|
|
|
|
|
|
class_name Die
|
|
|
|
|
|
|
|
#value of selected die type
|
|
|
|
var numFaces: int
|
2022-07-10 17:16:34 +00:00
|
|
|
|
2022-06-26 17:40:01 +00:00
|
|
|
#Class constructor
|
|
|
|
func _init(value):
|
|
|
|
numFaces = value
|
|
|
|
|
|
|
|
#returns an integer value of the rolled result (assuming the die is a valid type)
|
|
|
|
func rollDie():
|
|
|
|
randomize()
|
|
|
|
|
2022-07-03 16:13:15 +00:00
|
|
|
var rolledNum
|
|
|
|
rolledNum = randi() % numFaces + 1
|
|
|
|
return rolledNum
|
2022-06-26 17:40:01 +00:00
|
|
|
|
|
|
|
|
2022-07-10 17:16:34 +00:00
|
|
|
#Returns the number of faces on this die
|
|
|
|
func getNumFaces():
|
|
|
|
return numFaces
|