Fixed gamebreaking bug inside InsertVariables method. I might need to write some unit tests for RuriLib soon...

This commit is contained in:
ruri
2019-05-06 13:55:08 +02:00
parent 2688614030
commit 3dd837cf24
2 changed files with 5 additions and 9 deletions
+3 -5
View File
@@ -289,12 +289,10 @@ namespace RuriLib
/// <param name="suffix">The string to add at the end of the value</param>
public static void InsertVariables(BotData data, bool isCapture, bool recursive, List<string> values, string variableName, string prefix, string suffix)
{
var list = values
.Where(v => !string.IsNullOrEmpty(v)) // Remove the empty entries, e.g. the one added by default by the Parse Block
.Select(v => ReplaceValues(prefix, data) + v.Trim() + ReplaceValues(suffix, data));
var list = values.Select(v => ReplaceValues(prefix, data) + v.Trim() + ReplaceValues(suffix, data)).ToList();
CVar variable;
if (recursive) variable = new CVar(variableName, list.ToList(), isCapture);
else variable = new CVar(variableName, list.First(), isCapture);
if (recursive) variable = new CVar(variableName, list, isCapture);
else variable = new CVar(variableName, list.Count == 0 ? "" : list.First(), isCapture);
data.Variables.Set(variable);
data.Log(new LogEntry("Parsed variable" + " | Name: " + variable.Name + " | Value: " + variable.ToString() + Environment.NewLine, isCapture ? Colors.OrangeRed : Colors.Gold));
}