private Fighter BuildFighter() { Fighter newFighter; string errorMessage = ""; bool errorFlag = false; string name = nameBox.Text; if (name == "") { errorMessage += "Fighter must have a name."; errorFlag = true; } int initBonus = 0; try { initBonus = Int32.Parse(InitBox.Text); } catch { errorMessage += "\nInitiative bonus must be a number."; errorFlag = true; } if (editMode) { newFighter = editFighter; newFighter.Name = name; newFighter.InitBonus = initBonus; } else { newFighter = new Fighter(name, initBonus, false); } newFighter.Notes = bioBox.Text; int HP = 0; if (formulaButton.Checked) { HP = rollHP(); int HPMult = 0; int HPDieType = 0; int HPAdd = 0; try { HPMult = Int32.Parse(multBox.Text); HPAdd = Int32.Parse(addBox.Text); } catch { errorMessage += "\nBad HP formula."; errorFlag = true; } switch (dBox.SelectedIndex) { case 0: HPDieType = 4; break; case 1: HPDieType = 6; break; case 2: HPDieType = 8; break; case 3: HPDieType = 10; break; default: HPDieType = 12; break; } newFighter.HPDieType = HPDieType; newFighter.HPMult = HPMult; newFighter.HPAdd = HPAdd; newFighter.HP = HP; } else { try { int HPMult = 0; int HPDieType = 0; int HPAdd = 0; try { HPMult = Int32.Parse(multBox.Text); HPAdd = Int32.Parse(addBox.Text); switch (dBox.SelectedIndex) { case 0: HPDieType = 4; break; case 1: HPDieType = 6; break; case 2: HPDieType = 8; break; case 3: HPDieType = 10; break; default: HPDieType = 12; break; } newFighter.HPDieType = HPDieType; } catch { Console.WriteLine("No valid HP formula found."); } HP = Int32.Parse(HPValBox.Text); if (HP < 0) { errorFlag = true; errorMessage += "\nHP cannot be less than 0"; } newFighter.HP = HP; } catch { errorFlag = true; errorMessage += "\nInvalid HP value"; } } if (!editMode) { newFighter.MaxHP = HP; } try { newFighter.AC = Int32.Parse(ACValBox.Text); newFighter.FlatFootedAC = Int32.Parse(FFBox.Text); newFighter.TouchAC = Int32.Parse(touchBox.Text); newFighter.CMB = Int32.Parse(CMBBox.Text); newFighter.CMD = Int32.Parse(CMDBox.Text); newFighter.Fort.total = Int32.Parse(fortBox.Text); newFighter.Reflex.total = Int32.Parse(refBox.Text); newFighter.Will.total = Int32.Parse(willBox.Text); newFighter.SpellResist = Int32.Parse(srBox.Text); newFighter.DamageReduce = Int32.Parse(drBox.Text); int str = 0; int dex = 0; int con = 0; int intel = 0; int wis = 0; int cha = 0; try { str = Int32.Parse(strBox.Text); dex = Int32.Parse(dexBox.Text); con = Int32.Parse(conBox.Text); intel = Int32.Parse(intBox.Text); wis = Int32.Parse(wisBox.Text); cha = Int32.Parse(chaBox.Text); } catch { errorFlag = true; errorMessage += "\nOne or more ability scores is not valid"; } newFighter.Str = str; newFighter.Dex = dex; newFighter.Con = con; newFighter.Int = intel; newFighter.Wis = wis; newFighter.Cha = cha; } catch { errorMessage += "\nPlease enter numerical values for all stats"; errorFlag = true; } newFighter.attacks = this.attacks; newFighter.skills = this.skillList; if (errorFlag) { MessageBox.Show(errorMessage, "Error!"); return(null); } else { return(newFighter); } }
private void Insert(Fighter newFighter) { addFighters.Add(newFighter); }
private void Save(Fighter newFighter) { }
public void SetActiveFighter(Fighter active) { activeFighter = active; }
public SkillsTab() { InitializeComponent(); activeFighter = null; }
private void button1_Click(object sender, EventArgs e) { bool special = false; Fighter victim = null; if (targetBox.SelectedIndex < 3) { special = true; } else { victim = PCs.ElementAt(targetBox.SelectedIndex - 3); } bool errorFlag = false; string errorMessage = ""; string name = ""; int duration = 0; string description = ""; if (statusBox.Text == "") { errorFlag = true; errorMessage += "Status must have a name. \n"; } else { name = statusBox.Text; } try { duration = Int32.Parse(turnsBox.Text); if (duration <= 0) { errorFlag = true; errorMessage += "Duration must be at least 1 turn. \n"; } } catch { errorFlag = true; errorMessage += "Duration must be a number"; } description = effectsBox.Text; if (errorFlag) { MessageBox.Show(errorMessage, "Uh-oh"); } else { if (special) { switch (targetBox.SelectedIndex) { case 0: { foreach (Fighter f in PCs) { Status nStatus = new Status(name, duration); nStatus.Description = description; nStatus.SetTarget(f); f.StatusEffects.Add(nStatus); sendingForm.WriteToLog(f.Name + " was afflicted with " + nStatus.Name + "! Duration: " + nStatus.Turns + " turns. Effect: " + nStatus.Description); } this.Close(); break; } case 1: { foreach (Fighter f in PCs) { if (f.isPC) { Status nStatus = new Status(name, duration); nStatus.Description = description; nStatus.SetTarget(f); f.StatusEffects.Add(nStatus); sendingForm.WriteToLog(f.Name + " was afflicted with " + nStatus.Name + "! Duration: " + nStatus.Turns + " turns. Effect: " + nStatus.Description); } } this.Close(); break; } default: { { foreach (Fighter f in PCs) { if (!f.isPC) { Status nStatus = new Status(name, duration); nStatus.Description = description; nStatus.SetTarget(f); f.StatusEffects.Add(nStatus); sendingForm.WriteToLog(f.Name + " was afflicted with " + nStatus.Name + "! Duration: " + nStatus.Turns + " turns. Effect: " + nStatus.Description); } } this.Close(); break; } } } } else { Status newStatus = new Status(name, duration); newStatus.Description = description; newStatus.SetTarget(victim); victim.StatusEffects.Add(newStatus); sendingForm.AddStatus(newStatus); sendingForm.WriteToLog(victim.Name + " was afflicted with " + newStatus.Name + "! Duration: " + newStatus.Turns + " turns. Effect: " + newStatus.Description); this.Close(); } } }