-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.gd
103 lines (71 loc) · 3.33 KB
/
test.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
extends Panel
func _on_TestBtn_pressed() -> void:
print("Test launched")
var db := Datalogue.get_database("weapons")
var query := DlQuery.new()
var result := query.execute(db)
print("All: ", result)
result = query.from("combat_type", "melee").execute(db)
print("Melee weapons: ", result)
result = query.clear().from("combat_type", "launchers").execute(db)
print("Launchers weapons: ", result)
result = query.clear().from("type", "magical").execute(db)
print("Magical weapons: ", result)
result = query.clear().from("type", "magical").from("type", "hammer").execute(db)
print("Magical and hammers: ", result)
result = query.clear().from("type", "sword").or_begin().from("type", "hammer").execute(db)
print("Swords or hammers: ", result)
result = query.clear().where("damage", "<=", 10).execute(db)
print("Damage <= 10: ", result)
result = query.clear().where("value", ">", 400).execute(db)
print("Value > 400: ", result)
result = query.clear().where("range", "=", 100).execute(db)
print("Range = 100: ", result)
result = query.clear().where("range", "=", 100).where("damage", "<", 20).execute(db)
print("Range = 100 and damage < 20: ", result)
result = query.clear().where("range", "=", 1).or_begin().where("range", "=", 1.5).execute(db)
print("Range = 1 or range = 1.5: ", result)
result = query.clear().contains("name", "bow").execute(db)
print("Name contains bow: ", result)
result = query.clear().contains("desc", "sword").execute(db)
print("Description contains sword: ", result)
result = query.clear().contains("desc", "this").or_begin().contains("desc", "there").execute(db)
print("Description contains this or these: ", result)
result = query.clear().from("combat_type", "melee").where("damage", ">=", 10).contains("desc", "sword").execute(db)
print("Melee weapons with damage >= 10 and description contains sword: ", result)
var store := DlStore.new()
store.insert_back_multi(DlStore.instantiate_query(db, DlQuery.new()))
print("insert_back_multi:")
for inst in store.instances():
print(" - %s (%X) " % [inst.id(), inst.ref()])
var scimitar := db.get_item("scimitar")
store.insert_front_multi(DlStore.instanciate_multi(scimitar, 5))
print("insert_front_multi:")
for inst in store.instances():
print(" - %s (%X) " % [inst.id(), inst.ref()])
store.set_rng_seed("ABC123DEF")
store.shuffle()
print("shuffle:")
for inst in store.instances():
print(" - %s (%X) " % [inst.id(), inst.ref()])
var back := store.pop_back()
print("pop_back: %s (%X) " % [back.id(), back.ref()])
var front := store.pop_front()
print("pop_front: %s (%X) " % [front.id(), front.ref()])
var random := store.pop_random()
print("pop_random: %s (%X) " % [random.id(), random.ref()])
print("Final store state:")
for inst in store.instances():
print(" - %s (%X) " % [inst.id(), inst.ref()])
print("Store filtered:")
for inst in store.instances_filtered(query.clear().from("combat_type", "melee").from("type", "magical")):
print(" - %s (%X) " % [inst.id(), inst.ref()])
store.sort_by_value(["value", "damage"])
print("Store sorted by value and damage:")
for inst in store.instances():
print(" - %s (%X) " % [inst.id(), inst.ref()])
store.sort_by_text(["name"], false)
print("Store sorted by name in reverse alphabetical order:")
for inst in store.instances():
print(" - %s (%X) " % [inst.id(), inst.ref()])
print("Test finished")