/// <summary> /// Creates a new skill. /// </summary> /// <param name="player">The player.</param> /// <param name="dbSpell">The database model associated with the skill.</param> public Skill(Models.Entities.Player player, Database.Models.DbSpell dbSpell) : base() { Player = player; _dbSpell = dbSpell; _dbSpell.Type = "Skill"; _dbSpell.PlayerId = player.DbPlayer.Id; Skill = this; }
/// <summary> /// Creates a new proficiency. /// </summary> /// <param name="player">The player.</param> /// <param name="dbSpell">The database model tied with it.</param> public Proficiency(Models.Entities.Player player, Database.Models.DbSpell dbSpell) : base() { Player = player; _dbSpell = dbSpell; _dbSpell.Type = "Proficiency"; _dbSpell.PlayerId = player.DbPlayer.Id; Proficiency = this; }
/// <summary> /// Gets or creates a skill if non-existing. /// </summary> /// <param name="id">The id.</param> /// <returns>The skill.</returns> public Skill GetOrCreateSkill(ushort id) { Skill skill; if (!_skills.TryGetValue(id, out skill)) { var dbSpell = new Database.Models.DbSpell { SpellId = id }; skill = new Skill(_player, dbSpell); if (dbSpell.Create()) { _skills.TryAdd(id, skill); } } return(skill); }
/// <summary> /// Gets or creates a proficiency if non-existing. /// </summary> /// <param name="id">The id.</param> /// <returns>The proficiency.</returns> public Proficiency GetOrCreateProficiency(ushort id) { Proficiency proficiency; if (!_proficiencies.TryGetValue(id, out proficiency)) { var dbSpell = new Database.Models.DbSpell { SpellId = id }; proficiency = new Proficiency(_player, dbSpell); if (dbSpell.Create()) { _proficiencies.TryAdd(id, proficiency); } } return(proficiency); }
/// <summary> /// Attempts to add a proficiency. /// </summary> /// <param name="proficiency">The proficiency.</param> /// <returns>True if the proficiency was added.</returns> public bool TryAddProficiency(Database.Models.DbSpell proficiency) { return(_proficiencies.TryAdd(proficiency.SpellId, new Models.Spells.Proficiency(_player, proficiency))); }
/// <summary> /// Attempts to add a skill. /// </summary> /// <param name="skill">The database spell.</param> /// <returns>True if the skill was added.</returns> public bool TryAddSkill(Database.Models.DbSpell skill) { return(_skills.TryAdd(skill.SpellId, new Models.Spells.Skill(_player, skill))); }