Skip to content

Instantly share code, notes, and snippets.

@brunotdantas
Last active October 18, 2022 07:44
Show Gist options
  • Save brunotdantas/8dc61f86795290e17ab0c839bb15da11 to your computer and use it in GitHub Desktop.
Save brunotdantas/8dc61f86795290e17ab0c839bb15da11 to your computer and use it in GitHub Desktop.
PokeTrumps is a program where the user can select one attribute of its current card and if that attribute is bigger than his rival he scores, at the end of 5 rounds we check points.
internal class Program
{
private static void Main(string[] args)
{
Console.Title = "PokeTrumps";
Console.Clear();
Console.WriteLine("---------------------------------------------------------------------------------------------------------------");
Console.WriteLine("Hello my friend! Welcome to PokeTrumps!");
Console.WriteLine("Pokémons will be selected to you and your rival");
Console.WriteLine("you have to choose one of the attributes and the biggest one wins that round");
Console.WriteLine("one point will be rewarded each round, if the values are the same the point goes to who asked the attribute.");
Console.WriteLine("---------------------------------------------------------------------------------------------------------------");
Console.WriteLine("When you are ready press Enter to start");
Console.ReadKey();
List<Card> listCards = new List<Card>();
List<Card> player1Cards = new List<Card>();
List<Card> player2Cards = new List<Card>();
// TODO: buscar da API
listCards.Add(new Card(3, "Venusaur", 80, 82, 83, 80));
listCards.Add(new Card(6, "Charizard", 78, 84, 78, 100));
listCards.Add(new Card(9, "Blastoise", 79, 83, 100, 78));
listCards.Add(new Card(12, "Butterfree", 60, 45, 50, 70));
listCards.Add(new Card(15, "Beedrill", 65, 90, 40, 75));
listCards.Add(new Card(18, "Pidgeot", 83, 80, 75, 101));
listCards.Add(new Card(20, "Raticate", 55, 81, 60, 97));
listCards.Add(new Card(22, "Fearow", 65, 90, 65, 100));
listCards.Add(new Card(26, "Raichu", 60, 90, 55, 110));
listCards.Add(new Card(28, "Sandslash", 75, 100, 110, 65));
var rnd = new Random();
var randomizedDeck = listCards.OrderBy(item => rnd.Next());
bool _flag = true;
foreach (var card in randomizedDeck)
{
if (_flag)
{
player1Cards.Add(card);
_flag = false;
}
else
{
player2Cards.Add(card);
_flag = true;
}
}
int player1Points = 0, player2Points = 0;
int maxRounds = listCards.Count / 2;
int round = 0;
string userChoice = "";
bool player1Turn = true;
bool firstTime = true;
while (round < maxRounds)
{
if (firstTime)
{
firstTime = false;
}
else
{
player1Cards.RemoveAt(0);
player2Cards.RemoveAt(0);
Console.WriteLine("");
Console.WriteLine($"Player 1: {player1Points} points");
Console.WriteLine($"Player 2: {player2Points} points");
Console.WriteLine($"Press Enter to start another round");
Console.ReadKey();
}
bool validChoice = false;
do
{
Console.Clear();
Console.WriteLine("----------------------------------------------------------------------------------------------------------");
Console.WriteLine("Please see below details of your current card, choose wisely one of the attributes of this Pokémon: ");
Console.WriteLine("");
Console.WriteLine($"#: {player1Cards.ElementAt(0).id}");
Console.WriteLine($"Pokémon: {player1Cards.ElementAt(0).PokemonName}");
Console.WriteLine($"1- Hp: {player1Cards.ElementAt(0).Hp}");
Console.WriteLine($"2- Attack: {player1Cards.ElementAt(0).Attack}");
Console.WriteLine($"3- Defense: {player1Cards.ElementAt(0).Defense}");
Console.WriteLine($"4- Speed: {player1Cards.ElementAt(0).Speed}");
Console.WriteLine("----------------------------------------------------------------------------------------------------------");
userChoice = Console.ReadLine();
Console.Clear();
switch (userChoice)
{
case "1":
{
validChoice = true;
Console.WriteLine("******************************************************************************************************");
if (player1Cards.ElementAt(0).Hp == player2Cards.ElementAt(0).Hp)
{
Console.WriteLine("HP of your Pokemon and your rival are the same!");
if (player1Turn)
{
Console.WriteLine("Point goes to Player 1!");
player1Points++;
}
else
{
Console.WriteLine("Point goes to Player 2!");
player2Points++;
}
}
else if (player1Cards.ElementAt(0).Hp > player2Cards.ElementAt(0).Hp)
{
Console.WriteLine("HP of your Pokemon won!");
player1Points++;
}
else
{
Console.WriteLine("HP of your Pokemon lose!");
player2Points++;
}
Console.WriteLine("******************************************************************************************************");
Console.WriteLine("Your Pokémon Hp");
Console.WriteLine($"{player1Cards.ElementAt(0).PokemonName} - Hp: {player1Cards.ElementAt(0).Hp}");
Console.WriteLine("\nYour Rival's Pokémon Hp");
Console.WriteLine($"{player2Cards.ElementAt(0).PokemonName} - Hp: {player2Cards.ElementAt(0).Hp}");
Console.WriteLine("******************************************************************************************************");
break;
}
case "2":
{
validChoice = true;
Console.WriteLine("******************************************************************************************************");
if (player1Cards.ElementAt(0).Attack == player2Cards.ElementAt(0).Attack)
{
Console.WriteLine("Attack of your Pokemon and your rival are the same!");
if (player1Turn)
{
Console.WriteLine("Point goes to Player 1!");
player1Points++;
}
else
{
Console.WriteLine("Point goes to Player 2!");
player2Points++;
}
}
else if (player1Cards.ElementAt(0).Attack > player2Cards.ElementAt(0).Attack)
{
Console.WriteLine("Attack of your Pokemon won!");
player1Points++;
}
else
{
Console.WriteLine("Attack of your Pokemon lose!");
player2Points++;
}
Console.WriteLine("******************************************************************************************************");
Console.WriteLine("Your Pokémon Attack");
Console.WriteLine($"{player1Cards.ElementAt(0).PokemonName} - Attack: {player1Cards.ElementAt(0).Attack}");
Console.WriteLine("\nYour Rival's Pokémon Attack");
Console.WriteLine($"{player2Cards.ElementAt(0).PokemonName} - Attack: {player2Cards.ElementAt(0).Attack}");
Console.WriteLine("******************************************************************************************************");
break;
}
case "3":
{
validChoice = true;
Console.WriteLine("******************************************************************************************************");
if (player1Cards.ElementAt(0).Defense == player2Cards.ElementAt(0).Defense)
{
Console.WriteLine("Defense of your Pokemon and your rival are the same!");
if (player1Turn)
{
Console.WriteLine("Point goes to Player 1!");
player1Points++;
}
else
{
Console.WriteLine("Point goes to Player 2!");
player2Points++;
}
}
else if (player1Cards.ElementAt(0).Defense > player2Cards.ElementAt(0).Defense)
{
Console.WriteLine("Defense of your Pokemon won!");
player1Points++;
}
else
{
Console.WriteLine("Defense of your Pokemon lose!");
player2Points++;
}
Console.WriteLine("******************************************************************************************************");
Console.WriteLine("Your Pokémon Defense");
Console.WriteLine($"{player1Cards.ElementAt(0).PokemonName} - Defense: {player1Cards.ElementAt(0).Defense}");
Console.WriteLine("\nYour Rival's Pokémon Attack");
Console.WriteLine($"{player2Cards.ElementAt(0).PokemonName} - Defense: {player2Cards.ElementAt(0).Defense}");
Console.WriteLine("******************************************************************************************************");
break;
}
case "4":
{
validChoice = true;
Console.WriteLine("******************************************************************************************************");
if (player1Cards.ElementAt(0).Speed == player2Cards.ElementAt(0).Speed)
{
Console.WriteLine("Speed of your Pokemon and your rival are the same!");
if (player1Turn)
{
Console.WriteLine("Point goes to Player 1!");
player1Points++;
}
else
{
Console.WriteLine("Point goes to Player 2!");
player2Points++;
}
}
else if (player1Cards.ElementAt(0).Speed > player2Cards.ElementAt(0).Speed)
{
Console.WriteLine("Speed of your Pokemon won!");
player1Points++;
}
else
{
Console.WriteLine("Speed of your Pokemon lose!");
player2Points++;
}
Console.WriteLine("******************************************************************************************************");
Console.WriteLine("Your Pokémon Speed");
Console.WriteLine($"{player1Cards.ElementAt(0).PokemonName} - Defense: {player1Cards.ElementAt(0).Speed}");
Console.WriteLine("\nYour Rival's Pokémon Speed");
Console.WriteLine($"{player2Cards.ElementAt(0).PokemonName} - Defense: {player2Cards.ElementAt(0).Speed}");
Console.WriteLine("******************************************************************************************************");
break;
}
default:
break;
}
} while (validChoice == false);
if (player1Turn)
{
player1Turn = false;
}
else
{
player1Turn = true;
}
round++;
}
Console.WriteLine("----------------------------------------------------------------------------------------------------------");
Console.WriteLine("No cards left, that means GAME OVER");
Console.WriteLine($"Player 1: {player1Points} points");
Console.WriteLine($"Player 2: {player2Points} points");
Console.WriteLine("");
if (player1Points == player2Points)
{
Console.WriteLine("You and your rival scored the same amount of points!");
}
else if (player1Points > player2Points)
{
Console.WriteLine("Congratulations Player 1, you Won!");
}
else
{
Console.WriteLine("Sadly you lose this one! Try Again later and don't give up!");
}
ExitProgram();
}
static void ExitProgram()
{
Console.WriteLine("");
Console.WriteLine(":::::::::::::::::::::::::");
Console.WriteLine("Thanks for playing!");
Console.WriteLine(":::::::::::::::::::::::::");
Environment.Exit(0);
}
}
public class Card
{
public int id { get; private set; }
public string PokemonName { get; set; }
public int Hp { get; private set; }
public int Attack { get; private set; }
public int Defense { get; private set; }
public int Speed { get; private set; }
public Card(int _id, string _pokemonName, int _hp, int _attack, int _defense, int _speed)
{
this.id = _id;
this.PokemonName = _pokemonName;
this.Hp = _hp;
this.Defense = _defense;
this.Speed = _speed;
this.Attack = _attack;
}
public void ShowAttributes()
{
Console.WriteLine("--------------------------");
Console.WriteLine($"Card attributes:");
Console.WriteLine($"Pokemon: {this.PokemonName}");
Console.WriteLine($"Hp: {this.Hp}");
Console.WriteLine($"Attack: {this.Attack}");
Console.WriteLine($"Defense: {this.Defense}");
Console.WriteLine($"Speed: {this.Speed}");
Console.WriteLine("--------------------------");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment