2020-09-07 06:58:48 +00:00
using System ;
using System.Collections.Generic ;
2020-09-07 07:16:56 +00:00
using System.Threading ;
2020-09-09 09:56:39 +00:00
using Newtonsoft.Json ;
using System.IO ;
2020-09-09 13:20:12 +00:00
using System.Text.RegularExpressions ;
2020-09-07 06:58:48 +00:00
namespace creachopedia {
2020-09-09 09:56:39 +00:00
class Program {
static void Main ( string [ ] args ) {
2020-09-09 13:20:12 +00:00
var status = "base" ;
var substatus = 1 ;
var tempdict = new Dictionary < string , string > ( ) ;
2020-09-09 09:56:39 +00:00
var creacherdict = JsonConvert . DeserializeObject < Dictionary < string , Creacher > > ( File . ReadAllText ( "creachopedia.json" ) ) ;
2020-09-12 14:34:29 +00:00
var shortdefs = new Dictionary < string , string > ( ) {
{ "a" , "At" } ,
{ "b" , "Below" } ,
{ "v" , "Above" } ,
{ "n" , "None" } ,
{ "w" , "Walker" } ,
{ "s" , "Swimmer" } ,
{ "h" , "Hopper" } ,
{ "f" , "Flier" } ,
{ "l" , "Slitherer" } ,
{ "i" , "Incher" }
} ;
2020-09-07 06:58:48 +00:00
2020-09-09 09:56:39 +00:00
while ( true ) {
2020-09-09 13:20:12 +00:00
switch ( status ) {
case "base" :
Console . WriteLine ( "Please input a creacher name, (a) to add a creacher, or (q) to quit 0u0" ) ;
break ;
case "add" :
switch ( substatus ) {
2020-09-14 12:00:16 +00:00
case 0 :
Console . WriteLine ( "please hit enter to continue" ) ;
break ;
2020-09-09 13:20:12 +00:00
case 1 :
2020-09-14 11:56:07 +00:00
Console . WriteLine ( "Please enter a name for the creacher! Or type (x) to cancel and step back to the previous category, or (q) to cancel addition entirely." ) ;
2020-09-09 13:20:12 +00:00
break ;
case 2 :
Console . WriteLine ( "How many footsies? 0u0 (numerals only plz)" ) ;
break ;
case 3 :
Console . WriteLine ( "Please enter a biome (lowercase open text field)" ) ;
break ;
case 4 :
Console . WriteLine ( "Please enter a method of locomotion:" ) ;
Console . WriteLine ( "[n]one, [w]alker, [s]wimmer, [h]opper, [f]lier, s[l]itherer, [i]ncher" ) ;
break ;
case 5 :
Console . WriteLine ( "Please enter your creacher's relation to the surface: [b]elow, [a]t, abo[v]e" ) ;
break ;
2020-09-12 14:34:29 +00:00
case 6 :
break ;
2020-09-09 13:20:12 +00:00
}
break ;
}
2020-09-09 09:56:39 +00:00
string userin = Console . ReadLine ( ) ;
string luserin = userin . ToLower ( ) ;
2020-09-09 13:20:12 +00:00
2020-09-27 06:50:09 +00:00
switch ( status )
{
case "base" when luserin = = "q" | | luserin = = "quit" :
2020-09-14 12:01:27 +00:00
Console . WriteLine ( "Thank you for using the CreachoPedia, please come again!!!!" ) ;
2020-09-14 11:56:07 +00:00
return ;
2020-09-27 06:50:09 +00:00
case "base" when creacherdict . ContainsKey ( userin ) :
2020-09-09 09:56:39 +00:00
creacherdict [ userin ] . Introduce ( ) ;
creacherdict [ userin ] . Step ( ) ;
2020-09-27 06:50:09 +00:00
break ;
case "base" when luserin = = "heenlo!" | | luserin = = "henlo" | | luserin = = "heenlo" | | luserin = = "henlo!" :
2020-09-09 09:56:39 +00:00
Console . WriteLine ( "Well heenlo to you too! 0u0" ) ;
2020-09-27 06:50:09 +00:00
break ;
case "base" when userin = = "*pats*" :
2020-09-09 09:56:39 +00:00
Console . WriteLine ( "Oh! Thank you!" ) ;
2020-09-27 06:50:09 +00:00
break ;
case "base" when luserin = = "a" | | luserin = = "add" :
2020-09-09 13:20:12 +00:00
status = "add" ;
2020-09-27 06:50:09 +00:00
break ;
case "base" :
2020-09-09 13:20:12 +00:00
Console . WriteLine ( $"I don't know what {userin} is! What on boo Earth?!!?!?!?" ) ;
2020-09-27 06:50:09 +00:00
break ;
case "add" when luserin = = "x" :
2020-09-14 11:56:07 +00:00
substatus - - ;
luserin = "" ;
2020-09-27 06:50:09 +00:00
break ;
case "add" when luserin = = "q" :
2020-09-14 11:56:07 +00:00
status = "base" ;
2020-09-27 06:50:09 +00:00
break ;
case "add" when substatus = = 0 :
2020-09-14 11:56:07 +00:00
status = "base" ;
substatus = 1 ;
2020-09-27 06:50:09 +00:00
break ;
case "add" when substatus = = 1 :
{
2020-09-09 13:20:12 +00:00
tempdict = new Dictionary < string , string > ( ) ;
var namematcher = new Regex ( @"[^ ].[A-Za-z\- ]{2,}(?<! )" ) ;
if ( namematcher . Match ( userin ) . Success ) {
tempdict . Add ( "name" , userin ) ;
substatus + + ;
}
else {
Console . WriteLine ( "Sorry, this name is invalid, please try again." ) ;
}
2020-09-27 06:50:09 +00:00
break ;
2020-09-09 13:20:12 +00:00
}
2020-09-27 06:50:09 +00:00
case "add" when substatus = = 2 :
{
2020-09-09 13:20:12 +00:00
if ( int . TryParse ( userin , out int footsiecounter ) ) {
tempdict . Add ( "footsies" , userin ) ;
if ( footsiecounter > = 5 ) {
Console . WriteLine ( "That's a lot of footsies!!!! 0u0" ) ;
}
if ( footsiecounter % 2 = = 1 ) {
Console . WriteLine ( "An odd number of footsies? What a strange creacher!" ) ;
}
substatus + + ;
}
else {
Console . WriteLine ( "Sorry, this is not a number!" ) ;
}
2020-09-27 06:50:09 +00:00
break ;
2020-09-09 13:20:12 +00:00
}
2020-09-27 06:50:09 +00:00
case "add" when substatus = = 3 :
2020-09-09 13:20:12 +00:00
tempdict . Add ( "biome" , luserin ) ;
substatus + + ;
2020-09-27 06:50:09 +00:00
break ;
case "add" when substatus = = 4 :
{
2020-09-09 13:20:12 +00:00
var locomatcher = new Regex ( @"^[nwshfli]$" ) ;
if ( locomatcher . Match ( userin ) . Success ) {
tempdict . Add ( "locomethod" , userin ) ;
substatus + + ;
}
else {
Console . WriteLine ( "Sorry, this type is invalid, please try again." ) ;
}
2020-09-27 06:50:09 +00:00
break ;
2020-09-09 13:20:12 +00:00
}
2020-09-27 06:50:09 +00:00
case "add" when substatus = = 5 :
{
2020-09-09 13:20:12 +00:00
var relsurfacematcher = new Regex ( @"^[abv]$" ) ;
if ( relsurfacematcher . Match ( luserin ) . Success ) {
tempdict . Add ( "surfacerel" , luserin ) ;
2020-09-12 14:34:29 +00:00
substatus + + ;
2020-09-09 13:20:12 +00:00
}
else {
Console . WriteLine ( "Sorry, this surface relation did not match one of the three listed above. Please try again." ) ;
}
2020-09-27 06:50:09 +00:00
break ;
2020-09-09 13:20:12 +00:00
}
2020-09-14 11:56:07 +00:00
// foreach (var i in tempdict) {
// Console.WriteLine("{0}:{1}", i.Key, i.Value);
// }
2020-09-27 06:50:09 +00:00
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 ;
}
2020-09-09 09:56:39 +00:00
}
Console . WriteLine ( "" ) ;
2020-09-12 14:34:29 +00:00
Thread . Sleep ( 500 ) ;
2020-09-09 09:56:39 +00:00
}
2020-09-07 06:58:48 +00:00
}
2020-09-09 09:56:39 +00:00
}
2020-09-07 06:58:48 +00:00
}