Esempio n. 1
0
        public override bool Run()
        {
            try
            {
                Sim selectedObject = GetSelectedObject() as Sim;
                if (selectedObject != null)
                {
                    base.Run();
                    if (mResultCode != SocialInteraction.SocialResultCode.Succeeded)
                    {
                        return(false);
                    }

                    SocialRule targetEffect = mTargetEffect;
                    if (targetEffect != null)
                    {
                        if (targetEffect.RHS.STEffectCommodity != CommodityTypes.Friendly)
                        {
                            return(false);
                        }

                        Definition            interactionDefinition = InteractionDefinition as Definition;
                        InteractionPriority   priority    = GetPriority();
                        InteractionDefinition definition2 = interactionDefinition.GetPushDefintion(Target, selectedObject, priority);
                        if (definition2 == null)
                        {
                            return(false);
                        }

                        // Never could figure out why adding routing pushes here just does nothing...

                        Kill            instance = Kill.Singleton.CreateInstance(selectedObject, Target, priority, false, true) as Kill;
                        Kill.Definition def      = instance.InteractionDefinition as Kill.Definition;
                        def.mType   = interactionDefinition.mType;
                        def.mDirect = false;
                        if (!Target.InteractionQueue.PushAsContinuation(instance, true))
                        {
                            return(false);
                        }

                        Assassination skill = Assassination.EnsureSkill(Target);

                        skill.AddJob(Actor, selectedObject);

                        return(true);
                    }
                }
                return(false);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Esempio n. 2
0
        public override bool Run()
        {
            try
            {
                Sim selectedObject = GetSelectedObject() as Sim;
                if (selectedObject != null)
                {
                    Run();
                    if (mResultCode != SocialInteraction.SocialResultCode.Succeeded)
                    {
                        return(false);
                    }

                    SocialRule targetEffect = mTargetEffect;
                    if (targetEffect != null)
                    {
                        if (targetEffect.RHS.STEffectCommodity != CommodityTypes.Friendly)
                        {
                            return(false);
                        }

                        Definition            interactionDefinition = InteractionDefinition as Definition;
                        InteractionPriority   priority    = GetPriority();
                        InteractionDefinition definition2 = interactionDefinition.GetPushDefintion(Target, selectedObject, priority);
                        if (definition2 == null)
                        {
                            return(false);
                        }
                        InteractionInstance instance = definition2.CreateInstance(selectedObject, Target, priority, false, true);
                        if (!Target.InteractionQueue.PushAsContinuation(instance, true))
                        {
                            return(false);
                        }

                        Assassination skill = Assassination.EnsureSkill(Target);

                        skill.AddJob(Actor, selectedObject);

                        return(true);
                    }
                }
                return(false);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
        public void GetTax_ShouldReturnValue_WhenAboveLimit(double value, double expectedTax)
        {
            // Arrange
            var config = new ConfigEntity()
            {
                MinTaxAmount = 100, SocialPercentage = 0.1, MaxSocialAmount = 2000
            };
            var sut = new SocialRule(config);

            // Act
            var tax = sut.GetTax(value);

            // Assert
            Assert.AreEqual(expectedTax, tax);
        }
        public void GetTax_ShouldReturn0_WhenUnderLimit(double value)
        {
            // Arrange
            var config = new ConfigEntity()
            {
                MinTaxAmount = 100
            };
            var sut = new SocialRule(config);

            // Act
            var tax = sut.GetTax(value);

            // Assert
            Assert.AreEqual(0, tax);
        }