Example #1
0
        public static void Sequence(int id)
        {
            Battle      player        = Battle.FindPlayer();
            Battle      computer      = Battle.FindComputer();
            Mon         playerMon     = Mon.Find(player.GetMon_Id());
            Mon         computerMon   = Mon.Find(computer.GetMon_Id());
            Move        playerMove    = Move.Find(id);
            List <Move> computerMoves = Mon.Find(computer.GetMon_Id()).GetMoves();
            Random      move          = new Random();
            Move        computerMove  = computerMoves[move.Next(computerMoves.Count)];

            //Speed Check
            int tie = 0;

            if (computer.GetSpeed() == player.GetSpeed())
            {
                Random speedTie = new Random();
                tie = speedTie.Next(1, 3);
            }
            if (player.GetSpeed() > computer.GetSpeed() || tie == 1)
            {
                double newHP   = (double)computer.GetHitpoints() - (double)Battle.BaseDamage(player.GetBattleId(), playerMove) * (double)MonType.TypeMultiplier(computerMon, playerMove) * (double)MonType.STABMultiplier(playerMon, playerMove) * (double)playerMove.AccuracyMultiplier() * (double)Battle.CritMultiplier();
                int    roundHP = (int)newHP;
                if (roundHP > 0)
                {
                    computer.SetNewHP(roundHP);
                    double otherHP      = (double)player.GetHitpoints() - (double)Battle.BaseDamage(player.GetBattleId(), computerMove) * (double)MonType.TypeMultiplier(playerMon, computerMove) * (double)MonType.STABMultiplier(computerMon, computerMove) * (double)computerMove.AccuracyMultiplier() * (double)Battle.CritMultiplier();
                    int    roundOtherHP = (int)otherHP;

                    if (roundOtherHP > 0)
                    {
                        player.SetNewHP(roundOtherHP);
                    }
                    else
                    {
                        player.SetNewHP(0);
                    }
                }
                else
                {
                    computer.SetNewHP(0);
                }
            }
            else if (player.GetSpeed() < computer.GetSpeed() || tie == 2)
            {
                double otherHP      = (double)player.GetHitpoints() - (double)Battle.BaseDamage(computer.GetBattleId(), computerMove) * (double)MonType.TypeMultiplier(playerMon, computerMove) * (double)MonType.STABMultiplier(playerMon, playerMove) * (double)playerMove.AccuracyMultiplier() * (double)Battle.CritMultiplier();
                int    roundOtherHP = (int)otherHP;

                if (roundOtherHP > 0)
                {
                    player.SetNewHP(roundOtherHP);
                    double newHP   = (double)computer.GetHitpoints() - (double)Battle.BaseDamage(player.GetBattleId(), playerMove) * (double)MonType.TypeMultiplier(computerMon, playerMove) * (double)MonType.STABMultiplier(computerMon, computerMove) * (double)computerMove.AccuracyMultiplier();
                    int    roundHP = (int)newHP;
                    if (roundHP > 0)
                    {
                        computer.SetNewHP(roundHP);
                    }
                    else
                    {
                        computer.SetNewHP(0);
                    }
                }
                else
                {
                    player.SetNewHP(0);
                }
            }
        }
Example #2
0
        public static int Damage(Move usedMove, Battle attacker, Mon attackerMon, Mon defenderMon)
        {
            double damage = (double)Battle.BaseDamage(attacker.GetBattleId(), usedMove) * (double)Battle.CritMultiplier() * (double)MonType.STABMultiplier(attackerMon, usedMove) * (double)usedMove.AccuracyMultiplier();

            return((int)damage);
            // (double)MonType.TypeMultiplier(defenderMon, usedMove)
        }