Example #1
0
        public void FromJSObject(JSObject obj)
        {
            id                    = ++CreatureIdCounter;
            name                  = JSObjectHelper.GetString(obj, "name", "<Default Name>");
            team                  = JSObjectHelper.GetString(obj, "team", "good");
            maxHitPoints          = JSObjectHelper.GetInt(obj, "maxHitPoints", 1);
            baseStrengthScore     = JSObjectHelper.GetInt(obj, "baseStrengthScore", 1);
            baseDexterityScore    = JSObjectHelper.GetInt(obj, "baseDexterityScore", 1);
            baseConstitutionScore = JSObjectHelper.GetInt(obj, "baseConstitutionScore", 1);
            baseIntelligenceScore = JSObjectHelper.GetInt(obj, "baseIntelligenceScore", 1);
            baseWisdomScore       = JSObjectHelper.GetInt(obj, "baseWisdomScore", 1);
            baseCharismaScore     = JSObjectHelper.GetInt(obj, "baseCharismaScore", 1);
            baseArmorClass        = JSObjectHelper.GetInt(obj, "baseArmorClass", 1);

            string[] resistences = JSObjectHelper.GetString(obj, "resistences", "").Split(',');

            if (resistences.Length >= 1 && !resistences[0].Equals(""))
            {
                for (int i = 0; i < resistences.Length; i++)
                {
                    DamageTypes damageType;
                    if (Enum.TryParse <DamageTypes>(resistences[i], out damageType))
                    {
                        this.resistences.Add(damageType);
                    }
                }
            }

            string[] immunities = JSObjectHelper.GetString(obj, "immunities", "").Split(',');

            if (immunities.Length >= 1 && !immunities[0].Equals(""))
            {
                for (int i = 0; i < immunities.Length; i++)
                {
                    DamageTypes damageType;
                    if (Enum.TryParse <DamageTypes>(immunities[i], out damageType))
                    {
                        this.immunities.Add(damageType);
                    }
                }
            }

            string[] weaknesses = JSObjectHelper.GetString(obj, "weaknesses", "").Split(',');

            if (weaknesses.Length >= 1 && !weaknesses[0].Equals(""))
            {
                for (int i = 0; i < weaknesses.Length; i++)
                {
                    DamageTypes damageType;
                    if (Enum.TryParse <DamageTypes>(weaknesses[i], out damageType))
                    {
                        this.weaknesses.Add(damageType);
                    }
                }
            }
        }
Example #2
0
 public void FromJSObject(JSObject obj)
 {
     name = JSObjectHelper.GetString(obj, "name", "<Default Name>");
     strengthAbilityBonus     = JSObjectHelper.GetInt(obj, "strengthAbilityBonus", 0);
     constitutionAbilityBonus = JSObjectHelper.GetInt(obj, "constitutionAbilityBonus", 0);
     dexterityAbilityBonus    = JSObjectHelper.GetInt(obj, "dexterityAbilityBonus", 0);
     wisdomAbilityBonus       = JSObjectHelper.GetInt(obj, "wisdomAbilityBonus", 0);
     intelligenceAbilityBonus = JSObjectHelper.GetInt(obj, "intelligenceAbilityBonus", 0);
     charismaAbilityBonus     = JSObjectHelper.GetInt(obj, "charismaAbilityBonus", 0);
 }
Example #3
0
 public void FromJSObject(JSObject obj)
 {
     name                = JSObjectHelper.GetString(obj, "name", "<Default Name>");
     level               = JSObjectHelper.GetInt(obj, "level", 0);
     duration            = JSObjectHelper.GetInt(obj, "duration", 1);
     combatSpell         = JSObjectHelper.GetBool(obj, "combatSpell", false);
     good                = JSObjectHelper.GetBool(obj, "good", false);
     castHigherLevel     = JSObjectHelper.GetBool(obj, "castHigherLevel", false);
     maxTargets          = JSObjectHelper.GetInt(obj, "maxTargets", 1);
     minTargets          = JSObjectHelper.GetInt(obj, "minTargets", 1);
     damage              = JSObjectHelper.GetString(obj, "damage", "0");
     extraDamagePerLevel = JSObjectHelper.GetString(obj, "extraDamagePerLevel", "0");
 }
Example #4
0
        private void FromJSObject(JSObject obj, Dictionary <string, Race> races, Dictionary <string, Class> classes, Dictionary <string, Spell> spells)
        {
            string race = JSObjectHelper.GetString(obj, "race", "Human");

            Race r;

            if (races.TryGetValue(race, out r))
            {
                this.race = r;
            }

            string c = JSObjectHelper.GetString(obj, "classes", "");

            string[] split = c.Split(',');

            for (int i = 0; i < split.Length; i++)
            {
                string[] classSplit = split[i].Split('|');
                if (classSplit.Length == 2)
                {
                    Class cl;
                    if (classes.TryGetValue(classSplit[0], out cl))
                    {
                        try {
                            this.classes.Add(new ClassLevel(Int32.Parse(classSplit[1]), cl));
                        } catch (FormatException e) {
                            Console.Error.WriteLine($"Error parsing class integer for '{name}' class '{classSplit[0]}'. {e.Message}");
                        }
                    }
                }
            }

            string s = JSObjectHelper.GetString(obj, "spells", "");

            split = s.Split(',');

            for (int i = 0; i < split.Length; i++)
            {
                Spell spell;

                if (spells.TryGetValue(split[i], out spell))
                {
                    this.spells.Add(spell);
                }
            }
        }