static void Turn(team player, int PlayerIndex) { if (player.AllHome()) //Check if there are no pieces on the board { if (StartPiece()) //No globe rolled, stops the function { return; } else { player.Spawn(); } } int roll = rng.Next(1, 7); //Globe 5, stjerne 3 //Star move if (roll == 3) { WriteLine("Please choose the piece you want to move to a star"); PrintPieces(player); int.TryParse(ReadLine(), out int id); int PieceIndex = player.Pieces[id].Index; if (PieceIndex % 13 <= 7 && PieceIndex > 0) { Move(player.Pieces[id], 7 - (PlayerIndex % 13)); } else { Move(player.Pieces[id], 13 - (PlayerIndex % 13)); } //Star every 13. step. offset for first is +8 // (i % 13 == 2 || i % 13 == 10)globe // (i % 13 == 7 || i % 13 == 0) star } //Globe move else if (roll == 5) { WriteLine("choose to spawn a new piece or move a piece to a globe"); if (ReadLine() == "spawn")//Checks if player wants to spawn a piece { player.Spawn(); } else { WriteLine("Move a piece to a globe"); PrintPieces(player); //Mangler defination på globe int.TryParse(ReadLine(), out int id); int PieceIndex = player.Pieces[id].Index; if (PieceIndex % 13 <= 10 && PieceIndex > 2) { Move(player.Pieces[id], 10 - (PlayerIndex % 13)); } else if (PieceIndex % 13 > 10) { Move(player.Pieces[id], 15 - (PlayerIndex % 13)); } else { Move(player.Pieces[id], 2 - (PlayerIndex % 13)); } } } //Normal move else { WriteLine("Please write the piece you want to move " + roll + " steps"); PrintPieces(player); int.TryParse(ReadLine(), out int id); Move(player.Pieces[id], roll); } }
static void Main(string[] args) { //The teams List <string> test = new List <string> { "red", "blue", "green", "yellow" }; for (int i = 0; i < 52; i++) { if (i % 13 == 2 || i % 13 == 10)//If globe { board[i] = new BoardSpace(i, "globus"); } else if (i % 13 == 7 || i % 13 == 0)//If star { board[i] = new BoardSpace(i, "star"); } else //Normal { board[i] = new BoardSpace(i, "none"); } } //Get numbers WriteLine("Please write the number of human players"); Int32.TryParse(ReadLine(), out int players); while (players > 4 || players < 0) { WriteLine("Please write a number between 1 and 4"); Int32.TryParse(ReadLine(), out players); } for (int i = 0; i < players; i++) { WriteLine("Player {0}, please select your color", i + 1); foreach (string a in test) { Console.WriteLine(a); } int.TryParse(Console.ReadLine(), out int temp); Teams[i] = new team(test[temp - 1], true, i); test.RemoveAt(temp - 1); } WriteLine("How many ai's do you want? you can chose between {0} and {1}", 0, 4 - players); Int32.TryParse(ReadLine(), out int AIPlayers); while (AIPlayers > 4 - players || AIPlayers < 0) { WriteLine("Please write a number between 1 and {0}", 4 - players); Int32.TryParse(ReadLine(), out AIPlayers); } for (int i = 0; i < AIPlayers; i++) { Teams[players] = new team(test[0], false, players); test.RemoveAt(0); players++; } int counter = 0; int points = 0; while (points < 4) { if (Teams[counter].Human)//Seee if it's a player { Turn(Teams[counter], counter); if (Teams[counter].Points == 4) { Teams.RemoveAt(counter); points++; players--; } } else { //AITurn(pieces[k]); } counter = ++counter % players; //Check if it's the players turn or the ai } }