private void button1_Click(object sender, EventArgs e) { DataGridViewRow enemy = enemyDGV.CurrentRow; string enemyString = enemy.Cells[0].Value.ToString(); using (var ctx = new Shadowrun3Context()) { NamedEnemy enemy1 = ctx.NamedEnemys.FirstOrDefault(i => i.NamedEnemyId == enemyString); FormEnemy fe = new FormEnemy(enemy1); fe.Show(); } }
private void updateButton_Click(object sender, EventArgs e) { using (var ctx = new Shadowrun3Context()) { NamedEnemy ne = ctx.NamedEnemys.First(a => a.NamedEnemyId == nameTB.Text); ne.CurrentHP = (int)HPNB.Value; ne.CurrentStun = (int)StunNB.Value; ne.CurrentMatrix = (int)MatrixNB.Value; ne.CurrentEdge = (int)EdgeNB.Value; ne.CurrentAmmo = (int)AmmoNB.Value; ne.CommRating = (int)SysRatingNB.Value; ctx.SaveChanges(); ResetForm(); } }
private void updateButton_Click(object sender, EventArgs e) { using (var ctx = new Shadowrun3Context()) { DataGridViewRow enc = dataGridView1.CurrentRow; string encString = enc.Cells[0].Value.ToString(); Encounter encounter = ctx.Encounters.FirstOrDefault(i => i.EncounterId == encString); string neString = neCB.SelectedValue.ToString(); NamedEnemy ne = ctx.NamedEnemys.FirstOrDefault(i => i.NamedEnemyId == neString); ne.Encounter = encounter; ctx.SaveChanges(); ResetForm(); } }
public FormEnemy(NamedEnemy enemy1) { this.enemy1 = enemy1; InitializeComponent(); }
private void submitSpell_Click(object sender, EventArgs e) { using (var ctx = new Shadowrun3Context()) { try { //Create new named enemy NamedEnemy ne = new NamedEnemy(); ne.NamedEnemyId = nameTB.Text; //Find out the enemy type for the enemy to be based on string etString = enemyTypeCB.Text; EnemyType et = ctx.EnemyTypes.FirstOrDefault(i => i.EnemyTypeId == etString); ne.EnemyType = et; //Work out the starting HP (8 + body/2 rounded up) int body = 0; if (et.Body % 2 == 0) { body = et.Body / 2; } else { body = (et.Body / 2) + 1; } ne.CurrentHP = 8 + body; //Work out the starting stun (8 + will/2 rounded up) int will = 0; if (et.Willpower % 2 == 0) { will = et.Willpower / 2; } else { will = (et.Willpower / 2) + 1; } ne.CurrentStun = 8 + will; //Work out the starting matrix (8 + sys/2 rounded up) int sys = 0; if (et.SystemRating % 2 == 0) { sys = et.SystemRating / 2; } else { sys = (et.SystemRating / 2) + 1; } ne.CurrentMatrix = 8 + sys; //Get the starting edge and comm rating from enemy type ne.CurrentEdge = et.Edge; ne.CommRating = et.SystemRating; //Add the current ammo from user input ne.CurrentAmmo = (int)AmmoNB.Value; //Start the named enemy as alive ne.DeadOrAlive = false; ctx.NamedEnemys.Add(ne); ctx.SaveChanges(); ResetForm(); } catch { MessageBox.Show("That named enemy already exists"); } } }