Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Media;
- using System.Threading;
- namespace SoD_Parse
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.SetWindowSize(80, 25);
- Console.Beep();
- Game.ListAdder();
- Game.Start();
- }
- }
- class Game
- {
- public static int area = 0;
- public static int sword = 0;
- public static int revolver = 0;
- public static int shield = 0;
- public static int vines = 0;
- public static string commandIn = "";
- public static char delim = ' ';
- public static List<string> command = new List<string>();
- public static List<string> inv = new List<string>();
- public static List<string> vocab = new List<string>();
- public static List<string> hitable = new List<string>();
- public static List<string> hitter = new List<string>();
- public static List<string> gettable = new List<string>();
- public static List<string> seeable = new List<string>();
- public static void ListAdder()
- {
- //vocab
- //verbs
- vocab.Add("help");
- vocab.Add("exit");
- vocab.Add("yes");
- vocab.Add("no");
- vocab.Add("look");
- vocab.Add("get");
- vocab.Add("hit");
- vocab.Add("shoot");
- vocab.Add("die");
- vocab.Add("give");
- vocab.Add("north");
- vocab.Add("n");
- vocab.Add("south");
- vocab.Add("s");
- vocab.Add("east");
- vocab.Add("e");
- vocab.Add("west");
- vocab.Add("w");
- vocab.Add("flip");
- vocab.Add("f");
- vocab.Add("stand");
- //nouns
- //player parts
- vocab.Add("fists");
- hitter.Add("fists");
- //objects
- //inventory (mostly unimplemented)
- vocab.Add("sword");
- hitter.Add("sword");
- gettable.Add("sword");
- seeable.Add("sword");
- seeable.Add("revolver");
- vocab.Add("coin");
- vocab.Add("shield");
- vocab.Add("revolver");
- gettable.Add("revolver");
- vocab.Add("sign");
- vocab.Add("vines");
- //actors(can act as objects in certain conditions)
- vocab.Add("statue");
- vocab.Add("monster");
- //hittable
- hitable.Add("vines");
- hitable.Add("monster");
- }
- public static void Parser()
- {
- commandIn = Console.ReadLine().ToLower();
- command = commandIn.Split(delim).ToList();
- while (command.Contains("the")) { command.Remove("the"); }
- while (command.Contains("with")) { command.Remove("with"); }
- while (command.Contains("my")) { command.Remove("my"); }
- while (command.Contains("at")) { command.Remove("at"); }
- //List<string> dupe = new List<string>();
- foreach (string s in command.ToList())
- {
- foreach (string t in vocab.ToList())
- {
- /*if (command.Except(vocab).Any())
- {
- if command.Contains(vocab).any()
- Console.Write("I don't know how to make this display just once sorry try a different command\n");
- }*/
- if (s.ToLower() == t)
- {
- //if (command.Contains("and"))
- //{
- //run input after "and" when input before it is complete (do later)
- //}
- if (command.Count() == 1 && command.Intersect(seeable).Any())
- {
- Desc();
- }
- switch (s.ToLower())
- { //switch statement to work out player input
- case "help":
- Console.WriteLine("help output");
- break;
- case "exit":
- Environment.Exit(0);
- break;
- case "yes":
- switch (area.ToString())
- {
- case "0":
- if (command.Count() == 1)
- {
- GameplayStart();
- }
- break;
- default:
- Console.WriteLine("That is not a valid command at this time.");
- break;
- }
- break;
- case "no":
- switch (area.ToString())
- {
- case "0":
- if (command.Count() == 1)
- {
- Environment.Exit(0);
- }
- break;
- default:
- Console.WriteLine("That is not a valid command at this time.");
- break;
- }
- break;
- case "get":
- Get();
- break;
- case "hit":
- Hit();
- break;
- case "look":
- //could be method
- if (command.Count() >= 2)
- {
- Console.WriteLine("Sorry, I don't understand. Try just " + "\"" + command.Last() + "\".* \n\n\n*Commands such as these are currently sparsely implemented.");
- }
- else
- {
- switch (area.ToString())
- {
- case "1":
- if (sword == 1)
- {
- Console.WriteLine("You are in a small, barren room. There is a sign that reads \"CAVE\" on the wall \nand a statue in the corner.");
- }
- else
- {
- Console.WriteLine("You are in a small, barren room. There is a sign that reads \"CAVE\" on the wall, a statue in the corner, and a sword on the floor.");
- }
- break;
- case "0":
- Console.WriteLine("You see nothing. Are you ready to begin?");
- break;
- default:
- Console.WriteLine("You see nothing.");
- break;
- }
- }
- break;
- //could directions be methods?
- case "north": case "n":
- if (area == 1)
- {
- NorthernMost();
- }
- else if (area == 3)
- {
- GameplayStart();
- }
- else if (area == 5)
- {
- TreasureRoom();
- }
- else
- {
- Console.WriteLine("You cannot go north.");
- }
- break;
- case "south": case "s":
- if (area == 1)
- {
- SouthernMost();
- }
- else if (area == 2)
- {
- GameplayStart();
- }
- else if (area == 6)
- {
- EasternMost();
- }
- else
- {
- Console.WriteLine("You cannot go south.");
- }
- break;
- case "west": case "w":
- if(area == 1)
- {
- WesternMost();
- }
- else if(area == 5)
- {
- GameplayStart();
- }
- else if(area == 6)
- {
- Console.WriteLine("The way west is blocked by large boulders.");
- }
- else
- {
- Console.WriteLine("You cannot go west.");
- }
- break;
- case "east": case "e":
- if (area == 1)
- {
- EasternMost();
- }
- else if(area == 2)
- {
- Console.WriteLine("The way east is blocked by large stones.");
- }
- else if(area == 4)
- {
- GameplayStart();
- }
- else
- {
- Console.WriteLine("You cannot go east.");
- }
- break;
- default:
- break;
- }
- }
- }
- if (!vocab.Contains(s.ToLower()))
- {
- Console.WriteLine("I don't know what that means.");
- }
- }
- }
- public static void Start()
- {
- area = 0;
- Console.WriteLine( "welcome." );
- Console.WriteLine("Are you ready to begin?");
- while (true)
- {
- Parser();
- }
- }
- public static void GameplayStart()
- {
- area = 1;
- if (sword == 0)
- {
- Console.WriteLine("You are in a small, barren room. There is a sign that reads \"CAVE\" on the wall, a statue in the corner, and a sword on the floor.");
- }
- else if (sword == 1)
- {
- Console.WriteLine("You are in a small, barren room. There is a sign that reads \"CAVE\" on the wall \nand a statue in the corner.");
- }
- while (true)
- {
- Parser();
- }
- }
- public static void NorthernMost()
- {
- area = 2;
- if (revolver == 0)
- {
- Console.WriteLine("There is an excess of vegetation in this room. There is a doorway to the east, \nbut it is blocked by stones. A revolver is caught in some vines on the wall.");
- }
- else if(revolver == 1)
- {
- Console.WriteLine("There is an excess of vegetation in this room. There is a doorway to the east, \nbut it is blocked by stones. Vine fluid is everywhere.");
- }
- while (true)
- {
- Parser();
- }
- }
- public static void SouthernMost()
- {
- Console.WriteLine("You are in the south.");
- area = 3;
- while (true)
- {
- Parser();
- }
- }
- public static void WesternMost()
- {
- area = 4;
- Console.WriteLine("You are in the west.");
- while (true)
- {
- Parser();
- }
- }
- public static void EasternMost()
- {
- area = 5;
- Console.WriteLine("You are in the east.");
- while (true)
- {
- Parser();
- }
- }
- public static void TreasureRoom()
- {
- area = 6;
- Console.WriteLine("You are in the treasure room. Congrats, I guess.");
- while (true)
- {
- Parser();
- }
- }
- public static void Hit()
- {
- string hitr = command.Last();
- if (command.Count() == 3)
- {
- if (hitter.Contains(hitr))
- {
- command.Remove(command.Last());
- string hite = command.Last();
- if (hitable.Contains(hite) && area > 0)
- {
- if (area == 2)
- {
- if (hite == "vines")
- {
- switch (hitr)
- {
- case "sword":
- vines = 1;
- Console.WriteLine("The vines are easily cut by the sword, and begin spewing a strange liquid.\nThe revolver is now on the floor. Vine fluid is everywhere.");
- break;
- case "fists":
- Console.WriteLine("The vines are unimpressed by the blunt force trauma your fists inflict.");
- break;
- default:
- Console.WriteLine("Err no *#.' : undefined hitter");
- break;
- }
- }
- else { Console.WriteLine("hitting the " + hite + " does nothing."); }
- }
- else if (area == 1)
- {
- Console.WriteLine("hitting the " + hite + " does nothing.");
- }
- else
- {
- Console.WriteLine("There is no " + hite + " to hit.");
- }
- }
- else if (area > 0)
- {
- Console.WriteLine("Hitting the " + hite + " does nothing.");
- }
- }
- else { Console.WriteLine("You cannot hit with the " + command.Last() + "."); }
- }
- else if (command.Count() == 2)
- {
- Console.WriteLine("What do you want to hit the " + command.Last() + " with?");
- }
- else if (command.Count() == 1)
- {
- if (area == 0)
- {
- Console.WriteLine("There's nothing to hit. Are you ready to begin?");
- }
- else
- {
- Console.WriteLine("What do you want to hit?");
- }
- }
- }
- public static void Get()
- {
- string getted = command.Last();
- if (inv.Contains(getted))
- {
- Console.WriteLine("You already have a " + getted + ".");
- }
- if (!gettable.Contains(getted))
- {
- Console.WriteLine("You cannot get the " + getted + ".");
- }
- if (gettable.Contains(getted))
- {
- switch (area)
- {
- case 1:
- if (getted == "sword" && sword == 0)
- {
- Console.WriteLine("You picked up the sword.");
- sword = 1;
- inv.Add("sword");
- }
- break;
- case 2:
- if (getted == "revolver" && revolver == 0)
- {
- if (vines == 0)
- {
- Console.WriteLine("The revolver is lodged in the vines and will not budge.");
- }
- else if (vines == 1)
- {
- Console.WriteLine("You picked the revolver up off the ground. It is coated in vine fluid.");
- revolver = 1;
- inv.Add("revolver");
- }
- }
- break;
- default:
- Console.WriteLine("Err no *#._ : undefined get");
- break;
- }
- }
- else if (command.Count() == 1)
- {
- Console.WriteLine("Get what?");
- }
- }
- public static void Desc()
- {
- switch (command.Last())
- {
- case "sword":
- Items schvert = new Items("sword", "It's a sword.");
- break;
- case "revolver":
- Items spinn = new Items("revolver", "It looks to be fairly typical. It has no bullets in it.");
- break;
- default:
- Console.WriteLine("Err no. *#.. : undefined item");
- break;
- }
- }
- }//end of Game
- class Items
- {
- public Items() : this("", "")
- {
- //initializer
- }
- public Items(string name, string desc)
- { //generic versions of things needed in this if part
- // else if (name == "" && (Game.name == 1 || game.area == areanum)){ Console.WriteLine("{0}", desc); }
- // else if (name == "" && (Game.name != 1 || game.area != areanum)){ Console.WriteLine("I don't see a " + name + "."); }
- if (name == "revolver" && (Game.revolver == 1 || Game.area == 2))
- {
- Console.WriteLine("{0}", desc);
- }
- else if (name == "revolver" && (Game.revolver != 1 || Game.area != 2))
- { Console.WriteLine("I don't see a " + name + "."); }
- else if (name == "sword" && (Game.sword == 1 || Game.area == 1))
- {
- Console.WriteLine("{0}", desc);
- }
- else if (name == "sword" && (Game.sword != 1 || Game.area != 1))
- {
- Console.WriteLine("I don't see a " + name + ".");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement