From bec3c8424f2612a6b58244ae2462a17455da8303 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 3 Aug 2017 08:49:07 -0400 Subject: [PATCH] fire hydrant and banana cowfiles --- ShiftOS.Frontend/Apps/ChatClient.cs | 8 ++-- ShiftOS.Frontend/Apps/Installer.cs | 14 +++++- ShiftOS.Frontend/Commands.cs | 28 ++++++++---- .../Properties/Resources.Designer.cs | 43 +++++++++++++++++-- ShiftOS.Frontend/Properties/Resources.resx | 6 +++ ShiftOS.Frontend/Resources/LootInfo.txt | 12 ++++++ ShiftOS.Frontend/Resources/banana.cow.stp.txt | 6 +++ .../Resources/fire hydrant.cow.stp.txt | 6 +++ ShiftOS.Frontend/ShiftOS.Frontend.csproj | 3 ++ ShiftOS_TheReturn/CommandParser.cs | 24 +++++++---- 10 files changed, 124 insertions(+), 26 deletions(-) create mode 100644 ShiftOS.Frontend/Resources/banana.cow.stp.txt create mode 100644 ShiftOS.Frontend/Resources/fire hydrant.cow.stp.txt diff --git a/ShiftOS.Frontend/Apps/ChatClient.cs b/ShiftOS.Frontend/Apps/ChatClient.cs index de9d80f..cac665c 100644 --- a/ShiftOS.Frontend/Apps/ChatClient.cs +++ b/ShiftOS.Frontend/Apps/ChatClient.cs @@ -92,9 +92,7 @@ namespace ShiftOS.Frontend.Apps _input.Text = ""; //Let's try the AI stuff... :P - if (!messagecache.Contains(_messages.Last().Message)) - messagecache.Add(_messages.Last().Message); - var rmsg = messagecache[rnd.Next(messagecache.Count)]; + var rmsg = _messages[rnd.Next(_messages.Count)].Message; var split = new List(rmsg.Split(' ')); List nmsg = new List(); if (split.Count > 2) @@ -111,10 +109,10 @@ namespace ShiftOS.Frontend.Apps { split.RemoveAt(i); } - split.AddRange(Regex.Split(Regex.Replace(messagecache[rnd.Next(messagecache.Count)], "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase), " ")); + split.AddRange(Regex.Split(Regex.Replace(_messages[rnd.Next(_messages.Count)].Message, "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase), " ")); } split.RemoveAt(rnd.Next(split.Count)); - split.Add(Regex.Replace(messagecache[rnd.Next(messagecache.Count)], "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase)); + split.Add(Regex.Replace(_messages[rnd.Next(_messages.Count)].Message, "debugbot", outcomes[rnd.Next(outcomes.Length)], RegexOptions.IgnoreCase)); string combinedResult = string.Join(" ", split); _messages.Add(new ChatMessage { diff --git a/ShiftOS.Frontend/Apps/Installer.cs b/ShiftOS.Frontend/Apps/Installer.cs index 86045e1..816e9b5 100644 --- a/ShiftOS.Frontend/Apps/Installer.cs +++ b/ShiftOS.Frontend/Apps/Installer.cs @@ -66,6 +66,17 @@ namespace ShiftOS.Frontend.Apps Shiftorium.Buy(_setup.Source, 0); Engine.Infobox.Show("Upgrade installed.", "The upgrade \"" + _setup.Source + "\" has been installed and is now ready to be used!"); + break; + case SetupSource.CowFile: + string cow = _setup.Source; + string[] split = cow.Split('\t'); + string fname = split[0] + ".cow"; + string ascii = split[1]; + string csCowfiles = Paths.GetPath("data") + "/cows"; + if (!DirectoryExists(csCowfiles)) + CreateDirectory(csCowfiles); + WriteAllText(csCowfiles + "/" + fname, ascii); + Engine.Infobox.Show("Cowsay", "New cowfile installed! Have fun with your talking " + split[0] + "!"); break; } } @@ -126,6 +137,7 @@ namespace ShiftOS.Frontend.Apps public enum SetupSource { - ShiftoriumUpgrade + ShiftoriumUpgrade, + CowFile } } diff --git a/ShiftOS.Frontend/Commands.cs b/ShiftOS.Frontend/Commands.cs index a4b70b0..7218802 100644 --- a/ShiftOS.Frontend/Commands.cs +++ b/ShiftOS.Frontend/Commands.cs @@ -52,6 +52,7 @@ namespace ShiftOS.Frontend { var builder = new List(); int speechlen = (args.ContainsKey("width")) ? Convert.ToInt32(args["width"].ToString()) : 50; + string cowfile = (args.ContainsKey("file")) ? args["file"].ToString() : null; string speech = args["id"].ToString(); AnimalMode _mode = AnimalMode.Normal; if (args.ContainsKey("mode")) @@ -72,7 +73,7 @@ namespace ShiftOS.Frontend } DrawSpeechBubble(ref builder, speechlen, speech); - DrawCow(ref builder, _mode); + DrawCow(ref builder, _mode, cowfile); Console.WriteLine(string.Join(Environment.NewLine, builder.ToArray())); } @@ -150,7 +151,7 @@ namespace ShiftOS.Frontend Youthful } - private static void DrawCow(ref List Builder, AnimalMode AnimalMode) + private static void DrawCow(ref List Builder, AnimalMode AnimalMode, string cowfile) { var startingLinePadding = Builder.First().Length / 4; @@ -194,12 +195,23 @@ namespace ShiftOS.Frontend break; } - - Builder.Add($"{' '.RepeatChar(startingLinePadding)}\\ ^__^"); - Builder.Add($"{' '.RepeatChar(startingLinePadding)} \\ ({eyeChar.RepeatChar(2)})\\_______"); - Builder.Add($"{' '.RepeatChar(startingLinePadding)} (__)\\ )\\/\\"); - Builder.Add($"{' '.RepeatChar(startingLinePadding)} {tongueChar.RepeatChar(1)} ||----w |"); - Builder.Add($"{' '.RepeatChar(startingLinePadding)} || ||"); + string cowpath = Paths.GetPath("data") + "/cows/" + cowfile + ".cow"; + if (string.IsNullOrWhiteSpace(cowfile) || !Utils.FileExists(cowpath)) + { + Builder.Add($"{' '.RepeatChar(startingLinePadding)}\\ ^__^"); + Builder.Add($"{' '.RepeatChar(startingLinePadding)} \\ ({eyeChar.RepeatChar(2)})\\_______"); + Builder.Add($"{' '.RepeatChar(startingLinePadding)} (__)\\ )\\/\\"); + Builder.Add($"{' '.RepeatChar(startingLinePadding)} {tongueChar.RepeatChar(1)} ||----w |"); + Builder.Add($"{' '.RepeatChar(startingLinePadding)} || ||"); + } + else + { + string[] lines = Utils.ReadAllText(cowpath).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); + foreach(var line in lines) + { + Builder.Add($"{' '.RepeatChar(startingLinePadding)}{line.Replace("#", eyeChar.ToString())}"); + } + } } } diff --git a/ShiftOS.Frontend/Properties/Resources.Designer.cs b/ShiftOS.Frontend/Properties/Resources.Designer.cs index 0092c49..550ab28 100644 --- a/ShiftOS.Frontend/Properties/Resources.Designer.cs +++ b/ShiftOS.Frontend/Properties/Resources.Designer.cs @@ -60,6 +60,20 @@ namespace ShiftOS.Frontend.Properties { } } + /// + /// Looks up a localized string similar to { + /// Name: "Cowsay Banana Cowfile", + /// Description: "It's fun to play with food. Especially in the form of a cowfile. This install file adds a Banana to Cowsay's cowfile list. To use it, simply do \"cowsay --id Hello --file banana\".", + /// SourceType: "CowFile", + /// Source: "banana\t\"-..___ __.='>\r\n`. \"\"\"\"\" ,'\r\n \"-..__ _.-\"\r\n \"\"\"" + ///}. + /// + public static string banana_cow_stp { + get { + return ResourceManager.GetString("banana.cow.stp", resourceCulture); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -97,6 +111,19 @@ namespace ShiftOS.Frontend.Properties { } } + /// + /// Looks up a localized string similar to { + /// Name: "Cowsay Fire Hydrant Cowfile", + /// Description: "Ever been so thirsty that you wanted to open a fire hydrant and just take a giant drink of water? Well, you can't do that with this install file, but you can at least get a neat cowfile firehydrant so you can make one talk!", + /// SourceType: "CowFile", + /// Source:"fire hydrant\t \\ !\r\n \\ .:::.\r\n ///|\\\\\\\r\n {=-#-#-=}\r\n .-||||/..\\\r\n c[I ||||\\''/\r\n '-||||||| \r\n |||||||\r\n |||||||\r\n |||||||\r\n [rest of string was truncated]";. + /// + public static string fire_hydrant_cow_stp { + get { + return ResourceManager.GetString("fire hydrant.cow.stp", resourceCulture); + } + } + /// /// Looks up a localized string similar to /* ShiftOS hackables data file /// * @@ -152,13 +179,16 @@ namespace ShiftOS.Frontend.Properties { /// ID: "sploitset_keepalive" /// }, /// { + /// FriendlyName: "Banana Cow", + /// LootName: "banana.cow.stp", + /// Rarity: 1, + /// PointTo: "banana_cow_stp", + /// }, + /// { /// FriendlyName: "SSHardline", /// LootName: "sploitset_sshardline.stp", /// Rarity: 1, - /// PointTo: "sploitset_sshardline", - /// ID: "sploitset_keepalive" - /// } - ///]. + /// PointTo: "sploitset_ssh [rest of string was truncated]";. /// public static string LootInfo { get { @@ -260,6 +290,11 @@ namespace ShiftOS.Frontend.Properties { /// Cost: 1000000000, /// Description: "lolyouarentsupposedtobeabletobuythis", /// Dependencies: "thisupgradeshouldneverexistever", + /// }, + /// { + /// Name: "Pong", + /// Cost: 0, + /// Dependencies: "pong", /// } ///]. /// diff --git a/ShiftOS.Frontend/Properties/Resources.resx b/ShiftOS.Frontend/Properties/Resources.resx index 0298116..9f9582e 100644 --- a/ShiftOS.Frontend/Properties/Resources.resx +++ b/ShiftOS.Frontend/Properties/Resources.resx @@ -157,4 +157,10 @@ ..\Resources\sploitset_keepalive.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + ..\Resources\banana.cow.stp.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + + ..\Resources\fire hydrant.cow.stp.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + \ No newline at end of file diff --git a/ShiftOS.Frontend/Resources/LootInfo.txt b/ShiftOS.Frontend/Resources/LootInfo.txt index 188eb7c..dc0c109 100644 --- a/ShiftOS.Frontend/Resources/LootInfo.txt +++ b/ShiftOS.Frontend/Resources/LootInfo.txt @@ -12,6 +12,18 @@ PointTo: "sploitset_keepalive", ID: "sploitset_keepalive" }, + { + FriendlyName: "Banana Cow", + LootName: "banana.cow.stp", + Rarity: 1, + PointTo: "banana_cow_stp", + }, + { + FriendlyName: "Fire Hydrant Cow", + LootName: "fire hydrant.cow.stp", + Rarity: 1, + PointTo: "fire_hydrant_cow_stp", + }, { FriendlyName: "SSHardline", LootName: "sploitset_sshardline.stp", diff --git a/ShiftOS.Frontend/Resources/banana.cow.stp.txt b/ShiftOS.Frontend/Resources/banana.cow.stp.txt new file mode 100644 index 0000000..0147faf --- /dev/null +++ b/ShiftOS.Frontend/Resources/banana.cow.stp.txt @@ -0,0 +1,6 @@ +{ + Name: "Cowsay Banana Cowfile", + Description: "It's fun to play with food. Especially in the form of a cowfile. This install file adds a Banana to Cowsay's cowfile list. To use it, simply do \"cowsay --id Hello --file banana\".", + SourceType: "CowFile", + Source: "banana\t\"-..___ __.='>\r\n`. \"\"\"\"\" ,'\r\n \"-..__ _.-\"\r\n \"\"\"" +} \ No newline at end of file diff --git a/ShiftOS.Frontend/Resources/fire hydrant.cow.stp.txt b/ShiftOS.Frontend/Resources/fire hydrant.cow.stp.txt new file mode 100644 index 0000000..f25803c --- /dev/null +++ b/ShiftOS.Frontend/Resources/fire hydrant.cow.stp.txt @@ -0,0 +1,6 @@ +{ + Name: "Cowsay Fire Hydrant Cowfile", + Description: "Ever been so thirsty that you wanted to open a fire hydrant and just take a giant drink of water? Well, you can't do that with this install file, but you can at least get a neat cowfile firehydrant so you can make one talk!", + SourceType: "CowFile", + Source:"fire hydrant\t \\ !\r\n \\ .:::.\r\n ///|\\\\\\\r\n {=-#-#-=}\r\n .-||||/..\\\r\n c[I ||||\\''/\r\n '-||||||| \r\n |||||||\r\n |||||||\r\n |||||||\r\n [=======]\r\n" +} \ No newline at end of file diff --git a/ShiftOS.Frontend/ShiftOS.Frontend.csproj b/ShiftOS.Frontend/ShiftOS.Frontend.csproj index c029107..cfc1132 100644 --- a/ShiftOS.Frontend/ShiftOS.Frontend.csproj +++ b/ShiftOS.Frontend/ShiftOS.Frontend.csproj @@ -107,6 +107,7 @@ PublicResXFileCodeGenerator + Designer Resources.Designer.cs @@ -196,6 +197,8 @@ + + diff --git a/ShiftOS_TheReturn/CommandParser.cs b/ShiftOS_TheReturn/CommandParser.cs index 7568b98..8f25668 100644 --- a/ShiftOS_TheReturn/CommandParser.cs +++ b/ShiftOS_TheReturn/CommandParser.cs @@ -121,20 +121,28 @@ namespace ShiftOS.Engine i = 0; } - CommandFormat part = parts[i]; - string inp = text.Substring(position); + CommandFormat part = parts[i]; + string inp = text.Substring(position); string res = part.CheckValidity(inp); if(part is CommandFormatText) { - if(res == "+FALSE+") + if (res == "+FALSE+") { - if(id_found == false) +#if SUPERMOSQUITO_DIAGNOSIS + if (!inp.Remove(0, 1).Contains(" ")) { - id_found = true; - id_text = inp.Remove(0,1); - res = ""; - arguments.Add("id", id_text); + + + if (id_found == false) + { + id_found = true; + id_text = inp.Remove(0, 1); + res = ""; + arguments.Add("id", id_text); + + } } +#endif } }