Пример #1
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();
            }
Пример #2
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();
            }
Пример #3
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);
            }
        protected override void OnStart()
        {
            base.OnStart();

            //Damage everyone
            List <BattleEntity> entities = new List <BattleEntity>();

            BattleManager.Instance.GetAllBattleEntities(entities, AffectedHeightStates);
            entities.Remove(Bomb);

            for (int i = 0; i < entities.Count; i++)
            {
                //If the entity is not in the explosion area, remove it from the list
                if (ExplosionArea.Contains(entities[i].Position) == false)
                {
                    entities.RemoveAt(i);
                    i--;
                }
                else
                {
                    entities[i] = entities[i].GetTrueTarget();
                }
            }

            //Attempt to damage them
            Interactions.AttemptDamageEntities(Bomb, entities, DamageInfo, null);

            ElapsedTime = 0d;
        }
Пример #5
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);
            }
        /// <summary>
        /// Determines the result of contact, based on the type of contact made, when it's made with this entity.
        /// <para>Contacts that aren't a Success are prioritized over any Payback.
        /// If a ContactResult of Success is found, then the Payback for this entity is added if it exists
        /// and the ContactResult becomes a PartialSuccess.</para>
        /// </summary>
        /// <param name="attacker">The entity attacking this one</param>
        /// <param name="contactType">The type of contact made with this entity</param>
        /// <returns>A ContactResultInfo containing the result of the interaction</returns>
        public ContactResultInfo GetContactResult(BattleEntity attacker, ContactTypes contactType)
        {
            ContactResultInfo contactResultInfo = Interactions.GetContactResult(attacker, contactType, GetAllPhysAttributes(), attacker.EntityProperties.GetContactExceptions(contactType));

            //On a Success, check if this Entity has any Payback and add it if so
            if ((contactResultInfo.ContactResult == ContactResult.Success || contactResultInfo.ContactResult == ContactResult.PartialSuccess) && HasPayback() == true)
            {
                PaybackHolder paybackholder;

                //Factor in the contact's Payback on a PartialSuccess
                if (contactResultInfo.ContactResult == ContactResult.PartialSuccess)
                {
                    paybackholder = GetPayback(contactResultInfo.Paybackholder);
                }
                //Get only the BattleEntity's Payback on a Success
                else
                {
                    paybackholder = GetPayback();
                }

                //Since there's Payback, the result is now a PartialSuccess
                contactResultInfo.ContactResult = ContactResult.PartialSuccess;
                contactResultInfo.Paybackholder = paybackholder;
            }

            return(contactResultInfo);
        }
Пример #7
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);
            }
Пример #8
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);
            }
Пример #9
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);
            }
Пример #10
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);
            }
Пример #11
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();
            }
Пример #12
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);
            }
Пример #13
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);
            }
Пример #14
0
        /// <summary>
        /// Attempt to deal damage to a set of entities with this BattleAction.
        /// <para>Based on the ContactType of this BattleAction, this can fail, resulting in an interruption.
        /// In the event of an interruption, no further entities are tested, the ActionCommand is ended, and
        /// we go into the Interruption branch</para>
        /// </summary>
        /// <param name="damage">The damage the BattleAction deals to the entity if the attempt was successful</param>
        /// <param name="entities">The BattleEntities to attempt to inflict damage on</param>
        /// <param name="damageInfo">The damage information to use.</param>
        /// <param name="isTotalDamage">Whether the damage passed in is the total damage or not.
        /// If false, the total damage will be calculated</param>
        /// <returns>An int array containing the damage dealt to each BattleEntity targeted, in order</returns>
        protected int[] AttemptDamage(int damage, BattleEntity[] entities, DamageData damageInfo, bool isTotalDamage)
        {
            if (entities == null || entities.Length == 0)
            {
                Debug.LogWarning($"{nameof(entities)} is null or empty in {nameof(AttemptDamage)} for Action {Name}!");
                return(new int[0]);
            }

            //Ensure the MoveAction associated with this sequence supports damage
            if (Action.DealsDamage == false)
            {
                Debug.LogError($"Attempting to deal damage when {Action.Name} does not support it, as {nameof(Action.DamageProperties)} is null");
                return(new int[0]);
            }

            int totalDamage = isTotalDamage == true ? damage : GetTotalDamage(damage);

            //Check for the All or Nothing Badge if the move is affected by it
            //We check for it here since the CommandResult is fully determined by this point
            if (damageInfo.AllOrNothingAffected == true)
            {
                //If it's equipped, add the number to the damage if the Action Command succeeded, otherwise set the damage to the minimum value
                int allOrNothingCount = User.GetEquippedBadgeCount(BadgeGlobals.BadgeTypes.AllOrNothing);
                if (allOrNothingCount > 0)
                {
                    if (CommandResult == ActionCommand.CommandResults.Success)
                    {
                        totalDamage += allOrNothingCount;
                    }
                    else if (CommandResult == ActionCommand.CommandResults.Failure)
                    {
                        totalDamage = int.MinValue;
                    }
                }
            }

            //The damage dealt to each BattleEntity
            int[] damageValues = new int[entities.Length];

            //Go through all the entities and attempt damage
            for (int i = 0; i < entities.Length; i++)
            {
                BattleEntity victim = entities[i];

                InteractionResult finalResult = Interactions.GetDamageInteraction(new InteractionParamHolder(User, victim, totalDamage,
                                                                                                             damageInfo.DamagingElement, damageInfo.Piercing, damageInfo.ContactType, damageInfo.Statuses, damageInfo.DamageEffect,
                                                                                                             damageInfo.CantMiss, damageInfo.DefensiveOverride));

                //Set the total damage dealt to the victim
                damageValues[i] = finalResult.VictimResult.TotalDamage;

                //Make the victim take damage upon a PartialSuccess or a Success
                if (finalResult.VictimResult.HasValue == true)
                {
                    //Check if the attacker hit
                    if (finalResult.VictimResult.Hit == true)
                    {
                        finalResult.VictimResult.Entity.TakeDamage(finalResult.VictimResult);
                    }
                    //Handle a miss otherwise
                    else
                    {
                        OnMiss();
                    }
                }

                //Make the attacker take damage upon a PartialSuccess or a Failure
                //Break out of the loop when the attacker takes damage
                if (finalResult.AttackerResult.HasValue == true)
                {
                    finalResult.AttackerResult.Entity.TakeDamage(finalResult.AttackerResult);

                    break;
                }
            }

            return(damageValues);
        }