-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerData.gd
129 lines (100 loc) · 3.28 KB
/
PlayerData.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
extends Node
@onready var dicebag = Dicebag.new()
@onready var storyteller = $"../StorytellerPanel/Storyteller"
@onready var MainGameObject = $".."
@export var food_eaten_today : bool = false
@export var health : int = 10
@export var starvation : int = 0
@export var penalty : int = 0
@export var skills : Dictionary = {
"Pathfinding" : 0,
"Fishing" : 0,
"Foraging" : 0,
"Hunting" : 0,
"Farming" : 0,
"Animal husbandry" : 0,
"Food preservation" : 0,
"Woodcraft" : 0,
"Leatherworking" : 0,
"Toolmaking" : 0,
"Social insight" : 0
}
@export var inventory : Dictionary = {
"Unpreserved food" : 0,
"Preserved food" : 0,
"Firewood" : 0,
}
@export var unexplored_close_tiles = [
"fish",
"fish",
"game",
"game",
"berries",
"berries",
"nothing",
"nothing"
]
func starve():
starvation = starvation + 1
storyteller.add_text("You've been starving for "+var_to_str(starvation)+" day(s)")
storyteller.newline()
storyteller.add_text("You take "+var_to_str(starvation)+" health damage")
storyteller.newline()
modify_health(- starvation)
func eat_food():
if(inventory["Unpreserved food"] >= 1 && food_eaten_today == false):
inventory["Unpreserved food"] = inventory["Unpreserved food"] - 1
storyteller.add_text("Prioritizing food that might go bad overnight,")
storyteller.newline()
storyteller.add_text("you eat 1 ration of unpreserved food")
storyteller.newline()
starvation = 0
food_eaten_today = true
return
elif(inventory["Preserved food"] >= 1):
inventory["Preserved food"] = inventory["Preserved food"] - 1
storyteller.add_text("You eat 1 ration of preserved food")
storyteller.newline()
starvation = 0
food_eaten_today = true
return
else:
storyteller.add_text("ERROR: NO FOOD FOUND!")
func modify_health(amount):
health = health + amount
if (health <=0):
MainGameObject.game_over()
if (health >=10):
health = 10
MainGameObject.update_health_bar()
func calculate_penalty():
var health_penalty = health - 10
penalty = health_penalty #modify if anything else needs to add penalties.
func skill_roll(skill_name, target_dc):
randomize()
if(skills.has(skill_name)):
calculate_penalty()
storyteller.add_text("you attempt "+str(skill_name))
storyteller.newline()
var attempt = dicebag.roll_dice(1, 20, penalty)
attempt = attempt + skills[skill_name]
storyteller.add_text("Your rank in "+str(skill_name)+" is "+str(skills[skill_name]))
storyteller.newline()
if(penalty < 0):
storyteller.add_text("Penalty due to lack of health: "+var_to_str(penalty))
storyteller.newline()
storyteller.add_text("You hit a "+str(attempt)+" versus a target of "+str(target_dc)) #inform the player how close the were
storyteller.newline()
#if the player hits within 2 above or below their target DC they challanged themselves enough to learn something
if(attempt >= target_dc - 2 && attempt <= target_dc + 2):
storyteller.add_text("Challanging yourself you learned a lot") #output to the player
storyteller.newline()
skills[skill_name] = skills[skill_name] + 1 #Adds one to the skill rank
storyteller.add_text("Your skill is now "+str(skills[skill_name]))
storyteller.newline()
#return whether the skill roll was succesfull or not
if(attempt >= target_dc):
return true
else:
return false
print("nonexisting skill")