summaryrefslogtreecommitdiff
path: root/Global.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Global.gd')
-rw-r--r--Global.gd38
1 files changed, 30 insertions, 8 deletions
diff --git a/Global.gd b/Global.gd
index cef7b9f..3c8a3a3 100644
--- a/Global.gd
+++ b/Global.gd
@@ -7,16 +7,16 @@ signal game_ended()
signal game_won()
-const Levels = [
- "Level_0001",
- "Level_0001",
- "Level_0001",
- "Level_0001",
- "Level_0001",
- "Level_0001",
+var Levels = [
"Level_0001",
+ "Level_0002",
+ "Level_0003",
"Level_0001",
+ "Level_0002",
+ "Level_0003",
"Level_0001",
+ "Level_0002",
+ "Level_0003",
]
var Level_Map = []
@@ -30,6 +30,9 @@ func _ready():
func init():
+ randomize()
+ self.Levels.shuffle()
+
for level in self.Levels:
self.Level_Map.push_back({
time = 0,
@@ -116,7 +119,7 @@ func _on_Network_game_ended(winning_player):
self.init()
-func check_win():
+func has_won():
var has_won = false
var cleared_levels_idx = []
@@ -148,5 +151,24 @@ func check_win():
has_won = true
break
+ return has_won
+
+
+func check_win():
+ var has_won = self.has_won()
+
+ if has_won:
+ # TODO: start 10s timer with callback check_win_timer()
+ # SAVE IN REMOTE ARRAY USERS WITH CROWN = rpc_id + running timer?
+ # Check for each user that already has a crown if the win condition is still true
+ # if it's not, delete user from array and stop timer
+ # if it is, do nothing, keep running until game end
+ self.check_win_timer()
+ pass
+
+
+func check_win_timer():
+ var has_won = self.has_won()
+
if has_won:
emit_signal("game_won", Network.player)