/// <summary>
 /// Copies the column values into the given Dictionary using the database column name
 /// with a prefixed @ as the key. The keys must already exist in the Dictionary;
 /// this method will not create them if they are missing.
 /// </summary>
 /// <param name="source">The object to copy the values from.</param>
 /// <param name="dic">The Dictionary to copy the values into.</param>
 public static void CopyValues(ICharacterTemplateTable source, IDictionary <String, Object> dic)
 {
     dic["ai_id"]        = source.AIID;
     dic["alliance_id"]  = source.AllianceID;
     dic["body_id"]      = source.BodyID;
     dic["chat_dialog"]  = source.ChatDialog;
     dic["exp"]          = source.Exp;
     dic["give_cash"]    = source.GiveCash;
     dic["give_exp"]     = source.GiveExp;
     dic["id"]           = source.ID;
     dic["level"]        = source.Level;
     dic["move_speed"]   = source.MoveSpeed;
     dic["name"]         = source.Name;
     dic["respawn"]      = source.Respawn;
     dic["shop_id"]      = source.ShopID;
     dic["statpoints"]   = source.StatPoints;
     dic["stat_agi"]     = (Int16)source.GetStat(StatType.Agi);
     dic["stat_defence"] = (Int16)source.GetStat(StatType.Defence);
     dic["stat_int"]     = (Int16)source.GetStat(StatType.Int);
     dic["stat_maxhit"]  = (Int16)source.GetStat(StatType.MaxHit);
     dic["stat_maxhp"]   = (Int16)source.GetStat(StatType.MaxHP);
     dic["stat_maxmp"]   = (Int16)source.GetStat(StatType.MaxMP);
     dic["stat_minhit"]  = (Int16)source.GetStat(StatType.MinHit);
     dic["stat_str"]     = (Int16)source.GetStat(StatType.Str);
 }
/// <summary>
/// Checks if this <see cref="ICharacterTemplateTable"/> contains the same values as another <see cref="ICharacterTemplateTable"/>.
/// </summary>
/// <param name="source">The source <see cref="ICharacterTemplateTable"/>.</param>
/// <param name="otherItem">The <see cref="ICharacterTemplateTable"/> to compare the values to.</param>
/// <returns>
/// True if this <see cref="ICharacterTemplateTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false.
/// </returns>
        public static System.Boolean HasSameValues(this ICharacterTemplateTable source, ICharacterTemplateTable otherItem)
        {
            return(Equals(source.AIID, otherItem.AIID) &&
                   Equals(source.AllianceID, otherItem.AllianceID) &&
                   Equals(source.BodyID, otherItem.BodyID) &&
                   Equals(source.ChatDialog, otherItem.ChatDialog) &&
                   Equals(source.Exp, otherItem.Exp) &&
                   Equals(source.GiveCash, otherItem.GiveCash) &&
                   Equals(source.GiveExp, otherItem.GiveExp) &&
                   Equals(source.ID, otherItem.ID) &&
                   Equals(source.Level, otherItem.Level) &&
                   Equals(source.MoveSpeed, otherItem.MoveSpeed) &&
                   Equals(source.Name, otherItem.Name) &&
                   Equals(source.Respawn, otherItem.Respawn) &&
                   Equals(source.ShopID, otherItem.ShopID) &&
                   Equals(source.StatPoints, otherItem.StatPoints) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Agi)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Defence)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Int), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Int)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit)) &&
                   Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Str), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Str)));
        }
Exemple #3
0
/// <summary>
/// Copies the column values into the given Dictionary using the database column name
/// with a prefixed @ as the key. The keys must already exist in the Dictionary;
/// this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="dic">The Dictionary to copy the values into.</param>
        public static void CopyValues(ICharacterTemplateTable source, System.Collections.Generic.IDictionary <System.String, System.Object> dic)
        {
            dic["ai_id"]        = (System.Nullable <NetGore.AI.AIID>)source.AIID;
            dic["alliance_id"]  = (DemoGame.AllianceID)source.AllianceID;
            dic["body_id"]      = (DemoGame.BodyID)source.BodyID;
            dic["chat_dialog"]  = (System.Nullable <NetGore.Features.NPCChat.NPCChatDialogID>)source.ChatDialog;
            dic["exp"]          = (System.Int32)source.Exp;
            dic["give_cash"]    = (System.Int32)source.GiveCash;
            dic["give_exp"]     = (System.Int32)source.GiveExp;
            dic["id"]           = (DemoGame.CharacterTemplateID)source.ID;
            dic["level"]        = (System.Int16)source.Level;
            dic["move_speed"]   = (System.UInt16)source.MoveSpeed;
            dic["name"]         = (System.String)source.Name;
            dic["respawn"]      = (System.UInt16)source.Respawn;
            dic["shop_id"]      = (System.Nullable <NetGore.Features.Shops.ShopID>)source.ShopID;
            dic["statpoints"]   = (System.Int32)source.StatPoints;
            dic["stat_agi"]     = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi);
            dic["stat_defence"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence);
            dic["stat_int"]     = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int);
            dic["stat_maxhit"]  = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit);
            dic["stat_maxhp"]   = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP);
            dic["stat_maxmp"]   = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP);
            dic["stat_minhit"]  = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit);
            dic["stat_str"]     = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str);
        }
/// <summary>
/// Copies the column values into the given DbParameterValues using the database column name
/// with a prefixed @ as the key. The keys must already exist in the DbParameterValues;
///  this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="paramValues">The DbParameterValues to copy the values into.</param>
        public static void CopyValues(this ICharacterTemplateTable source, NetGore.Db.DbParameterValues paramValues)
        {
            paramValues["ai_id"]        = (System.Nullable <System.UInt16>)source.AIID;
            paramValues["alliance_id"]  = (System.Byte)source.AllianceID;
            paramValues["body_id"]      = (System.UInt16)source.BodyID;
            paramValues["chat_dialog"]  = (System.Nullable <System.UInt16>)source.ChatDialog;
            paramValues["exp"]          = (System.Int32)source.Exp;
            paramValues["give_cash"]    = (System.Int32)source.GiveCash;
            paramValues["give_exp"]     = (System.Int32)source.GiveExp;
            paramValues["id"]           = (System.UInt16)source.ID;
            paramValues["level"]        = (System.Int16)source.Level;
            paramValues["move_speed"]   = (System.UInt16)source.MoveSpeed;
            paramValues["name"]         = (System.String)source.Name;
            paramValues["respawn"]      = (System.UInt16)source.Respawn;
            paramValues["shop_id"]      = (System.Nullable <System.UInt16>)source.ShopID;
            paramValues["statpoints"]   = (System.Int32)source.StatPoints;
            paramValues["stat_agi"]     = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi);
            paramValues["stat_defence"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence);
            paramValues["stat_int"]     = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int);
            paramValues["stat_maxhit"]  = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit);
            paramValues["stat_maxhp"]   = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP);
            paramValues["stat_maxmp"]   = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP);
            paramValues["stat_minhit"]  = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit);
            paramValues["stat_str"]     = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str);
        }
Exemple #5
0
/// <summary>
/// Copies the values from the given <paramref name="source"/> into this CharacterTemplateTable.
/// </summary>
/// <param name="source">The ICharacterTemplateTable to copy the values from.</param>
        public void CopyValuesFrom(ICharacterTemplateTable source)
        {
            this.AIID       = (System.Nullable <NetGore.AI.AIID>)source.AIID;
            this.AllianceID = (DemoGame.AllianceID)source.AllianceID;
            this.BodyID     = (DemoGame.BodyID)source.BodyID;
            this.ChatDialog = (System.Nullable <NetGore.Features.NPCChat.NPCChatDialogID>)source.ChatDialog;
            this.Exp        = (System.Int32)source.Exp;
            this.GiveCash   = (System.Int32)source.GiveCash;
            this.GiveExp    = (System.Int32)source.GiveExp;
            this.ID         = (DemoGame.CharacterTemplateID)source.ID;
            this.Level      = (System.Int16)source.Level;
            this.MoveSpeed  = (System.UInt16)source.MoveSpeed;
            this.Name       = (System.String)source.Name;
            this.Respawn    = (System.UInt16)source.Respawn;
            this.ShopID     = (System.Nullable <NetGore.Features.Shops.ShopID>)source.ShopID;
            this.StatPoints = (System.Int32)source.StatPoints;
            this.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit));
            this.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str));
        }
 /// <summary>
 /// Copies the values from the given <paramref name="source"/> into this CharacterTemplateTable.
 /// </summary>
 /// <param name="source">The ICharacterTemplateTable to copy the values from.</param>
 public void CopyValuesFrom(ICharacterTemplateTable source)
 {
     AIID       = source.AIID;
     AllianceID = source.AllianceID;
     BodyID     = source.BodyID;
     ChatDialog = source.ChatDialog;
     Exp        = source.Exp;
     GiveCash   = source.GiveCash;
     GiveExp    = source.GiveExp;
     ID         = source.ID;
     Level      = source.Level;
     MoveSpeed  = source.MoveSpeed;
     Name       = source.Name;
     Respawn    = source.Respawn;
     ShopID     = source.ShopID;
     StatPoints = source.StatPoints;
     SetStat(StatType.Agi, source.GetStat(StatType.Agi));
     SetStat(StatType.Defence, source.GetStat(StatType.Defence));
     SetStat(StatType.Int, source.GetStat(StatType.Int));
     SetStat(StatType.MaxHit, source.GetStat(StatType.MaxHit));
     SetStat(StatType.MaxHP, source.GetStat(StatType.MaxHP));
     SetStat(StatType.MaxMP, source.GetStat(StatType.MaxMP));
     SetStat(StatType.MinHit, source.GetStat(StatType.MinHit));
     SetStat(StatType.Str, source.GetStat(StatType.Str));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CharacterTemplate"/> class.
        /// </summary>
        /// <param name="templateTable">The template table.</param>
        /// <param name="inventory">The inventory.</param>
        /// <param name="equipment">The equipment.</param>
        /// <param name="quests">The quests.</param>
        /// <param name="knownSkills">The known skills.</param>
        /// <exception cref="ArgumentNullException"><paramref name="templateTable" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="inventory" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="equipment" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="knownSkills" /> is <c>null</c>.</exception>
        public CharacterTemplate(ICharacterTemplateTable templateTable, IEnumerable<CharacterTemplateInventoryItem> inventory,
                                 IEnumerable<CharacterTemplateEquipmentItem> equipment, IEnumerable<IQuest<User>> quests,
                                 IEnumerable<SkillType> knownSkills)
        {
            _templateTable = templateTable;

            if (templateTable == null)
                throw new ArgumentNullException("templateTable");
            if (inventory == null)
                throw new ArgumentNullException("inventory");
            if (equipment == null)
                throw new ArgumentNullException("equipment");
            if (knownSkills == null)
                throw new ArgumentNullException("knownSkills");

            // Compact all the collections given to us to ensure they are immutable and have minimal overhead
            _inventory = inventory.ToCompact();
            _equipment = equipment.ToCompact();
            _quests = quests.ToCompact();
            _knownSkills = knownSkills.ToCompact();

            // Assert values are valid
            Debug.Assert(_inventory.All(x => x != null));
            Debug.Assert(_equipment.All(x => x != null));
            Debug.Assert(_quests.All(x => x != null));
            Debug.Assert(_knownSkills.All(EnumHelper<SkillType>.IsDefined),
                string.Format("One or more SkillTypes for CharacterTemplate `{0}` are invalid!", this));

            if (log.IsInfoEnabled)
                log.InfoFormat("Loaded CharacterTemplate `{0}`.", this);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EditorCharacterTemplate"/> class.
        /// </summary>
        /// <param name="charTemplateTable">The <see cref="ICharacterTemplateTable"/>.</param>
        /// <param name="dbController">The <see cref="IDbController"/>.</param>
        public EditorCharacterTemplate(ICharacterTemplateTable charTemplateTable, IDbController dbController)
        {
            var id = charTemplateTable.ID;

            // Load the main table values
            CopyValuesFrom(charTemplateTable);

            // Load values from other tables
            // Equipped
            var equippedRaw = dbController.GetQuery<SelectCharacterTemplateEquippedQuery>().Execute(id);
            if (equippedRaw != null)
            {
                var equipped = equippedRaw.Select(x => new CharacterTemplateEquippedItem(x.ItemTemplateID, x.Chance));
                _equipped.AddRange(equipped);
            }

            // Inventory
            var inventoryRaw = dbController.GetQuery<SelectCharacterTemplateInventoryQuery>().Execute(id);
            if (inventoryRaw != null)
            {
                var inventory =
                    inventoryRaw.Select(x => new CharacterTemplateInventoryItem(x.ItemTemplateID, x.Chance, x.Min, x.Max));
                _inventory.AddRange(inventory);
            }

            // Known skills
            var knownSkills = dbController.GetQuery<SelectCharacterTemplateSkillsQuery>().Execute(id);
            if (knownSkills != null)
                _knownSkills.AddRange(knownSkills);

            // Quests
            var quests = dbController.GetQuery<SelectCharacterTemplateQuestsQuery>().Execute(id);
            if (quests != null)
                _quests.AddRange(quests);
        }
 /// <summary>
 /// Checks if this <see cref="ICharacterTemplateTable"/> contains the same values as another <see cref="ICharacterTemplateTable"/>.
 /// </summary>
 /// <param name="source">The source <see cref="ICharacterTemplateTable"/>.</param>
 /// <param name="otherItem">The <see cref="ICharacterTemplateTable"/> to compare the values to.</param>
 /// <returns>
 /// True if this <see cref="ICharacterTemplateTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false.
 /// </returns>
 public static Boolean HasSameValues(this ICharacterTemplateTable source, ICharacterTemplateTable otherItem)
 {
     return Equals(source.AIID, otherItem.AIID) && Equals(source.AllianceID, otherItem.AllianceID) &&
            Equals(source.BodyID, otherItem.BodyID) && Equals(source.ChatDialog, otherItem.ChatDialog) &&
            Equals(source.Exp, otherItem.Exp) && Equals(source.GiveCash, otherItem.GiveCash) &&
            Equals(source.GiveExp, otherItem.GiveExp) && Equals(source.ID, otherItem.ID) &&
            Equals(source.Level, otherItem.Level) && Equals(source.MoveSpeed, otherItem.MoveSpeed) &&
            Equals(source.Name, otherItem.Name) && Equals(source.Respawn, otherItem.Respawn) &&
            Equals(source.ShopID, otherItem.ShopID) && Equals(source.StatPoints, otherItem.StatPoints) &&
            Equals(source.GetStat(StatType.Agi), otherItem.GetStat(StatType.Agi)) &&
            Equals(source.GetStat(StatType.Defence), otherItem.GetStat(StatType.Defence)) &&
            Equals(source.GetStat(StatType.Int), otherItem.GetStat(StatType.Int)) &&
            Equals(source.GetStat(StatType.MaxHit), otherItem.GetStat(StatType.MaxHit)) &&
            Equals(source.GetStat(StatType.MaxHP), otherItem.GetStat(StatType.MaxHP)) &&
            Equals(source.GetStat(StatType.MaxMP), otherItem.GetStat(StatType.MaxMP)) &&
            Equals(source.GetStat(StatType.MinHit), otherItem.GetStat(StatType.MinHit)) &&
            Equals(source.GetStat(StatType.Str), otherItem.GetStat(StatType.Str));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="EditorCharacterTemplate"/> class.
        /// </summary>
        /// <param name="charTemplateTable">The <see cref="ICharacterTemplateTable"/>.</param>
        /// <param name="dbController">The <see cref="IDbController"/>.</param>
        public EditorCharacterTemplate(ICharacterTemplateTable charTemplateTable, IDbController dbController)
        {
            var id = charTemplateTable.ID;

            // Load the main table values
            CopyValuesFrom(charTemplateTable);

            // Load values from other tables
            // Equipped
            var equippedRaw = dbController.GetQuery <SelectCharacterTemplateEquippedQuery>().Execute(id);

            if (equippedRaw != null)
            {
                var equipped = equippedRaw.Select(x => new CharacterTemplateEquippedItem(x.ItemTemplateID, x.Chance));
                _equipped.AddRange(equipped);
            }

            // Inventory
            var inventoryRaw = dbController.GetQuery <SelectCharacterTemplateInventoryQuery>().Execute(id);

            if (inventoryRaw != null)
            {
                var inventory =
                    inventoryRaw.Select(x => new CharacterTemplateInventoryItem(x.ItemTemplateID, x.Chance, x.Min, x.Max));
                _inventory.AddRange(inventory);
            }

            // Known skills
            var knownSkills = dbController.GetQuery <SelectCharacterTemplateSkillsQuery>().Execute(id);

            if (knownSkills != null)
            {
                _knownSkills.AddRange(knownSkills);
            }

            // Quests
            var quests = dbController.GetQuery <SelectCharacterTemplateQuestsQuery>().Execute(id);

            if (quests != null)
            {
                _quests.AddRange(quests);
            }
        }
Exemple #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CharacterTemplate"/> class.
        /// </summary>
        /// <param name="templateTable">The template table.</param>
        /// <param name="inventory">The inventory.</param>
        /// <param name="equipment">The equipment.</param>
        /// <param name="quests">The quests.</param>
        /// <param name="knownSkills">The known skills.</param>
        /// <exception cref="ArgumentNullException"><paramref name="templateTable" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="inventory" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="equipment" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="knownSkills" /> is <c>null</c>.</exception>
        public CharacterTemplate(ICharacterTemplateTable templateTable, IEnumerable <CharacterTemplateInventoryItem> inventory,
                                 IEnumerable <CharacterTemplateEquipmentItem> equipment, IEnumerable <IQuest <User> > quests,
                                 IEnumerable <SkillType> knownSkills)
        {
            _templateTable = templateTable;

            if (templateTable == null)
            {
                throw new ArgumentNullException("templateTable");
            }
            if (inventory == null)
            {
                throw new ArgumentNullException("inventory");
            }
            if (equipment == null)
            {
                throw new ArgumentNullException("equipment");
            }
            if (knownSkills == null)
            {
                throw new ArgumentNullException("knownSkills");
            }

            // Compact all the collections given to us to ensure they are immutable and have minimal overhead
            _inventory   = inventory.ToCompact();
            _equipment   = equipment.ToCompact();
            _quests      = quests.ToCompact();
            _knownSkills = knownSkills.ToCompact();

            // Assert values are valid
            Debug.Assert(_inventory.All(x => x != null));
            Debug.Assert(_equipment.All(x => x != null));
            Debug.Assert(_quests.All(x => x != null));
            Debug.Assert(_knownSkills.All(EnumHelper <SkillType> .IsDefined),
                         string.Format("One or more SkillTypes for CharacterTemplate `{0}` are invalid!", this));

            if (log.IsInfoEnabled)
            {
                log.InfoFormat("Loaded CharacterTemplate `{0}`.", this);
            }
        }
 /// <summary>
 /// Copies the values from the given <paramref name="source"/> into this CharacterTemplateTable.
 /// </summary>
 /// <param name="source">The ICharacterTemplateTable to copy the values from.</param>
 public void CopyValuesFrom(ICharacterTemplateTable source)
 {
     AIID = source.AIID;
     AllianceID = source.AllianceID;
     BodyID = source.BodyID;
     ChatDialog = source.ChatDialog;
     Exp = source.Exp;
     GiveCash = source.GiveCash;
     GiveExp = source.GiveExp;
     ID = source.ID;
     Level = source.Level;
     MoveSpeed = source.MoveSpeed;
     Name = source.Name;
     Respawn = source.Respawn;
     ShopID = source.ShopID;
     StatPoints = source.StatPoints;
     SetStat(StatType.Agi, source.GetStat(StatType.Agi));
     SetStat(StatType.Defence, source.GetStat(StatType.Defence));
     SetStat(StatType.Int, source.GetStat(StatType.Int));
     SetStat(StatType.MaxHit, source.GetStat(StatType.MaxHit));
     SetStat(StatType.MaxHP, source.GetStat(StatType.MaxHP));
     SetStat(StatType.MaxMP, source.GetStat(StatType.MaxMP));
     SetStat(StatType.MinHit, source.GetStat(StatType.MinHit));
     SetStat(StatType.Str, source.GetStat(StatType.Str));
 }
 /// <summary>
 /// Copies the column values into the given Dictionary using the database column name
 /// with a prefixed @ as the key. The keys must already exist in the Dictionary;
 /// this method will not create them if they are missing.
 /// </summary>
 /// <param name="source">The object to copy the values from.</param>
 /// <param name="dic">The Dictionary to copy the values into.</param>
 public static void CopyValues(ICharacterTemplateTable source, IDictionary<String, Object> dic)
 {
     dic["ai_id"] = source.AIID;
     dic["alliance_id"] = source.AllianceID;
     dic["body_id"] = source.BodyID;
     dic["chat_dialog"] = source.ChatDialog;
     dic["exp"] = source.Exp;
     dic["give_cash"] = source.GiveCash;
     dic["give_exp"] = source.GiveExp;
     dic["id"] = source.ID;
     dic["level"] = source.Level;
     dic["move_speed"] = source.MoveSpeed;
     dic["name"] = source.Name;
     dic["respawn"] = source.Respawn;
     dic["shop_id"] = source.ShopID;
     dic["statpoints"] = source.StatPoints;
     dic["stat_agi"] = (Int16)source.GetStat(StatType.Agi);
     dic["stat_defence"] = (Int16)source.GetStat(StatType.Defence);
     dic["stat_int"] = (Int16)source.GetStat(StatType.Int);
     dic["stat_maxhit"] = (Int16)source.GetStat(StatType.MaxHit);
     dic["stat_maxhp"] = (Int16)source.GetStat(StatType.MaxHP);
     dic["stat_maxmp"] = (Int16)source.GetStat(StatType.MaxMP);
     dic["stat_minhit"] = (Int16)source.GetStat(StatType.MinHit);
     dic["stat_str"] = (Int16)source.GetStat(StatType.Str);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CharacterTemplateTable"/> class.
 /// </summary>
 /// <param name="source">ICharacterTemplateTable to copy the initial values from.</param>
 public CharacterTemplateTable(ICharacterTemplateTable source)
 {
     CopyValuesFrom(source);
 }
/// <summary>
/// Copies the column values into the given DbParameterValues using the database column name
/// with a prefixed @ as the key. The key must already exist in the DbParameterValues
/// for the value to be copied over. If any of the keys in the DbParameterValues do not
/// match one of the column names, or if there is no field for a key, then it will be
/// ignored. Because of this, it is important to be careful when using this method
/// since columns or keys can be skipped without any indication.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="paramValues">The DbParameterValues to copy the values into.</param>
        public static void TryCopyValues(this ICharacterTemplateTable source, NetGore.Db.DbParameterValues paramValues)
        {
            for (int i = 0; i < paramValues.Count; i++)
            {
                switch (paramValues.GetParameterName(i))
                {
                case "ai_id":
                    paramValues[i] = (System.Nullable <System.UInt16>)source.AIID;
                    break;


                case "alliance_id":
                    paramValues[i] = (System.Byte)source.AllianceID;
                    break;


                case "body_id":
                    paramValues[i] = (System.UInt16)source.BodyID;
                    break;


                case "chat_dialog":
                    paramValues[i] = (System.Nullable <System.UInt16>)source.ChatDialog;
                    break;


                case "exp":
                    paramValues[i] = (System.Int32)source.Exp;
                    break;


                case "give_cash":
                    paramValues[i] = (System.Int32)source.GiveCash;
                    break;


                case "give_exp":
                    paramValues[i] = (System.Int32)source.GiveExp;
                    break;


                case "id":
                    paramValues[i] = (System.UInt16)source.ID;
                    break;


                case "level":
                    paramValues[i] = (System.Int16)source.Level;
                    break;


                case "move_speed":
                    paramValues[i] = (System.UInt16)source.MoveSpeed;
                    break;


                case "name":
                    paramValues[i] = (System.String)source.Name;
                    break;


                case "respawn":
                    paramValues[i] = (System.UInt16)source.Respawn;
                    break;


                case "shop_id":
                    paramValues[i] = (System.Nullable <System.UInt16>)source.ShopID;
                    break;


                case "statpoints":
                    paramValues[i] = (System.Int32)source.StatPoints;
                    break;


                case "stat_agi":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi);
                    break;


                case "stat_defence":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence);
                    break;


                case "stat_int":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int);
                    break;


                case "stat_maxhit":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit);
                    break;


                case "stat_maxhp":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP);
                    break;


                case "stat_maxmp":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP);
                    break;


                case "stat_minhit":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit);
                    break;


                case "stat_str":
                    paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str);
                    break;
                }
            }
        }
/// <summary>
/// Copies the column values into the given Dictionary using the database column name
/// with a prefixed @ as the key. The keys must already exist in the Dictionary;
/// this method will not create them if they are missing.
/// </summary>
/// <param name="source">The object to copy the values from.</param>
/// <param name="dic">The Dictionary to copy the values into.</param>
public static void CopyValues(ICharacterTemplateTable source, System.Collections.Generic.IDictionary<System.String,System.Object> dic)
{
dic["ai_id"] = (System.Nullable<NetGore.AI.AIID>)source.AIID;
dic["alliance_id"] = (DemoGame.AllianceID)source.AllianceID;
dic["body_id"] = (DemoGame.BodyID)source.BodyID;
dic["chat_dialog"] = (System.Nullable<NetGore.Features.NPCChat.NPCChatDialogID>)source.ChatDialog;
dic["exp"] = (System.Int32)source.Exp;
dic["give_cash"] = (System.Int32)source.GiveCash;
dic["give_exp"] = (System.Int32)source.GiveExp;
dic["id"] = (DemoGame.CharacterTemplateID)source.ID;
dic["level"] = (System.Int16)source.Level;
dic["move_speed"] = (System.UInt16)source.MoveSpeed;
dic["name"] = (System.String)source.Name;
dic["respawn"] = (System.UInt16)source.Respawn;
dic["shop_id"] = (System.Nullable<NetGore.Features.Shops.ShopID>)source.ShopID;
dic["statpoints"] = (System.Int32)source.StatPoints;
dic["stat_agi"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi);
dic["stat_defence"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence);
dic["stat_int"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int);
dic["stat_maxhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit);
dic["stat_maxhp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP);
dic["stat_maxmp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP);
dic["stat_minhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit);
dic["stat_str"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str);
}
Exemple #17
0
/// <summary>
/// Initializes a new instance of the <see cref="CharacterTemplateTable"/> class.
/// </summary>
/// <param name="source">ICharacterTemplateTable to copy the initial values from.</param>
        public CharacterTemplateTable(ICharacterTemplateTable source)
        {
            CopyValuesFrom(source);
        }
/// <summary>
/// Copies the values from the given <paramref name="source"/> into this CharacterTemplateTable.
/// </summary>
/// <param name="source">The ICharacterTemplateTable to copy the values from.</param>
public void CopyValuesFrom(ICharacterTemplateTable source)
{
this.AIID = (System.Nullable<NetGore.AI.AIID>)source.AIID;
this.AllianceID = (DemoGame.AllianceID)source.AllianceID;
this.BodyID = (DemoGame.BodyID)source.BodyID;
this.ChatDialog = (System.Nullable<NetGore.Features.NPCChat.NPCChatDialogID>)source.ChatDialog;
this.Exp = (System.Int32)source.Exp;
this.GiveCash = (System.Int32)source.GiveCash;
this.GiveExp = (System.Int32)source.GiveExp;
this.ID = (DemoGame.CharacterTemplateID)source.ID;
this.Level = (System.Int16)source.Level;
this.MoveSpeed = (System.UInt16)source.MoveSpeed;
this.Name = (System.String)source.Name;
this.Respawn = (System.UInt16)source.Respawn;
this.ShopID = (System.Nullable<NetGore.Features.Shops.ShopID>)source.ShopID;
this.StatPoints = (System.Int32)source.StatPoints;
this.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi));
this.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence));
this.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int));
this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit));
this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP));
this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP));
this.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit));
this.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str));
}