public SpellCasting(IObjectStore configuration, EntityGateway <SpellList> spellLists) { this.SpellListName = configuration.GetString("list"); this.SpellList = spellLists.Find(this.SpellListName); this.SpellType = configuration.GetEnum <SpellType>("spell-type"); this.castingAbilityType = configuration.GetEnum <AbilityScoreTypes>("casting-ability"); var slots = configuration.GetObject("spell-slots"); foreach (var slot in slots.Keys) { var spellCounts = slots.GetList(slot).Select(x => x.ToInteger()).ToArray(); spellSlots.Add(slot.ToInteger(), spellCounts); } }
public FireBolt(IObjectStore configuration) { this.baseAbilityType = configuration.GetEnum <AbilityScoreTypes>("base-ability"); this.AttackType = AttackTypes.Ranged; this.DamageType = "fire"; this.Range = 30; }
private void LoadFromObjectStore(IObjectStore data) { Name = data.GetString("name"); ShortLog.Debug("Loading Class: " + Name); SkillPoints = data.GetInteger("skillpoints"); HitDice = DiceStrings.ParseSides(data.GetString("hitdice")); BaseAttackBonusRate = data.GetFloat("baseattackbonus"); FortitudeSaveRate = data.GetFloat("fortitude"); ReflexSaveRate = data.GetFloat("reflex"); WillSaveRate = data.GetFloat("will"); ClassDevelopmentAge = data.GetEnum <ClassDevelopmentAge>("developedage"); CustomBuildStep = data.GetStringOptional("custom-build-step"); //Load Levels var levels = data.GetObjectListOptional("levels"); if (levels != null) { foreach (var l in levels) { var level = new Level(l); Levels.Add(level); } } var dice = data.GetStringOptional("startingwealth"); if (dice != null) { StartingWealthDice = DiceStrings.ParseDice(dice); } this.HitDicePerLevel = new DiceClassLevelModifier(new Cup(new Die(HitDice)), StatNames.HitDice, this.Name, 1); }
public CharacterDesigner(IObjectStore data) { Name = data.GetString("name"); if (data.HasKey("type")) { DesignerType = data.GetEnum <Type>("type"); } ShortLog.DebugFormat("Loading Character Creator: {0}", Name); designSteps = new List <ICharacterDesignStep>(); foreach (var step in data.GetObjectList("steps")) { if (step.HasKey("step")) { var typeName = step.GetString("step"); ShortLog.DebugFormat("Adding Build Step: {0}", typeName); var item = typeName.Instantiate <ICharacterDesignStep>(step); designSteps.Add(item); } else if (step.HasKey("designer")) { var designer = step.GetString("designer"); ShortLog.DebugFormat("Adding Designer: {0}", designer); var item = new DesignerExecuterStep(designer); designSteps.Add(item); } } }
public Skill(IObjectStore data) { Name = data.GetString("name"); Ability = data.GetEnum <AbilityScoreTypes>("ability"); TrainingRequired = data.GetBool("trained"); Description = data.GetStringOptional("description"); UseArmorCheckPenalty = data.GetBoolOptional("armor-check-penalty"); }
public Weapon(IObjectStore data) { ShortLog.DebugFormat("Loading Weapon: {0}", data.GetString("name")); this.Name = data.GetString("name"); this.Weight = data.GetFloat("weight"); this.Damage = data.GetString("damage"); this.DamageType = data.GetEnum <DamageTypes>("damage_type"); this.CriticalThreat = data.GetIntegerOptional("critical_threat"); this.CriticalModifier = data.GetIntegerOptional("critical_modifier"); this.Range = data.GetIntegerOptional("range"); this.Type = data.GetEnum <WeaponType>("type"); this.Group = data.GetEnum <WeaponGroup>("group"); this.Level = data.GetEnum <WeaponTrainingLevel>("training_level"); this.Value = data.GetStringOptional("cost").ToCoinValue(); this.CriticalThreat = this.CriticalThreat == 0 ? 20 : this.CriticalThreat; this.CriticalModifier = this.CriticalModifier == 0 ? 2 : this.CriticalModifier; }
public NameInformation(IObjectStore data) : this() { this.Gender = data.GetString("gender"); this.Type = data.GetEnum <NameTypes>("category"); this.Race = data.GetString("race"); var names = data.GetList("names"); this.Names.Add(names.Where(x => string.IsNullOrEmpty(x) == false)); }
public Armor(IObjectStore data) { ShortLog.DebugFormat("Loading Armor: {0}", data.GetString("name")); this.Name = data.GetString("name"); this.ArmorClass = data.GetInteger("armor_class"); this.Weight = data.GetFloat("weight"); this.MaximumDexterityBonus = data.GetInteger("maximum_dexterity_bonus"); this.ArmorCheckPenalty = data.GetInteger("armor_check_penalty"); this.ArcaneSpellFailureChance = data.GetInteger("arcane_spell_failure_chance"); this.ArmorType = data.GetEnum <ArmorType>("armor_type"); this.Value = data.GetString("cost").ToCoinValue(); }
public GraveTouch(IObjectStore configuration) { baseAbilityType = configuration.GetEnum <AbilityScoreTypes>("base-ability"); }
public AcidDart(IObjectStore configuration) : this() { baseAbilityType = configuration.GetEnum <AbilityScoreTypes>("base-ability"); }
public DomainCasting(IObjectStore configuration) { castingAbilityType = configuration.GetEnum <AbilityScoreTypes>("casting-ability"); }
public static T Deserialize <T>(this IObjectStore data, T result) { var typeInfo = typeof(T); var properties = typeInfo.GetProperties(); foreach (var prop in properties) { var attribute = prop.GetCustomAttribute <ObjectStoreAttribute>(); if (attribute == null) { continue; } var propType = prop.PropertyType.Name.ToLower(); object propertyValue = null; object defaultValue = attribute.DefaultValue; bool useDefault = defaultValue != null; string keyName = attribute.PropertyName; switch (propType) { case "single": if (attribute.Optional) { if (useDefault) { propertyValue = data.GetFloatOptional(keyName, (float)defaultValue); } else { propertyValue = data.GetFloatOptional(keyName); } } else { propertyValue = data.GetFloat(keyName); } break; case "int32": if (attribute.Optional) { if (useDefault) { propertyValue = data.GetIntegerOptional(keyName, (int)defaultValue); } else { propertyValue = data.GetIntegerOptional(keyName); } } else { propertyValue = data.GetInteger(keyName); } break; case "string": if (attribute.Optional) { if (useDefault) { propertyValue = data.GetStringOptional(keyName, defaultValue.ToString()); } else { propertyValue = data.GetStringOptional(keyName); } } else { propertyValue = data.GetString(keyName); } break; case "string[]": if (attribute.Optional) { propertyValue = data.GetListOptional(keyName); } else { propertyValue = data.GetList(keyName); } break; case "boolean": if (attribute.Optional) { if (useDefault) { propertyValue = data.GetBoolOptional(keyName, (bool)defaultValue); } else { propertyValue = data.GetBoolOptional(keyName); } } else { propertyValue = data.GetBool(keyName); } break; case "movementtype": //TODO: Cannot just keep adding types here, but let's see how common it is first propertyValue = data.GetEnum <MovementType>(keyName); break; case "cup": propertyValue = DiceStrings.ParseDice(data.GetString(keyName)); break; case "spelltype": propertyValue = data.GetEnum <Spells.SpellType>(keyName); break; case "object[]": var objectList = data.GetObjectList(keyName); var newList = new List <object>(); foreach (var o in objectList) { var instance = o.GetString(SERIALIZED_TYPE_KEY).Instantiate <object>(o); newList.Add(instance); } propertyValue = newList.ToArray(); break; default: ShortLog.DebugFormat("Attempting to deserialize: {0}", propType); if (prop.PropertyType.IsEnum) { propertyValue = System.Enum.Parse(prop.PropertyType, data.GetString(keyName), true); } else { propertyValue = DeserializeObject(data, keyName, attribute.Optional, prop.PropertyType); } break; } prop.SetValue(result, propertyValue); } return(result); }