Trading: shop kind and trade.open schema; trade test passes the RPG Plus prologue

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cthangoverandClaude Opus 5.5 committed 2026-10-24 10:01:16 +02:00
1 parent 3199679355
commit b5878df34a
10 files changed
+187 -2

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "Trade Test",
"description": "Integration test of trading on the rpg_demo game: gathers brushwood, stones and a mushroom in the forest by walking onto them, heals the hero with the mushroom, talks to the village merchant whose dialog opens the trade window, sells the junk and buys an elixir by clicking the two inventories, checks that walking is blocked while the window is open and that Esc closes it. Activated by --itest=trade with --game=rpg_demo --new; --shots=<dir> saves screenshots (windowed runs only).",
"description": "Integration test of trading on the rpg_plus game (its rpg_demo_game world): gathers brushwood, stones and a mushroom in the forest by walking onto them, heals the hero with the mushroom, talks to the village merchant whose dialog opens the trade window, sells the junk and buys an elixir by clicking the two inventories, checks that walking is blocked while the window is open and that Esc closes it. Activated by --itest=trade with --game=rpg_plus --new (the prologue is clicked through first); --shots=<dir> saves screenshots (windowed runs only).",
"sources": [
"src/*.cs"
],
+26 -1
View File
@@ -88,13 +88,18 @@ namespace Cthangover.Mods.Trading.Tests
switch (step)
{
case 0:
if (Boot.IsReady && SkipPrologue())
return;
if (Boot.IsReady && View?.Map?.ID == Village)
Next();
return;
case 1:
if (AdvanceDialog())
return;
Check(Inventory.CheckCount(Coin) == 0, "a new game starts without money");
// The prologue gives a purse; the deals below count from an empty one.
if (Inventory.CheckCount(Coin) > 0)
Inventory.Remove(Coin, Inventory.CheckCount(Coin));
Check(Inventory.CheckCount(Coin) == 0, "the purse is emptied for the test");
RpgWorldHost.Teleport(new RpgTeleport { Map = Forest, X = 6, Y = 4, Dir = RpgDirection.Down });
Next();
return;
@@ -292,6 +297,26 @@ namespace Cthangover.Mods.Trading.Tests
}
/// <summary>Advances a running dialog with the action key; true while it is still running.</summary>
/// <summary>
/// The game opens with a novel-style prologue (no map yet): its lines are clicked
/// through and every choice takes the first answer. True while it runs.
/// </summary>
private static bool SkipPrologue()
{
// Asking for the dialog box before the first scene is up caches the wrong node.
var scene = ((SceneTree)Engine.GetMainLoop()).Root.GetNodeOrNull<SceneManager>("SceneManager")?.CurrentSceneName;
if (string.IsNullOrEmpty(scene) || RpgWorldHost.Current?.View?.Map != null)
return false;
var box = RpgInput.FindDialogBox();
if (box == null || !box.IsRunning)
return false;
if (box.IsWaitingAnswer)
box.TrySelectVariant(0);
else
box.NextAction();
return true;
}
private static bool AdvanceDialog()
{
var box = RpgInput.FindDialogBox();