feat(client): TagExtractor — pure regex parse/strip of §12 tags

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-09 14:46:11 -05:00
parent 7c5eaf3ba3
commit 5388979bf1
4 changed files with 80 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
extends "res://addons/gut/test.gd"
const TagExtractor = preload("res://scripts/text/tag_extractor.gd")
func test_fact_extracted_and_stripped():
var r := TagExtractor.extract("A muddy road. [FACT: the eastern bridge is out]")
assert_eq(r["facts"], ["the eastern bridge is out"])
assert_eq(r["clean_text"], "A muddy road.")
func test_positive_and_negative_disposition():
assert_eq(TagExtractor.extract("\"Aye.\" [ADJUST_DISPOSITION: +5]")["dispositions"], [5])
assert_eq(TagExtractor.extract("[ADJUST_DISPOSITION: -10]")["dispositions"], [-10])
func test_move_parsed_with_args():
var r := TagExtractor.extract("[MOVE: offer_quest(14)]")
assert_eq(r["moves"][0]["name"], "offer_quest")
assert_eq(r["moves"][0]["args"], ["14"])
func test_move_with_no_args():
var r := TagExtractor.extract("[MOVE: refuse()]")
assert_eq(r["moves"][0]["name"], "refuse")
assert_eq(r["moves"][0]["args"], [])
func test_multiple_facts_collected():
var r := TagExtractor.extract("Hi [FACT: a] mid [FACT: b] end")
assert_eq(r["facts"], ["a", "b"])
assert_eq(r["clean_text"], "Hi mid end")
func test_no_tags_is_clean_passthrough():
var r := TagExtractor.extract("no tags here")
assert_eq(r["facts"], [])
assert_eq(r["dispositions"], [])
assert_eq(r["moves"], [])
assert_eq(r["clean_text"], "no tags here")

View File

@@ -0,0 +1 @@
uid://piviwupch8rt