@@ -13,36 +13,36 @@ func _prepare() -> void:
13
13
14
14
15
15
func test_inventory_has_correct_keys ():
16
- var source : Dictionary = inventory .get ("inventory" )
17
-
16
+ var source : Dictionary = inventory .get ("inventory" )
17
+
18
18
if source .size () != desired_inventory .size ():
19
19
return tr (
20
- "The amount of items is not correct. Are you missing any or add to many?"
21
- )
22
-
20
+ "The amount of items is not as expected. The inventory should have %s items but your inventory has %s ."
21
+ ) % [desired_inventory .size (), source .size ()] + " " + \
22
+ tr ("Are you missing any items?" )
23
+
23
24
var inventories_match := desired_inventory .has_all (source .keys ())
24
25
if inventories_match :
25
26
return ""
26
27
27
28
return tr (
28
- "The item names aren 't correct. Are you missing any? "
29
- )
29
+ "The inventory doesn 't contain all the required items. Make sure you have ' %s ' as keys in your inventory dictionary. "
30
+ ) % PoolStringArray ( desired_inventory . keys ()). join ( "', '" )
30
31
31
32
return ""
32
33
33
34
34
35
func test_inventory_has_correct_values ():
35
36
var source : Dictionary = inventory .get ("inventory" )
36
- var inventories_match := desired_inventory .has_all (source .keys ())
37
+ var inventories_match := desired_inventory .size () == source . size () and desired_inventory . has_all (source .keys ())
37
38
if inventories_match :
38
39
for key in source .keys ():
39
40
if not desired_inventory [key ] == source [key ]:
40
41
inventories_match = false
41
42
break
42
-
43
- if not inventories_match :
43
+ else :
44
44
return tr (
45
- "The amount of items isn 't correct. Does each key have the correct value? "
46
- )
45
+ "The values for one or more items aren 't correct. You need %s healing hearts, %s gems, and %s sword. "
46
+ ) % [ desired_inventory [ "healing heart" ], desired_inventory [ "gems" ], desired_inventory [ "sword" ]]
47
47
48
48
return ""
0 commit comments