public void Play() { int userInput = 0; int firstOrSecondUser = ActivePlayer.Id == 0 ? 0 : 1; int winner = -1; while (turn < 4 && !CheckIfEndGame()) { bool drawCard = false; //turno 0 o configuracion if (turn == 0) { for (int _ = 0; _ < Players.Length; _++) { ActivePlayer = Players[firstOrSecondUser]; Visualization.ClearConsole(); //Mostrar mensaje de inicio Visualization.ShowProgramMessage($"Player {ActivePlayer.Id + 1} select Deck and Captain:"); //Preguntar por deck Visualization.ShowDecks(this.Decks); userInput = Visualization.GetUserInput(this.Decks.Count - 1); Deck deck = new Deck(); deck.Cards = new List <Card>(Decks[userInput].Cards); ActivePlayer.Deck = deck; //Preguntar por capitan Visualization.ShowCaptains(Captains); userInput = Visualization.GetUserInput(this.Captains.Count - 1); ActivePlayer.ChooseCaptainCard(new SpecialCard(Captains[userInput].Name, Captains[userInput].Type, Captains[userInput].CardEffect)); //Asignar mano ActivePlayer.FirstHand(); //Mostrar mano Visualization.ShowHand(ActivePlayer.Hand); //Mostar opciones, cambiar carta o pasar userInput = -1; int changedCards = 0; while (userInput != 2 && changedCards < DEFAULT_CHANGE_CARDS_NUMBER) { Visualization.ShowListOptions(new List <string>() { "Change Card", "See card", "Pass" }, "Change 3 cards or ready to play:"); userInput = Visualization.GetUserInput(2); switch (userInput) { case 0: Visualization.ClearConsole(); Visualization.ShowProgramMessage($"Player {ActivePlayer.Id + 1} change cards:"); Visualization.ShowHand(ActivePlayer.Hand); Visualization.ShowProgramMessage($"Input the number of the card to change (max {DEFAULT_CHANGE_CARDS_NUMBER}). To stop enter -1"); userInput = Visualization.GetUserInput(ActivePlayer.Hand.Cards.Count - 1, true); if (userInput == -1) { continue; } ActivePlayer.ChangeCard(userInput); Visualization.ShowHand(ActivePlayer.Hand); changedCards += 1; userInput = -1; break; case 1: Visualization.ClearConsole(); Visualization.ShowHand(ActivePlayer.Hand); Visualization.ShowProgramMessage($"Input the number of the card to see. To stop enter -1"); userInput = Visualization.GetUserInput(ActivePlayer.Hand.Cards.Count - 1, true); if (userInput == -1) { continue; } Visualization.ShowCard(ActivePlayer.Hand.Cards[userInput]); userInput = -1; break; default: break; } } firstOrSecondUser = ActivePlayer.Id == 0 ? 1 : 0; } turn += 1; } //turnos siguientes else { Players[0].CardPlayed += this.OnPlayedCard; Players[1].CardPlayed += this.OnPlayedCard; Boolean cycle = true; while (cycle) { ActivePlayer = Players[firstOrSecondUser]; //Obtener lifePoints int[] lifePoints = new int[2] { Players[0].LifePoints, Players[1].LifePoints }; //Obtener total de ataque: int[] attackPoints = new int[2] { Players[0].GetAttackPoints()[0], Players[1].GetAttackPoints()[0] }; //Mostrar tablero, mano y solicitar jugada Visualization.ClearConsole(); Visualization.ShowBoard(boardGame, ActivePlayer.Id, lifePoints, attackPoints); //Robar carta if (!drawCard) { ActivePlayer.DrawCard(); drawCard = true; } Visualization.ShowHand(ActivePlayer.Hand); Visualization.ShowListOptions(new List <string> { "Play Card", "See card", "Pass" }, $"Make your move player {ActivePlayer.Id + 1}:"); userInput = Visualization.GetUserInput(2); switch (userInput) { case 0: //Si la carta es un buff solicitar a la fila que va. Visualization.ShowProgramMessage($"Input the number of the card to play. To cancel enter -1"); userInput = Visualization.GetUserInput(ActivePlayer.Hand.Cards.Count - 1, true); if (userInput != -1) { if (ActivePlayer.Hand.Cards[userInput].Type == EnumType.buff) { Visualization.ShowListOptions(new List <string> { "Melee", "Range", "LongRange" }, $"Choose row to buff {ActivePlayer.Id}:"); int cardId = userInput; userInput = Visualization.GetUserInput(2); if (userInput == 0) { ActivePlayer.PlayCard(cardId, EnumType.buffmelee); } else if (userInput == 1) { ActivePlayer.PlayCard(cardId, EnumType.buffrange); } else { ActivePlayer.PlayCard(cardId, EnumType.bufflongRange); } } else { Effect.CardID = userInput; //paso el id de la carta en caso de que sea la carta clearweather. para asi poder usar el metodo board.destroycard(cardid) ActivePlayer.PlayCard(userInput); ActivePlayer.OnCardPlayed(ActivePlayer.Hand.Cards[userInput]); } } //Revisar si le quedan cartas, si no le quedan obligar a pasar. if (ActivePlayer.Hand.Cards.Count == 0) { firstOrSecondUser = ActivePlayer.Id == 0 ? 1 : 0; break; } break; case 1: Visualization.ClearConsole(); Visualization.ShowHand(ActivePlayer.Hand); Visualization.ShowProgramMessage($"Input the number of the card to see. To stop enter -1"); userInput = Visualization.GetUserInput(ActivePlayer.Hand.Cards.Count - 1, true); if (userInput == -1) { continue; } Visualization.ShowCard(ActivePlayer.Hand.Cards[userInput]); Visualization.ShowListOptions(new List <string> { "Continue" }); userInput = Visualization.GetUserInput(0); break; default: firstOrSecondUser = ActivePlayer.Id == 0 ? 1 : 0; cycle = false; break; } } //Cambiar al oponente si no ha jugado if (!bothPlayersPlayed) { bothPlayersPlayed = true; drawCard = false; } //Si ambos jugaron obtener el ganador de la ronda, reiniciar el tablero y pasar de turno. else { winner = GetRoundWinner(); if (winner == 0) { Players[1].LifePoints -= 1; } else if (winner == 1) { Players[0].LifePoints -= 1; } else { Players[0].LifePoints -= 1; Players[1].LifePoints -= 1; } bothPlayersPlayed = false; turn += 1; //Destruir Cartas BoardGame.DestroyCards(); } } Players[0].CardPlayed -= this.OnPlayedCard; Players[1].CardPlayed -= this.OnPlayedCard; actualData["decks"] = Decks; actualData["captains"] = Captains; actualData["players"] = Players; actualData["activePlayer"] = Players[ActivePlayer.Id == 0 ? 1 : 0]; actualData["board"] = BoardGame; actualData["turn"] = turn; actualData["bothPlayersPlayed"] = bothPlayersPlayed; SaveData(); } //Definir cual es el ganador. winner = GetWinner(); if (winner == 0) { Visualization.ShowProgramMessage($"Player 1 is the winner!"); } else if (winner == 1) { Visualization.ShowProgramMessage($"Player 2 is the winner!"); } else { Visualization.ShowProgramMessage($"Draw!"); } }