private void CBgloves_SelectedIndexChanged(object sender, EventArgs e) { if (CBgloves.SelectedItem != null) { TBitem.Clear(); TBequiped.Clear(); Gloves glove = (Gloves)CBgloves.SelectedItem; viimeksivalittu = glove; Naytaglovet(glove, CBgloves); } }
public void VieGloves(Gloves glove, int id) { string command = "INSERT INTO PlayerItems (characterId, lifeleech, hp, accuracy, defence, addeddmg, itemtype, equiped) VALUES(@id, @lifeleech, @hp, @accuracy, @def, @adddmg, @itemtype, @equiped)"; SqlCommand komento = new SqlCommand(command, connection); komento.Parameters.AddWithValue("@id", id); komento.Parameters.AddWithValue("@accuracy", glove.Accuracy); komento.Parameters.AddWithValue("@adddmg", glove.Addeddmg); komento.Parameters.AddWithValue("@def", glove.Def); komento.Parameters.AddWithValue("@hp", glove.Hp); komento.Parameters.AddWithValue("@incdef", glove.Increaseddef); komento.Parameters.AddWithValue("@lifeleech", glove.Lifeleech); komento.Parameters.AddWithValue("@itemtype", "gloves"); komento.Parameters.AddWithValue("@equiped", glove.Equiped); komento.ExecuteNonQuery(); }
private void Naytaglovet(Gloves glove, ComboBox sender) { // näytetään valittu esine if (glove.Accuracy > 0) { TBitem.Text += "Accuracy: " + glove.Accuracy; } if (glove.Def > 0) { TBitem.Text += Environment.NewLine + "Defence: " + glove.Def * (1 + glove.Increaseddef); } if (glove.Hp > 0) { TBitem.Text += Environment.NewLine + "HP: " + glove.Hp; } if (glove.Lifeleech > 0) { TBitem.Text += Environment.NewLine + "Lifeleech: " + glove.Lifeleech; } if (glove.Addeddmg > 0) { TBitem.Text += Environment.NewLine + "Added damage: " + glove.Addeddmg; } // näytetään pelaajan esine if (player.Gloves.Accuracy > 0) { TBequiped.Text += "Accuracy: " + player.Gloves.Accuracy; } if (player.Gloves.Def > 0) { TBequiped.Text += Environment.NewLine + "Defence: " + player.Gloves.Def * (1 + player.Gloves.Increaseddef); } if (player.Gloves.Hp > 0) { TBequiped.Text += Environment.NewLine + "HP: " + player.Gloves.Hp; } if (player.Gloves.Lifeleech > 0) { TBequiped.Text += Environment.NewLine + "Lifeleech: " + player.Gloves.Lifeleech; } if (player.Gloves.Addeddmg > 0) { TBequiped.Text += Environment.NewLine + "Added damage: " + player.Gloves.Addeddmg; } }
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); }