Exemple #1
0
        public void Battle(ref BattleBot battleBot)
        {
            if (!blnIsBattleSoundPlaying)
            {
                battleSound.PlayLooping();
                blnIsBattleSoundPlaying = true;
            }

            if (battleBot.Fuel > 0 && battleBot.HP > 0)
            {
                intBattleStartTime = intTimeSinceGameStart;
                string computerWeapon = WEAPONS[rGen.Next(WEAPONS.Length)];
                Console.ForegroundColor = GetColorForWeapon(battleBot.Weapon);
                Console.WriteLine("███████████████████████████");
                SpeakingConsole.WriteLine("\n\t" + battleBot.Weapon + "           ");

                Console.ForegroundColor = ConsoleColor.White;
                SpeakingConsole.WriteLine("\n\t----- VS -----   ");

                Console.ForegroundColor = GetColorForWeapon(computerWeapon);
                SpeakingConsole.WriteLine("\n\t" + computerWeapon);    // Pokemon
                Console.WriteLine("███████████████████████████");

                Console.ForegroundColor = ConsoleColor.White;
                //SpeakingConsole.WriteLine("\nYou are being attacked by a " + computerWeapon + ". What do you do?");
                bool blnValidAction = false;
                char charReadKey    = '\0';
                while (!blnValidAction)
                {
                    bool blnCheatCodeWorked = false;
                    SpeakingConsole.WriteLine("\nAttack, Defend, or Retreat");
                    for (int i = 0; i < KONAMI_CODE.Length; i++)
                    {
                        ConsoleKeyInfo key = Console.ReadKey();
                        charReadKey = key.KeyChar;
                        if (key.Key != KONAMI_CODE[i])
                        {
                            break;
                        }
                        if (i == KONAMI_CODE.Length - 1)
                        {
                            battleBot.addScore(20);
                            SpeakingConsole.WriteLine("\nYou have cheated, trainer!! But you will get 20 extra points because that's just how the world is (unfair)");
                            blnCheatCodeWorked = true;
                        }
                    }
                    if (blnCheatCodeWorked)
                    {
                        continue;
                    }

                    string strAction = SpeakingConsole.SpeakAndReturn(charReadKey + Console.ReadLine());
                    switch (strAction.Trim().ToLower())
                    {
                    case "attack":
                        blnValidAction = true;
                        if (CanBeat(battleBot.Weapon, computerWeapon))
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.addScore(rGen.Next(6, 11));
                                SpeakingConsole.WriteLine("You have critically destroyed your opponent!!");
                            }
                            else
                            {
                                battleBot.addScore(5);
                                SpeakingConsole.WriteLine("You have destroyed your opponent!!");
                            }
                        }
                        else
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.HPDown(rGen.Next(6, 11));
                                SpeakingConsole.WriteLine("You have tragically lost!!");
                            }
                            else
                            {
                                battleBot.HPDown(5);
                                SpeakingConsole.WriteLine("You have lost!!");
                            }
                        }
                        battleBot.FuelDown(2 * intTimeElapsed);
                        break;

                    case "defend":
                        blnValidAction = true;
                        if (CanBeat(battleBot.Weapon, computerWeapon))
                        {
                            battleBot.addScore(2);
                            SpeakingConsole.WriteLine("You have defended yourself like a noble man!!");
                        }
                        else
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.HPDown(rGen.Next(3, 5));
                                SpeakingConsole.WriteLine("Whoops, your shield has completely failed!!");
                            }
                            else
                            {
                                battleBot.HPDown(2);
                                SpeakingConsole.WriteLine("Whoops, your shield has failed!!");
                            }
                        }
                        battleBot.FuelDown(intTimeElapsed);
                        break;

                    case "retreat":
                        blnValidAction = true;
                        if (rGen.Next(0, 4) == 0)
                        {
                            SpeakingConsole.WriteLine("Unfortunately, you couldn't escape in time!!");
                            battleBot.HPDown(7);
                        }
                        else
                        {
                            SpeakingConsole.WriteLine("You have succesfully escaped from the battle like a coward!! No points for you!!");
                        }
                        battleBot.FuelDown(3 * intTimeElapsed);
                        break;

                    case "absorb":
                        if (battleBot.Weapon == computerWeapon)
                        {
                            blnValidAction = true;
                            SpeakingConsole.WriteLine("You have succesfully absorbed the opponent's power!! This tastes yummy OwO");
                            Console.WriteLine("Professor Oak<> MMMMMmmmm... Fried " + battleBot.Weapon);
                            battleBot.Refuel(10);
                            battleBot.Heal(10);
                        }
                        break;
                    }
                    if (blnValidAction)
                    {
                        GetSoundForWeapon(battleBot.Weapon).PlaySync();
                        battleSound.Play();
                    }
                }
                Thread.Sleep(1000);
                SpeakingConsole.WriteLine("\nBot stats:\nName: " + battleBot.Name + "\nWeapon: " + battleBot.Weapon + "\nHP: " + battleBot.HP + "\nPower Points Left: " + battleBot.Fuel + "\nTurn Time: " + intTimeElapsed + "\nTotal Battle Time: " + intTimeSinceGameStart + "\nPoints: " + battleBot.Score + "\nHighest Score: " + battleBot.HighestScore);
                Thread.Sleep(1000);
                Battle(ref battleBot);
            }
            else
            {
                battleBot.UpdateHighScore(battleBot.Score);
                SpeakingConsole.WriteLine("Your bot has lost. Do you want to play again?");
                string strInput = "";
                if ((strInput = SpeakingConsole.ReadLine()) != "" && strInput.Trim().ToLower()[0] == 'y')
                {
                    battleBot = PromptUserForBot(battleBot.HighestScore);
                    Battle(ref battleBot);
                }
            }
        }
Exemple #2
0
        public void Battle(ref BattleBot battleBot)
        {
            if (!blnIsBattleSoundPlaying)
            {
                BattleSFX.PlayLooping();
                blnIsBattleSoundPlaying = true;
            }

            if (battleBot.FuelLevel > 0 && battleBot.ConditionLevel > 0)
            {
                intBattleStartTime = intTimeSinceGameStart;
                string computerWeapon = WEAPONS[rGen.Next(WEAPONS.Length)];
                //////////////////////////////////
                Console.ForegroundColor = GetColorForWeapon(battleBot.Weapon);
                Console.WriteLine("███████████████████████████");
                SpeakingConsole.WriteLine("\n\t\t" + battleBot.Weapon + "           ");

                Console.ForegroundColor = ConsoleColor.White;
                SpeakingConsole.WriteLine("\n\t\t----- VS -----   ");

                Console.ForegroundColor = GetColorForWeapon(computerWeapon);
                SpeakingConsole.WriteLine("\n\t\t" + computerWeapon);    // Pokemon
                Console.WriteLine("███████████████████████████");

                Console.ForegroundColor = ConsoleColor.White;
                //////////////////////////////////
                //SpeakingConsole.WriteLine("\nYou are being attacked by a " + computerWeapon + ". What do you do?");
                bool blnValidAction = false;
                char charReadKey    = '\0';
                while (!blnValidAction)
                {
                    bool blnCheatCodeWorked = false;
                    SpeakingConsole.WriteLine("\nAttack, Defend, or Retreat");
                    for (int i = 0; i < KONAMI_CODE.Length; i++)
                    {
                        ConsoleKeyInfo key = Console.ReadKey();
                        charReadKey = key.KeyChar;
                        if (key.Key != KONAMI_CODE[i])
                        {
                            break;
                        }
                        if (i == KONAMI_CODE.Length - 1)
                        {
                            battleBot.GainPoints(20);
                            SpeakingConsole.WriteLine("\nYou have cheated, trainer!! But you will get 20 extra points because that's just how the world is (unfair)");
                            PokeBallOpenSFX.PlaySync();

                            blnCheatCodeWorked = true;
                            BattleSFX.PlayLooping();
                        }
                    }
                    if (blnCheatCodeWorked)
                    {
                        continue;
                    }

                    string strAction = SpeakingConsole.SpeakAndReturn(charReadKey + Console.ReadLine());
                    switch (strAction.Trim().ToLower())
                    {
                    case "attack":
                        blnValidAction = true;
                        if (CanBeat(battleBot.Weapon, computerWeapon))
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.GainPoints(rGen.Next(6, 11));
                                SpeakingConsole.WriteLine("Professor Oak: You have critically destroyed your opponent!!");

                                //////////////////////////////////
                                ///////////////////////////////////
                                /////////////////////////////////
                            }
                            else
                            {
                                battleBot.GainPoints(5);
                                SpeakingConsole.WriteLine("Professor Oak: You have destroyed your opponent!!");
                            }
                        }
                        else
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.HandleDamage(rGen.Next(6, 11));
                                SpeakingConsole.WriteLine("Professor Oak: You have tragically lost!!");
                            }
                            else
                            {
                                battleBot.HandleDamage(5);
                                SpeakingConsole.WriteLine("Professor Oak: You have lost!!");
                            }
                        }
                        battleBot.ConsumeFuel(2 * intTimeElapsed);
                        break;

                    case "defend":
                        blnValidAction = true;
                        if (CanBeat(battleBot.Weapon, computerWeapon))
                        {
                            battleBot.GainPoints(2);
                            SpeakingConsole.WriteLine("Professor Oak: You have defended yourself like a noble man!!");
                        }
                        else
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.HandleDamage(rGen.Next(3, 5));
                                SpeakingConsole.WriteLine("Professor Oak: Whoops, your shield has completely failed!!");
                            }
                            else
                            {
                                battleBot.HandleDamage(2);
                                SpeakingConsole.WriteLine("Professor Oak: Whoops, your shield has failed!!");
                            }
                        }
                        battleBot.ConsumeFuel(intTimeElapsed);
                        break;

                    case "retreat":
                        blnValidAction = true;
                        if (rGen.Next(0, 4) == 0)
                        {
                            SpeakingConsole.WriteLine("Professor Oak: Unfortunately, you couldn't escape in time!!");
                            battleBot.HandleDamage(7);
                        }
                        else
                        {
                            SpeakingConsole.WriteLine("Professor Oak: You have succesfully escaped from the battle like a coward!! No points for you!!");
                        }
                        battleBot.ConsumeFuel(3 * intTimeElapsed);
                        break;

                    case "absorb":
                        if (battleBot.Weapon == computerWeapon)
                        {
                            blnValidAction = true;
                            SpeakingConsole.WriteLine("You have succesfully absorbed the opponent's power!! This tastes yummy OwO");
                            SpeakingConsole.WriteLine("Professor Oak: Mmmmm... Fried " + computerWeapon);
                            battleBot.Refuel(10);
                            battleBot.Heal(10);
                        }
                        break;
                    }

                    if (blnValidAction)
                    {
                        GetSoundForWeapon(battleBot.Weapon).PlaySync();
                        BattleSFX.Play();
                    }
                }
                Thread.Sleep(1000);
                SpeakingConsole.WriteLine("\nBot stats:");

                if (battleBot.Name == "PokeBall")
                {
                    Console.WriteLine("────────▄███████████▄────────");
                    Console.WriteLine("─────▄███▓▓▓▓▓▓▓▓▓▓▓███▄─────");
                    Console.WriteLine("────███▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███────");
                    Console.WriteLine("───██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██───");
                    Console.WriteLine("──██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██──");
                    Console.WriteLine("─██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██─");
                    Console.WriteLine("██▓▓▓▓▓▓▓▓▓███████▓▓▓▓▓▓▓▓▓██");
                    Console.WriteLine("██▓▓▓▓▓▓▓▓██░░░░░██▓▓▓▓▓▓▓▓██");
                    Console.WriteLine("██▓▓▓▓▓▓▓██░░███░░██▓▓▓▓▓▓▓██");
                    Console.WriteLine("███████████░░███░░███████████");
                    Console.WriteLine("██░░░░░░░██░░███░░██░░░░░░░██");
                    Console.WriteLine("██░░░░░░░░██░░░░░██░░░░░░░░██");
                    Console.WriteLine("██░░░░░░░░░███████░░░░░░░░░██");
                    Console.WriteLine("─██░░░░░░░░░░░░░░░░░░░░░░░██─");
                    Console.WriteLine("──██░░░░░░░░░░░░░░░░░░░░░██──");
                    Console.WriteLine("───██░░░░░░░░░░░░░░░░░░░██───");
                    Console.WriteLine("────███░░░░░░░░░░░░░░░███────");
                    Console.WriteLine("─────▀███░░░░░░░░░░░███▀─────");
                    Console.WriteLine("────────▀███████████▀────────");
                }

                SpeakingConsole.WriteLine("Trainers Name: " + battleBot.Name + ",");

                // Color Desiders
                if (battleBot.Weapon == "Pickachu")
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }
                else if (battleBot.Weapon == "Geodude")
                {
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                else if (battleBot.Weapon == "Squirtle")
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                else if (battleBot.Weapon == "Swadloon")
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                else if (battleBot.Weapon == "Charmander")
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                }



                SpeakingConsole.WriteLine("Pokemon: " + battleBot.Weapon + ",");
                Console.ForegroundColor = ConsoleColor.White;
                SpeakingConsole.WriteLine("Condition Level: " + battleBot.ConditionLevel + ",");
                SpeakingConsole.WriteLine("Power Points:" + battleBot.FuelLevel + ",\nTurn Time: " + intTimeElapsed + ",\nTotal Battle Time: " + intTimeSinceGameStart + ",\nPoints: " + battleBot.Score + ",\nHighest Score: " + battleBot.HighScore);

                SpeakingConsole.WriteLine("\n Health Left: ##");
                SpeakingConsole.WriteLine("\n Power Left: ");
                //Console.WriteLine("\n Next Move: ");

                Thread.Sleep(1000);
                Battle(ref battleBot);
            }
            else
            {
                battleBot.UpdateHighScore(battleBot.Score);
                SpeakingConsole.WriteLine("Your pokemon has lost. Do you want to play again?");
                if (SpeakingConsole.ReadLine().Trim().ToLower()[0] == 'y')
                {
                    battleBot = PromptUserForBot(battleBot.HighScore);
                    Battle(ref battleBot);
                }
            }
        }