stop silly recursion. Implement init vers of question answering

This commit is contained in:
WillJeynes
2026-08-24 17:15:52 +01:00
parent f4e5de25c5
commit 7fa82ce8ec
8 changed files with 193 additions and 13 deletions
+68
View File
@@ -1,3 +1,5 @@
using System;
using DefaultNamespace;
using UnityEditor;
using UnityEngine;
@@ -25,4 +27,70 @@ public class GuardManager : MonoBehaviour
);
#endif
}
public QuestionAnswer Answer(string question)
{
//first get actual answer
var origAnswer = GetHonestAnswer(question);
if (type == "TRUTHER")
{
//if tell truth just return it
return origAnswer;
}
else if (type == "LIAR")
{
//if tell lies invert it
return origAnswer switch
{
QuestionAnswer.YES => QuestionAnswer.NO,
QuestionAnswer.NO => QuestionAnswer.YES,
QuestionAnswer.NO_YES => QuestionAnswer.NO_YES // i think? since we cannot confidently lie?
};
}
else
{//add joker at some point
throw new NotImplementedException();
}
}
private QuestionAnswer GetHonestAnswer(string question)
{
//first get wether to think about another guard
if (question[2] == '%')
{
if (question[0] == 'G')
{
Debug.Log(question);
Debug.Log(question.Substring(1,1));
int index = int.Parse(question.Substring(1,1));
var guard = LevelLoader.Instance.Guards[index];
return guard.Answer(question.Substring(3));
}
else
{
throw new NotImplementedException();
}
}
//if not get a property
else if (question[2] == '#')
{
if (question[0] == 'D')
{
int index = int.Parse(question.Substring(1,1));
var door = LevelLoader.Instance.Doors[index];
return door.GetProperty(question.Substring(3));
}
else
{
throw new NotImplementedException();
}
}
else
{
throw new NotImplementedException();
}
}
}