From 500ae171fc5abece7758b00a2787565717d3faa0 Mon Sep 17 00:00:00 2001 From: Pecha Date: Sun, 27 Sep 2020 16:50:09 +1000 Subject: [PATCH] fixed a couple of minor issues --- .gitignore | 2 ++ Creacher.cs | 14 ++++---- Program.cs | 86 ++++++++++++++++++++++++++------------------- creachopedia.csproj | 4 +-- creachopedia.json | 14 ++++++-- 5 files changed, 73 insertions(+), 47 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbbd0b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bin/ +obj/ \ No newline at end of file diff --git a/Creacher.cs b/Creacher.cs index 0526cb1..d93adc9 100644 --- a/Creacher.cs +++ b/Creacher.cs @@ -2,7 +2,7 @@ using System; using Newtonsoft.Json; namespace creachopedia { - enum Locomotion { + internal enum Locomotion { None, //barnacles, plants and so on Walker, Swimmer, @@ -11,22 +11,22 @@ namespace creachopedia { Slitherer, Incher // snails et al } - enum SurfaceRel { + + internal enum SurfaceRel { Below, At, Above } - class Creacher { + + internal class Creacher { public string name {get; set;} - // public int kingdom; - // public string description; [JsonProperty] private int _footsies { get; set; } [JsonIgnore] public int footsies {get { return this._footsies; } set { Console.WriteLine("What do you think you're doing?! 0uo Leave those footsies alone!!!"); }} public string type = "simple creacher"; - Locomotion locoStyle {get; set;} - SurfaceRel height {get; set;} + private Locomotion locoStyle {get; set;} + private SurfaceRel height {get; set;} public Creacher(string name, int footsyCount = 4, string biome = "land", Locomotion locoStyle = Locomotion.Walker, SurfaceRel height = SurfaceRel.At) { this.name = name; diff --git a/Program.cs b/Program.cs index dbc7f7a..c5ba965 100644 --- a/Program.cs +++ b/Program.cs @@ -62,41 +62,40 @@ namespace creachopedia { string userin = Console.ReadLine(); string luserin = userin.ToLower(); - if (status == "base") { - if (luserin == "q" || luserin == "quit") { + switch (status) + { + case "base" when luserin == "q" || luserin == "quit": Console.WriteLine("Thank you for using the CreachoPedia, please come again!!!!"); return; - } - if (creacherdict.ContainsKey(userin)) { + case "base" when creacherdict.ContainsKey(userin): creacherdict[userin].Introduce(); creacherdict[userin].Step(); - } - else if (luserin == "heenlo!" || luserin == "henlo" || luserin == "heenlo" || luserin == "henlo!") { + break; + case "base" when luserin == "heenlo!" || luserin == "henlo" || luserin == "heenlo" || luserin == "henlo!": Console.WriteLine("Well heenlo to you too! 0u0"); - } - else if (userin == "*pats*") { + break; + case "base" when userin == "*pats*": Console.WriteLine("Oh! Thank you!"); - } - else if (luserin == "a" || luserin == "add") { + break; + case "base" when luserin == "a" || luserin == "add": status = "add"; - } - else { + break; + case "base": Console.WriteLine($"I don't know what {userin} is! What on boo Earth?!!?!?!?"); - } - } - else if (status == "add") { - if (luserin == "x") { + break; + case "add" when luserin == "x": substatus--; luserin = ""; - } - else if (luserin == "q") { + break; + case "add" when luserin == "q": status = "base"; - } - else if (substatus == 0) { + break; + case "add" when substatus == 0: status = "base"; substatus = 1; - } - else if (substatus == 1) { + break; + case "add" when substatus == 1: + { tempdict = new Dictionary(); var namematcher = new Regex(@"[^ ].[A-Za-z\- ]{2,}(?= 5) { @@ -121,12 +123,15 @@ namespace creachopedia { else { Console.WriteLine("Sorry, this is not a number!"); } + + break; } - else if (substatus == 3) { + case "add" when substatus == 3: tempdict.Add("biome", luserin); substatus ++; - } - else if (substatus == 4) { + break; + case "add" when substatus == 4: + { var locomatcher = new Regex(@"^[nwshfli]$"); if (locomatcher.Match(userin).Success) { tempdict.Add("locomethod", userin); @@ -135,8 +140,11 @@ namespace creachopedia { else { Console.WriteLine("Sorry, this type is invalid, please try again."); } + + break; } - else if (substatus == 5) { + case "add" when substatus == 5: + { var relsurfacematcher = new Regex(@"^[abv]$"); if (relsurfacematcher.Match(luserin).Success) { tempdict.Add("surfacerel", luserin); @@ -145,19 +153,25 @@ namespace creachopedia { else { Console.WriteLine("Sorry, this surface relation did not match one of the three listed above. Please try again."); } - } - else if (substatus == 6) { - Console.WriteLine("test0"); - var tempcreach = new Creacher(tempdict["name"], int.Parse(tempdict["footsies"]), tempdict["biome"], (Locomotion)Enum.Parse(typeof(Locomotion), shortdefs[tempdict["locomethod"]]), (SurfaceRel)Enum.Parse(typeof(SurfaceRel), shortdefs[tempdict["surfacerel"]])); - creacherdict.Add(tempdict["name"], tempcreach); - File.WriteAllText("creachopedia.json", JsonConvert.SerializeObject(creacherdict, Formatting.Indented)); - Console.WriteLine("Creacher adde! 0u0"); - status = "base"; - substatus = 1; + + break; } // foreach (var i in tempdict) { // Console.WriteLine("{0}:{1}", i.Key, i.Value); // } + case "add": + { + if (substatus == 6) { + var tempcreach = new Creacher(tempdict["name"], int.Parse(tempdict["footsies"]), tempdict["biome"], (Locomotion)Enum.Parse(typeof(Locomotion), shortdefs[tempdict["locomethod"]]), (SurfaceRel)Enum.Parse(typeof(SurfaceRel), shortdefs[tempdict["surfacerel"]])); + creacherdict.Add(tempdict["name"], tempcreach); + File.WriteAllText("creachopedia.json", JsonConvert.SerializeObject(creacherdict, Formatting.Indented)); + Console.WriteLine("Creacher added! 0u0"); + status = "base"; + substatus = 1; + } + + break; + } } Console.WriteLine(""); diff --git a/creachopedia.csproj b/creachopedia.csproj index 088c274..ba2177a 100644 --- a/creachopedia.csproj +++ b/creachopedia.csproj @@ -5,8 +5,8 @@ netcoreapp3.1 - - + + diff --git a/creachopedia.json b/creachopedia.json index 0c11d93..2322ae1 100644 --- a/creachopedia.json +++ b/creachopedia.json @@ -14,9 +14,19 @@ "name": "stingray", "_footsies": 0 }, - "Snool": { + "snool": { "type": "creacher of the urban", - "name": "Snool", + "name": "snool", "_footsies": 1 + }, + "aquapig": { + "type": "creacher of the sea", + "name": "aquapig", + "_footsies": 4 + }, + "croncher the crab": { + "type": "creacher of the sea", + "name": "croncher the crab", + "_footsies": 6 } } \ No newline at end of file