about summary refs log tree commit diff stats
path: root/Archipelago/client.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Archipelago/client.gd')
-rw-r--r--Archipelago/client.gd58
1 files changed, 55 insertions, 3 deletions
diff --git a/Archipelago/client.gd b/Archipelago/client.gd index d1f95c8..13a7635 100644 --- a/Archipelago/client.gd +++ b/Archipelago/client.gd
@@ -15,8 +15,10 @@ var ap_user = ""
15var ap_pass = "" 15var ap_pass = ""
16var confusify_world = false 16var confusify_world = false
17var enable_multiplayer = false 17var enable_multiplayer = false
18var track_player = false
19var connection_history = []
18 20
19const my_version = "sunwarps-beta2" 21const my_version = "2.2.0"
20const ap_version = {"major": 0, "minor": 4, "build": 5, "class": "Version"} 22const ap_version = {"major": 0, "minor": 4, "build": 5, "class": "Version"}
21const color_items = [ 23const color_items = [
22 "White", "Black", "Red", "Blue", "Green", "Brown", "Gray", "Orange", "Purple", "Yellow" 24 "White", "Black", "Red", "Blue", "Green", "Brown", "Gray", "Orange", "Purple", "Yellow"
@@ -110,6 +112,7 @@ var _item_name_to_id = {} # LINGO only
110var _location_name_to_id = {} # LINGO only 112var _location_name_to_id = {} # LINGO only
111 113
112var _remote_version = {"major": 0, "minor": 0, "build": 0} 114var _remote_version = {"major": 0, "minor": 0, "build": 0}
115var _gen_version = {"major": 0, "minor": 0, "build": 0}
113 116
114# TODO: caching per MW/slot, reset between connections 117# TODO: caching per MW/slot, reset between connections
115var _authenticated = false 118var _authenticated = false
@@ -151,6 +154,7 @@ var _puzzle_skips = 0
151var _cached_slowness = 0 154var _cached_slowness = 0
152var _cached_iceland = 0 155var _cached_iceland = 0
153var _cached_atbash = 0 156var _cached_atbash = 0
157var _geronimo_skip = false
154 158
155signal could_not_connect 159signal could_not_connect
156signal connect_status 160signal connect_status
@@ -180,6 +184,10 @@ func _init():
180 confusify_world = data[4] 184 confusify_world = data[4]
181 if data.size() > 5: 185 if data.size() > 5:
182 enable_multiplayer = data[5] 186 enable_multiplayer = data[5]
187 if data.size() > 6:
188 track_player = data[6]
189 if data.size() > 7:
190 connection_history = data[7]
183 191
184 processDatapackages() 192 processDatapackages()
185 193
@@ -249,6 +257,7 @@ func _on_data():
249 if cmd == "RoomInfo": 257 if cmd == "RoomInfo":
250 _seed = message["seed_name"] 258 _seed = message["seed_name"]
251 _remote_version = message["version"] 259 _remote_version = message["version"]
260 _gen_version = message["generator_version"]
252 261
253 var needed_games = [] 262 var needed_games = []
254 for game in message["datapackage_checksums"].keys(): 263 for game in message["datapackage_checksums"].keys():
@@ -332,6 +341,11 @@ func _on_data():
332 if _slot_data.has("sunwarp_permutation"): 341 if _slot_data.has("sunwarp_permutation"):
333 _sunwarp_mapping = _slot_data["sunwarp_permutation"] 342 _sunwarp_mapping = _slot_data["sunwarp_permutation"]
334 343
344 if track_player:
345 setValue("PlayerPos", {"x": 0, "z": 0})
346 else:
347 setValue("PlayerPos", null)
348
335 _puzzle_skips = 0 349 _puzzle_skips = 0
336 350
337 _localdata_file = "user://archipelago_data/%s_%d" % [_seed, _slot] 351 _localdata_file = "user://archipelago_data/%s_%d" % [_seed, _slot]
@@ -364,6 +378,11 @@ func _on_data():
364 else: 378 else:
365 _cached_atbash = 0 379 _cached_atbash = 0
366 380
381 if localdata.size() > 5:
382 _geronimo_skip = localdata[5]
383 else:
384 _geronimo_skip = false
385
367 requestSync() 386 requestSync()
368 387
369 emit_signal("client_connected") 388 emit_signal("client_connected")
@@ -499,7 +518,16 @@ func saveSettings():
499 var file = File.new() 518 var file = File.new()
500 file.open("user://settings/archipelago", File.WRITE) 519 file.open("user://settings/archipelago", File.WRITE)
501 520
502 var data = [ap_server, ap_user, ap_pass, _datapackages, confusify_world, enable_multiplayer] 521 var data = [
522 ap_server,
523 ap_user,
524 ap_pass,
525 _datapackages,
526 confusify_world,
527 enable_multiplayer,
528 track_player,
529 connection_history
530 ]
503 file.store_var(data, true) 531 file.store_var(data, true)
504 file.close() 532 file.close()
505 533
@@ -523,7 +551,8 @@ func saveLocaldata():
523 _puzzle_skips, 551 _puzzle_skips,
524 effects_node.slowness_remaining, 552 effects_node.slowness_remaining,
525 effects_node.iceland_remaining, 553 effects_node.iceland_remaining,
526 effects_node.atbash_remaining 554 effects_node.atbash_remaining,
555 _geronimo_skip
527 ] 556 ]
528 file.store_var(data, true) 557 file.store_var(data, true)
529 file.close() 558 file.close()
@@ -777,6 +806,15 @@ func usePuzzleSkip():
777 saveLocaldata() 806 saveLocaldata()
778 807
779 808
809func geronimo():
810 if !_geronimo_skip:
811 messages.showMessage("Geronimo! You found a puzzle skip.")
812
813 _puzzle_skips += 1
814 _geronimo_skip = true
815 saveLocaldata()
816
817
780func colorForItemType(flags): 818func colorForItemType(flags):
781 var int_flags = int(flags) 819 var int_flags = int(flags)
782 if int_flags & 1: # progression 820 if int_flags & 1: # progression
@@ -787,3 +825,17 @@ func colorForItemType(flags):
787 return "#d63a22" 825 return "#d63a22"
788 else: # filler 826 else: # filler
789 return "#14de9e" 827 return "#14de9e"
828
829
830func compareVersion(lhs, rhs):
831 if lhs["major"] == rhs["major"]:
832 if lhs["minor"] == rhs["minor"]:
833 return lhs["build"] < rhs["build"]
834 else:
835 return lhs["minor"] < rhs["minor"]
836 else:
837 return lhs["major"] < rhs["major"]
838
839
840func wasGeneratedBeforeVersion(major, minor, build):
841 return compareVersion(_gen_version, {"major": major, "minor": minor, "build": build})