private void saveBtn_Click(object sender, EventArgs e) { PersonLogic personLogic = new PersonLogic(); if (personIDTxtBx.Text == "" || leaderTxtBx.Text == "" || companionTxtBx.Lines.Length == 0) { MessageBox.Show("Please fill out all fields before saving to the database", "Invalid Data"); } else if (!Int32.TryParse(personIDTxtBx.Text, out int result)) { MessageBox.Show("ID must be a number!", "Invalid Data"); } else if (personLogic.GetPerson(result) == null) { MessageBox.Show("Please select a valid person ID", "Invalid Data"); } else { ReadOnlyValues(true); ChangeToEditMode(false); currentAdventure.MainPersonID = result; currentAdventure.LeaderName = leaderTxtBx.Text; currentAdventure.CompanionNames = string.Join(",", companionTxtBx.Lines.ToArray()); currentAdventure.Fatal = fatal.Checked; currentAdventure.Successful = successful.Checked; adventureLogic.UpdateAdventure(); MessageBox.Show("Successfully saved the Role.", "Success!"); } }
//constructors public Dwarf Generate(Random rand, int numberOfPhysical, int numberOfMental, int numberOfMagical = 0) { PersonLogic personLogic = new PersonLogic(); //Person person = Dwarf dwarfPerson = (Dwarf)personLogic.Generate("dwarf", rand, new Dwarf());; dwarfPerson.RaceType = "dwarf"; int index; //set name dwarfPerson.Name = GenerateName(dwarfPerson.Gender, rand); //reset age dwarfPerson.Age = rand.Next(1, MAXAGE); //reset position dwarfPerson.LengthOfRoleOccupancy = rand.Next(1, dwarfPerson.Age); //set DwarfFamily index = rand.Next(0, DwarfGroupOptions.Length); dwarfPerson.DwarfGroup = DwarfGroupOptions[index]; AddDwarf(dwarfPerson); personLogic.GenerateAdventures(dwarfPerson.PersonID, rand.Next(1, 10), rand); return(dwarfPerson); }
public Wizard Generate(Random rand, int numberOfPhysical, int numberOfMagic, int numberOfMental) { PersonLogic personLogic = new PersonLogic(); Wizard wizard = (Wizard)personLogic.Generate("wizard", rand, new Wizard()); wizard.RaceType = "wizard"; int index; //set wizard color index = rand.Next(0, WizardColors.Length); wizard.WizardColor = WizardColors[index]; //set Name wizard.Name = GenerateName(wizard.Gender, rand, wizard.WizardColor); //Generate Magic Type index = rand.Next(0, MagicTypeOptions.Length); wizard.MagicType = MagicTypeOptions[index]; AddWizard(wizard); personLogic.GenerateAdventures(wizard.PersonID, rand.Next(1, 10), rand); return(wizard); }
public Human Generate(Random rand, int numberOfPhysical, int numberOfMental, int numberOfMagical = 0) { PersonLogic personLogic = new PersonLogic(); Human human = (Human)personLogic.Generate("men", rand, new Human()); human.RaceType = "men"; int index; //set name human.Name = GenerateName(human.Gender, rand); //reset age human.Age = rand.Next(1, MAXAGE); //set Position human.LengthOfRoleOccupancy = rand.Next(1, human.Age); //set ancestral line index = rand.Next(0, AncestralLineOptions.Length); human.AncestralLine = AncestralLineOptions[index]; AddHuman(human); personLogic.GenerateAdventures(human.PersonID, rand.Next(1, 10), rand); return(human); }
//constructors public Hobbit Generate(Random rand, int numberOfAbilities, int numberOfMagical = 0, int numberOfMental = 0) { PersonLogic personLogic = new PersonLogic(); Hobbit hobbit = (Hobbit)personLogic.Generate("hobbit", rand, new Hobbit()); hobbit.RaceType = "Hobbit"; int index; //set Name hobbit.Name = GenerateName(hobbit.Gender, rand); //reset age hobbit.Age = rand.Next(1, MAXAGE); //reset position hobbit.LengthOfRoleOccupancy = rand.Next(1, hobbit.Age); //set Home type index = rand.Next(0, HomeTypeOptions.Length); hobbit.HomeType = HomeTypeOptions[index]; //set Booleans hobbit.OwnsOneRing = rand.Next(2) == 1; hobbit.IsAdventurer = rand.Next(2) == 1; AddHobbit(hobbit); personLogic.GenerateAdventures(hobbit.PersonID, rand.Next(1, 10), rand); return(hobbit); }
private void newBtn_Click(object sender, EventArgs e) { PersonLogic personLogic = new PersonLogic(); LocationLogic locationLogic = new LocationLogic(); Random rand = new Random(); currentAdventure = adventureLogic.Generate(rand.Next(1, 20), personLogic.GetRandomID(rand), rand); currentAdventure.Person = personLogic.GetPerson(currentAdventure.MainPersonID); currentAdventure.Location = locationLogic.GetLocation(currentAdventure.WhereToLocationID); Display(); }
private void personIDTxtBx_TextChanged(object sender, EventArgs e) { PersonLogic personLogic = new PersonLogic(); if (Int32.TryParse(personIDTxtBx.Text, out int result)) { Person person = personLogic.GetPerson(result); if (person == null) { personNameLbl.Text = "INVALID"; } else { personNameLbl.Text = person.Name; } } else { MessageBox.Show("This field must be numbers only!", "Invalid Data"); } }
//constructors public Elf Generate(Random rand, int numberOfPhysical, int numberOfMental, int numberOfMagical) { PersonLogic personLogic = new PersonLogic(); Elf elfPerson = (Elf)personLogic.Generate("elf", rand, new Elf()); elfPerson.RaceType = "elf"; int index; //set Elf elfPerson.Name = GenerateName(elfPerson.Gender, rand); //set Elf Type index = rand.Next(0, ElfTypeOptions.Length); elfPerson.ElfType = ElfTypeOptions[index]; //set owns ring of power elfPerson.OwnsRingOfPower = rand.Next(2) == 1; AddElf(elfPerson); personLogic.GenerateAdventures(elfPerson.PersonID, rand.Next(1, 10), rand); return(elfPerson); }