This commit is contained in:
2026-09-10 10:59:37 +03:00
commit 4fc9b337c2
16 changed files with 199 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
{
"id": "gdscript_test",
"name": "GDScript Integration Test Mod",
"version": "1.0.0",
"author": "ct",
"description": "Integration tests for GDScript mod actions. Exercises the full pipeline: .gd load -> compile -> action registration -> scenario execution.",
"gd_sources": [
"scripts/*.gd"
],
"depends": [
"core>=1"
]
}
@@ -0,0 +1,8 @@
scene: home_kitchen
priority: 8
condition: true
is_one_run: true
---
action gds.greet name=Always
text "Fallback scene always runs."
end
+9
View File
@@ -0,0 +1,9 @@
scene: home_kitchen
priority: 7
condition: gds.flag_equals("victory")
is_one_run: true
---
set custom_flag=victory
action gds.inventory_demo item_id=health_potion
text "GDScript condition with args and inventory action executed."
end
+9
View File
@@ -0,0 +1,9 @@
scene: home_kitchen
priority: 6
condition: gds.is_rain
is_one_run: true
---
set weather=rain
action gds.greet name=RainVisitor
text "It's raining! GDScript condition gds.is_rain passed."
end
+10
View File
@@ -0,0 +1,10 @@
scene: home_kitchen
priority: 5
condition: true
is_one_run: true
---
set my_name=Marao
action gds.greet name=my_name
action gds.quest_log quest_id=test_quest message=Scenario started from GDScript
text "GDScript test actions executed. Check logs."
end
+21
View File
@@ -0,0 +1,21 @@
extends RefCounted
# Custom battle action executor: deals triple damage based on user's Attack
# ActionId must match the battle action ID in the character's JSON data
# The execute method returns a GDBattleResult with SourceDamage/TargetDamage etc.
func get_action_id():
return "gds.triple_attack"
func execute(action, user, target):
var result = GDBattleResult.new()
var damage = user.AttackValue * 3 - target.DefenceValue
if damage < 1:
damage = 1
result.TargetDamage = damage
result.TargetDefence = target.DefenceValue
result.Result = true
return result
+14
View File
@@ -0,0 +1,14 @@
extends RefCounted
func get_name():
return "gds.char_welcome"
func run(ctx):
var char_type = ctx.GetParam("char_type")
if char_type == "":
ctx.LogWarning("GDS", "gds.char_welcome: missing char_type")
return
ctx.Character.AddToParty(char_type)
ctx.Character.SendNotification(char_type)
ctx.Log("GDS", "Character '" + char_type + "' added to party via GDScript")
+13
View File
@@ -0,0 +1,13 @@
extends RefCounted
# Custom condition with arguments: checks if a flag equals the passed value
# Usage in scenario: condition: gds.flag_equals("expected_value")
func get_condition_name():
return "gds.flag_equals"
func evaluate(flags, args):
var expected = args.get("0", "")
if expected == "":
return false
return flags.get("custom_flag", "") == expected
+11
View File
@@ -0,0 +1,11 @@
extends RefCounted
# Custom condition: checks if the "weather" flag equals "rain"
# Usage in scenario: condition: gds.is_rain
# Or: condition: gds.is_rain && Quest.hasTag("active")
func get_condition_name():
return "gds.is_rain"
func evaluate(flags, args):
return flags.get("weather", "") == "rain"
+10
View File
@@ -0,0 +1,10 @@
extends RefCounted
func get_name():
return "gds.greet"
func run(ctx):
var name = ctx.GetParam("name")
if name == "":
name = "Stranger"
ctx.Log("EVENT", "GDScript greet action: Hello, " + name + "!")
+21
View File
@@ -0,0 +1,21 @@
extends RefCounted
# Demonstrates inventory queries and mod presence checks from a scenario action
# Usage in scenario DSL: action gds.inventory_demo
func get_name():
return "gds.inventory_demo"
func run(ctx):
var itemId = ctx.GetParam("item_id")
if ctx.Inventory.HasItem(itemId):
var count = ctx.Inventory.CheckCount(itemId)
ctx.Log("EVENT", "Inventory has " + itemId + " x" + str(count))
else:
ctx.Log("EVENT", "Inventory does NOT have " + itemId)
if ctx.ModRegistry.IsLoaded("core"):
ctx.Log("EVENT", "Core mod is loaded")
else:
ctx.LogWarning("EVENT", "Core mod is NOT loaded")
+16
View File
@@ -0,0 +1,16 @@
extends RefCounted
# Custom item action: heals the character by a fixed amount when the item is used
# ID must match the ItemAction field in the item's JSON data
# The use(item) method receives a GDItem (with fields Id, Name, Description, Cost, ItemType)
# Returns true on success
func get_item_action_id():
return "gds.heal_item"
func use(item):
print("[GDS_ITEM] Using item: " + item.Name + " (id=" + item.Id + ")")
# In a real mod, perform actual healing logic here (e.g. via player stats)
# For demonstration, simply return success
return true
+9
View File
@@ -0,0 +1,9 @@
extends RefCounted
func get_name():
return "gds.light_reset"
func run(ctx):
ctx.Lighting.ClearDepthMap()
ctx.Lighting.SetUseTime(false)
ctx.Log("GDS", "Lighting reset via GDScript")
+12
View File
@@ -0,0 +1,12 @@
extends RefCounted
func get_name():
return "gds.quest_log"
func run(ctx):
var quest_id = ctx.GetParam("quest_id")
var message = ctx.GetParam("message")
if quest_id == "":
ctx.LogWarning("GDS", "gds.quest_log: missing quest_id param")
return
ctx.Log("QUEST", "[" + quest_id + "] " + message)
+16
View File
@@ -0,0 +1,16 @@
extends RefCounted
func get_name():
return "gds.quest_setup"
func run(ctx):
var quest_id = ctx.GetParam("quest_id")
if quest_id == "":
ctx.LogWarning("GDS", "gds.quest_setup: missing quest_id")
return
if ctx.Quests.Exists(quest_id):
ctx.Quests.SetStatus(quest_id, "Active")
ctx.Quests.AddTag(quest_id, "gds_started")
ctx.Quests.SendNotification(quest_id)
ctx.Log("GDS", "Quest '" + quest_id + "' activated by GDScript")
+7
View File
@@ -0,0 +1,7 @@
extends RefCounted
func on_mod_loaded(mod_id):
print("[GDS_TEST] on_mod_loaded: " + mod_id)
func on_mod_resources_ready():
print("[GDS_TEST] on_mod_resources_ready: all mods loaded")