commit 4fc9b337c244af2551f941f8da33cc1995fe04f3 Author: iisaev Date: Thu Sep 10 10:59:37 2026 +0300 init diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..9c4992f --- /dev/null +++ b/manifest.json @@ -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" + ] +} diff --git a/scenarios/gdscript_fallback_test.scenario b/scenarios/gdscript_fallback_test.scenario new file mode 100644 index 0000000..0609dab --- /dev/null +++ b/scenarios/gdscript_fallback_test.scenario @@ -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 diff --git a/scenarios/gdscript_flag_test.scenario b/scenarios/gdscript_flag_test.scenario new file mode 100644 index 0000000..c58cf61 --- /dev/null +++ b/scenarios/gdscript_flag_test.scenario @@ -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 diff --git a/scenarios/gdscript_rain_test.scenario b/scenarios/gdscript_rain_test.scenario new file mode 100644 index 0000000..60a1d7a --- /dev/null +++ b/scenarios/gdscript_rain_test.scenario @@ -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 diff --git a/scenarios/gdscript_test.scenario b/scenarios/gdscript_test.scenario new file mode 100644 index 0000000..60894a4 --- /dev/null +++ b/scenarios/gdscript_test.scenario @@ -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 diff --git a/scripts/battle_executor_example.gd b/scripts/battle_executor_example.gd new file mode 100644 index 0000000..a52eb63 --- /dev/null +++ b/scripts/battle_executor_example.gd @@ -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 diff --git a/scripts/char_welcome_action.gd b/scripts/char_welcome_action.gd new file mode 100644 index 0000000..c24a3e6 --- /dev/null +++ b/scripts/char_welcome_action.gd @@ -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") diff --git a/scripts/condition_args_example.gd b/scripts/condition_args_example.gd new file mode 100644 index 0000000..e1c9217 --- /dev/null +++ b/scripts/condition_args_example.gd @@ -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 diff --git a/scripts/condition_example.gd b/scripts/condition_example.gd new file mode 100644 index 0000000..ea1c8ac --- /dev/null +++ b/scripts/condition_example.gd @@ -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" diff --git a/scripts/greet_action.gd b/scripts/greet_action.gd new file mode 100644 index 0000000..693871b --- /dev/null +++ b/scripts/greet_action.gd @@ -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 + "!") diff --git a/scripts/inventory_action.gd b/scripts/inventory_action.gd new file mode 100644 index 0000000..b004dca --- /dev/null +++ b/scripts/inventory_action.gd @@ -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") diff --git a/scripts/item_action_example.gd b/scripts/item_action_example.gd new file mode 100644 index 0000000..d69566c --- /dev/null +++ b/scripts/item_action_example.gd @@ -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 diff --git a/scripts/light_reset_action.gd b/scripts/light_reset_action.gd new file mode 100644 index 0000000..04796cc --- /dev/null +++ b/scripts/light_reset_action.gd @@ -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") diff --git a/scripts/quest_log_action.gd b/scripts/quest_log_action.gd new file mode 100644 index 0000000..ce57dad --- /dev/null +++ b/scripts/quest_log_action.gd @@ -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) diff --git a/scripts/quest_setup_action.gd b/scripts/quest_setup_action.gd new file mode 100644 index 0000000..543e5ac --- /dev/null +++ b/scripts/quest_setup_action.gd @@ -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") diff --git a/scripts/test_initializer.gd b/scripts/test_initializer.gd new file mode 100644 index 0000000..00b896e --- /dev/null +++ b/scripts/test_initializer.gd @@ -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")