예제 #1
0
        private void ProcessHit(CombatMove combatMove, PokemonInstance origin)
        {
            PokemonInstance target = null;

            switch (combatMove.Archetype.MoveTarget) {
                case MoveTarget.ActiveEnemy:
                    target = origin == ActiveEnemyPokemon.PokemonInstance ? ActiveAlliedPokemon.PokemonInstance : ActiveEnemyPokemon.PokemonInstance;
                    break;
                case MoveTarget.Self:
                    target = origin;
                    break;
            }

            if (target != null && combatMove.Archetype.BattleEffectType == BattleEffectType.DamageOnly) {
                var moveElement = combatMove.Archetype.ElementType;
                var targetPrimaryElement = target.Archetype.PrimaryType;
                var targetSecondaryElement = target.Archetype.SecondaryType;

                // Weaknesses and resistances
                var damageModifier = DataManager.GetEffectiveness(moveElement, targetPrimaryElement) * DataManager.GetEffectiveness(moveElement, targetSecondaryElement);

                // Random modifier
                damageModifier *= (Random.Next(85, 101) + 0f)/100;

                // Same Type Attack Bonus (STAB)
                if (moveElement == origin.Archetype.PrimaryType || moveElement == origin.Archetype.SecondaryType)
                    damageModifier *= 1.5f;

                // Critical hit
                if (Random.Next(0, 10001) <= 625)
                    damageModifier *= 2;

                var attack = combatMove.Archetype.MoveType == MoveType.Physical
                                 ? origin.CombatStats[Stats.Attack].CurrentStatValue
                                 : origin.CombatStats[Stats.SpecialAttack].CurrentStatValue;

                var defense = combatMove.Archetype.MoveType == MoveType.Physical
                                  ? target.CombatStats[Stats.Defense].CurrentStatValue
                                  : target.CombatStats[Stats.SpecialDefense].CurrentStatValue;

                var appliedDamage = (int) Math.Ceiling((((2*origin.Level + 10)/(float)250)*(attack/defense)*combatMove.Archetype.Power + 2)*
                                                       damageModifier);

                if (target.CurrentHealth < appliedDamage)
                    appliedDamage = target.CurrentHealth;

                //Console.WriteLine(appliedDamage);

                target.ApplyDamage(appliedDamage);

                //Console.WriteLine(ActiveEnemyPokemon.CurrentHealth + "," + ActiveAlliedPokemon.CurrentHealth);
            }
        }
예제 #2
0
        private void CalculateHitOrMiss(CombatMove combatMove, PokemonInstance origin)
        {
            combatMove.RemainingPP--;

            PokemonInstance target = null;

            switch (combatMove.Archetype.MoveTarget)
            {
                case MoveTarget.ActiveEnemy:
                    target = origin == ActiveEnemyPokemon.PokemonInstance ? ActiveAlliedPokemon.PokemonInstance : ActiveEnemyPokemon.PokemonInstance;
                    break;
                case MoveTarget.Self:
                    target = origin;
                    break;
            }

            if (target != null && combatMove.Archetype.BattleEffectType == BattleEffectType.DamageOnly)
            {
                var hitThreshold = Math.Ceiling(target.CombatStats[Stats.Evasion].CurrentStatValue/100f * origin.CombatStats[Stats.Accuracy].CurrentStatValue/100f) * combatMove.Archetype.Accuracy;

                AttackState = Random.Next(0,101) > hitThreshold ? AttackState.Miss : AttackState.Hit;
            }
        }