private void btnHeal_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtBoxHealth.Text)) { int heal = Int32.Parse(txtBoxHealth.Text); Combatants target = (Combatants)dataGridCombat.CurrentRow.DataBoundItem; if ((target.currentHealth + heal) >= target.maxHealth) { target.currentHealth = target.maxHealth; DataRefresh(); } else { target.currentHealth += heal; } DataRefresh(); } }
private void btnDamage_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(txtBoxHealth.Text)) { int dmg = Int32.Parse(txtBoxHealth.Text); Combatants target = (Combatants)dataGridCombat.CurrentRow.DataBoundItem; if ((target.currentHealth - dmg >= 0)) { target.currentHealth -= dmg; DataRefresh(); } else { target.currentHealth = 0; DataRefresh(); } } }
protected void LoadCreatures(List <string> list) { foreach (string i in list) { if (monlist.Any(p => p.name == i)) { var select = monlist.Where(j => j.name == i).FirstOrDefault(); string ACString = select.ac[0].ToString(); string match = Regex.Match(ACString, @"\d+").Value; Combatants comb = new Combatants(); comb.Name = select.name; comb.AC = Int32.Parse(match); comb.maxHealth = select.hp.average; comb.currentHealth = select.hp.average; comb.DexMod = (select.dex - 10) % 2; comb.Initiative = InitiativeRoll(comb.DexMod); combatants.Add(comb); } if (playerlist.Any(p => p.name == i)) { var select = playerlist.Where(j => j.name == i).FirstOrDefault(); Combatants comb = new Combatants(); int ac2 = select.ac; comb.Name = select.name; comb.AC = select.ac; comb.maxHealth = select.hp; comb.currentHealth = select.hp; comb.DexMod = (select.dex - 10) % 2; comb.Initiative = InitiativeRoll(comb.DexMod); combatants.Add(comb); } DataRefresh(); } }