Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Media;
  5. using System.Threading;
  6.  
  7. namespace SoD_Parse
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.SetWindowSize(80, 25);
  14. Console.Beep();
  15. Game.ListAdder();
  16. Game.Start();
  17. }
  18. }
  19. class Game
  20. {
  21. public static int area = 0;
  22. public static int sword = 0;
  23. public static int revolver = 0;
  24. public static int shield = 0;
  25. public static int vines = 0;
  26. public static string commandIn = "";
  27. public static char delim = ' ';
  28. public static List<string> command = new List<string>();
  29. public static List<string> inv = new List<string>();
  30. public static List<string> vocab = new List<string>();
  31. public static List<string> hitable = new List<string>();
  32. public static List<string> hitter = new List<string>();
  33. public static List<string> gettable = new List<string>();
  34. public static List<string> seeable = new List<string>();
  35. public static void ListAdder()
  36. {
  37. //vocab
  38. //verbs
  39. vocab.Add("help");
  40. vocab.Add("exit");
  41. vocab.Add("yes");
  42. vocab.Add("no");
  43. vocab.Add("look");
  44. vocab.Add("get");
  45. vocab.Add("hit");
  46. vocab.Add("shoot");
  47. vocab.Add("die");
  48. vocab.Add("give");
  49. vocab.Add("north");
  50. vocab.Add("n");
  51. vocab.Add("south");
  52. vocab.Add("s");
  53. vocab.Add("east");
  54. vocab.Add("e");
  55. vocab.Add("west");
  56. vocab.Add("w");
  57. vocab.Add("flip");
  58. vocab.Add("f");
  59. vocab.Add("stand");
  60. //nouns
  61. //player parts
  62. vocab.Add("fists");
  63. hitter.Add("fists");
  64. //objects
  65. //inventory (mostly unimplemented)
  66. vocab.Add("sword");
  67. hitter.Add("sword");
  68. gettable.Add("sword");
  69. seeable.Add("sword");
  70. seeable.Add("revolver");
  71. vocab.Add("coin");
  72. vocab.Add("shield");
  73. vocab.Add("revolver");
  74. gettable.Add("revolver");
  75. vocab.Add("sign");
  76. vocab.Add("vines");
  77. //actors(can act as objects in certain conditions)
  78. vocab.Add("statue");
  79. vocab.Add("monster");
  80. //hittable
  81. hitable.Add("vines");
  82. hitable.Add("monster");
  83. }
  84. public static void Parser()
  85. {
  86. commandIn = Console.ReadLine().ToLower();
  87. command = commandIn.Split(delim).ToList();
  88. while (command.Contains("the")) { command.Remove("the"); }
  89. while (command.Contains("with")) { command.Remove("with"); }
  90. while (command.Contains("my")) { command.Remove("my"); }
  91. while (command.Contains("at")) { command.Remove("at"); }
  92. //List<string> dupe = new List<string>();
  93. foreach (string s in command.ToList())
  94. {
  95. foreach (string t in vocab.ToList())
  96. {
  97. /*if (command.Except(vocab).Any())
  98. {
  99. if command.Contains(vocab).any()
  100. Console.Write("I don't know how to make this display just once sorry try a different command\n");
  101. }*/
  102. if (s.ToLower() == t)
  103. {
  104. //if (command.Contains("and"))
  105. //{
  106. //run input after "and" when input before it is complete (do later)
  107. //}
  108. if (command.Count() == 1 && command.Intersect(seeable).Any())
  109. {
  110. Desc();
  111. }
  112. switch (s.ToLower())
  113. { //switch statement to work out player input
  114. case "help":
  115. Console.WriteLine("help output");
  116. break;
  117. case "exit":
  118. Environment.Exit(0);
  119. break;
  120. case "yes":
  121. switch (area.ToString())
  122. {
  123. case "0":
  124. if (command.Count() == 1)
  125. {
  126. GameplayStart();
  127. }
  128. break;
  129. default:
  130. Console.WriteLine("That is not a valid command at this time.");
  131. break;
  132. }
  133. break;
  134. case "no":
  135. switch (area.ToString())
  136. {
  137. case "0":
  138. if (command.Count() == 1)
  139. {
  140. Environment.Exit(0);
  141. }
  142. break;
  143. default:
  144. Console.WriteLine("That is not a valid command at this time.");
  145. break;
  146. }
  147. break;
  148. case "get":
  149. Get();
  150. break;
  151. case "hit":
  152. Hit();
  153. break;
  154. case "look":
  155. //could be method
  156. if (command.Count() >= 2)
  157. {
  158. Console.WriteLine("Sorry, I don't understand. Try just " + "\"" + command.Last() + "\".* \n\n\n*Commands such as these are currently sparsely implemented.");
  159. }
  160. else
  161. {
  162. switch (area.ToString())
  163. {
  164. case "1":
  165. if (sword == 1)
  166. {
  167. 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.");
  168. }
  169. else
  170. {
  171. 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.");
  172. }
  173. break;
  174. case "0":
  175. Console.WriteLine("You see nothing. Are you ready to begin?");
  176. break;
  177. default:
  178. Console.WriteLine("You see nothing.");
  179. break;
  180. }
  181. }
  182. break;
  183. //could directions be methods?
  184. case "north": case "n":
  185. if (area == 1)
  186. {
  187. NorthernMost();
  188. }
  189. else if (area == 3)
  190. {
  191. GameplayStart();
  192. }
  193. else if (area == 5)
  194. {
  195. TreasureRoom();
  196. }
  197. else
  198. {
  199. Console.WriteLine("You cannot go north.");
  200. }
  201. break;
  202. case "south": case "s":
  203. if (area == 1)
  204. {
  205. SouthernMost();
  206. }
  207. else if (area == 2)
  208. {
  209. GameplayStart();
  210. }
  211. else if (area == 6)
  212. {
  213. EasternMost();
  214. }
  215. else
  216. {
  217. Console.WriteLine("You cannot go south.");
  218. }
  219. break;
  220. case "west": case "w":
  221. if(area == 1)
  222. {
  223. WesternMost();
  224. }
  225. else if(area == 5)
  226. {
  227. GameplayStart();
  228. }
  229. else if(area == 6)
  230. {
  231. Console.WriteLine("The way west is blocked by large boulders.");
  232. }
  233. else
  234. {
  235. Console.WriteLine("You cannot go west.");
  236. }
  237. break;
  238. case "east": case "e":
  239. if (area == 1)
  240. {
  241. EasternMost();
  242. }
  243. else if(area == 2)
  244. {
  245. Console.WriteLine("The way east is blocked by large stones.");
  246. }
  247. else if(area == 4)
  248. {
  249. GameplayStart();
  250. }
  251. else
  252. {
  253. Console.WriteLine("You cannot go east.");
  254. }
  255. break;
  256. default:
  257. break;
  258.  
  259. }
  260.  
  261. }
  262.  
  263. }
  264. if (!vocab.Contains(s.ToLower()))
  265. {
  266.  
  267. Console.WriteLine("I don't know what that means.");
  268.  
  269.  
  270. }
  271. }
  272.  
  273. }
  274.  
  275. public static void Start()
  276. {
  277. area = 0;
  278. Console.WriteLine( "welcome." );
  279. Console.WriteLine("Are you ready to begin?");
  280. while (true)
  281. {
  282. Parser();
  283. }
  284. }
  285. public static void GameplayStart()
  286. {
  287. area = 1;
  288. if (sword == 0)
  289. {
  290. 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.");
  291. }
  292. else if (sword == 1)
  293. {
  294. 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.");
  295. }
  296. while (true)
  297. {
  298. Parser();
  299. }
  300. }
  301. public static void NorthernMost()
  302. {
  303. area = 2;
  304. if (revolver == 0)
  305. {
  306. 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.");
  307. }
  308. else if(revolver == 1)
  309. {
  310. 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.");
  311. }
  312. while (true)
  313. {
  314. Parser();
  315. }
  316. }
  317. public static void SouthernMost()
  318. {
  319. Console.WriteLine("You are in the south.");
  320. area = 3;
  321. while (true)
  322. {
  323. Parser();
  324. }
  325. }
  326. public static void WesternMost()
  327. {
  328. area = 4;
  329. Console.WriteLine("You are in the west.");
  330. while (true)
  331. {
  332. Parser();
  333. }
  334. }
  335. public static void EasternMost()
  336. {
  337. area = 5;
  338. Console.WriteLine("You are in the east.");
  339. while (true)
  340. {
  341. Parser();
  342. }
  343. }
  344. public static void TreasureRoom()
  345. {
  346. area = 6;
  347. Console.WriteLine("You are in the treasure room. Congrats, I guess.");
  348. while (true)
  349. {
  350. Parser();
  351. }
  352. }
  353. public static void Hit()
  354. {
  355.  
  356. string hitr = command.Last();
  357. if (command.Count() == 3)
  358. {
  359. if (hitter.Contains(hitr))
  360. {
  361. command.Remove(command.Last());
  362. string hite = command.Last();
  363. if (hitable.Contains(hite) && area > 0)
  364. {
  365. if (area == 2)
  366. {
  367. if (hite == "vines")
  368. {
  369. switch (hitr)
  370. {
  371. case "sword":
  372. vines = 1;
  373. 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.");
  374. break;
  375. case "fists":
  376. Console.WriteLine("The vines are unimpressed by the blunt force trauma your fists inflict.");
  377. break;
  378. default:
  379. Console.WriteLine("Err no *#.' : undefined hitter");
  380. break;
  381. }
  382.  
  383.  
  384. }
  385. else { Console.WriteLine("hitting the " + hite + " does nothing."); }
  386. }
  387. else if (area == 1)
  388. {
  389. Console.WriteLine("hitting the " + hite + " does nothing.");
  390. }
  391.  
  392. else
  393. {
  394. Console.WriteLine("There is no " + hite + " to hit.");
  395. }
  396. }
  397. else if (area > 0)
  398. {
  399. Console.WriteLine("Hitting the " + hite + " does nothing.");
  400. }
  401. }
  402. else { Console.WriteLine("You cannot hit with the " + command.Last() + "."); }
  403. }
  404. else if (command.Count() == 2)
  405. {
  406. Console.WriteLine("What do you want to hit the " + command.Last() + " with?");
  407. }
  408. else if (command.Count() == 1)
  409. {
  410. if (area == 0)
  411. {
  412. Console.WriteLine("There's nothing to hit. Are you ready to begin?");
  413. }
  414. else
  415. {
  416. Console.WriteLine("What do you want to hit?");
  417. }
  418. }
  419. }
  420. public static void Get()
  421. {
  422. string getted = command.Last();
  423. if (inv.Contains(getted))
  424. {
  425. Console.WriteLine("You already have a " + getted + ".");
  426. }
  427. if (!gettable.Contains(getted))
  428. {
  429. Console.WriteLine("You cannot get the " + getted + ".");
  430. }
  431. if (gettable.Contains(getted))
  432. {
  433. switch (area)
  434. {
  435. case 1:
  436. if (getted == "sword" && sword == 0)
  437. {
  438. Console.WriteLine("You picked up the sword.");
  439. sword = 1;
  440. inv.Add("sword");
  441. }
  442. break;
  443. case 2:
  444. if (getted == "revolver" && revolver == 0)
  445. {
  446. if (vines == 0)
  447. {
  448. Console.WriteLine("The revolver is lodged in the vines and will not budge.");
  449. }
  450. else if (vines == 1)
  451. {
  452. Console.WriteLine("You picked the revolver up off the ground. It is coated in vine fluid.");
  453. revolver = 1;
  454. inv.Add("revolver");
  455. }
  456. }
  457. break;
  458. default:
  459. Console.WriteLine("Err no *#._ : undefined get");
  460. break;
  461. }
  462. }
  463. else if (command.Count() == 1)
  464. {
  465. Console.WriteLine("Get what?");
  466. }
  467. }
  468. public static void Desc()
  469. {
  470. switch (command.Last())
  471. {
  472. case "sword":
  473. Items schvert = new Items("sword", "It's a sword.");
  474. break;
  475. case "revolver":
  476. Items spinn = new Items("revolver", "It looks to be fairly typical. It has no bullets in it.");
  477. break;
  478. default:
  479. Console.WriteLine("Err no. *#.. : undefined item");
  480. break;
  481. }
  482. }
  483. }//end of Game
  484. class Items
  485. {
  486. public Items() : this("", "")
  487. {
  488. //initializer
  489. }
  490. public Items(string name, string desc)
  491. { //generic versions of things needed in this if part
  492. // else if (name == "" && (Game.name == 1 || game.area == areanum)){ Console.WriteLine("{0}", desc); }
  493. // else if (name == "" && (Game.name != 1 || game.area != areanum)){ Console.WriteLine("I don't see a " + name + "."); }
  494. if (name == "revolver" && (Game.revolver == 1 || Game.area == 2))
  495. {
  496. Console.WriteLine("{0}", desc);
  497. }
  498. else if (name == "revolver" && (Game.revolver != 1 || Game.area != 2))
  499. { Console.WriteLine("I don't see a " + name + "."); }
  500. else if (name == "sword" && (Game.sword == 1 || Game.area == 1))
  501. {
  502. Console.WriteLine("{0}", desc);
  503. }
  504. else if (name == "sword" && (Game.sword != 1 || Game.area != 1))
  505. {
  506. Console.WriteLine("I don't see a " + name + ".");
  507. }
  508. }
  509.  
  510. }
  511. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement