private void CBboots_SelectedIndexChanged(object sender, EventArgs e) { if (CBboots.SelectedItem != null) { TBitem.Clear(); TBequiped.Clear(); Boots boots = (Boots)CBboots.SelectedItem; viimeksivalittu = boots; Naytabootsit(boots, CBboots); } }
public void VieBoots(Boots bootsit, int id) { string command = "INSERT INTO PlayerItems (characterId, speed, hp, accuracy, incdef, defence, itemtype, equiped) VALUES(@id, @speed, @hp, @accuracy, @incdef, @def, @itemtype, @equiped)"; SqlCommand komento = new SqlCommand(command, connection); komento.Parameters.AddWithValue("@id", id); komento.Parameters.AddWithValue("@accuracy", bootsit.Accuracy); komento.Parameters.AddWithValue("@def", bootsit.Def); komento.Parameters.AddWithValue("@hp", bootsit.Hp); komento.Parameters.AddWithValue("@incdef", bootsit.Increaseddef); komento.Parameters.AddWithValue("@speed", bootsit.Speed); komento.Parameters.AddWithValue("@itemtype", "bootsit"); komento.Parameters.AddWithValue("@equiped", bootsit.Equiped); komento.ExecuteNonQuery(); }
private void Naytabootsit(Boots boots, ComboBox sender) { // näytetään valittu esine if (boots.Accuracy > 0) { TBitem.Text += "Accuracy: " + boots.Accuracy; } if (boots.Def > 0) { TBitem.Text += Environment.NewLine + "Defence: " + boots.Def * (1 + boots.Increaseddef); } if (boots.Hp > 0) { TBitem.Text += Environment.NewLine + "HP: " + boots.Hp; } if (boots.Speed > 0) { TBitem.Text += Environment.NewLine + "Speed: " + boots.Speed; } // näytetään pelaajan esine if (player.Boots.Accuracy > 0) { TBequiped.Text += "Accuracy: " + player.Boots.Accuracy; } if (player.Boots.Def > 0) { TBequiped.Text += Environment.NewLine + "Defence: " + player.Boots.Def * (1 + player.Boots.Increaseddef); } if (player.Boots.Hp > 0) { TBequiped.Text += Environment.NewLine + "HP: " + player.Boots.Hp; } if (player.Boots.Speed > 0) { TBequiped.Text += Environment.NewLine + "Speed: " + player.Boots.Speed; } }
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); }