Changed the data format for tiebreaker rounds.
This commit is contained in:
parent
dfaa5a9132
commit
1f8eeadb08
@ -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}
|
||||||
|
|||||||
@ -1556,6 +1556,44 @@ public class GameManagerRound1 : GameManagerBase
|
|||||||
if (JSONResult.TokenType == TokenType.DataDictionary)
|
if (JSONResult.TokenType == TokenType.DataDictionary)
|
||||||
{
|
{
|
||||||
DataDictionary TiebreakerDictionary = JSONResult.DataDictionary;
|
DataDictionary TiebreakerDictionary = JSONResult.DataDictionary;
|
||||||
|
if (!TiebreakerDictionary.ContainsKey("Version"))
|
||||||
|
{
|
||||||
|
ErrorString = ParseTiebreakerData_v1(Interface, TiebreakerDictionary);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
ErrorString = "Ensure the first element is a dictionary.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ErrorString = "Could not parse JSON document.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (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();
|
DataList TiebreakerRegions = TiebreakerDictionary.GetKeys();
|
||||||
|
|
||||||
Random.InitState(Networking.GetServerTimeInMilliseconds());
|
Random.InitState(Networking.GetServerTimeInMilliseconds());
|
||||||
@ -1581,39 +1619,74 @@ public class GameManagerRound1 : GameManagerBase
|
|||||||
{
|
{
|
||||||
Interface.CluesUI[i].text = KeyLocations[i].String;
|
Interface.CluesUI[i].text = KeyLocations[i].String;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnableBuzzInPeriodForPlayer(_TiebreakerPlayerNumbers[0]);
|
|
||||||
EnableBuzzInPeriodForPlayer(_TiebreakerPlayerNumbers[1]);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ErrorString = "The Key Locations key should be a list of locations.";
|
return "The Key Locations key should be a list of locations.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ErrorString = "Each region entry should have a region type and a list of key locations.";
|
return "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.";
|
return "Ensure the elements of the root dictionary are all dictionaries.";
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ErrorString = "Ensure the first element is a dictionary.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ErrorString = "Could not parse JSON document.";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ErrorString != "")
|
return "";
|
||||||
{
|
|
||||||
Debug.LogError("Malformed tiebreaker data file. " + ErrorString);
|
|
||||||
}
|
}
|
||||||
|
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()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user