Merge remote-tracking branch 'origin/monogame' into monogame

# Conflicts:
#	ShiftOS.Frontend/Apps/ChatClient.cs
This commit is contained in:
Michael 2017-08-03 09:46:48 -04:00
commit 8fe8026de5
2 changed files with 50 additions and 24 deletions

View file

@ -93,6 +93,13 @@ namespace ShiftOS.Frontend.Apps
//Let's try the AI stuff... :P
var rmsg = _messages[rnd.Next(_messages.Count)].Message;
if (!messagecache.Contains(_messages.Last().Message))
{
messagecache.Add(_messages.Last().Message);
#if RIP_USERS_SSD
SaveCache();
#endif
}
var split = new List<string>(rmsg.Split(' '));
List<string> nmsg = new List<string>();
if (split.Count > 2)
@ -109,10 +116,10 @@ namespace ShiftOS.Frontend.Apps
{
split.RemoveAt(i);
}
split.AddRange(Regex.Split(Regex.Replace(_messages[rnd.Next(_messages.Count)].Message, "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase), " "));
split.AddRange(Regex.Split(Regex.Replace(messagecache[rnd.Next(messagecache.Count)], "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase), " "));
}
split.RemoveAt(rnd.Next(split.Count));
split.Add(Regex.Replace(_messages[rnd.Next(_messages.Count)].Message, "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase));
split.Add(Regex.Replace(messagecache[rnd.Next(messagecache.Count)], "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase));
string combinedResult = string.Join(" ", split);
_messages.Add(new ChatMessage
{
@ -125,7 +132,7 @@ namespace ShiftOS.Frontend.Apps
readonly string[] outcomes = new string[] { "ok", "sure", "yeah", "yes", "no", "nope", "alright" };
Random rnd = new Random();
List<string> messagecache = new List<string>();
private List<string> messagecache = new List<string>();
public void SendClientMessage(string nick, string message)
{
@ -168,21 +175,30 @@ namespace ShiftOS.Frontend.Apps
}
gfx.DrawRectangle(vertSeparatorLeft, 0, 1, _bottomseparator, UIManager.SkinTextures["ControlTextColor"]);
}
public void OnLoad()
{
if (System.IO.File.Exists("aicache.dat"))
messagecache = System.IO.File.ReadAllLines("aicache.dat").ToList();
}
public void OnSkinLoad()
{
}
public bool OnUnload()
{
// this doesn't get called... dammit
SaveCache();
return true;
}
private void SaveCache()
{
// It's watching you...
System.IO.File.WriteAllLines("aicache.dat", messagecache);
}
public void OnUpgrade()
{
}

View file

@ -85,16 +85,22 @@ namespace ShiftOS.Engine
int commandPos;
int firstValuePos = -1;
int lastValuePos = -1;
int firstTextPart = -1;
for (int ii = 0; ii < parts.Count; ii++)
{
CommandFormat part = parts[ii];
if(part is CommandFormatText)
{
if(firstTextPart < 0)
firstTextPart = ii;
}
if (part is CommandFormatMarker)
{
if (part is CommandFormatCommand)
{
commandPos = ii;
}
else if (part is CommandFormatValue)
{
if (firstValuePos > -1)
@ -110,40 +116,44 @@ namespace ShiftOS.Engine
int help = -1;
bool id_found = false;
string id_text = "";
while (position < text.Length)
{
if (i >= parts.Count)
{
position = text.Length;
command = "+FALSE+";
i = 0;
i = 1;
}
CommandFormat part = parts[i];
var part = parts[i];
string inp = text.Substring(position);
string res = part.CheckValidity(inp);
if(part is CommandFormatText)
if (part is CommandFormatText)
{
if (res == "+FALSE+")
{
#if SUPERMOSQUITO_DIAGNOSIS
if (!inp.Remove(0, 1).Contains(" "))
if (id_found == false)
{
if (id_found == false)
id_found = true;
currentArgument = "id";
if (!arguments.ContainsKey("id"))
{
id_found = true;
id_text = inp.Remove(0, 1);
res = "";
arguments.Add("id", id_text);
arguments.Add("id", "");
i = firstValuePos;
position++;
continue;
}
else
{
Console.WriteLine("Duplicate command-line argument detected: id");
command = "+FALSE+";
position = text.Length;
}
}
#endif
}
}
// ok so: