mirror of
https://github.com/RPG-Research/bcirpg.git
synced 2024-04-16 14:23:01 +00:00
Mades some changes to my die roller class, and fixed a few typos.
This commit is contained in:
@ -6,42 +6,76 @@ class_name Die
|
||||
# var b = "text"
|
||||
|
||||
enum DieCategory{
|
||||
D4,
|
||||
D6,
|
||||
D8,
|
||||
D10,
|
||||
D12,
|
||||
D00,
|
||||
D20
|
||||
D4 = 4,
|
||||
D6 = 6,
|
||||
D8 = 8,
|
||||
D10 = 10,
|
||||
D12 = 12,
|
||||
D00 = 00,
|
||||
D20 = 20
|
||||
}
|
||||
|
||||
var dieType = DieCategory
|
||||
var numberOfFaces = 0
|
||||
var DieType = DieCategory
|
||||
var NumberOfFaces = 0
|
||||
|
||||
|
||||
func RollDie(InputDie):
|
||||
#InputDie is supposed to be DieType for example.
|
||||
var DieFaceResult = 0;
|
||||
var LowestPossibleNumberOnDie = 0
|
||||
var rng = RandomNumberGenerator.new()
|
||||
|
||||
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, NumberOfFaces)
|
||||
|
||||
var DieSuccessPercentage = DieFaceResult/NumberOfFaces
|
||||
|
||||
print("DieFace:")
|
||||
print(DieFaceResult)
|
||||
|
||||
|
||||
func SetNumberOfSides():
|
||||
var DSides = dieType
|
||||
|
||||
var DSides = DieType
|
||||
# For 7 Die Set, testing purposes
|
||||
|
||||
|
||||
########################################
|
||||
# Need to Seed Random Number Generator #
|
||||
########################################
|
||||
|
||||
match DSides:
|
||||
D4:
|
||||
numberOfFaces = 4
|
||||
D6:
|
||||
numberOfFaces = 6
|
||||
D8:
|
||||
numberOfFaces = 8
|
||||
D10:
|
||||
numberOfFaces = 10
|
||||
D12:
|
||||
numberOfFaces = 12
|
||||
D00:
|
||||
numberOfFaces = 100
|
||||
D20:
|
||||
numberOfFaces = 20
|
||||
4:
|
||||
NumberOfFaces = 4
|
||||
6:
|
||||
NumberOfFaces = 6
|
||||
8:
|
||||
NumberOfFaces = 8
|
||||
10:
|
||||
NumberOfFaces = 10
|
||||
12:
|
||||
NumberOfFaces = 12
|
||||
00:
|
||||
NumberOfFaces = 100
|
||||
20:
|
||||
NumberOfFaces = 20
|
||||
|
||||
print(NumberOfFaces)
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
DieType = DieCategory.D20
|
||||
SetNumberOfSides()
|
||||
RollDie(NumberOfFaces)
|
||||
# Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
@ -1,9 +1,10 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Player_Settings_Button.gd" type="Script" id=1]
|
||||
[ext_resource path="res://HostAndJoinGame.gd" type="Script" id=2]
|
||||
[ext_resource path="res://Start Game.gd" type="Script" id=3]
|
||||
[ext_resource path="res://GUI.gd" type="Script" id=4]
|
||||
[ext_resource path="res://Die.gd" type="Script" id=5]
|
||||
|
||||
[node name="GUI" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
@ -37,33 +38,41 @@ custom_constants/separation = 30
|
||||
alignment = 1
|
||||
|
||||
[node name="Start Game" type="Label" parent="HBoxContainer/VBoxContainer/MenuOptions"]
|
||||
margin_top = 147.0
|
||||
margin_top = 125.0
|
||||
margin_right = 112.0
|
||||
margin_bottom = 161.0
|
||||
margin_bottom = 139.0
|
||||
mouse_filter = 1
|
||||
text = "Start Game"
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Load Game" type="Label" parent="HBoxContainer/VBoxContainer/MenuOptions"]
|
||||
margin_top = 191.0
|
||||
[node name="DieTest" type="Label" parent="HBoxContainer/VBoxContainer/MenuOptions"]
|
||||
margin_top = 169.0
|
||||
margin_right = 112.0
|
||||
margin_bottom = 205.0
|
||||
margin_bottom = 183.0
|
||||
mouse_filter = 1
|
||||
text = "Die Test"
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="Load Game" type="Label" parent="HBoxContainer/VBoxContainer/MenuOptions"]
|
||||
margin_top = 213.0
|
||||
margin_right = 112.0
|
||||
margin_bottom = 227.0
|
||||
mouse_filter = 1
|
||||
text = "Load Game"
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="HostAndJoinGame" type="Label" parent="HBoxContainer/VBoxContainer/MenuOptions"]
|
||||
margin_top = 235.0
|
||||
margin_top = 257.0
|
||||
margin_right = 112.0
|
||||
margin_bottom = 249.0
|
||||
margin_bottom = 271.0
|
||||
mouse_filter = 1
|
||||
text = "Host / Join Game"
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Player Settings" type="Label" parent="HBoxContainer/VBoxContainer/MenuOptions"]
|
||||
margin_top = 279.0
|
||||
margin_top = 301.0
|
||||
margin_right = 112.0
|
||||
margin_bottom = 293.0
|
||||
margin_bottom = 315.0
|
||||
mouse_filter = 1
|
||||
text = "Player Settings"
|
||||
script = ExtResource( 1 )
|
||||
@ -83,6 +92,7 @@ margin_bottom = 227.0
|
||||
text = "Test Menu"
|
||||
|
||||
[connection signal="gui_input" from="HBoxContainer/VBoxContainer/MenuOptions/Start Game" to="HBoxContainer/VBoxContainer/MenuOptions/Start Game" method="_on_Start_Game_gui_input"]
|
||||
[connection signal="gui_input" from="HBoxContainer/VBoxContainer/MenuOptions/DieTest" to="HBoxContainer/VBoxContainer/MenuOptions/DieTest" method="_on_Start_Game_gui_input"]
|
||||
[connection signal="gui_input" from="HBoxContainer/VBoxContainer/MenuOptions/Load Game" to="HBoxContainer/VBoxContainer/MenuOptions/Load Game" method="_on_Start_Game_gui_input"]
|
||||
[connection signal="gui_input" from="HBoxContainer/VBoxContainer/MenuOptions/HostAndJoinGame" to="HBoxContainer/VBoxContainer/MenuOptions/HostAndJoinGame" method="_on_HostAndJoinGame_gui_input"]
|
||||
[connection signal="gui_input" from="HBoxContainer/VBoxContainer/MenuOptions/Player Settings" to="HBoxContainer/VBoxContainer/MenuOptions/Player Settings" method="_on_Player_Settings_gui_input"]
|
||||
|
Reference in New Issue
Block a user