The password hint unlocks after the trade with the cat
- Preconditions
-
- The cat quest is completed up to trading catnip for the note
- The shed table requires the cat trade
- Steps
-
- Set the flag the cat quest writes after the trade
- Put the password note in the inventory
- Ask the table whether dialogue D26 may start
- Repeat without the flag and without the note
- Expected result
- With the flag and the note, D26 is unlocked. Without either one, it stays locked.
- Actual result before the fix Failed before the fix
- PaperDialogUnlocksAfterCatExchange failed. The cat wrote cat_exchange_done while the table waited for cat_catnip_given, which nothing ever set. The password hint never played.
- Fix
- One shared constant in ProgressFlags for both scripts, the old key removed. The flag value is unchanged, so old saves still work.
Test code CatTradeTableDialogTests.cs
public class CatTradeTableDialogTests
{
[SetUp]
public void SetUp()
{
_saveHost = new GameObject("SaveManager");
_saveManager = _saveHost.AddComponent<SaveManager>();
SetSaveManagerInstance(_saveManager);
_playerHost = new GameObject("Player");
_inventory = _playerHost.AddComponent<PlayerInventory>();
PlayerBrain brain = _playerHost.AddComponent<PlayerBrain>();
ReflectionTestHelper.SetField(brain, "_playerInventory", _inventory);
_paperPassword = ScriptableObject.CreateInstance<T_Item>();
_tableHost = new GameObject("Table");
_table = _tableHost.AddComponent<CircleTableMiniGameWorld>();
ReflectionTestHelper.SetField(_table, "_playerBrain", brain);
ReflectionTestHelper.SetField(_table, "_paperPasswordItem", _paperPassword);
ReflectionTestHelper.SetField(_table, "_requireCatTrade", true);
}
// Флаг берётся у того, кто его пишет (квест кота), а не у того, кто читает (стол).
// Так тест ловит расхождение ключей между двумя скриптами.
private static string FlagWrittenByCatQuest()
{
FieldInfo field = typeof(CatQuestProgress).GetField("F_EXCHANGE_DONE", BindingFlags.NonPublic | BindingFlags.Static);
Assert.IsNotNull(field);
return (string)field.GetValue(null);
}
private bool TableUnlocksPaperDialog()
{
return (bool)ReflectionTestHelper.Invoke(_table, "HasPaperPasswordAfterCatTrade");
}
[Test]
public void PaperDialogStaysLockedBeforeCatExchange()
{
_inventory.AddItem(_paperPassword);
Assert.IsFalse(TableUnlocksPaperDialog());
}
[Test]
public void PaperDialogNeedsPaperInInventory()
{
_saveManager.SetFlag(FlagWrittenByCatQuest(), true);
Assert.IsFalse(TableUnlocksPaperDialog());
}
[Test]
public void PaperDialogUnlocksAfterCatExchange()
{
_saveManager.SetFlag(FlagWrittenByCatQuest(), true);
_inventory.AddItem(_paperPassword);
Assert.IsTrue(TableUnlocksPaperDialog());
}
} Fix code ProgressFlags.cs, CatQuestProgress.cs, CircleTableMiniGameWorld.cs
// ProgressFlags.cs: один ключ на два скрипта
public const string CatExchangeDone = "cat_exchange_done";
// CatQuestProgress.cs: квест кота пишет флаг
private const string F_EXCHANGE_DONE = ProgressFlags.CatExchangeDone;
// CircleTableMiniGameWorld.cs: стол читает тот же флаг
bool tradeCompleted = ProgressFlags.Get(ProgressFlags.CatExchangeDone, false);