From 4c3f94dba1569ba59caaecd1f5d84278e60d8242 Mon Sep 17 00:00:00 2001 From: WillJeynes Date: Tue, 25 Aug 2026 15:16:25 +0100 Subject: [PATCH] Add joker type. Allow automatic conversion to are you --- Assets/LevelData/old_classic.json | 4 ++++ Assets/Scripts/DialogManager.cs | 8 ++++++++ Assets/Scripts/GuardManager.cs | 17 ++++++++++++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Assets/LevelData/old_classic.json b/Assets/LevelData/old_classic.json index a7a54b2..be924b2 100644 --- a/Assets/LevelData/old_classic.json +++ b/Assets/LevelData/old_classic.json @@ -17,6 +17,10 @@ { "type": "BASE", "action": "TRUTHER" + }, + { + "type": "BASE", + "action": "JOKER" } ], "guardsmods": [ diff --git a/Assets/Scripts/DialogManager.cs b/Assets/Scripts/DialogManager.cs index 9f3b84e..0e0827d 100644 --- a/Assets/Scripts/DialogManager.cs +++ b/Assets/Scripts/DialogManager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text.RegularExpressions; using DefaultNamespace; using JetBrains.Annotations; using Newtonsoft.Json.Linq; @@ -229,6 +230,13 @@ public class DialogManager : Singleton r = r.Replace("NOREC_", ""); + + r = Regex.Replace( + r, + @"^is\s+(?:\S+\s+)*guard\s+\(you\)", + "are you", + RegexOptions.IgnoreCase + ); string responsePrefix = ""; if (FullQuestion.Contains("%")) diff --git a/Assets/Scripts/GuardManager.cs b/Assets/Scripts/GuardManager.cs index e17a88b..29f9ab2 100644 --- a/Assets/Scripts/GuardManager.cs +++ b/Assets/Scripts/GuardManager.cs @@ -3,6 +3,7 @@ using DefaultNamespace; using UnityEditor; using UnityEngine; using Utils; +using Random = UnityEngine.Random; public class GuardManager : MonoBehaviour, IDescribable { @@ -61,10 +62,12 @@ public class GuardManager : MonoBehaviour, IDescribable QuestionAnswer.NO_YES => QuestionAnswer.NO_YES // i think? since we cannot confidently lie? }; } - else - {//add joker at some point - throw new NotImplementedException(); + else if (type == "JOKER") + { + return Random.value > 0.5? QuestionAnswer.YES : QuestionAnswer.NO; } + + throw new NotImplementedException(); } @@ -129,8 +132,12 @@ public class GuardManager : MonoBehaviour, IDescribable else if (mod == "HAT") { return "the guard with the hat"; - }// add more modification here - throw new NotImplementedException(); + } + else + { + return "the plain guard"; + } + // add more modification here } public QuestionAnswer GetProperty(string property)