Beispiel #1
0
        public void GetFeatRemainingUsesReturnsValidValue()
        {
            Location   startLocation = NwModule.Instance.StartingLocation;
            NwCreature?creature      = NwCreature.Create(StandardResRef.Creature.tanarukk, startLocation);

            Assert.That(creature, Is.Not.Null, "Creature was null after creation.");
            Assert.That(creature !.IsValid, Is.True, "Creature was invalid after creation.");

            createdTestObjects.Add(creature);

            NwFeat?feat = NwFeat.FromFeatType(Feat.BarbarianRage);

            Assert.That(creature.GetFeatRemainingUses(feat !), Is.EqualTo(1));
        }
Beispiel #2
0
            private static int OnApplyDisarm(void *pEffectHandler, void *pObject, void *pEffect, int bLoadingGame)
            {
                CNWSObject  gameObject = CNWSObject.FromPointer(pObject);
                CGameEffect gameEffect = CGameEffect.FromPointer(pEffect);

                OnDisarmWeapon eventData = new OnDisarmWeapon
                {
                    DisarmedObject = gameObject.ToNwObject <NwGameObject>() !,
                    DisarmedBy     = gameEffect.m_oidCreator.ToNwObject <NwGameObject>() !,
                    Feat           = gameEffect.GetInteger(0) == 1 ? NwFeat.FromFeatType(API.Feat.ImprovedDisarm) ! : NwFeat.FromFeatType(API.Feat.Disarm) !,
                };

                eventData.Result = new Lazy <bool>(() => !eventData.PreventDisarm && Hook.CallOriginal(pEffectHandler, pObject, pEffect, bLoadingGame).ToBool());
                ProcessEvent(eventData);

                return(eventData.Result.Value.ToInt());
            }
        }
Beispiel #3
0
        public void SetFeatRemainingUsesCorrectlyUpdatesState(byte uses)
        {
            Location   startLocation = NwModule.Instance.StartingLocation;
            NwCreature?creature      = NwCreature.Create(StandardResRef.Creature.tanarukk, startLocation);

            Assert.That(creature, Is.Not.Null, "Creature was null after creation.");
            Assert.That(creature !.IsValid, Is.True, "Creature was invalid after creation.");

            createdTestObjects.Add(creature);
            NwFeat?feat = NwFeat.FromFeatType(Feat.BarbarianRage);

            Assert.That(feat, Is.Not.Null, "Could not get feat.");

            creature.SetFeatRemainingUses(feat !, uses);

            Assert.That(creature.GetFeatRemainingUses(feat !), Is.EqualTo(Math.Min(uses, creature.GetFeatTotalUses(feat !))), "Remaining feat uses was not updated after being set.");
            Assert.That(creature.HasFeatPrepared(feat !), Is.EqualTo(uses > 0), "Creature incorrectly assumes the feat is/is not available.");
        }