Changed the data format for tiebreaker rounds.

This commit is contained in:
Jamie Greunbaum 2026-06-21 21:46:29 -04:00
parent dfaa5a9132
commit 1f8eeadb08
2 changed files with 112 additions and 39 deletions

View File

@ -20960,7 +20960,7 @@ MonoBehaviour:
_HostPositionMarker: {fileID: 596933552} _HostPositionMarker: {fileID: 596933552}
_CameraController: {fileID: 1524477936} _CameraController: {fileID: 1524477936}
_TiebreakerData: _TiebreakerData:
url: https://witwics.actual.horse/static/TiebreakerData.json url: https://witwics.actual.horse/static/TiebreakerData-NewFormat.json
_PlayerPodiums: _PlayerPodiums:
- {fileID: 4438766482650780795} - {fileID: 4438766482650780795}
- {fileID: 1993364535} - {fileID: 1993364535}

View File

@ -1556,48 +1556,20 @@ public class GameManagerRound1 : GameManagerBase
if (JSONResult.TokenType == TokenType.DataDictionary) if (JSONResult.TokenType == TokenType.DataDictionary)
{ {
DataDictionary TiebreakerDictionary = JSONResult.DataDictionary; DataDictionary TiebreakerDictionary = JSONResult.DataDictionary;
DataList TiebreakerRegions = TiebreakerDictionary.GetKeys(); if (!TiebreakerDictionary.ContainsKey("Version"))
Random.InitState(Networking.GetServerTimeInMilliseconds());
int TiebreakerIndex = Random.Range(0, TiebreakerRegions.Count);
string TiebreakerRegion = TiebreakerRegions[TiebreakerIndex].String;
Interface.ChoiceUI[1].text = TiebreakerRegion;
if (TiebreakerDictionary[TiebreakerRegion].TokenType == TokenType.DataDictionary)
{ {
DataDictionary RegionDictionary = TiebreakerDictionary[TiebreakerRegion].DataDictionary; ErrorString = ParseTiebreakerData_v1(Interface, TiebreakerDictionary);
if (RegionDictionary.ContainsKey("Type") && RegionDictionary.ContainsKey("Key Locations"))
{
Interface.HeaderUI.text = "Tiebreaker | " + RegionDictionary["Type"].String;
if (RegionDictionary["Key Locations"].TokenType == TokenType.DataList)
{
for (int i = 0; i < Interface.CluesUI.Length; i++)
{
Interface.CluesUI[i].text = "";
}
DataList KeyLocations = RegionDictionary["Key Locations"].DataList;
for (int i = 0; i < KeyLocations.Count && i < Interface.CluesUI.Length; i++)
{
Interface.CluesUI[i].text = KeyLocations[i].String;
}
EnableBuzzInPeriodForPlayer(_TiebreakerPlayerNumbers[0]);
EnableBuzzInPeriodForPlayer(_TiebreakerPlayerNumbers[1]);
}
else
{
ErrorString = "The Key Locations key should be a list of locations.";
}
}
else
{
ErrorString = "Each region entry should have a region type and a list of key locations.";
}
} }
else else
{ {
ErrorString = "Ensure the elements of the root dictionary are all dictionaries."; int TieBreakerVersion = (int)TiebreakerDictionary["Version"].Number;
switch(TieBreakerVersion)
{
case 2:
ParseTiebreakerData_v2(Interface, TiebreakerDictionary); break;
default:
ErrorString = "No version information could be parsed for this JSON file."; break;
}
} }
} }
else else
@ -1614,6 +1586,107 @@ public class GameManagerRound1 : GameManagerBase
{ {
Debug.LogError("Malformed tiebreaker data file. " + ErrorString); Debug.LogError("Malformed tiebreaker data file. " + ErrorString);
} }
else
{
EnableBuzzInPeriodForPlayer(_TiebreakerPlayerNumbers[0]);
EnableBuzzInPeriodForPlayer(_TiebreakerPlayerNumbers[1]);
}
}
private string ParseTiebreakerData_v1(HostCardTiebreakerInterface Interface, DataDictionary TiebreakerDictionary)
{
DataList TiebreakerRegions = TiebreakerDictionary.GetKeys();
Random.InitState(Networking.GetServerTimeInMilliseconds());
int TiebreakerIndex = Random.Range(0, TiebreakerRegions.Count);
string TiebreakerRegion = TiebreakerRegions[TiebreakerIndex].String;
Interface.ChoiceUI[1].text = TiebreakerRegion;
if (TiebreakerDictionary[TiebreakerRegion].TokenType == TokenType.DataDictionary)
{
DataDictionary RegionDictionary = TiebreakerDictionary[TiebreakerRegion].DataDictionary;
if (RegionDictionary.ContainsKey("Type") && RegionDictionary.ContainsKey("Key Locations"))
{
Interface.HeaderUI.text = "Tiebreaker | " + RegionDictionary["Type"].String;
if (RegionDictionary["Key Locations"].TokenType == TokenType.DataList)
{
for (int i = 0; i < Interface.CluesUI.Length; i++)
{
Interface.CluesUI[i].text = "";
}
DataList KeyLocations = RegionDictionary["Key Locations"].DataList;
for (int i = 0; i < KeyLocations.Count && i < Interface.CluesUI.Length; i++)
{
Interface.CluesUI[i].text = KeyLocations[i].String;
}
}
else
{
return "The Key Locations key should be a list of locations.";
}
}
else
{
return "Each region entry should have a region type and a list of key locations.";
}
}
else
{
return "Ensure the elements of the root dictionary are all dictionaries.";
}
return "";
}
private string ParseTiebreakerData_v2(HostCardTiebreakerInterface Interface, DataDictionary TiebreakerDictionary)
{
if (TiebreakerDictionary.ContainsKey("Categories") && TiebreakerDictionary["Categories"].TokenType == TokenType.DataDictionary)
{
DataDictionary Categories = TiebreakerDictionary["Categories"].DataDictionary;
DataList TiebreakerRegions = Categories.GetKeys();
Random.InitState(Networking.GetServerTimeInMilliseconds());
int TiebreakerIndex = Random.Range(0, TiebreakerRegions.Count);
string TiebreakerCategory = TiebreakerRegions[TiebreakerIndex].String;
Interface.HeaderUI.text = "Tiebreaker | " + TiebreakerCategory;
if (Categories[TiebreakerCategory].TokenType == TokenType.DataDictionary)
{
DataDictionary Locations = Categories[TiebreakerCategory].DataDictionary;
DataList TiebreakerLocations = Locations.GetKeys();
int LocationIndex = Random.Range(0, TiebreakerLocations.Count);
string TiebreakerLocation = TiebreakerLocations[LocationIndex].String;
Interface.ChoiceUI[1].text = TiebreakerLocation;
if (Locations[TiebreakerLocation].TokenType == TokenType.DataList)
{
for (int i = 0; i < Interface.CluesUI.Length; i++)
{
Interface.CluesUI[i].text = "";
}
DataList KeyLocations = Locations[TiebreakerLocation].DataList;
for (int i = 0; i < KeyLocations.Count && i < Interface.CluesUI.Length; i++)
{
Interface.CluesUI[i].text = KeyLocations[i].String;
}
}
else
{
return "Incorrect location format. Ensure all location keys have array values.";
}
}
else
{
return "Incorrect category format. Ensure all categories are dictionary types.";
}
}
else
{
return "No categories in the JSON file. Ensure all categories are dictionary types.";
}
return "";
} }
public void TiebreakerIncorrectResponse() public void TiebreakerIncorrectResponse()