Esempio n. 1
0
 /// <summary>
 /// Changes a value by the given amount, or creates that value, if it doesn't exist already.
 /// If prefixed with 'sv', the value change happens in the soft values.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="change"></param>
 public void ChangeValue(string value, double change)
 {
     if (value.StartsWith("sv"))
     {
         if (SoftValues.ContainsKey(value))
         {
             SoftValues[value] += change;
         }
         else
         {
             SoftValues[value] = change;
         }
     }
     else if (Values.ContainsKey(value))
     {
         Values[value] += change;
     }
     else
     {
         Values[value] = change;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Returns a value after being modified. This may be the start of some kind of mini bytecode.
        /// The given value string may sometime become the basis of this bytecode.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public double GetValue(string value)
        {
            if (value.StartsWith(E.LEVEL))
            {
                if (Statics.skills.Contains(value.Substring(E.LEVEL.Length)))
                {
                    return((int)Math.Log(Xp[value.Substring(E.LEVEL.Length)] / 100, 1.2));
                }
            }
            else if (value.StartsWith(E.COUNT))
            {
                if (Entities.ContainsKey(value.Substring(E.COUNT.Length)))
                {
                    return(Entities[value.Substring(E.COUNT.Length)].Amount);
                }
            }
            else if (value.StartsWith("stat"))
            {
                if (Stats.ContainsKey(value.Substring(4)))
                {
                    return(Stats[value.Substring(4)]);
                }
            }
            else if (value.Equals("mana"))
            {
                return(Mana);
            }
            else if (value.Equals("hp"))
            {
                return(Hp);
            }
            else if (value.StartsWith("!I"))
            {
                return(int.Parse(value.Substring(2)));
            }
            else if (value.StartsWith("!F"))
            {
                return(float.Parse(value.Substring(2)));
            }
            else if (value.StartsWith("!B"))
            {
                return(bool.Parse(value.Substring(2)) ? 1 : 0);
            }
            else if (value == E.STYLE_FIGHT)
            {
                return(FightingStyle == E.STYLE_FIGHT ? 1 : 0);
            }
            else if (value == E.STYLE_SOOTHE)
            {
                return(FightingStyle == E.STYLE_SOOTHE ? 1 : 0);
            }
            else if (value.StartsWith("sv"))
            {
                if (SoftValues.ContainsKey(value))
                {
                    return(Modifier.Modify(Modifiers.Values, value, SoftValues[value]));
                }
            }
            else if (Values.ContainsKey(value))
            {
                return(Modifier.Modify(Modifiers.Values, value, Values[value]));
            }
            else
            {
                return(Modifier.Modify(Modifiers.Values, value, 0));
            }

            return(0);
        }