Advertisement
ViValDam

Untitled

Mar 25th, 2014
490
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. class GameHangman
  4. {
  5. static void Main()
  6. {
  7.  
  8. Console.WriteLine();
  9. Console.Write(" HANGMAN ");
  10. Console.WriteLine();
  11. Console.WriteLine("********************************************************************************");
  12. Console.WriteLine("WANT TO PLAY MY GAME? PLAY IT, BUT BE AWARE - I CAN HANG YOU ON THE GIBBET!");
  13. Console.WriteLine();
  14. Console.WriteLine("RULLS :");
  15. Console.WriteLine();
  16. Console.WriteLine("GUESING THE 8 HIDDEN LETTERS OF MY SECRET WORD YOU ARE ALOWED TO 12 MISTAKES");
  17. Console.WriteLine();
  18. Console.WriteLine();
  19. Console.WriteLine("COMANDS : ");
  20. Console.WriteLine();
  21. Console.WriteLine("YOU HAVE ONLY 3 COMANDS AVAILIBLE IN THIS GAME:");
  22. Console.WriteLine();
  23. Console.WriteLine("VIEW <-> SEE HOW MANY MISTAKES AND UNHIDE LETTERS YOU HAVE LEFT ");
  24. Console.WriteLine("GUESS <-> GUESS A HIDDEN LETTER ");
  25. Console.WriteLine("RESTART GAME <-> IF YOU WANT TO RESTART THE GAME )");
  26. Console.WriteLine();
  27. Console.WriteLine("********************************************************************************");
  28. Console.WriteLine();
  29. Console.Write(" START GAME ");
  30. Console.WriteLine();
  31.  
  32.  
  33. string comand;
  34. int falseLettersGuessed = 0;
  35. int trueLettersGuessed = 0;
  36. bool revealC, revealH, revealA, revealM, revealP, revealI, revealO, revealN;
  37. revealC = revealH = revealA = revealM = revealP = revealI = revealO = revealN = false;
  38.  
  39.  
  40. while ( falseLettersGuessed <= 12 )
  41.  
  42. {
  43. Console.WriteLine();
  44. Console.Write("TYPE GAME COMAND : ");
  45.  
  46. comand = Console.ReadLine();
  47.  
  48. // COMAND GUESS - UNHIDING LETTERS
  49.  
  50. if ((comand == "GUESS") || (comand == "guess"))
  51. {
  52. Console.WriteLine();
  53. Console.WriteLine();
  54.  
  55. Console.WriteLine("OKI-DOKI!");
  56. Console.WriteLine("GUT LUCK TO YOU!");
  57. Console.Write("GO - GUESS A LETTER ! ");
  58.  
  59. // READING FROM CONSOLE
  60. char letter = (char)Console.Read();
  61.  
  62.  
  63. if ((letter == 'c') || (letter == 'C'))
  64.  
  65. {
  66. Console.WriteLine();
  67. Console.WriteLine();
  68.  
  69. Console.WriteLine("GOOD GUESS! \nLETTER \"C\" IS CORRECT!");
  70.  
  71. trueLettersGuessed ++;
  72. revealC = true;
  73. Console.WriteLine();
  74. Console.WriteLine();
  75. }
  76.  
  77. else if ((letter == 'h') || (letter == 'H'))
  78.  
  79. {
  80. Console.WriteLine();
  81. Console.WriteLine();
  82.  
  83. Console.WriteLine("GOOD GUESS! \nLETTER \"H\" IS CORRECT!");
  84.  
  85. trueLettersGuessed ++ ;
  86. revealH = true;
  87. Console.WriteLine();
  88. Console.WriteLine();
  89. }
  90.  
  91. else if ((letter == 'a') || (letter == 'A'))
  92.  
  93. {
  94. Console.WriteLine();
  95. Console.WriteLine();
  96.  
  97. Console.WriteLine("GOOD GUESS! \nLETTER \"A\" IS CORRECT!");
  98.  
  99. trueLettersGuessed ++ ;
  100. revealA = true;
  101. Console.WriteLine();
  102. Console.WriteLine();
  103. }
  104.  
  105. else if ((letter == 'm') || (letter == 'M'))
  106.  
  107. {
  108. Console.WriteLine();
  109. Console.WriteLine();
  110.  
  111. Console.WriteLine("GOOD GUESS! \nLETTER \"M\" IS CORRECT!");
  112.  
  113. trueLettersGuessed ++ ;
  114. revealM = true;
  115. Console.WriteLine();
  116. Console.WriteLine();
  117. }
  118.  
  119. else if ((letter == 'p') || (letter == 'P'))
  120.  
  121. {
  122. Console.WriteLine();
  123. Console.WriteLine();
  124.  
  125. Console.WriteLine("GOOD GUESS! \nLETTER \"P\" IS CORRECT!");
  126.  
  127. trueLettersGuessed ++ ;
  128. revealP = true;
  129. Console.WriteLine();
  130. Console.WriteLine();
  131. }
  132.  
  133. else if ((letter == 'i') || (letter == 'I'))
  134.  
  135. {
  136. Console.WriteLine();
  137. Console.WriteLine();
  138.  
  139. Console.WriteLine("GOOD GUESS! \nLETTER \"I\" IS CORRECT!");
  140.  
  141. trueLettersGuessed ++ ;
  142. revealI = true;
  143. Console.WriteLine();
  144. Console.WriteLine();
  145. }
  146.  
  147. else if ((letter == 'o') || (letter == 'O'))
  148.  
  149. {
  150. Console.WriteLine();
  151. Console.WriteLine();
  152.  
  153. Console.WriteLine("GOOD GUESS! \nLETTER \"O\" IS CORRECT!");
  154.  
  155. trueLettersGuessed ++ ;
  156. revealO = true;
  157. Console.WriteLine();
  158. Console.WriteLine();
  159. }
  160.  
  161. else if ((letter == 'n') || (letter == 'N'))
  162.  
  163. {
  164. Console.WriteLine();
  165. Console.WriteLine();
  166. Console.WriteLine("GOOD GUESS! \nLETTER \"N\" IS CORRECT!");
  167. trueLettersGuessed ++ ;
  168. revealN = true;
  169. Console.WriteLine();
  170. Console.WriteLine();
  171. }
  172.  
  173. else // FALSE LETTER
  174.  
  175. {
  176. Console.WriteLine();
  177. Console.WriteLine();
  178.  
  179. Console.WriteLine("OH, YOU MISS ! \nLETTER \"{0}\" WAS A WRONG CHOICE!", letter);
  180.  
  181. Console.WriteLine();
  182. Console.WriteLine();
  183. falseLettersGuessed ++ ;
  184. }
  185.  
  186.  
  187. // TRUE LETTER OR FALSE
  188.  
  189. char letter1, letter2, letter3, letter4, letter5, letter6, letter7, letter8;
  190.  
  191. if (revealC == true)
  192. {
  193. letter1 = 'C';
  194. }
  195. else
  196. {
  197. letter1 = '_';
  198. }
  199.  
  200.  
  201. if (revealH == true)
  202. {
  203. letter2 = 'H';
  204. }
  205. else
  206. {
  207. letter2 = '_';
  208. }
  209.  
  210.  
  211. if (revealA == true)
  212. {
  213. letter3 = 'A';
  214. }
  215. else
  216. {
  217. letter3 = '_';
  218. }
  219.  
  220.  
  221. if (revealM == true)
  222. {
  223. letter4 = 'M';
  224. }
  225. else
  226. {
  227. letter4 = '_';
  228. }
  229.  
  230.  
  231. if (revealP == true)
  232. {
  233. letter5 = 'P';
  234. }
  235. else
  236. {
  237. letter5 = '_';
  238. }
  239.  
  240.  
  241. if (revealI == true)
  242. {
  243. letter6 = 'I';
  244. }
  245. else
  246. {
  247. letter6 = '_';
  248. }
  249.  
  250.  
  251. if (revealO == true)
  252. {
  253. letter7 = '0';
  254. }
  255. else
  256. {
  257. letter7 = '_';
  258.  
  259.  
  260. } if (revealN == true)
  261. {
  262. letter8 = 'N';
  263. }
  264. else
  265. {
  266. letter8 = '_';
  267. }
  268.  
  269. // PRINTING THE WORD
  270.  
  271. Console.WriteLine("MY SECRET WORD WITH 8 HIDDEN LETTERS IS : ");
  272. Console.WriteLine();
  273. Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7}",
  274. letter1, letter2, letter3, letter4, letter5, letter6, letter7, letter8);
  275. Console.WriteLine();
  276. Console.WriteLine();
  277.  
  278.  
  279. // HANGING THE PLAYER
  280.  
  281. if (falseLettersGuessed == 1)
  282.  
  283. {
  284. Console.WriteLine(" __| |__ ");
  285. Console.WriteLine();
  286. Console.WriteLine();
  287.  
  288. }
  289.  
  290.  
  291. if (falseLettersGuessed == 2)
  292.  
  293. {
  294. Console.WriteLine(" | | ");
  295. Console.WriteLine(" __| |__ ");
  296. Console.WriteLine();
  297. Console.WriteLine();
  298.  
  299. }
  300.  
  301. if (falseLettersGuessed == 3)
  302.  
  303. {
  304. Console.WriteLine(" | | ");
  305. Console.WriteLine(" | | ");
  306. Console.WriteLine(" __| |__ ");
  307. Console.WriteLine();
  308. Console.WriteLine();
  309.  
  310.  
  311. }
  312.  
  313. if (falseLettersGuessed == 4)
  314.  
  315. {
  316. Console.WriteLine(" __|__ ");
  317. Console.WriteLine(" | | ");
  318. Console.WriteLine(" | | ");
  319. Console.WriteLine(" __| |__ ");
  320. Console.WriteLine();
  321. Console.WriteLine();
  322.  
  323.  
  324. }
  325.  
  326.  
  327.  
  328. if (falseLettersGuessed == 5)
  329.  
  330. {
  331. Console.WriteLine(" | ");
  332. Console.WriteLine(" __|__ ");
  333. Console.WriteLine(" | | ");
  334. Console.WriteLine(" | | ");
  335. Console.WriteLine(" __| |__ ");
  336. Console.WriteLine();
  337. Console.WriteLine();
  338.  
  339. }
  340.  
  341. if (falseLettersGuessed == 6)
  342.  
  343. {
  344. Console.WriteLine(" | ");
  345. Console.WriteLine(" | ");
  346. Console.WriteLine(" __|__ ");
  347. Console.WriteLine(" | | ");
  348. Console.WriteLine(" | | ");
  349. Console.WriteLine(" __| |__ ");
  350. Console.WriteLine();
  351. Console.WriteLine();
  352.  
  353. }
  354.  
  355.  
  356. if (falseLettersGuessed == 7)
  357.  
  358. {
  359. Console.WriteLine(" <-----|-----> ");
  360. Console.WriteLine(" | ");
  361. Console.WriteLine(" | ");
  362. Console.WriteLine(" __|__ ");
  363. Console.WriteLine(" | | ");
  364. Console.WriteLine(" | | ");
  365. Console.WriteLine(" __| |__ ");
  366. Console.WriteLine();
  367. Console.WriteLine();
  368.  
  369.  
  370. }
  371.  
  372. if (falseLettersGuessed == 8)
  373.  
  374. {
  375. Console.WriteLine(" | ");
  376. Console.WriteLine(" <-----|-----> ");
  377. Console.WriteLine(" | ");
  378. Console.WriteLine(" | ");
  379. Console.WriteLine(" __|__ ");
  380. Console.WriteLine(" | | ");
  381. Console.WriteLine(" | | ");
  382. Console.WriteLine(" __| |__ ");
  383. Console.WriteLine();
  384. Console.WriteLine();
  385.  
  386.  
  387. }
  388.  
  389. if (falseLettersGuessed == 9)
  390.  
  391. {
  392. Console.WriteLine(" " + (char)1 );
  393. Console.WriteLine(" | ");
  394. Console.WriteLine(" <-----|-----> ");
  395. Console.WriteLine(" | ");
  396. Console.WriteLine(" | ");
  397. Console.WriteLine(" __|__ ");
  398. Console.WriteLine(" | | ");
  399. Console.WriteLine(" | | ");
  400. Console.WriteLine(" __| |__ ");
  401. Console.WriteLine();
  402. Console.WriteLine();
  403.  
  404.  
  405. }
  406.  
  407. if (falseLettersGuessed == 10)
  408.  
  409. {
  410. Console.WriteLine(" | ");
  411. Console.WriteLine(" " + (char)1 );
  412. Console.WriteLine(" | ");
  413. Console.WriteLine(" <-----|-----> ");
  414. Console.WriteLine(" | ");
  415. Console.WriteLine(" | ");
  416. Console.WriteLine(" __|__ ");
  417. Console.WriteLine(" | | ");
  418. Console.WriteLine(" | | ");
  419. Console.WriteLine(" __| |__ ");
  420. Console.WriteLine();
  421. Console.WriteLine();
  422.  
  423.  
  424. }
  425.  
  426.  
  427. if (falseLettersGuessed == 11)
  428.  
  429. {
  430. Console.WriteLine(" | ");
  431. Console.WriteLine(" | ");
  432. Console.WriteLine(" " + (char)1 );
  433. Console.WriteLine(" | ");
  434. Console.WriteLine(" <-----|-----> ");
  435. Console.WriteLine(" | ");
  436. Console.WriteLine(" | ");
  437. Console.WriteLine(" __|__ ");
  438. Console.WriteLine(" | | ");
  439. Console.WriteLine(" | | ");
  440. Console.WriteLine(" __| |__ ");
  441. Console.WriteLine();
  442. Console.WriteLine();
  443.  
  444.  
  445. }
  446.  
  447. if (falseLettersGuessed == 12)
  448.  
  449. {
  450. Console.WriteLine(" ||| ");
  451. Console.WriteLine(" | ");
  452. Console.WriteLine(" | ");
  453. Console.WriteLine(" " + (char)1 );
  454. Console.WriteLine(" | ");
  455. Console.WriteLine(" <-----|-----> ");
  456. Console.WriteLine(" | ");
  457. Console.WriteLine(" | ");
  458. Console.WriteLine(" __|__ ");
  459. Console.WriteLine(" | | ");
  460. Console.WriteLine(" | | ");
  461. Console.WriteLine(" __| |__ ");
  462. Console.WriteLine();
  463. Console.WriteLine();
  464.  
  465.  
  466. }
  467.  
  468. if (falseLettersGuessed == 13)
  469.  
  470. {
  471.  
  472. Console.WriteLine("================ ");
  473. Console.WriteLine(" ||| ");
  474. Console.WriteLine(" | ");
  475. Console.WriteLine(" | ");
  476. Console.WriteLine(" " + (char)1 );
  477. Console.WriteLine(" | ");
  478. Console.WriteLine(" <-----|-----> ");
  479. Console.WriteLine(" | ");
  480. Console.WriteLine(" | ");
  481. Console.WriteLine(" __|__ ");
  482. Console.WriteLine(" | | ");
  483. Console.WriteLine(" | | ");
  484. Console.WriteLine(" __| |__ ");
  485. Console.WriteLine();
  486. Console.WriteLine();
  487.  
  488. }
  489.  
  490.  
  491. // GAME RESULT - SUCSSES
  492. if (trueLettersGuessed == 8)
  493. {
  494.  
  495. Console.WriteLine("CONGRATULATION! YOU WON !");
  496. Console.WriteLine("YOU KNOW MY SECRET WORD !");
  497. Console.WriteLine();
  498. Console.WriteLine();
  499. Console.WriteLine("GAME OVER");
  500. Console.WriteLine();
  501. Console.WriteLine();
  502. Console.WriteLine("WANT TO STOP PLAYNG ?");
  503. Console.WriteLine("PRESS ENTER");
  504. Console.WriteLine();
  505. Console.WriteLine("WANT TO PLAY HANGMAN AGAIN ?");
  506. Console.WriteLine("TYPE RESTART");
  507.  
  508. }
  509.  
  510. // CONTINUE
  511.  
  512. comand = Console.ReadLine();
  513.  
  514.  
  515. } // END GUESS
  516.  
  517.  
  518. // COMAND VIEW - VIEWS AVALIBLE MISTAKES
  519.  
  520. else if ((comand == "VIEW") || (comand == "view"))
  521. {
  522.  
  523. Console.WriteLine();
  524. Console.WriteLine();
  525. Console.WriteLine("YOU STILL HAVE " + ( 12 - falseLettersGuessed ) + " MISTAKES TO MAKE UNPANISHED");
  526. Console.WriteLine("YOU STILL HAVE " + ( 8 - trueLettersGuessed ) + " SECRET LETTERS TO UNHIDE ");
  527. Console.WriteLine("UNHIDE MY SECRET WORD AND WIN !");
  528. Console.WriteLine();
  529. Console.WriteLine();
  530.  
  531. }// END VIEW
  532.  
  533.  
  534. // COMAND RESTART - RESTARTS THE GAME
  535.  
  536. else if ((comand == "RESTART") || (comand == "restart"))
  537.  
  538. {
  539.  
  540. Console.WriteLine();
  541. Console.WriteLine( "WANT TO RESTART THE GAME ?");
  542. Console.WriteLine();
  543. Console.WriteLine("IF \"YES\" - PRESS [CTRL + X] TO RESTART ");
  544. Console.WriteLine("IF \"NO\" - PRESS [ENTER]");
  545.  
  546.  
  547. ConsoleKeyInfo info = Console.ReadKey();
  548. if (info.KeyChar == 'r')
  549.  
  550. // ConsoleKeyInfo restartKeyCombination;
  551.  
  552. //restartKeyCombination = Console.ReadKey();
  553.  
  554. // if ((restartKeyCombination.Modifiers == ConsoleModifiers.Control) && (restartKeyCombination.Key == ConsoleKey.X))
  555.  
  556. {
  557. falseLettersGuessed = 0;
  558. trueLettersGuessed = 0;
  559. revealC = revealH = revealA = revealM = revealP = revealI = revealO = revealN = false;
  560. Console.Clear();
  561. Console.WriteLine("OKI-DOKI!");
  562. Console.WriteLine("HANGMAN RESTARTED!");
  563. Console.WriteLine("LET'S PLAY!");
  564. Console.WriteLine();
  565. }
  566.  
  567. } //END RESTART
  568.  
  569. else // INVALID INPUT for comand
  570. {
  571. Console.WriteLine();
  572. Console.WriteLine("THIS IS NOT A VALID COMAND!");
  573. Console.WriteLine();
  574.  
  575. }//END WHILE
  576.  
  577.  
  578. } // falseLettersGuessed = 13 ,
  579. //end while
  580.  
  581. // GAME RESULT - FAILURE
  582.  
  583. Console.WriteLine();
  584. Console.WriteLine();
  585. Console.WriteLine();
  586. Console.WriteLine("YOU LOST!!! I HANG YOU !!!" + (char)1 + (char)1 + (char)1 );
  587.  
  588. comand = Console.ReadLine();
  589.  
  590. }
  591. }
  592.  
  593. /*Console.WriteLine("... Press escape, a, then control X");
  594. // Call ReadKey method and store result in local variable.
  595. // ... Then test the result for escape.
  596. ConsoleKeyInfo info = Console.ReadKey();
  597. if (info.Key == ConsoleKey.Escape)
  598. {
  599. Console.WriteLine("You pressed escape!");
  600. }
  601. // Call ReadKey again and test for the letter a.
  602. info = Console.ReadKey();
  603. if (info.KeyChar == 'a')
  604. {
  605. Console.WriteLine("You pressed a");
  606. }
  607. // Call ReadKey again and test for control-X.
  608. // ... This implements a shortcut sequence.
  609. info = Console.ReadKey();
  610. if (info.Key == ConsoleKey.X &&
  611. info.Modifiers == ConsoleModifiers.Control)
  612. {
  613. Console.WriteLine("You pressed control X");
  614. }
  615. Console.Read();
  616. } */
Advertisement
RAW Paste Data Copied
Advertisement