public PositiveQualities(Character charpass, ListBox qualpass, CharUpdater charupdaterpass)
        {
            InitializeComponent();

            character = charpass;
            quallist = qualpass;
            charupdater = charupdaterpass;

            character.RetrieveQualityList(PQualitiesList,character.listOfUnselectedPositiveQualities);
        }
 public void LoadButton_Click(object sender, EventArgs e)
 {
     loadCharacter.ShowDialog();
     string filename = loadCharacter.FileName;
     character = character.LoadCharacter(character, filename);
     newChar.LoadRace(character.race);
     this.PopulateValues();
     character.RetrieveQualityList(QualitiesSelected, character.listOfSelectedPositiveQualities);
 }
 public void SetParamCharacter(Character newChar, MaskedTextBox buildP)
 {
     character = newChar;
     bp = buildP;
     maxReached = false;
 }
 public void StoreValues(Character character, NewCharacter newchar)
 {
     switch(character.race)
     {
         case "Human":
             humanAgility = character.agility;
             humanStrength = character.strength;
             humanBody = character.body;
             humanReaction = character.reaction;
             humanLogic = character.logic;
             humanCharisma = character.charisma;
             humanWillpower = character.willpower;
             humanIntuition = character.intuition;
             humanEdge = character.edge;
             humanAttributeAccum = character.attributeAccum;
             humanAttributeCost = character.AttributeRaceSwitch(newchar, character);
             character.BuildPointCost(character, humanAttributeCost, false, false);
             humanAttributeMax = character.attributeMax;
             humanSwitch = true;
             break;
         case "Ork":
             orkAgility = character.agility;
             orkStrength = character.strength;
             orkBody = character.body;
             orkReaction = character.reaction;
             orkLogic = character.logic;
             orkCharisma = character.charisma;
             orkWillpower = character.willpower;
             orkIntuition = character.intuition;
             orkEdge = character.edge;
             orkAttributeAccum = character.attributeAccum;
             orkAttributeCost = character.AttributeRaceSwitch(newchar, character);
             character.BuildPointCost(character, orkAttributeCost, false, false);
             orkAttributeMax = character.attributeMax;
             orkSwitch = true;
             break;
         case "Dwarf":
             dwarfAgility = character.agility;
             dwarfStrength = character.strength;
             dwarfBody = character.body;
             dwarfReaction = character.reaction;
             dwarfLogic = character.logic;
             dwarfCharisma = character.charisma;
             dwarfWillpower = character.willpower;
             dwarfIntuition = character.intuition;
             dwarfEdge = character.edge;
             dwarfAttributeAccum = character.attributeAccum;
             dwarfAttributeCost = character.AttributeRaceSwitch(newchar, character);
             character.BuildPointCost(character, dwarfAttributeCost, false, false);
             dwarfAttributeMax = character.attributeMax;
             dwarfSwitch = true;
             break;
         case "Elf":
             elfAgility = character.agility;
             elfStrength = character.strength;
             elfBody = character.body;
             elfReaction = character.reaction;
             elfLogic = character.logic;
             elfCharisma = character.charisma;
             elfWillpower = character.willpower;
             elfIntuition = character.intuition;
             elfEdge = character.edge;
             elfAttributeAccum = character.attributeAccum;
             elfAttributeCost = character.AttributeRaceSwitch(newchar, character);
             character.BuildPointCost(character, elfAttributeCost, false, false);
             elfAttributeMax = character.attributeMax;
             elfSwitch = true;
             break;
         case "Troll":
             trollAgility = character.agility;
             trollStrength = character.strength;
             trollBody = character.body;
             trollReaction = character.reaction;
             trollLogic = character.logic;
             trollCharisma = character.charisma;
             trollWillpower = character.willpower;
             trollIntuition = character.intuition;
             trollEdge = character.edge;
             trollAttributeAccum = character.attributeAccum;
             trollAttributeCost = character.AttributeRaceSwitch(newchar, character);
             character.BuildPointCost(character, trollAttributeCost, false, false);
             trollAttributeMax = character.attributeMax;
             trollSwitch = true;
             break;
         default: break;
     }
 }
 public void GetRaceValues(Character character)
 {
     switch (character.race)
     {
         case "Human":
             character.agility = humanAgility;
             character.body = humanBody;
             character.strength = humanStrength;
             character.reaction = humanReaction;
             character.logic = humanLogic;
             character.charisma = humanCharisma;
             character.willpower = humanWillpower;
             character.intuition = humanIntuition;
             character.edge = humanEdge;
             character.attributeMax = humanAttributeMax;
             character.attributeAccum = humanAttributeAccum;
             character.BuildPointCost(character, humanAttributeCost, true, false);
             break;
         case "Ork": character.agility = orkAgility;
             character.body = orkBody;
             character.strength = orkStrength;
             character.reaction = orkReaction;
             character.logic = orkLogic;
             character.charisma = orkCharisma;
             character.willpower = orkWillpower;
             character.intuition = orkIntuition;
             character.edge = orkEdge;
             character.attributeMax = orkAttributeMax;
             character.attributeAccum = orkAttributeAccum;
             character.BuildPointCost(character, orkAttributeCost, true, false);
             break;
         case "Dwarf":
             character.agility   =   dwarfAgility;
             character.body      =   dwarfBody;
             character.strength  =   dwarfStrength;
             character.reaction  =   dwarfReaction;
             character.logic     =   dwarfLogic;
             character.charisma  =   dwarfCharisma;
             character.willpower =   dwarfWillpower;
             character.intuition =   dwarfIntuition;
             character.edge      =   dwarfEdge;
             character.attributeMax = dwarfAttributeMax;
             character.attributeAccum = dwarfAttributeAccum;
             character.BuildPointCost(character, orkAttributeCost, true, false);
             break;
         case "Elf":
             character.agility = elfAgility;
             character.body = elfBody;
             character.strength = elfStrength;
             character.reaction = elfReaction;
             character.logic = elfLogic;
             character.charisma = elfCharisma;
             character.willpower = elfWillpower;
             character.intuition = elfIntuition;
             character.edge = elfEdge;
             character.attributeMax = elfAttributeMax;
             character.attributeAccum = elfAttributeAccum;
             character.BuildPointCost(character, elfAttributeCost, true, false);
             break;
         case "Troll":
             character.agility   =   trollAgility;
             character.body      =   trollBody;
             character.strength  =   trollStrength;
             character.reaction  =   trollReaction;
             character.logic     =   trollLogic;
             character.charisma  =   trollCharisma;
             character.willpower =   trollWillpower;
             character.intuition =   trollIntuition;
             character.edge      =   trollEdge;
             character.attributeMax = trollAttributeMax;
             character.attributeAccum = trollAttributeAccum;
             character.BuildPointCost(character, trollAttributeCost, true, false);
             break;
         default: break;
     }
 }
 //serialize to XML
 public void SaveCharacter(Character character, String filename)
 {
     String fileNamed = filename;
     XmlSerializer ser = new XmlSerializer(typeof(Character));
     StreamWriter streamy = new StreamWriter(fileNamed);
     ser.Serialize(streamy, character);
     streamy.Close();
 }
 //deserialize from XML
 public Character LoadCharacter(Character character, String filename)
 {
     String fileNamed = filename;
     XmlSerializer reader = new XmlSerializer(typeof(Character));
     StreamReader file = new StreamReader(fileNamed);
     character = (Character)reader.Deserialize(file);
     return character;
 }
        //updates total buildpoints based on action made, true = spend points, false = acquire points
        //additionally tests for requirements that 0 buildpoints returns an error and spending > 200 buildpoints on attributes is an error
        public int BuildPointCost(Character character, int cost, bool trueIsSubtract, bool isAttribute = false)
        {
            if (trueIsSubtract == true && isAttribute == false)
            {
                buildPoints = character.buildPoints - cost;
                return buildPoints;
            }
            else if (trueIsSubtract == true & isAttribute == true)
            {
                attributeAccum = character.attributeAccum - cost;
                character.buildPoints = character.buildPoints - cost;
                return attributeAccum;

            }
            else if (trueIsSubtract == false & isAttribute == true)
            {
                character.buildPoints = character.buildPoints + cost;
                character.attributeAccum = character.attributeAccum + cost;
            }
            else
            {
                character.buildPoints = character.buildPoints + cost;
                return character.buildPoints;
            }
            return buildPoints;
        }
        //calculates refund cost of attributes upon race switch
        public int AttributeRaceSwitch(NewCharacter newchar, Character character)
        {
            int refundAgility, refundStrength, refundReaction, refundBody, refundLogic, refundCharisma, refundIntuition, refundWillpower, refundEdge;
            if (newchar.created == true)
            {
                if (character.agility != newchar.agility[1])
                {
                    refundAgility = (character.agility - newchar.agility[0]) * 10;
                }
                else
                {
                    character.agility = character.agility - 1;
                    refundAgility = ((character.agility - newchar.agility[0]) * 10) + 25;
                }

                if (character.strength != newchar.strength[1])
                {
                    refundStrength = (character.strength - newchar.strength[0]) * 10;
                }
                else
                {
                    character.strength = character.strength - 1;
                    refundStrength = ((character.strength - newchar.strength[0]) * 10) + 25;
                }

                if (character.reaction != newchar.reaction[1])
                {
                    refundReaction = (character.reaction - newchar.reaction[0]) * 10;
                }
                else
                {
                    character.reaction = character.reaction - 1;
                    refundReaction = ((character.reaction - newchar.reaction[0]) * 10) + 25;
                }

                if (character.body != newchar.body[1])
                {
                    refundBody = (character.body - newchar.body[0]) * 10;
                }
                else
                {
                    character.body = character.body - 1;
                    refundBody = ((character.body - newchar.body[0]) * 10) + 25;
                }

                if (character.logic != newchar.logic[1])
                {
                    refundLogic = (character.logic - newchar.logic[0]) * 10;
                }
                else
                {
                    character.logic = character.logic - 1;
                    refundLogic = ((character.logic - newchar.logic[0]) * 10) + 25;
                }

                if (character.charisma != newchar.charisma[1])
                {
                    refundCharisma = (character.charisma - newchar.charisma[0]) * 10;
                }
                else
                {
                    character.charisma = character.charisma - 1;
                    refundCharisma = ((character.charisma - newchar.charisma[0]) * 10) + 25;
                }

                if (character.intuition != newchar.intuition[1])
                {
                    refundIntuition = (character.intuition - newchar.intuition[0]) * 10;
                }
                else
                {
                    character.intuition = character.intuition - 1;
                    refundIntuition = ((character.intuition - newchar.intuition[0]) * 10) + 25;
                }

                if (character.willpower != newchar.willpower[1])
                {
                    refundWillpower = (character.willpower - newchar.willpower[0]) * 10;
                }
                else
                {
                    character.willpower = character.willpower - 1;
                    refundWillpower = ((character.willpower - newchar.willpower[0]) * 10) + 25;
                }

                if (character.edge != newchar.edge[1])
                {
                    refundEdge = (character.edge - newchar.edge[0]) * 10;
                }
                else
                {
                    character.edge = character.edge - 1;
                    refundEdge = ((character.edge - newchar.edge[0]) * 10) + 25;
                }
            }
            else
            {
                refundAgility = 0;
                refundStrength = 0;
                refundReaction = 0;
                refundBody = 0;
                refundLogic = 0;
                refundCharisma = 0;
                refundIntuition = 0;
                refundWillpower = 0;
                refundEdge = 0;
            }
            return (refundAgility + refundStrength + refundReaction + refundBody + refundLogic + refundCharisma +
                refundLogic + refundIntuition + refundWillpower + refundEdge + newchar.bp);
        }