예제 #1
0
        //The code for determining type multipliers during combat.

        public static double Check(Moves attack, string defender, string defender2)
        {
            //The main checking method. It takes 3 arguments - a move, and the defending Pokemon's 2 types.
            //Then, it runs Calculate method - twice if the defending Pokemon has two types - and returns the result of the calculation.
            double mult = 1;

            if (defender2 == "")
            {
                mult = Calculate(attack, defender);
            }

            else
            {                
                mult = (Calculate(attack, defender) * Calculate(attack, defender2));
            }

            return mult;
        }
예제 #2
0
        public static double Calculate(Moves attack, string defender)
        {
            //The actual calculation method. It checks whether the defender is weak, resistant or immune to the attack.
            //If it is, it returns the corresponding multiplier. Otherwise, it returns 1, for normal effectiveness.
            double mult = 1;
            string attacker = attack.Type;

            if (attacker == "Normal")
            {
                switch (defender)
                {
                    case "Rock":
                    case "Steel":
                        mult = 0.5;
                        break;
                    case "Ghost":
                        mult = 0;
                        break;
                }
            }

            else if (attacker == "Fire")
            {
                switch (defender)
                {
                    case "Water":
                    case "Rock":
                    case "Fire":
                    case "Dragon":
                        mult = 0.5;
                        break;
                    case "Grass":
                    case "Ice":
                    case "Steel":
                    case "Bug":
                        mult = 2;
                        break;
                }
            }

            else if (attacker == "Water")
            {
                switch (defender)
                {
                    case "Water":
                    case "Grass":
                    case "Dragon":
                        mult = 0.5;
                        break;
                    case "Ground":
                    case "Rock":
                    case "Fire":
                        mult = 2;
                        break;
                }
            }

            else if (attacker == "Grass")
            {
                switch (defender)
                {
                    case "Flying":
                    case "Poison":
                    case "Fire":
                    case "Bug":
                    case "Grass":
                    case "Dragon":
                    case "Steel":
                        mult = 0.5;
                        break;
                    case "Water":
                    case "Ground":
                    case "Rock":
                        mult = 2;
                        break;
                }
            }

            else if (attacker == "Electric")
            {
                switch (defender)
                {
                    case "Electric":
                    case "Grass":
                    case "Dragon":
                        mult = 0.5;
                        break;
                    case "Flying":
                    case "Water":
                        mult = 2;
                        break;
                    case "Ground":
                        mult = 0;
                        break;
                }
            }

            else if (attacker == "Ice")
            {
                switch (defender)
                {
                    case "Water":
                    case "Ice":
                    case "Steel":
                    case "Fire":
                        mult = 0.5;
                        break;
                    case "Flying":
                    case "Ground":
                    case "Grass":
                    case "Dragon":
                        mult = 2;
                        break;
                }
            }

            else if (attacker == "Fighting")
            {
                switch (defender)
                {
                    case "Flying":
                    case "Poison":
                    case "Bug":
                    case "Psychic":
                    case "Fairy":
                        mult = 0.5;
                        break;
                    case "Normal":
                    case "Ice":
                    case "Rock":
                    case "Dark":
                    case "Steel":
                        mult = 2;
                        break;
                    case "Ghost":
                        mult = 0;
                        break;
                }
            }

            else if (attacker == "Poison")
            {
                switch (defender)
                {

                    case "Poison":
                    case "Ground":
                    case "Rock":
                    case "Ghost":
                        mult = 0.5;
                        break;
                    case "Grass":
                    case "Fairy":
                        mult = 2;
                        break;
                    case "Steel":
                        mult = 0;
                        break;
                }
            }

            else if (attacker == "Ground")
            {
                switch (defender)
                {
                    case "Bug":
                    case "Grass":
                        mult = 0.5;
                        break;
                    case "Poison":
                    case "Fire":
                    case "Rock":
                    case "Electric":
                    case "Steel":
                        mult = 2;
                        break;
                    case "Flying":
                        mult = 0;
                        break;
                }
            }

            else if (attacker == "Flying")
            {
                switch (defender)
                {
                    case "Rock":
                    case "Electric":
                    case "Steel":
                        mult = 0.5;
                        break;
                    case "Fighting":
                    case "Bug":
                    case "Grass":
                        mult = 2;
                        break;
                }
            }

            else if (attacker == "Psychic")
            {
                switch (defender)
                {
                    case "Psychic":
                    case "Steel":
                        mult = 0.5;
                        break;
                    case "Fighting":
                    case "Poison":
                        mult = 2;
                        break;
                    case "Dark":
                        mult = 0;
                        break;
                }
            }

            else if (attacker == "Bug")
            {
                switch (defender)
                {
                    case "Flying":
                    case "Fighting":
                    case "Fire":
                    case "Ghost":
                    case "Poison":
                    case "Steel":
                    case "Fairy":
                        mult = 0.5;
                        break;
                    case "Grass":
                    case "Psychic":
                    case "Dark":
                        mult = 2;
                        break;
                }
            }

            else if (attacker == "Rock")
            {
                switch (defender)
                {
                    case "Fighting":
                    case "Ground":
                    case "Steel":
                        mult = 0.5;
                        break;
                    case "Flying":
                    case "Bug":
                    case "Fire":
                    case "Ice":
                        mult = 2;
                        break;
                }
            }

            else if (attacker == "Ghost")
            {
                switch (defender)
                {
                    case "Dark":
                        mult = 0.5;
                        break;
                    case "Ghost":
                    case "Psychic":
                        mult = 2;
                        break;                   
                    case "Normal":
                        mult = 0;
                        break;
                }
            }

            else if (attacker == "Dragon")
            {
                switch (defender)
                {
                    case "Steel":
                        mult = 0.5;
                        break;
                    case "Dragon":
                        mult = 2;
                        break;                    
                    case "Fairy":
                        mult = 0;
                        break;
                }
            }

            else if (attacker == "Dark")
            {
                switch (defender)
                {
                    case "Dark":
                    case "Fairy":
                    case "Ice":
                        mult = 0.5;
                        break;
                    case "Psychic":
                    case "Ghost":
                        mult = 2;
                        break;
                }
            }

            else if (attacker == "Steel")
            {
                switch (defender)
                {
                    case "Steel":
                    case "Fire":
                    case "Water":
                    case "Electric":
                        mult = 0.5;
                        break;
                    case "Fairy":
                    case "Rock":
                    case "Ice":
                        mult = 2;
                        break;
                }
            }

            else if (attacker == "Fairy")
            {
                switch (defender)
                {
                    case "Steel":
                    case "Fire":
                    case "Poison":
                        mult = 0.5;
                        break;
                    case "Dark":
                    case "Fighting":
                    case "Dragon":
                        mult = 2;
                        break;                    
                }
            }

            else //This doesn't need to exist, but I've included it as a failproof in case I've assigned an incorrect type to an attack.
            {
                Program.Log(attack.Name + " did not have a correctly assigned type, so TypeChart.Check returned 1. (Type = " + attack.Type + ")", 2);
                mult = 1;
            }

            return mult;
        }
예제 #3
0
        void AI()
        {
            //The AI's attack code. It uses a random number generator to simulate the AI selecting attacks.
            //TODO: Add more complex logic.           

            //While the enemy's Pokemon is not move-locked, it picks a random move.
            if (!enemyPokemon.moveLocked)
                enemyMove = enemyPokemon.knownMoves.ElementAt(rng.Next(0, enemyPokemon.knownMoves.Count));

            //If the enemy Pokemon is movelocked, it just uses the same move again.
            else
                enemyMove = previousEnemyMove;

            Program.Log("The AI selected the move " + enemyMove.Name + ".", 0);
        }
예제 #4
0
        void PreBattle(string attacker)
        {
            //Quick pre-battle calculations and helpful message adjustments.

            Program.Log("The " + attacker + " attacks.", 1);

            if (attacker == "player")
            {
                attackingPokemon = playerPokemon;
                defendingPokemon = enemyPokemon;
                currentMove = playerMove;
                attackerName = playerPokemon.name;
                defenderName = "The enemy " + enemyPokemon.name;

                //If the selected move does double damage after being used consecutively and was used last turn, sameMoveDamageBonus becomes 2.
                if (playerMove == previousPlayerMove && playerMove.EffectID == 4)
                    sameMoveDamageBonus = 2;
                else
                    sameMoveDamageBonus = 1;

                previousPlayerMove = playerMove;
            }

            else if (attacker == "AI")
            {
                attackingPokemon = enemyPokemon;
                defendingPokemon = playerPokemon;
                currentMove = enemyMove;
                attackerName = "The enemy " + enemyPokemon.name;
                defenderName = playerPokemon.name;

                //If the selected move does double damage after being used consecutively and was used last turn, sameMoveDamageBonus becomes 2.
                if (enemyMove == previousEnemyMove && enemyMove.EffectID == 4)
                    sameMoveDamageBonus = 2;
                else
                    sameMoveDamageBonus = 1;

                previousEnemyMove = enemyMove;
            }

            if (attackingPokemon.status == "paralysis" && !Paralyzed() || attackingPokemon.status == "sleep" && !Asleep() || attackingPokemon.status == "" || attackingPokemon.status == "poison")
            {
                Console.WriteLine("\n{0} used {1}!", attackerName, currentMove.Name);

                if (defendingPokemon.protect)
                    Console.WriteLine("{0} was protected from the attack!", defenderName);

                else
                {
                    double typeMod = TypeChart.Check(currentMove, defendingPokemon.type, defendingPokemon.type2);

                    if (typeMod == 0.0)
                    {
                        Console.WriteLine("{0} was immune to the attack!", defenderName);
                    }

                    else
                    {
                        //If a player uses a move that locks you into a move, this sets the moveLocked flag to true.
                        if (currentMove.EffectID == 4)
                        {
                            Program.Log(attackingPokemon.name + " used " + currentMove + ", which move-locked it.", 0);
                            attackingPokemon.moveLocked = true;
                        }

                        if (currentMove.Attribute == "Status")
                        {
                            Program.Log("The attack selected by the " + attacker + " does not deal damage, so Effect() will take place.", 0);

                            if (Hit())
                                Effect(attacker);
                        }

                        else
                        {
                            Program.Log("The attack selected by the " + attacker + " deals damage, so Damage() will take place.", 0);

                            if (Hit())
                                Damage(attacker, typeMod);
                        }
                    }
                }
            }
        }
예제 #5
0
        void Fight()
        {
            //The first part of the fighting code. Here, the player selects a move.

            Program.Log("The player chooses to fight.", 1);

            //If the player's Pokemon is not move-locked, the player selects a move.
            if (!playerPokemon.moveLocked)
            {
                Console.WriteLine("Please select a move. (Valid input: 1-{0}, or press Enter to return.)\n", playerPokemon.knownMoves.Count);

                Moves tempMove = playerPokemon.SelectMove(false);

                //The player is asked to select a move. If his selecetion is correct, the operation goes on.
                if (tempMove.Name != "Blank")
                {
                    playerMove = tempMove;

                    Program.Log("The player selected the move " + playerMove.Name + ".", 0);

                    //The AI then selects a move.
                    AI();

                    //The program then goes into Speed priority calculation.
                    SpeedPriority();
                }

                else
                {
                    //Otherwise, an error message is displayed, and the player is taken back to the Actions menu.
                    Program.Log("The player chose an invalid move. Returning to Actions.", 0);

                    Actions();
                }
            }

            else
            {
                //Else if the player's Pokemon is movelocked and it still knows the move it used last turn, that move gets automatically selected.
                if (playerPokemon.knownMoves.Exists(m => m.Name == previousPlayerMove.Name))
                {
                    playerMove = playerPokemon.knownMoves.Find(m => m.Name == previousPlayerMove.Name);

                    Program.Log("The player's Pokemon is movelocked and automatically uses the move " + playerMove.Name + ".", 0);

                    //The AI then selects a move.
                    AI();

                    //The program then goes into Speed priority calculation.
                    SpeedPriority();
                }
            }
        }