private void BtnAddCharbtnAddChar_Click(object sender, EventArgs e) { if (txtName.Text.Trim() != "") { try { Catalog.Armor armor; List <Catalog.Weapon> weapons = new List <Catalog.Weapon>(); String name = txtName.Text; if (cbWeapon1.SelectedIndex != -1) { weapons.Add((Catalog.Weapon)(((ComboboxItem)cbWeapon1.SelectedItem).Value)); } if (cbWeapon2.SelectedIndex != -1) { //weapons.Add(Program.catalog.findWeapon((String)cbWeapon2.Text)); weapons.Add((Catalog.Weapon)(((ComboboxItem)cbWeapon2.SelectedItem).Value)); } armor = Program.catalog.findArmor((String)cbArmor1.Text); player = new Catalog.PlayerCharacter(name, statRolls, className, raceName, speed, weapons, armor, alignment, equipment, languages, resistances, spellcastingStat, proficiencies, hitDiceSides, savingThrows, traits); Program.storage.addCharacterSheet(player); MessageBox.Show("Success!", "Character Created!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("Error", "Error creating a character. Please try again", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Error: No Name", "Please input a name", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CbCharName_SelectedIndexChanged(object sender, EventArgs e) { ComboboxItem selectedCharacterItem = (ComboboxItem)(cbCharName.SelectedItem); selectedCharacter = (Catalog.PlayerCharacter)selectedCharacterItem.Value; storedWeapons = new List <Catalog.Weapon>(); storedArmor = null; Int16 i = 0; #region Calculate Core Modifiers foreach (TextBox box in statModifierBoxes) { box.Text = selectedCharacter.statMods[i].ToString(); i++; } #endregion i = 0; foreach (TextBox box in coreStatBoxes) { box.Text = selectedCharacter.stats[i].ToString(); i++; } txtRace.Text = selectedCharacter.raceName; txtClass.Text = selectedCharacter.className; txtProf.Text = "2"; txtSpeed.Text = selectedCharacter.speed.ToString(); txtAC.Text = selectedCharacter.ac.ToString(); lblAlignment.Text = selectedCharacter.alignment; txtInit.Text = txtDexMod.Text; txtHP.Text = (selectedCharacter.hitDiceSides + ((selectedCharacter.stats[2] - 10) / 2)).ToString(); if (selectedCharacter.armor != null) { storedArmor = selectedCharacter.armor; txtArmor.Text = storedArmor.name; } else { txtArmor.Text = ""; } chbShield.Checked = selectedCharacter.hasShield; lbWeapons.Items.Clear(); if (selectedCharacter.weapons != null) { foreach (Catalog.Weapon weap in selectedCharacter.weapons) { storedWeapons.Add(weap); lbWeapons.Items.Add($"{weap.quantity} x {weap.name}"); } } else { lbWeapons.Items.Clear(); } txtName.Text = selectedCharacter.name; rtbNotes.Text = selectedCharacter.notes; rtbProficiencies.Text = "PROFICIENCIES\n\n"; try { foreach (String prof in selectedCharacter.proficiencies) { rtbProficiencies.Text += prof + "\n"; } } catch { } rtbTraits.Text = "TRAITS\n\n"; try { foreach (String trait in selectedCharacter.traits) { rtbTraits.Text += trait + "\n"; } } catch { } rtbLanguages.Text = "LANGUAGES\n\n"; try { foreach (String language in selectedCharacter.languages) { rtbLanguages.Text += language + "\n"; } } catch { } rtbEquipment.Text = "EQUIPMENT\n\n"; try { foreach (String equip in selectedCharacter.equipment) { rtbEquipment.Text += equip + "\n"; } } catch { } }
public void addCharacterSheet(Catalog.PlayerCharacter charToAdd) { storedCharacterSheets.Add(charToAdd); }