bcirpggithubmirror/Phase2/Godot ===(Game Code)===/DiceRoller/Die.gd
Andrew Tang 3a4ca5fdcd Squashed commit of the following:
commit 59b74b946a
Author: Andrew Tang <tandrew@gmail.com>
Date:   Mon Jul 11 01:16:34 2022 +0800

    Complete DiceRoller Singleton Version

    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

commit 3a402d4331
Author: Andrew Tang <90939405+TangoDevelopments@users.noreply.github.com>
Date:   Sun Jul 3 13:05:28 2022 -0400

    Delete .DS_Store

commit c00b24c60a
Author: Andrew Tang <90939405+TangoDevelopments@users.noreply.github.com>
Date:   Sun Jul 3 13:05:16 2022 -0400

    Delete .DS_Store

commit 4f788de0c7
Author: Andrew Tang <90939405+TangoDevelopments@users.noreply.github.com>
Date:   Sun Jul 3 13:05:05 2022 -0400

    Delete .DS_Store

commit c20fd85567
Author: Andrew Tang <tandrew@gmail.com>
Date:   Mon Jul 4 00:13:15 2022 +0800

    Added D10 and easier die selection
2022-07-11 01:39:53 +08:00

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