Example #1
0
        public void VieAmuletti(Amulet amulet, int id)
        {
            string command;

            command = "INSERT INTO PlayerItems (characterId, lifeleech, manaleech, extradmg, hp, accuracy, defence, itemtype, equiped) VALUES(@id, @lifeleech, @manaleech, @extradmg, @hp, @accuracy, @def, @itemtype, @equiped)";
            SqlCommand komento = new SqlCommand(command, connection);

            komento.Parameters.AddWithValue("@id", id);
            komento.Parameters.AddWithValue("@lifeleech", amulet.Lifeleech);
            komento.Parameters.AddWithValue("@manaleech", amulet.Manaleech);
            komento.Parameters.AddWithValue("@hp", amulet.Hp);
            komento.Parameters.AddWithValue("@accuracy", amulet.Accuracy);
            komento.Parameters.AddWithValue("@def", amulet.Def);
            komento.Parameters.AddWithValue("@extradmg", amulet.ElderExtradmg);
            komento.Parameters.AddWithValue("@incdef", amulet.Increaseddef);
            komento.Parameters.AddWithValue("@itemtype", "amulet");
            komento.Parameters.AddWithValue("@equiped", amulet.Equiped);
            komento.ExecuteNonQuery();
        }
Example #2
0
        public List <Esineet> HaeEsineet(int id)
        {
            List <Esineet> inventory = new List <Esineet>();

            try
            {
                using (connection)
                {
                    yhdista();
                    string command;
                    command = "Select * From PlayerItems Where characterid = @id";
                    SqlCommand komento = new SqlCommand(command, connection);
                    komento.Parameters.AddWithValue("@id", id);
                    using (SqlDataReader reader = komento.ExecuteReader())
                    {
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            reader.Read();
                            string vertaa = reader.GetString(13);
                            switch (vertaa)
                            {
                            case "amulet":
                                Amulet amulet = new Amulet();
                                amulet.Accuracy      = reader.GetDecimal(8);
                                amulet.Def           = reader.GetDecimal(9);
                                amulet.Hp            = reader.GetDecimal(7);
                                amulet.Increaseddef  = reader.GetDecimal(12);
                                amulet.ElderExtradmg = reader.GetDecimal(6);
                                amulet.Lifeleech     = reader.GetDecimal(2);
                                amulet.Manaleech     = reader.GetDecimal(3);
                                amulet.Equiped       = reader.GetBoolean(14);
                                inventory.Add(amulet);
                                break;

                            case "belt":
                                Belt belt = new Belt();
                                belt.Accuracy     = reader.GetDecimal(8);
                                belt.Def          = reader.GetDecimal(9);
                                belt.Hp           = reader.GetDecimal(7);
                                belt.Increaseddef = reader.GetDecimal(12);
                                belt.Equiped      = reader.GetBoolean(14);
                                inventory.Add(belt);
                                break;

                            case "body":
                                Body body = new Body();
                                body.Accuracy     = reader.GetDecimal(8);
                                body.Def          = reader.GetDecimal(9);
                                body.Hp           = reader.GetDecimal(7);
                                body.Increaseddef = reader.GetDecimal(12);
                                body.Equiped      = reader.GetBoolean(14);
                                inventory.Add(body);
                                break;

                            case "bootsit":
                                Boots boots = new Boots();
                                boots.Accuracy     = reader.GetDecimal(8);
                                boots.Def          = reader.GetDecimal(9);
                                boots.Hp           = reader.GetDecimal(7);
                                boots.Increaseddef = reader.GetDecimal(12);
                                boots.Speed        = reader.GetDecimal(5);
                                boots.Equiped      = reader.GetBoolean(14);
                                inventory.Add(boots);
                                break;

                            case "gloves":
                                Gloves gloves = new Gloves();
                                gloves.Accuracy     = reader.GetDecimal(8);
                                gloves.Def          = reader.GetDecimal(9);
                                gloves.Hp           = reader.GetDecimal(7);
                                gloves.Increaseddef = reader.GetDecimal(12);
                                gloves.Addeddmg     = reader.GetDecimal(10);
                                gloves.Lifeleech    = reader.GetDecimal(2);
                                gloves.Equiped      = reader.GetBoolean(14);
                                inventory.Add(gloves);
                                break;

                            case "helmet":
                                Helmet helmet = new Helmet();
                                helmet.Accuracy     = reader.GetDecimal(8);
                                helmet.Def          = reader.GetDecimal(9);
                                helmet.Hp           = reader.GetDecimal(7);
                                helmet.Increaseddef = reader.GetDecimal(12);
                                helmet.Equiped      = reader.GetBoolean(14);
                                inventory.Add(helmet);
                                break;

                            case "ring":
                                Ring ring = new Ring();
                                ring.Accuracy     = reader.GetDecimal(8);
                                ring.Def          = reader.GetDecimal(9);
                                ring.Hp           = reader.GetDecimal(7);
                                ring.Increaseddef = reader.GetDecimal(12);
                                ring.Lifeleech    = reader.GetDecimal(2);
                                ring.Manaleech    = reader.GetDecimal(3);
                                ring.Addeddmg     = reader.GetDecimal(10);
                                ring.Equiped      = reader.GetBoolean(14);
                                inventory.Add(ring);
                                break;

                            case "weapon":
                                weapon weapon = new weapon();
                                weapon.Elderextra   = reader.GetDecimal(6);
                                weapon.Dmg          = reader.GetDecimal(4);
                                weapon.Increaseddmg = reader.GetDecimal(11);
                                weapon.Equiped      = reader.GetBoolean(14);
                                weapon.Critchance   = reader.GetDecimal(16);
                                weapon.Critdmg      = reader.GetDecimal(15);
                                inventory.Add(weapon);
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(inventory);
        }