From cc7ff5cd08e10147b12f12e0ac1538146915aab1 Mon Sep 17 00:00:00 2001 From: David Finol Date: Mon, 8 Jul 2024 15:14:12 -0500 Subject: [PATCH] Fix deck loading bug --- .../FinolDigital.Cgs.CardGameDef.Unity/UnityDeck.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/FinolDigital.Cgs.CardGameDef.Unity/UnityDeck.cs b/Assets/Scripts/FinolDigital.Cgs.CardGameDef.Unity/UnityDeck.cs index 824f7109..d5661244 100644 --- a/Assets/Scripts/FinolDigital.Cgs.CardGameDef.Unity/UnityDeck.cs +++ b/Assets/Scripts/FinolDigital.Cgs.CardGameDef.Unity/UnityDeck.cs @@ -216,14 +216,16 @@ private void LoadTxt(string line) tokens.RemoveAt(0); } - if (tokens.Count > 0 && tokens[^1].StartsWith("(") && - tokens[^1].EndsWith(")")) + if (tokens.Count > 0 && line.Contains("(") && line.EndsWith(")")) { - var inParens = tokens[^1].Substring(1, tokens[^1].Length - 2); + var indexOfParens = line.LastIndexOf("(", StringComparison.Ordinal); + var inParens = line.Substring(indexOfParens + 1, line.Length - (indexOfParens + 2)); if (((UnityCardGame) SourceGame).Sets.ContainsKey(inParens)) { cardSet = inParens; - tokens.RemoveAt(tokens.Count - 1); + var cardSetTokenCount = cardSet.Count(f => f == ' ') + 1; + for (var i = 0; i < cardSetTokenCount; i++) + tokens.RemoveAt(tokens.Count - 1); } }