Ejemplo n.º 1
0
        /// <summary>
        /// Insere items no inventario
        /// </summary>
        /// <param name="name"></param>
        /// <param name="classeID"></param>
        public static void InsertInitialItems(string name, int classeID)
        {
            var varQuery = new StringBuilder();
            var index    = Classe.FindClasseIndexByID(classeID);
            var charID   = ID(name);

            for (var item = 0; item < Common.Settings.MAX_ITEM; item++)
            {
                //se não há nenhum item, próximo
                if (Classe.Classes[index].GetItem((ItemType)item).ID == 0)
                {
                    continue;
                }

                varQuery.Append("INSERT INTO player_inventory (char_id, inventory_slot, ");
                varQuery.Append("item_id, item_unique_id, item_count, enchant, item_element, durability, slots, expire_time, ");
                varQuery.Append("is_soul_bound, is_equipped) ");
                varQuery.Append("VALUES (");
                varQuery.Append($"'{charID}', ");
                varQuery.Append($"'{item}', "); //inv slot
                varQuery.Append($"'{Classe.Classes[index].GetItem((ItemType)item).ID}', ");
                varQuery.Append($"'{Classe.Classes[index].GetItem((ItemType)item).UniqueID}', ");
                varQuery.Append("'1', "); //quantidade
                varQuery.Append($"'{Classe.Classes[index].GetItem((ItemType)item).Enchant}', ");
                varQuery.Append($"'{Classe.Classes[index].GetItem((ItemType)item).Element}', ");
                varQuery.Append($"'{Classe.Classes[index].GetItem((ItemType)item).Durability}', ");
                varQuery.Append($"'{Classe.Classes[index].GetItem((ItemType)item).Slots}', ");
                varQuery.Append($"'{Classe.Classes[index].GetItem((ItemType)item).ExpireTime}', ");
                varQuery.Append($"'{Classe.Classes[index].GetItem((ItemType)item).IsSoulBound}', ");
                varQuery.Append("'1')"); //equipado

                var cmd = new MySqlCommand(varQuery.ToString(), Common_DB.Connection);
                cmd.ExecuteNonQuery();

                varQuery.Clear();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Insere um novo personagem ao banco de dados.
        /// </summary>
        /// <param name="hexID"></param>
        /// <param name="gender"></param>
        /// <param name="classeID"></param>
        /// <param name="name"></param>
        /// <param name="sprite"></param>
        /// <param name="charSlot"></param>
        public static void InsertNewCharacter(string hexID, int gender, int classeID, string name, int sprite, int charSlot)
        {
            var query = new StringBuilder();
            var pData = Authentication.FindByHexID(hexID);
            var index = Classe.FindClasseIndexByID(classeID);

            query.Append("INSERT INTO players (account_id, class_id, char_slot, name, level, gender, sprite, ");
            query.Append("strenght, dexterity, agility, constitution, intelligence, wisdom, will, mind, charisma, statpoints)");
            query.Append("VALUES (?accountID, ?classeID, ?charSlot, ?name, ?level, ?gender, ?sprite, ?strenght, ?dexterity, ?agility, ");
            query.Append("?constitution, ?intelligence, ?wisdom, ?will, ?mind, ?charisma, ?statpoints)");

            var list = new List <MySqlParameter>();

            list.Add(new MySqlParameter("?accountID", pData.AccountID));
            list.Add(new MySqlParameter("?classeID", classeID));
            list.Add(new MySqlParameter("?charSlot", charSlot));
            list.Add(new MySqlParameter("?name", name));
            list.Add(new MySqlParameter("?level", Classe.Classes[index].Level));
            list.Add(new MySqlParameter("?gender", gender));
            list.Add(new MySqlParameter("?sprite", sprite));
            list.Add(new MySqlParameter("?strenght", Classe.Classes[index].Strenght));
            list.Add(new MySqlParameter("?dexterity", Classe.Classes[index].Dexterity));
            list.Add(new MySqlParameter("?agility", Classe.Classes[index].Agility));
            list.Add(new MySqlParameter("?constitution", Classe.Classes[index].Constitution));
            list.Add(new MySqlParameter("?intelligence", Classe.Classes[index].Intelligence));
            list.Add(new MySqlParameter("?wisdom", Classe.Classes[index].Wisdom));
            list.Add(new MySqlParameter("?will", Classe.Classes[index].Will));
            list.Add(new MySqlParameter("?mind", Classe.Classes[index].Mind));
            list.Add(new MySqlParameter("?charisma", Classe.Classes[index].Charisma));
            list.Add(new MySqlParameter("?statpoints", Classe.Classes[index].Points));

            var cmd = new MySqlCommand(query.ToString(), Common_DB.Connection);

            cmd.Parameters.AddRange(list.ToArray());
            cmd.ExecuteNonQuery();
        }
Ejemplo n.º 3
0
        public static void UpdateCharacterStats(int playerID)
        {
            var pData = Authentication.FindByAccountID(playerID);
            var index = Classe.FindClasseIndexByID(pData.ClasseID);

            //items stat value
            int[] value = new int[10] {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            // before update, check all item StatType
            pData.Strenght     = Classe.Classes[index].GetPlayerStat(StatType.Strenght, pData, value);
            pData.Dexterity    = Classe.Classes[index].GetPlayerStat(StatType.Dexterity, pData, value);
            pData.Agility      = Classe.Classes[index].GetPlayerStat(StatType.Agility, pData, value);
            pData.Constitution = Classe.Classes[index].GetPlayerStat(StatType.Constitution, pData, value);
            pData.Intelligence = Classe.Classes[index].GetPlayerStat(StatType.Intelligence, pData, value);
            pData.Wisdom       = Classe.Classes[index].GetPlayerStat(StatType.Wisdom, pData, value);
            pData.Will         = Classe.Classes[index].GetPlayerStat(StatType.Will, pData, value);
            pData.Mind         = Classe.Classes[index].GetPlayerStat(StatType.Mind, pData, value);
            pData.Charisma     = Classe.Classes[index].GetPlayerStat(StatType.Charisma, pData, value);

            pData.MaxHP = Classe.Classes[index].GetPlayerStat(StatType.MaxHP, pData, value);
            pData.MaxMP = Classe.Classes[index].GetPlayerStat(StatType.MaxMP, pData, value);
            pData.MaxSP = Classe.Classes[index].GetPlayerStat(StatType.MaxSP, pData, value);

            if (pData.HP > pData.MaxHP || pData.HP == 0)
            {
                pData.HP = pData.MaxHP;
            }
            if (pData.MP > pData.MaxMP || pData.MP == 0)
            {
                pData.MP = pData.MaxMP;
            }
            if (pData.SP > pData.MaxSP || pData.SP == 0)
            {
                pData.SP = pData.MaxSP;
            }

            pData.RegenHP                   = Classe.Classes[index].GetPlayerStat(StatType.RegenHP, pData, value);
            pData.RegenMP                   = Classe.Classes[index].GetPlayerStat(StatType.RegenMP, pData, value);
            pData.RegenSP                   = Classe.Classes[index].GetPlayerStat(StatType.RegenSP, pData, value);
            pData.DamageSuppression         = Classe.Classes[index].GetPlayerStat(StatType.DamageSuppression, pData, value);
            pData.Enmity                    = Classe.Classes[index].GetPlayerStat(StatType.Enmity, pData, value);
            pData.AdditionalDamage          = Classe.Classes[index].GetPlayerStat(StatType.AdditionalDamage, pData, value);
            pData.HealingPower              = Classe.Classes[index].GetPlayerStat(StatType.HealingPower, pData, value);
            pData.Concentration             = Classe.Classes[index].GetPlayerStat(StatType.Concentration, pData, value);
            pData.AttackSpeed               = Classe.Classes[index].GetPlayerStat(StatType.AttackSpeed, pData, value);
            pData.CastSpeed                 = Classe.Classes[index].GetPlayerStat(StatType.CastSpeed, pData, value);
            pData.Attack                    = Classe.Classes[index].GetPlayerStat(StatType.Attack, pData, value);
            pData.Accuracy                  = Classe.Classes[index].GetPlayerStat(StatType.Accuracy, pData, value);
            pData.Defense                   = Classe.Classes[index].GetPlayerStat(StatType.Defense, pData, value);
            pData.Evasion                   = Classe.Classes[index].GetPlayerStat(StatType.Evasion, pData, value);
            pData.Block                     = Classe.Classes[index].GetPlayerStat(StatType.Block, pData, value);
            pData.Parry                     = Classe.Classes[index].GetPlayerStat(StatType.Parry, pData, value);
            pData.CriticalRate              = Classe.Classes[index].GetPlayerStat(StatType.CriticalRate, pData, value);
            pData.CriticalDamage            = Classe.Classes[index].GetPlayerStat(StatType.CriticalDamage, pData, value);
            pData.MagicAttack               = Classe.Classes[index].GetPlayerStat(StatType.MagicAttack, pData, value);
            pData.MagicAccuracy             = Classe.Classes[index].GetPlayerStat(StatType.MagicAccuracy, pData, value);
            pData.MagicDefense              = Classe.Classes[index].GetPlayerStat(StatType.MagicDefense, pData, value);
            pData.MagicResist               = Classe.Classes[index].GetPlayerStat(StatType.MagicResist, pData, value);
            pData.MagicCriticalRate         = Classe.Classes[index].GetPlayerStat(StatType.MagicCriticalRate, pData, value);
            pData.MagicCriticalDamage       = Classe.Classes[index].GetPlayerStat(StatType.MagicCriticalDamage, pData, value);
            pData.AttributeFire             = Classe.Classes[index].GetPlayerStat(StatType.AttributeFire, pData, value);
            pData.AttributeWater            = Classe.Classes[index].GetPlayerStat(StatType.AttributeWater, pData, value);
            pData.AttributeEarth            = Classe.Classes[index].GetPlayerStat(StatType.AttributeEarth, pData, value);
            pData.AttributeWind             = Classe.Classes[index].GetPlayerStat(StatType.AttributeWind, pData, value);
            pData.MagicCriticalRate         = Classe.Classes[index].GetPlayerStat(StatType.MagicCriticalRate, pData, value);
            pData.MagicCriticalDamage       = Classe.Classes[index].GetPlayerStat(StatType.MagicCriticalDamage, pData, value);
            pData.ResistStun                = Classe.Classes[index].GetPlayerStat(StatType.ResistStun, pData, value);
            pData.ResistParalysis           = Classe.Classes[index].GetPlayerStat(StatType.ResistParalysis, pData, value);
            pData.ResistSilence             = Classe.Classes[index].GetPlayerStat(StatType.ResistSilence, pData, value);
            pData.ResistBlind               = Classe.Classes[index].GetPlayerStat(StatType.ResistBlind, pData, value);
            pData.ResistCriticalRate        = Classe.Classes[index].GetPlayerStat(StatType.ResistCriticalRate, pData, value);
            pData.ResistCriticalDamage      = Classe.Classes[index].GetPlayerStat(StatType.ResistCriticalDamage, pData, value);
            pData.ResistMagicCriticalRate   = Classe.Classes[index].GetPlayerStat(StatType.ResistMagicCriticalRate, pData, value);
            pData.ResistMagicCriticalDamage = Classe.Classes[index].GetPlayerStat(StatType.ResistMagicCriticalDamage, pData, value);
        }