Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace IT_Village
- {
- using System;
- using System.Linq;
- class ITVillage
- {
- private static char[][] board;
- static void Main(string[] args)
- {
- board = new char[4][];
- CreateTheGameBoard();
- string[] startPosition = Console.ReadLine().Split();
- byte startY = (byte)(byte.Parse(startPosition[0]) - 1);
- byte startX = (byte)(byte.Parse(startPosition[1]) - 1);
- byte[] diceNumbers = Console.ReadLine().Split()
- .Select(byte.Parse).ToArray();
- int coins = 50;
- byte totalInns = CountAllInnsOnBoard();
- byte ownInns = 0;
- byte row = startY;
- byte col = startX;
- for (byte i = 0; i < diceNumbers.Length; i++)
- {
- coins += ownInns * 20;
- MoveToTheNextField(ref row, ref col, diceNumbers[i]);
- switch (board[row][col])
- {
- case 'P':
- coins -= 5;
- break;
- case 'I':
- if (coins < 100)
- {
- coins -= 10;
- }
- else
- {
- coins -= 100;
- ownInns++;
- board[row][col] = '0';
- }
- break;
- case 'F':
- coins += 20;
- break;
- case 'S':
- i += 2;
- break;
- case 'V':
- coins *= 10;
- break;
- case 'N':
- Console.WriteLine("<p>You won! Nakov's force was with you!<p>");
- return;
- }
- if (ownInns == totalInns)
- {
- Console.WriteLine("<p>You won! You own the village now! You have {0} coins!<p>", coins);
- return;
- }
- if (i >= diceNumbers.Length - 1)
- {
- Console.WriteLine("<p>You lost! No more moves! You have {0} coins!<p>",
- coins);
- return;
- }
- if (coins <= 0)
- {
- Console.WriteLine("<p>You lost! You ran out of money!<p>");
- return;
- }
- }
- }
- private static void CreateTheGameBoard()
- {
- string[] inputBoard = Console.ReadLine().Split('|');
- for (byte i = 0; i < inputBoard.Length; i++)
- {
- string[] letters = inputBoard[i].Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
- board[i] = new char[letters.Length];
- for (byte j = 0; j < letters.Length; j++)
- {
- board[i][j] = letters[j][0];
- }
- }
- }
- private static byte CountAllInnsOnBoard()
- {
- byte count = 0;
- for (int i = 0; i < 4; i++)
- {
- for (int j = 0; j < 4; j++)
- {
- if (board[i][j] == 'I')
- {
- count++;
- }
- }
- }
- return count;
- }
- private static void MoveToTheNextField(ref byte row, ref byte col, byte nextNumber)
- {
- byte diceValue = (byte)(nextNumber % 12);
- for (byte j = 0; j < diceValue; j++)
- {
- if (row == 0 && col < 3) col++;
- else if (col == 3 && row < 3) row++;
- else if (row == 3 && col > 0) col--;
- else if (col == 0 && row > 0) row--;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement