Skip to content

Commit a33396e

Browse files
committed
fix: the state are kept after the minigame
1 parent 65b8de5 commit a33396e

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

autocomplete_upgrade.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
extends UpgradeButton
22

33
func _init():
4+
index = 2
45
upgrades = [[10, "Utiliser TabNine"]]
56
maxed_text = "Tu es autocompletemaxxed"
67
visible_condition = func(): return Globals.features >= 1

editor_upgrade.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
extends UpgradeButton
22

33
func _init():
4+
index = 0
45
upgrades = [[10, "Passer a Notepad++"]]
56
maxed_text = "Tu es editormaxxed"
67
visible_condition = func(): return true

feature_upgrade.gd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
extends UpgradeButton
22

33
func _init():
4+
index = 1
45
upgrades = [[10, "Activer l’autocomplete"]]
56
maxed_text = "Tu es featuremaxxed"
67
visible_condition = func(): return Globals.editor >= 1

globals.gd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var editor: int
77
var features: int
88
var autocomplete: int
99
var __couisine_counter: float
10-
10+
var actual_state: Array
1111

1212
func add_commits(nb: int):
1313
if nb:
@@ -22,6 +22,7 @@ func _ready():
2222
self.editor = 0
2323
self.features = 0
2424
self.autocomplete = 0
25+
self.actual_state = [0, 0, 0]
2526
self.__couisine_counter = 0.
2627

2728
# Called every frame. 'delta' is the elapsed time since the previous frame.

upgrade_button.gd

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ var maxed_text: String = "Button maxed"
99
var currency: Callable = func(): return Globals.commits
1010
var remove_currency: Callable = func(x: int): Globals.commits -= x
1111
var on_pressed: Callable
12-
13-
var __actual_state = 0
12+
var index: int
1413

1514
func _ready():
1615
visible = default_visible
@@ -22,18 +21,18 @@ func _process(_delta):
2221
return
2322
else:
2423
visible = true
25-
if __actual_state >= upgrades.size():
24+
if Globals.actual_state[index] >= upgrades.size():
2625
text = maxed_text
2726
disabled = true
2827
return
29-
var needed = upgrades[__actual_state][0]
30-
text = "%s %d" % [upgrades[__actual_state][1], needed]
31-
if upgrades[__actual_state][0] > currency.call():
28+
var needed = upgrades[Globals.actual_state[index]][0]
29+
text = "%s %d" % [upgrades[Globals.actual_state[index]][1], needed]
30+
if upgrades[Globals.actual_state[index]][0] > currency.call():
3231
disabled = true
3332
else:
3433
disabled = false
3534

3635
func _pressed():
37-
remove_currency.call(upgrades[__actual_state][0])
36+
remove_currency.call(upgrades[Globals.actual_state[index]][0])
3837
on_pressed.call()
39-
__actual_state += 1
38+
Globals.actual_state[index] += 1

0 commit comments

Comments
 (0)