-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerDataObject.gd
69 lines (44 loc) · 1.4 KB
/
PlayerDataObject.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
extends Node
@onready var dicebag = Dicebag.new()
@onready var storyteller = $"../Storyteller"
#Values
@export var max_health : int = 20
@export var health : int = max_health
@export var rads : int = 0
@export var improve_stat_margin : int = 10
var stat_improved : String = ""
@export var stats : Dictionary = {
"Strength" : 0,
"Perception" : 0,
"Constitution" : 0,
"Dexterity" : 0,
"Intelligence" : 0,
"Charisma" : 0
}
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func roll_stat(stat_name,dificulty):
#debug print(stat_name)
if stats.has(stat_name):
randomize()
var stat_roll = dicebag.roll_dice(1,100)
print("Dice roll "+str(stat_roll))
stat_roll = stat_roll + stats[stat_name]
print("Stat roll "+str(stat_roll))
if (stat_roll >= dificulty):
if (stat_roll <= dificulty + improve_stat_margin):
improve_stat(stat_name)
return true
return true
else: return false
else: print("ERROR NONEXISTING STAT!")
func improve_stat(stat_name):
var amount_to_improve = dicebag.roll_dice(1, 10)
stats[stat_name] = stats[stat_name] + amount_to_improve
print("You improve "+stat_name+" by "+str(amount_to_improve))
$"../StatGainPopup".display_popup(amount_to_improve, stat_name)
return