Ejemplo n.º 1
0
        private int GetValueWithImmunity(GovMoralEffects.MoralEffect effect, int moral)
        {
            switch (effect.Condition)
            {
            case MoralCondition.All:
                moral = 0;
                break;

            case MoralCondition.Negative:
                if (moral < 0)
                {
                    moral = (double)effect.Value == 0.0 ? 0 : moral + (int)((double)moral * (double)effect.Value);
                    break;
                }
                break;

            case MoralCondition.Positive:
                if (moral > 0)
                {
                    moral = (double)effect.Value == 0.0 ? 0 : moral + (int)((double)moral * (double)effect.Value);
                    break;
                }
                break;

            default:
                moral += (int)((double)moral * (double)effect.Value);
                break;
            }
            return(moral);
        }
Ejemplo n.º 2
0
        public void LoadEffects(EffectAvailability availability, XmlElement moralEffects)
        {
            if (moralEffects == null)
            {
                return;
            }
            XmlElement moralEffect1 = moralEffects["ALL"];

            if (moralEffect1 != null)
            {
                if (moralEffect1.HasAttributes)
                {
                    GovMoralEffects.MoralEffect moralEffect2 = new GovMoralEffects.MoralEffect();
                    string attribute1 = moralEffect1.GetAttribute("condition");
                    string attribute2 = moralEffect1.GetAttribute("value");
                    moralEffect2.Condition = !(attribute1 == "all") ? (!(attribute1 == "negative") ? (!(attribute1 == "positive") ? MoralCondition.None : MoralCondition.Positive) : MoralCondition.Negative) : MoralCondition.All;
                    moralEffect2.Value     = string.IsNullOrEmpty(attribute2) ? 0.0f : float.Parse(attribute2);
                    this.AllMoralEffects.Add(availability, moralEffect2);
                }
                else
                {
                    string innerText = moralEffect1.InnerText;
                    GovMoralEffects.MoralEffect moralEffect2 = new GovMoralEffects.MoralEffect()
                    {
                        Condition = !(innerText == "immune") ? (!(innerText == "immune_neg") ? (!(innerText == "immune_pos") ? MoralCondition.None : MoralCondition.Positive) : MoralCondition.Negative) : MoralCondition.All
                    };
                    moralEffect2.Value = moralEffect2.Condition != MoralCondition.None ? 0.0f : float.Parse(innerText);
                    this.AllMoralEffects.Add(availability, moralEffect2);
                }
            }
            foreach (MoralEvent key in Enum.GetValues(typeof(MoralEvent)))
            {
                XmlElement moralEffect2 = moralEffects[key.ToString()];
                if (moralEffect2 != null)
                {
                    if (moralEffect2.HasAttributes)
                    {
                        GovMoralEffects.MoralEffect moralEffect3 = new GovMoralEffects.MoralEffect();
                        string attribute1 = moralEffect2.GetAttribute("immune");
                        string attribute2 = moralEffect2.GetAttribute("value");
                        moralEffect3.Condition = !(attribute1 == "all") ? (!(attribute1 == "negative") ? (!(attribute1 == "positive") ? MoralCondition.None : MoralCondition.Positive) : MoralCondition.Negative) : MoralCondition.All;
                        moralEffect3.Value     = string.IsNullOrEmpty(attribute2) ? 0.0f : float.Parse(attribute2);
                        this.MoralEffects.Add(key, new Dictionary <EffectAvailability, GovMoralEffects.MoralEffect>()
                        {
                            {
                                availability,
                                moralEffect3
                            }
                        });
                    }
                    else
                    {
                        string innerText = moralEffect2.InnerText;
                        GovMoralEffects.MoralEffect moralEffect3 = new GovMoralEffects.MoralEffect()
                        {
                            Condition = !(innerText == "immune") ? (!(innerText == "immune_neg") ? (!(innerText == "immune_pos") ? MoralCondition.None : MoralCondition.Positive) : MoralCondition.Negative) : MoralCondition.All
                        };
                        moralEffect3.Value = moralEffect3.Condition != MoralCondition.None ? 0.0f : float.Parse(innerText);
                        this.MoralEffects.Add(key, new Dictionary <EffectAvailability, GovMoralEffects.MoralEffect>()
                        {
                            {
                                availability,
                                moralEffect3
                            }
                        });
                    }
                }
            }
        }