protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
            {
                //Factor in Double Pain for the Victim
                int doublePainCount = StepResult.VictimResult.Entity.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.DoublePain);

                StepResult.VictimResult.TotalDamage *= (1 + doublePainCount);
            }
Пример #2
0
            public static void PaybackInteractionUT2()
            {
                BattleMario mario = new BattleMario(new MarioStats(1, 5, 50, 0, 0, EquipmentGlobals.BootLevels.Super, EquipmentGlobals.HammerLevels.Normal));
                KoopaTroopa koopa = new KoopaTroopa();

                koopa.RaiseAttack(2);

                ReturnPostageBadge returnPostage = new ReturnPostageBadge();
                ZapTapBadge        zapTap        = new ZapTapBadge();

                returnPostage.Equip(mario);
                zapTap.Equip(mario);

                Debug.Assert(mario.EntityProperties.HasPayback());
                Debug.Assert(mario.EntityProperties.HasPhysAttributes(true, Enumerations.PhysicalAttributes.Electrified));

                int damage = new ShellTossAction(koopa).DamageProperties.Damage + koopa.BattleStats.TotalAttack;

                InteractionParamHolder paramHolder = new InteractionParamHolder(koopa, mario, damage, Enumerations.Elements.Normal, false,
                                                                                Enumerations.ContactTypes.SideDirect, Enumerations.ContactProperties.Protected, null, Enumerations.DamageEffects.None, false,
                                                                                Enumerations.DefensiveActionTypes.None);

                InteractionResult interaction = Interactions.GetDamageInteraction(paramHolder);

                PrintInteractionResult(interaction);

                returnPostage.UnEquip();
                zapTap.UnEquip();

                Debug.Assert(interaction.VictimResult.TotalDamage == 4);
                Debug.Assert(interaction.AttackerResult.TotalDamage == 2);
            }
            protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
            {
                //The unscaled damage the Attacker dealt to the Victim
                //This will be the Payback damage dealt from a Defensive Action if one that deals damage has been performed
                int unscaledAttackerDamage = StepResult.AttackerResult.TotalDamage;

                int           damageDealt   = unscaledAttackerDamage;
                PaybackHolder paybackHolder = StepContactResultInfo.Paybackholder;

                //Get the damage done to the Attacker, factoring in Weaknesses/Resistances
                ElementDamageResultHolder attackerElementDamage = GetElementalDamage(StepResult.AttackerResult.Entity,
                                                                                     paybackHolder.Element, damageDealt);

                //Get Payback damage - Payback damage is calculated after everything else
                //However, it does NOT factor in Double Pain or Last Stand, hence why we use the unscaled Victim damage
                int paybackDamage = paybackHolder.GetPaybackDamage(attackerElementDamage.Damage);

                //If Constant Payback, the constant damage value will be returned as the Payback damage
                //Therefore, update the final Payback damage value to factor in Weaknesses/Resistances using the constant Payback damage
                //Ex. This causes an enemy with a +1 Weakness to Fire to be dealt 2 damage instead of 1 for a Constant 1 Fire Payback
                if (paybackHolder.PaybackType == PaybackTypes.Constant)
                {
                    paybackDamage = GetElementalDamage(StepResult.AttackerResult.Entity, paybackHolder.Element, paybackDamage).Damage;
                }

                //Fill out the rest of the Attacker information since we have it
                //Payback damage is always direct, piercing, and guaranteed to hit
                StepResult.AttackerResult.TotalDamage       = paybackDamage;
                StepResult.AttackerResult.DamageElement     = paybackHolder.Element;
                StepResult.AttackerResult.ElementResult     = attackerElementDamage.InteractionResult;
                StepResult.AttackerResult.ContactType       = ContactTypes.TopDirect;
                StepResult.AttackerResult.Piercing          = true;
                StepResult.AttackerResult.StatusesInflicted = paybackHolder.StatusesInflicted;
                StepResult.AttackerResult.Hit = true;
            }
            protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
            {
                //Defense added from Damage Dodge Badges upon a successful Guard
                int damageDodgeDefense = 0;

                //Defensive actions take priority. If the attack didn't hit, don't check for defensive actions
                BattleGlobals.DefensiveActionHolder?victimDefenseData = null;
                if (StepResult.VictimResult.Hit == true)
                {
                    victimDefenseData = StepResult.VictimResult.Entity.GetDefensiveActionResult(StepResult.VictimResult.TotalDamage,
                                                                                                StepResult.VictimResult.StatusesInflicted, StepResult.VictimResult.DamageEffect);
                }

                //A Defensive Action has been performed
                if (victimDefenseData.HasValue == true)
                {
                    StepResult.VictimResult.TotalDamage       = victimDefenseData.Value.Damage;
                    StepResult.VictimResult.StatusesInflicted = victimDefenseData.Value.Statuses;
                    StepResult.VictimResult.DamageEffect      = victimDefenseData.Value.DamageEffect;

                    //Store the damage dealt to the attacker, if any
                    if (victimDefenseData.Value.ElementHolder.HasValue == true)
                    {
                        ElementDamageHolder elementHolder = victimDefenseData.Value.ElementHolder.Value;

                        //If the Defensive action dealt damage and the contact was direct
                        //the Defensive action has caused a Failure for the Attacker (Ex. Superguarding)
                        if (StepResult.VictimResult.ContactType == ContactTypes.TopDirect ||
                            StepResult.VictimResult.ContactType == ContactTypes.SideDirect)
                        {
                            StepContactResultInfo.ContactResult = ContactResult.Failure;

                            //Use the damage from the Defensive Action
                            StepResult.AttackerResult.TotalDamage = elementHolder.Damage;

                            //Update the Paybackholder to use the Payback data from the Defensive Action
                            StepContactResultInfo.Paybackholder = new PaybackHolder(PaybackTypes.Constant, elementHolder.Element, elementHolder.Damage);
                        }

                        StepResult.AttackerResult.DamageElement = victimDefenseData.Value.ElementHolder.Value.Element;
                    }

                    //Factor in the additional Guard defense for all DefensiveActions (for now, at least)
                    //If it's not Piercing, this will be subtracted, in addition to the Victim's Defense, from the damage dealt to the Victim
                    damageDodgeDefense = StepResult.VictimResult.Entity.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.DamageDodge);
                }

                //Subtract Defense on non-piercing damage
                if (StepResult.VictimResult.Piercing == false)
                {
                    int totalDefense = StepResult.VictimResult.Entity.BattleStats.TotalDefense + damageDodgeDefense;
                    StepResult.VictimResult.TotalDamage -= totalDefense;
                }

                //Store the final unscaled damage in the Attacker's result if there was no Defensive Action payback, as it will use it later
                if (victimDefenseData.HasValue == false || victimDefenseData.Value.ElementHolder.HasValue == false)
                {
                    StepResult.AttackerResult.TotalDamage = StepResult.VictimResult.TotalDamage;
                }
            }
Пример #5
0
            public static void NewInteractionUT7()
            {
                BattleMario mario  = new BattleMario(new MarioStats(1, 50, 50, 0, 0, EquipmentGlobals.BootLevels.Normal, EquipmentGlobals.HammerLevels.Normal));
                Goomba      goomba = new Goomba();

                goomba.EntityProperties.AddPhysAttribute(Enumerations.PhysicalAttributes.Fiery);
                goomba.EntityProperties.AddWeakness(Enumerations.Elements.Ice, new WeaknessHolder(WeaknessTypes.PlusDamage, 2));

                Badge badge = new IcePowerBadge();

                badge?.Equip(mario);

                InteractionParamHolder param = new InteractionParamHolder(mario, goomba, 3, Enumerations.Elements.Normal, false,
                                                                          Enumerations.ContactTypes.TopDirect, null, Enumerations.DamageEffects.None, false, Enumerations.DefensiveMoveOverrides.None);

                InteractionResult oldInteraction = Interactions.GetDamageInteractionOld(param);
                InteractionResult newInteraction = Interactions.GetDamageInteraction(param);

                Debug.Log("Old: ");
                PrintInteractionResult(oldInteraction);
                Debug.Log("New: ");
                PrintInteractionResult(newInteraction);

                badge?.UnEquip();
            }
Пример #6
0
            public static void NewInteractionUT8()
            {
                BattleMario mario  = new BattleMario(new MarioStats(1, 5, 50, 0, 0, EquipmentGlobals.BootLevels.Normal, EquipmentGlobals.HammerLevels.Normal));
                Goomba      goomba = new Goomba();

                mario.EntityProperties.AddWeakness(Enumerations.Elements.Normal, new WeaknessHolder(WeaknessTypes.KO, 4));
                goomba.EntityProperties.AfflictStatus(new PaybackStatus(5), true);

                Badge badge = new DoublePainBadge();

                goomba.SetHeldCollectible(badge);
                goomba.OnBattleStart();

                InteractionParamHolder param = new InteractionParamHolder(mario, goomba, 4, Enumerations.Elements.Water, false,
                                                                          Enumerations.ContactTypes.TopDirect, null, Enumerations.DamageEffects.None, false, Enumerations.DefensiveMoveOverrides.None);

                InteractionResult oldInteraction = Interactions.GetDamageInteractionOld(param);
                InteractionResult newInteraction = Interactions.GetDamageInteraction(param);

                Debug.Log("Old: ");
                PrintInteractionResult(oldInteraction);
                Debug.Log("New: ");
                PrintInteractionResult(newInteraction);

                badge?.UnEquip();
                goomba.SetHeldCollectible(null);
            }
 public InteractionResult Calculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
 {
     StepResult            = new InteractionResult(curResult);
     StepContactResultInfo = curContactResult;
     OnCalculate(damageInfo, curResult, curContactResult);
     return(StepResult);
 }
Пример #8
0
            public static void NewInteractionUT9()
            {
                BattleMario mario  = new BattleMario(new MarioStats(1, 5, 50, 0, 0, EquipmentGlobals.BootLevels.Normal, EquipmentGlobals.HammerLevels.Normal));
                Goomba      goomba = new Goomba();

                //Update HealthState for Last Stand to kick in on Danger
                mario.TakeDamage(Enumerations.Elements.Normal, 0, false);

                Badge badge = new LastStandBadge();

                badge?.Equip(mario);

                InteractionParamHolder param = new InteractionParamHolder(goomba, mario, 80, Enumerations.Elements.Water, false,
                                                                          Enumerations.ContactTypes.TopDirect, null, Enumerations.DamageEffects.None, false, Enumerations.DefensiveMoveOverrides.None);

                InteractionResult oldInteraction = Interactions.GetDamageInteractionOld(param);
                InteractionResult newInteraction = Interactions.GetDamageInteraction(param);

                Debug.Log("Old: ");
                PrintInteractionResult(oldInteraction);
                Debug.Log("New: ");
                PrintInteractionResult(newInteraction);

                badge?.UnEquip();
            }
            protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
            {
                ElementDamageResultHolder victimElementDamage = GetElementalDamage(StepResult.VictimResult.Entity,
                                                                                   StepResult.VictimResult.DamageElement, StepResult.VictimResult.TotalDamage);

                StepResult.VictimResult.ElementResult = victimElementDamage.InteractionResult;
                StepResult.VictimResult.TotalDamage   = victimElementDamage.Damage;
            }
            protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
            {
                BattleEntity victim   = StepResult.VictimResult.Entity;
                BattleEntity attacker = StepResult.AttackerResult.Entity;

                //Get contact results
                StepContactResultInfo = victim.EntityProperties.GetContactResult(attacker, StepResult.VictimResult.ContactType);
            }
 protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
 {
     if (StepContactResultInfo.ContactResult == ContactResult.Success)
     {
         //If the Attacker succeeded to attack, set the Attacker to null to mark it as not having a value
         //This prevents the code afterwards from dealing damage to the Attacker
         StepResult.AttackerResult.Entity = null;
     }
 }
 protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
 {
     //Check if the Attacker is Invincible. If so, ignore all damage and Status Effects
     if (StepResult.AttackerResult.Entity.EntityProperties.GetAdditionalProperty <bool>(AdditionalProperty.Invincible) == true)
     {
         StepResult.AttackerResult.TotalDamage       = 0;
         StepResult.AttackerResult.ElementResult     = ElementInteractionResult.Damage;
         StepResult.AttackerResult.StatusesInflicted = null;
     }
 }
 protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
 {
     StepResult.AttackerResult.Entity          = damageInfo.Attacker;
     StepResult.VictimResult.Entity            = damageInfo.Victim;
     StepResult.VictimResult.ContactType       = damageInfo.ContactType;
     StepResult.VictimResult.DamageElement     = damageInfo.DamagingElement;
     StepResult.VictimResult.StatusesInflicted = damageInfo.Statuses;
     StepResult.VictimResult.TotalDamage       = damageInfo.Damage;
     StepResult.VictimResult.Piercing          = damageInfo.Piercing;
     StepResult.VictimResult.DamageEffect      = damageInfo.DamageEffect;
 }
 protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
 {
     //If the move cannot miss, hit is set to true
     if (damageInfo.CantMiss == true)
     {
         StepResult.VictimResult.Hit = true;
     }
     else
     {
         StepResult.VictimResult.Hit = StepResult.AttackerResult.Entity.AttemptHitEntity(StepResult.VictimResult.Entity);
     }
 }
        /// <summary>
        /// Calculates and returns the entire damage interaction between two BattleEntities.
        /// <para>This returns all the necessary information for both BattleEntities, including the total amount of damage dealt,
        /// the type of Elemental damage to deal, the Status Effects to inflict, and whether the attack successfully hit or not.</para>
        /// </summary>
        /// <param name="interactionParam">An InteractionParamHolder containing the BattleEntities interacting and data about their interaction.</param>
        /// <returns>An InteractionResult containing InteractionHolders for both the victim and the attacker.</returns>
        public static InteractionResult GetDamageInteraction(InteractionParamHolder interactionParam)
        {
            InteractionResult finalInteraction  = new InteractionResult();
            ContactResultInfo contactResultInfo = new ContactResultInfo();

            for (int i = 0; i < DamageCalculationSteps.Count; i++)
            {
                finalInteraction  = DamageCalculationSteps[i].Calculate(interactionParam, finalInteraction, contactResultInfo);
                contactResultInfo = DamageCalculationSteps[i].StepContactResultInfo;
            }

            return(finalInteraction);
        }
            protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
            {
                //Factor in Last Stand for the Victim, if the Victim is in Danger or Peril
                if (StepResult.VictimResult.Entity.IsInDanger == true)
                {
                    //PM rounds down, whereas TTYD rounds up. We're going with the latter
                    //TTYD always ceilings the value (Ex. 3.2 turns to 4)
                    int lastStandCount = StepResult.VictimResult.Entity.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.LastStand);

                    int lastStandDivider = (1 + lastStandCount);
                    StepResult.VictimResult.TotalDamage = (int)Math.Ceiling(StepResult.VictimResult.TotalDamage / (float)lastStandDivider);
                }
            }
Пример #17
0
            public static void NewInteractionUT2()
            {
                BattleMario  mario        = new BattleMario(new MarioStats(1, 50, 50, 0, 0, EquipmentGlobals.BootLevels.Normal, EquipmentGlobals.HammerLevels.Normal));
                SpikedGoomba spikedGoomba = new SpikedGoomba();

                InteractionParamHolder param = new InteractionParamHolder(mario, spikedGoomba, 5, Enumerations.Elements.Normal, false,
                                                                          Enumerations.ContactTypes.TopDirect, null, Enumerations.DamageEffects.None, false, Enumerations.DefensiveMoveOverrides.None);

                InteractionResult oldInteraction = Interactions.GetDamageInteractionOld(param);
                InteractionResult newInteraction = Interactions.GetDamageInteraction(param);

                Debug.Log("Old: ");
                PrintInteractionResult(oldInteraction);
                Debug.Log("New: ");
                PrintInteractionResult(newInteraction);
            }
Пример #18
0
            public static void PaybackInteractionUT3()
            {
                BattleMario mario = new BattleMario(new MarioStats(1, 5, 50, 0, 0, EquipmentGlobals.BootLevels.Super, EquipmentGlobals.HammerLevels.Normal));
                Pokey       pokey = new Pokey();

                Debug.Assert(pokey.EntityProperties.HasPhysAttributes(true, Enumerations.PhysicalAttributes.Spiked));
                Debug.Assert(pokey.EntityProperties.HasPayback());

                InteractionParamHolder paramHolder = new InteractionParamHolder(mario, pokey, 3, Enumerations.Elements.Normal, false,
                                                                                Enumerations.ContactTypes.SideDirect, Enumerations.ContactProperties.None, null, Enumerations.DamageEffects.None, false,
                                                                                Enumerations.DefensiveActionTypes.None);

                InteractionResult interaction = Interactions.GetDamageInteraction(paramHolder);

                PrintInteractionResult(interaction);

                Debug.Assert(interaction.VictimResult.DontDamageEntity == true);
                Debug.Assert(interaction.AttackerResult.IsPaybackDamage == true);
            }
Пример #19
0
            public static void NewInteractionUT5()
            {
                BattleMario mario  = new BattleMario(new MarioStats(1, 50, 50, 0, 0, EquipmentGlobals.BootLevels.Normal, EquipmentGlobals.HammerLevels.Normal));
                Goomba      goomba = new Goomba();

                goomba.EntityProperties.AddPhysAttribute(Enumerations.PhysicalAttributes.Electrified);
                goomba.EntityProperties.AddPayback(new StatusGlobals.PaybackHolder(StatusGlobals.PaybackTypes.Half, Enumerations.Elements.Poison, new StatusChanceHolder(100d, new PoisonStatus(5))));

                InteractionParamHolder param = new InteractionParamHolder(mario, goomba, 10, Enumerations.Elements.Normal, false,
                                                                          Enumerations.ContactTypes.TopDirect, null, Enumerations.DamageEffects.None, false, Enumerations.DefensiveMoveOverrides.None);

                InteractionResult oldInteraction = Interactions.GetDamageInteractionOld(param);
                InteractionResult newInteraction = Interactions.GetDamageInteraction(param);

                Debug.Log("Old: ");
                PrintInteractionResult(oldInteraction);
                Debug.Log("New: ");
                PrintInteractionResult(newInteraction);
            }
Пример #20
0
            public static void PaybackInteractionUT1()
            {
                BattleMario mario  = new BattleMario(new MarioStats(1, 5, 50, 0, 0, EquipmentGlobals.BootLevels.Normal, EquipmentGlobals.HammerLevels.Normal));
                Goomba      goomba = new Goomba();

                mario.EntityProperties.AfflictStatus(new HoldFastStatus(3));

                Debug.Assert(mario.EntityProperties.HasPayback());

                InteractionParamHolder paramHolder = new InteractionParamHolder(goomba, mario, 0, Enumerations.Elements.Normal, true,
                                                                                Enumerations.ContactTypes.Latch, Enumerations.ContactProperties.None, null, Enumerations.DamageEffects.None, false,
                                                                                Enumerations.DefensiveActionTypes.Guard | Enumerations.DefensiveActionTypes.Superguard);

                InteractionResult interaction = Interactions.GetDamageInteraction(paramHolder);

                PrintInteractionResult(interaction);

                Debug.Assert(interaction.AttackerResult.TotalDamage == 1);
                Debug.Assert(interaction.VictimResult.TotalDamage == 0);
            }
Пример #21
0
            public static void NewInteractionUT6()
            {
                BattleMario mario  = new BattleMario(new MarioStats(1, 50, 50, 0, 0, EquipmentGlobals.BootLevels.Normal, EquipmentGlobals.HammerLevels.Normal));
                Goomba      goomba = new Goomba();

                mario.EntityProperties.AddPayback(new StatusGlobals.PaybackHolder(StatusGlobals.PaybackTypes.Full, Enumerations.Elements.Star));
                goomba.EntityProperties.AddPhysAttribute(Enumerations.PhysicalAttributes.Electrified);
                goomba.EntityProperties.AddPayback(new StatusGlobals.PaybackHolder(StatusGlobals.PaybackTypes.Half, Enumerations.Elements.Poison, new StatusChanceHolder(100d, new PoisonStatus(5))));

                Badge dd1 = new DamageDodgeBadge();

                dd1?.Equip(mario);
                Badge dd2 = new DamageDodgeBadge();

                dd2?.Equip(mario);

                //For defensive actions; add flags in their code to make them always succeed
                //We'll need to implement the debug badge that automatically completes action commands as well as
                //make it easier to start input for action commands for debugging
                mario.OnTurnEnd();
                mario.Update();

                InteractionParamHolder param = new InteractionParamHolder(goomba, mario, 10, Enumerations.Elements.Normal, false,
                                                                          Enumerations.ContactTypes.TopDirect, null, Enumerations.DamageEffects.None, false, Enumerations.DefensiveMoveOverrides.None);

                InteractionResult oldInteraction = Interactions.GetDamageInteractionOld(param);
                InteractionResult newInteraction = Interactions.GetDamageInteraction(param);

                Debug.Log("Old: ");
                PrintInteractionResult(oldInteraction);
                Debug.Log("New: ");
                PrintInteractionResult(newInteraction);

                if (BattleManager.Instance.EntityTurn.PreviousAction?.MoveSequence.InSequence == false)
                {
                    BattleManager.Instance.EntityTurn.OnTurnStart();
                }

                dd1?.UnEquip();
                dd2?.UnEquip();
            }
Пример #22
0
            public static void NewInteractionUT10()
            {
                BattleMario mario  = new BattleMario(new MarioStats(1, 5, 50, 0, 0, EquipmentGlobals.BootLevels.Normal, EquipmentGlobals.HammerLevels.Normal));
                Goomba      goomba = new Goomba();

                mario.EntityProperties.AddResistance(Enumerations.Elements.Electric, new ResistanceHolder(ResistanceTypes.Heal, 0));

                goomba.EntityProperties.AddPayback(new StatusGlobals.PaybackHolder(StatusGlobals.PaybackTypes.Half, Enumerations.Elements.Electric));
                goomba.EntityProperties.AfflictStatus(new ElectrifiedStatus(5), true);

                InteractionParamHolder param = new InteractionParamHolder(mario, goomba, 90, Enumerations.Elements.Normal, false,
                                                                          Enumerations.ContactTypes.TopDirect, null, Enumerations.DamageEffects.None, false, Enumerations.DefensiveMoveOverrides.None);

                InteractionResult oldInteraction = Interactions.GetDamageInteractionOld(param);
                InteractionResult newInteraction = Interactions.GetDamageInteraction(param);

                Debug.Log("Old: ");
                PrintInteractionResult(oldInteraction);
                Debug.Log("New: ");
                PrintInteractionResult(newInteraction);
            }
            protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
            {
                //If the attack didn't hit, don't factor in DamageEffects
                if (StepResult.VictimResult.Hit == false)
                {
                    StepResult.VictimResult.DamageEffect = DamageEffects.None;
                }

                //If the current result has no DamageEffects (whether the move didn't have any or a Defensive Action removed them)
                //or if the BattleEntity isn't vulnerable to any DamageEffects, then don't bother doing anything else
                if (StepResult.VictimResult.DamageEffect == DamageEffects.None ||
                    StepResult.VictimResult.Entity.EntityProperties.HasDamageEffectVulnerabilities() == false)
                {
                    return;
                }

                //The DamageEffects stored in the result
                DamageEffects resultEffects = DamageEffects.None;

                //Get all the DamageEffects
                DamageEffects[] damageEffects = UtilityGlobals.GetEnumValues <DamageEffects>();

                //Start at index 1, as 0 is the value of None indicating no DamageEffects
                for (int i = 1; i < damageEffects.Length; i++)
                {
                    DamageEffects curEffect = damageEffects[i];

                    //If the move has the DamageEffect and the entity is affected by it, add it to the result
                    //This approach is easier and more readable than removing effects
                    if (UtilityGlobals.EnumHasFlag(StepResult.VictimResult.DamageEffect, curEffect) == true &&
                        StepResult.VictimResult.Entity.EntityProperties.IsVulnerableToDamageEffect(curEffect) == true)
                    {
                        resultEffects |= curEffect;
                    }
                }

                //Set the result
                StepResult.VictimResult.DamageEffect = resultEffects;
            }
Пример #24
0
            public static void ElementOverrideInteractionUT1()
            {
                BattleMario mario  = new BattleMario(new MarioStats(1, 5, 50, 0, 0, EquipmentGlobals.BootLevels.Normal, EquipmentGlobals.HammerLevels.Normal));
                Goomba      goomba = new Goomba();

                IcePowerBadge icePower = new IcePowerBadge();

                icePower.Equip(mario);
                IcePowerBadge icePower2 = new IcePowerBadge();

                icePower2.Equip(mario);

                goomba.EntityProperties.AddPhysAttribute(Enumerations.PhysicalAttributes.Fiery);
                goomba.EntityProperties.AddWeakness(Enumerations.Elements.Ice, new WeaknessHolder(WeaknessTypes.PlusDamage, 1));

                Debug.Assert(goomba.EntityProperties.HasPhysAttributes(true, Enumerations.PhysicalAttributes.Fiery));
                Debug.Assert(goomba.EntityProperties.HasWeakness(Enumerations.Elements.Ice));

                ElementOverrideHolder overrideHolder = mario.EntityProperties.GetTotalElementOverride(goomba);

                Debug.Assert(overrideHolder.Element == Enumerations.Elements.Ice);
                Debug.Assert(overrideHolder.OverrideCount == 2);

                InteractionParamHolder param = new InteractionParamHolder(mario, goomba, 1, Enumerations.Elements.Ice, true,
                                                                          Enumerations.ContactTypes.TopDirect, null, Enumerations.DamageEffects.None, false, Enumerations.DefensiveMoveOverrides.None);
                InteractionResult interaction = Interactions.GetDamageInteraction(param);

                Debug.Assert(interaction.VictimResult.TotalDamage == 4);

                PrintInteractionResult(interaction);

                icePower.UnEquip();
                icePower2.UnEquip();

                ElementOverrideHolder overrideHolder2 = mario.EntityProperties.GetTotalElementOverride(goomba);

                Debug.Assert(overrideHolder2.Element == Enumerations.Elements.Invalid);
            }
            protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
            {
                Elements     element = StepResult.VictimResult.DamageElement;
                BattleEntity victim  = StepResult.VictimResult.Entity;

                //Retrieve an overridden type of Elemental damage to inflict based on the Victim's PhysicalAttributes
                //(Ex. The Ice Power Badge only deals Ice damage to Fiery entities)
                ElementOverrideHolder newElement = StepResult.AttackerResult.Entity.EntityProperties.GetTotalElementOverride(victim);

                if (newElement.Element != Elements.Invalid)
                {
                    /*NOTE: Idea for stacking weaknesses
                     * (Ex. 1 Ice Power is 1 weakness, Ice Power + Ice Smash = 2 weaknesses)
                     *
                     * Ex. damage = 2
                     * player inflicts ice 2 times: ice power & ice smash
                     *
                     * ice_inflicted_times = 2
                     * if (enemy weak to ice)
                     *  damage += ice_inflicted_times
                     * end
                     *
                     #damage = 4
                     */

                    //Add the number of element overrides to the damage if the element used already exists as an override and the victim has a Weakness
                    //to the Element. This allows Badges such as Ice Power to deal more damage if used in conjunction with attacks
                    //that deal the same type of damage (Ex. Ice Power and Ice Smash deal 2 additional damage total rather than 1).
                    //If any new knowledge is discovered to improve this, this will be changed
                    //Ice Power is the only Badge of its kind across the first two PM games that does anything like this
                    if (element == newElement.Element && victim.EntityProperties.HasWeakness(element) == true)
                    {
                        StepResult.VictimResult.TotalDamage += newElement.OverrideCount;
                    }

                    StepResult.VictimResult.DamageElement = newElement.Element;
                }
            }
 protected abstract void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult);
            protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
            {
                StrengthHolder totalStrength = StepResult.AttackerResult.Entity.EntityProperties.GetTotalStrength(StepResult.VictimResult.Entity);

                StepResult.VictimResult.TotalDamage += totalStrength.Value;
            }
 protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
 {
     StepResult.VictimResult.TotalDamage -= StepResult.VictimResult.Entity.BattleStats.DamageReduction;
 }
 protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
 {
     StepResult.AttackerResult.TotalDamage =
         UtilityGlobals.Clamp(StepResult.AttackerResult.TotalDamage, BattleGlobals.MinDamage, BattleGlobals.MaxDamage);
 }
 protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult)
 {
     StepResult.AttackerResult.StatusesInflicted =
         GetFilteredInflictedStatuses(StepResult.AttackerResult.Entity, StepResult.AttackerResult.StatusesInflicted);
 }