a game about throwing hammers made for the github game off
Diffstat (limited to 'autoloads/Utils.gd')
-rw-r--r--autoloads/Utils.gd18
1 files changed, 18 insertions, 0 deletions
diff --git a/autoloads/Utils.gd b/autoloads/Utils.gd
index 484e146..631d2b0 100644
--- a/autoloads/Utils.gd
+++ b/autoloads/Utils.gd
@@ -1,6 +1,24 @@
extends Node
class_name Util
+static func dict_cmp(d1: Dictionary, d2: Dictionary) -> bool:
+ return (
+ len(d1) == len(d2)
+ and sort(d1.keys()) == sort(d2.keys())
+ and value_types(d1.values()) == value_types(d2.values())
+ )
+
+static func sort(arr: Array) -> Array:
+ arr.sort()
+ return arr
+
+static func value_types(arr: Array) -> Array:
+ var types = []
+ for value in arr:
+ types.append(typeof(value))
+ types.sort()
+ return types
+
static func is_in_range(val: float, start: float, end: float) -> bool:
return val >= start and val <= end