Advertisement
NonaG

JapaneseRoulette

Feb 27th, 2017
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7.  
  8. class JapaneseRoulette
  9. {
  10. static void Main()
  11. {
  12. var arr = Console.ReadLine().Split().Select(int.Parse).ToList();
  13. var players = Console.ReadLine().Split();
  14. var position = 2;
  15. var bulletIndex = arr.IndexOf(1);
  16. for (int i = 0; i < players.Length; i++)
  17. {
  18. var args = players[i].Split(',');
  19. var power = int.Parse(args[0]);
  20. var direction = args[1];
  21. if (position == bulletIndex && i > 0)
  22. {
  23. Console.WriteLine($"Game over! Player {i} is dead.");
  24. return;
  25. }
  26. else
  27. {
  28. switch (direction)
  29. {
  30. case "Right":
  31. while (power > 0)
  32. {
  33. power--;
  34. bulletIndex++;
  35. if (bulletIndex == arr.Count)
  36. {
  37. bulletIndex = 0;
  38. }
  39. }
  40. if (position == bulletIndex)
  41. {
  42. Console.WriteLine($"Game over! Player {i} is dead.");
  43. return;
  44. }
  45. else
  46. {
  47. if (position <= 4)
  48. {
  49. position++;
  50. }
  51. else
  52. {
  53. position = 0;
  54. }
  55. }
  56. break;
  57. case "Left":
  58. while (power > 0)
  59. {
  60. power--;
  61. bulletIndex--;
  62. if (bulletIndex < 0)
  63. {
  64. bulletIndex = 5;
  65. }
  66. }
  67. if (position == bulletIndex)
  68. {
  69. Console.WriteLine($"Game over! Player {i} is dead.");
  70. return;
  71. }
  72. else
  73. {
  74. if (position <= 4)
  75. {
  76. position++;
  77. }
  78. else
  79. {
  80. position = 0;
  81. }
  82. }
  83. break;
  84. }
  85. }
  86. }
  87. Console.WriteLine("Everybody got lucky!");
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement