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.Text;
- using System.Threading.Tasks;
- class JapaneseRoulette
- {
- static void Main()
- {
- var arr = Console.ReadLine().Split().Select(int.Parse).ToList();
- var players = Console.ReadLine().Split();
- var position = 2;
- var bulletIndex = arr.IndexOf(1);
- for (int i = 0; i < players.Length; i++)
- {
- var args = players[i].Split(',');
- var power = int.Parse(args[0]);
- var direction = args[1];
- if (position == bulletIndex && i > 0)
- {
- Console.WriteLine($"Game over! Player {i} is dead.");
- return;
- }
- else
- {
- switch (direction)
- {
- case "Right":
- while (power > 0)
- {
- power--;
- bulletIndex++;
- if (bulletIndex == arr.Count)
- {
- bulletIndex = 0;
- }
- }
- if (position == bulletIndex)
- {
- Console.WriteLine($"Game over! Player {i} is dead.");
- return;
- }
- else
- {
- if (position <= 4)
- {
- position++;
- }
- else
- {
- position = 0;
- }
- }
- break;
- case "Left":
- while (power > 0)
- {
- power--;
- bulletIndex--;
- if (bulletIndex < 0)
- {
- bulletIndex = 5;
- }
- }
- if (position == bulletIndex)
- {
- Console.WriteLine($"Game over! Player {i} is dead.");
- return;
- }
- else
- {
- if (position <= 4)
- {
- position++;
- }
- else
- {
- position = 0;
- }
- }
- break;
- }
- }
- }
- Console.WriteLine("Everybody got lucky!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement