Commit 69cd5ef3 authored by SherryChaos's avatar SherryChaos

Fix segmentation error in description of pendulum card

parent 117ecad5
......@@ -258,7 +258,7 @@ namespace MDPro3
cardArtPendulum.gameObject.SetActive(true);
cardArtPendulum.texture = art;
}
var pendulumDescription = CardDescription.GetCardDescriptionSplit(data.Desc);
var pendulumDescription = CardDescription.GetCardDescriptionSplit(data.Desc, true);
cardDescription.text = StringHelper.GetType(data, true).Replace(Program.slash, bigSlash) + "\r\n" + TextForRender(pendulumDescription[1]);
cardDescriptionPendulum.text = TextForRender(pendulumDescription[0]);
lScale.text = data.LScale.ToString();
......
......@@ -501,30 +501,50 @@ namespace MDPro3
return returnValue;
}
public static string[] GetCardDescriptionSplit(string description)
public static string[] GetCardDescriptionSplit(string description, bool render = false)
{
var returnValue = new string[2];
var lines = description.Replace("\r", "").Split('\n');
var language = render ? Config.Get("CardLanguage", "zh-CN") : Config.Get("Language", "zh-CN");
int pendulumEnd = 0;
for (int i = 1; i < lines.Length; i++)
int beforePendulum = 1;
int splitLines = 1;
string symbol = "";
int monsterStart = 0;
if (language == "en-US")
{
if (lines[i].Contains(""))
beforePendulum = 2;
splitLines = 2;
symbol = "[";
}
if (language == "es-ES")
{
pendulumEnd = i;
break;
beforePendulum = 2;
splitLines = 2;
}
if (language == "zh-TW")
{
beforePendulum = 0;
}
for (int i = 1; i < lines.Length; i++)
for (int i = beforePendulum; i < lines.Length; i++)
if (lines[i].StartsWith(symbol))
{
monsterStart = i;
break;
}
for (int i = beforePendulum; i < lines.Length; i++)
{
if (i < pendulumEnd)
if (i <= monsterStart - splitLines)
{
if (pendulumEnd - i == 1)
if (monsterStart - i == splitLines)
returnValue[0] += lines[i];
else
returnValue[0] += lines[i] + "\r\n";
}
else if (i > pendulumEnd)
else if (i > monsterStart)
{
if (i == lines.Length - 1)
returnValue[1] += lines[i];
......@@ -532,6 +552,8 @@ namespace MDPro3
returnValue[1] += lines[i] + "\r\n";
}
}
if (language == "es-ES")
returnValue[0] = returnValue[0].Replace("-n/a-", string.Empty);
return returnValue;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment