mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
59b74b946a
Created script: "DiceRoller.gd" to be the only dice script attached to a node and will act as a singleton. A single DieManager object is created in this script. The DieManager's values can be changed and methods can be called through the DiceRoller Script
25 lines
413 B
GDScript
25 lines
413 B
GDScript
#Die class
|
|
extends Node2D
|
|
|
|
class_name Die
|
|
|
|
#value of selected die type
|
|
var numFaces: int
|
|
|
|
#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()
|
|
|
|
var rolledNum
|
|
rolledNum = randi() % numFaces + 1
|
|
return rolledNum
|
|
|
|
|
|
#Returns the number of faces on this die
|
|
func getNumFaces():
|
|
return numFaces
|