fixed a couple of minor issues

This commit is contained in:
Pecha 2020-09-27 16:50:09 +10:00
parent dd7ab78096
commit 500ae171fc
5 changed files with 73 additions and 47 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
bin/
obj/

View File

@ -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;

View File

@ -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<string, string>();
var namematcher = new Regex(@"[^ ].[A-Za-z\- ]{2,}(?<! )");
if (namematcher.Match(userin).Success) {
@ -106,8 +105,11 @@ namespace creachopedia {
else {
Console.WriteLine("Sorry, this name is invalid, please try again.");
}
break;
}
else if (substatus == 2) {
case "add" when substatus == 2:
{
if (int.TryParse(userin, out int footsiecounter)) {
tempdict.Add("footsies", userin);
if (footsiecounter >= 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("");

View File

@ -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
}
}