Пример #1
0
        //event handler for when a user clicks on a servant button in the My Servants tab
        private void servantButtonClickEvent(Object sender, EventArgs e)
        {
            splitContainer1.Panel2.Controls.Clear();                    //clear everything from panel 2

            Servant servant = user.getServant((sender as Button).Text); //get the servant to pull data from

            servantToAdd = servant;

            displayServantData(servant);
        }
Пример #2
0
 //public method for checking if a user already has a specific servant
 public bool hasServant(Servant servant)
 {
     foreach (Servant ser in this.myServants)
     {
         if (ser.getName() == servant.getName())
         {
             return(true);
         }
     }
     return(false);
 }
Пример #3
0
        //when a user clicks this button, a search will happen with the database to find a return a servant
        private void searchButton_Click(object sender, EventArgs e)
        {
            //need to add input error checking before we open a connection to the database

            servantToAdd = controller.getServant(searchBox.Text);
            if (servantToAdd != null)
            {
                addServantErrorLabel.Text = servantToAdd.getName(); //temp printout so I can read the results
            }
            else
            {
                addServantErrorLabel.Text = "Didn't work fam";  //temp printout so I can read the results
            }
        }
Пример #4
0
        //event handler for when a user switches tabs
        private void mainTabControl_SelectedIndexChange(Object sender, EventArgs e)
        {
            switch (mainTabControl.SelectedIndex)
            {
            case 0:
                break;

            case 1:
                //this is where the update for the split panel will go, so that when a user adds a new servant it gets reflected

                //temp thing in order to have stuff to iterate through before I finish the User class
                Servant temp = controller.getServant("Ushiwakamaru");
                user.addServant(temp);
                ;

                updateMyServantListVisuals(user.getAllServants());

                break;
            }
        }
Пример #5
0
        //public method for adding a servant to a users servant list
        public bool addServant(Servant servant)
        {
            if (!hasServant(servant))
            {
                this.myServants.Add(servant);   //add the new servant to the servant list

                //update the user's materials after adding a new servant with potentially new materials needed
                foreach (var mat in servant.getAscMats())
                {
                    addMaterial(mat.Key);
                }
                foreach (var mat in servant.getSkillMats())
                {
                    addMaterial(mat.Key);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
        //private method to display a Servant's data on panel 2 in the "My Servant" tab
        private void displayServantData(Servant servant)
        {
            //set servantMaterialTextBoxes to a new List
            servantMaterialTextBoxes = new List <TextBox>();
            //set servantMaterialIncrementButtons to a new List
            servantMaterialIncrementButtons = new List <Button>();
            //set servantMaterialDecrementButtons to a new List
            servantMaterialDecrementButtons = new List <Button>();
            //set servantMaterials to a new List
            servantMaterials = new List <String>();

            Label serName = new Label();                                                                         //create a label for the servants name

            serName.AutoSize = true;                                                                             //set label autosize to true
            serName.Font     = new Font(serName.Font.FontFamily, serName.Font.Size + 10.0f, serName.Font.Style); //increase the label's font size
            serName.Location = new Point(splitContainer1.Location.X, splitContainer1.Location.Y);                //set the label's location
            serName.Text     = servant.getName();;                                                               //set the label's text to the servant name
            splitContainer1.Panel2.Controls.Add(serName);                                                        //add the label to panel 2's controls

            //base hp, max hp, grail hp
            Label serHPNames = new Label();

            serHPNames.AutoSize = true;
            serHPNames.Font     = new Font(serHPNames.Font.FontFamily, serHPNames.Font.Size + 5.0f, serHPNames.Font.Style);
            serHPNames.Location = new Point(splitContainer1.Location.X + serName.Height + 10, splitContainer1.Location.Y + serName.Height + 10);
            serHPNames.Text     = "";

            //hp numbers
            Label serHPNums = new Label();

            serHPNums.AutoSize  = true;
            serHPNums.Font      = new Font(serHPNums.Font.FontFamily, serHPNums.Font.Size + 5.0f, serHPNums.Font.Style);
            serHPNums.Location  = new Point(splitContainer1.Location.X + serHPNames.Location.X + serHPNames.Width + 20, splitContainer1.Location.Y + serName.Height + 10);
            serHPNums.Text      = "";
            serHPNums.TextAlign = ContentAlignment.TopRight;

            //base atk, max atk, grail atk
            Label serATKNames = new Label();

            serATKNames.AutoSize = true;
            serATKNames.Font     = new Font(serATKNames.Font.FontFamily, serATKNames.Font.Size + 5.0f, serATKNames.Font.Style);
            serATKNames.Location = new Point(splitContainer1.Location.X + serHPNums.Location.X + 100, splitContainer1.Location.Y + serName.Height + 10);
            serATKNames.Text     = "";

            //atk numbers
            Label serATKNums = new Label();

            serATKNums.AutoSize  = true;
            serATKNums.Font      = new Font(serATKNums.Font.FontFamily, serATKNums.Font.Size + 5.0f, serATKNums.Font.Style);
            serATKNums.Location  = new Point(splitContainer1.Location.X + serATKNames.Location.X + serATKNames.Width + 20, splitContainer1.Location.Y + serName.Height + 10);
            serATKNums.Text      = "";
            serATKNums.TextAlign = ContentAlignment.TopRight;

            int counter = 0;

            foreach (var stat in servant.getStats())
            {
                if (counter < 3)
                {
                    serHPNames.Text += stat.Key + ":" + Environment.NewLine;
                    serHPNums.Text  += String.Format("{0:n0}", stat.Value) + Environment.NewLine;
                }
                else
                {
                    serATKNames.Text += stat.Key + ":" + Environment.NewLine;
                    serATKNums.Text  += String.Format("{0:n0}", stat.Value) + Environment.NewLine;
                }
                counter++;
            }
            splitContainer1.Panel2.Controls.Add(serHPNames);
            splitContainer1.Panel2.Controls.Add(serHPNums);
            splitContainer1.Panel2.Controls.Add(serATKNames);
            splitContainer1.Panel2.Controls.Add(serATKNums);

            counter = 0;
            foreach (var mat in servant.getTotalMats())
            {
                //label to display the name of a material
                Label serMatNames = new Label();
                serMatNames.AutoSize = true;
                serMatNames.Font     = new Font(serMatNames.Font.FontFamily, serMatNames.Font.Size + 5.0f, serMatNames.Font.Style);
                serMatNames.Location = new Point(splitContainer1.Location.X + serName.Height + 10, splitContainer1.Location.Y + serHPNames.Height + 65 + (35 * counter));
                serMatNames.Text    += mat.Key + ":";

                //label to display the total number of a material that a servant needs
                Label serMatNums = new Label();
                serMatNums.Width     = 110;
                serMatNums.Font      = new Font(serMatNums.Font.FontFamily, serMatNums.Font.Size + 5.0f, serMatNums.Font.Style);
                serMatNums.Location  = new Point(splitContainer1.Location.X + serMatNames.Location.X + serMatNames.Width + 100, splitContainer1.Location.Y + serHPNames.Height + 65 + (35 * counter));
                serMatNums.TextAlign = ContentAlignment.TopRight;
                serMatNums.Text     += String.Format("{0:n0}", mat.Value);



                //skip the textbox for a servant's QP numbers, it won't be very usable to have a user increment QP by 1 each time
                //      or remember how much they've gone up by an manually type it in
                if (counter != 0)
                {
                    //get the current value of counter to use for the increment and decrement button events
                    int index = counter;

                    //add the material to the servantMaterials List
                    servantMaterials.Add(mat.Key);

                    //textbox to display user entered values for the number of materials used
                    TextBox usedMatBox = new TextBox();
                    usedMatBox.Font      = new Font(usedMatBox.Font.FontFamily, usedMatBox.Font.Size + 5.0f, usedMatBox.Font.Style);
                    usedMatBox.Location  = new Point(splitContainer1.Location.X + serMatNums.Location.X + serMatNums.Width + 40, splitContainer1.Location.Y + serHPNames.Height + 63 + (35 * counter));
                    usedMatBox.TextAlign = HorizontalAlignment.Right;
                    usedMatBox.Text      = String.Format("{0:n0}", servant.getMatCount()[mat.Key]);
                    //add an event to limit textbox character input
                    usedMatBox.KeyPress += servantMaterialTextBox_KeyPress;
                    //add an event to check what text gets put in the textbox
                    usedMatBox.TextChanged += (sender, EventArgs) => { servantMaterialTextBox_TextChanged(sender, EventArgs, index - 1, servant.getName()); };
                    //add an event to highlight all the text in the textbox when selected
                    usedMatBox.Click += servantMaterialTextBox_Selected;

                    Button decrement = new Button();
                    decrement.Width     = usedMatBox.Height;
                    decrement.Height    = usedMatBox.Height;
                    decrement.Location  = new Point(splitContainer1.Location.X + usedMatBox.Location.X + usedMatBox.Width + 10, splitContainer1.Location.Y + serHPNames.Height + 63 + (35 * counter));
                    decrement.Font      = new Font(decrement.Font.FontFamily, decrement.Font.Size + 3.0f, decrement.Font.Style);
                    decrement.TextAlign = ContentAlignment.MiddleCenter;
                    decrement.Text      = "-";
                    //add an event to the decrement button click, pass in counter-1 so we have the index in the List where the button will be stored
                    decrement.Click += (sender, EventArgs) => { servantMaterialDecrementButton_ClickEvent(sender, EventArgs, index - 1, servant.getName()); };

                    //if the user entered material number is less than or equal to zero
                    if (servant.getMatCount()[mat.Key] <= 0)
                    {
                        //disable the decrement button
                        decrement.Enabled = false;
                    }

                    Button increment = new Button();
                    increment.Width     = usedMatBox.Height;
                    increment.Height    = usedMatBox.Height;
                    increment.Location  = new Point(splitContainer1.Location.X + decrement.Location.X + decrement.Width + 5, splitContainer1.Location.Y + serHPNames.Height + 63 + (35 * counter));
                    increment.Font      = new Font(increment.Font.FontFamily, increment.Font.Size + 3.0f, increment.Font.Style);
                    increment.TextAlign = ContentAlignment.MiddleCenter;
                    increment.Text      = "+";
                    //add an event to the increment button click, pass in counter-1 so we have the index in the List where the button will be stored
                    increment.Click += (sender, EventArgs) => { servantMaterialIncrementButton_ClickEvent(sender, EventArgs, index - 1, servant.getName()); };

                    //if the user entered material number is greater than or equal to the max for this servant
                    if (servant.getMatCount()[mat.Key] >= mat.Value)
                    {
                        //disable the increment button
                        increment.Enabled = false;
                    }

                    //add the textbox to the panel controls
                    splitContainer1.Panel2.Controls.Add(usedMatBox);
                    //add the button to the panel controls
                    splitContainer1.Panel2.Controls.Add(decrement);
                    //add the button to the panel controls
                    splitContainer1.Panel2.Controls.Add(increment);

                    //add the textbox to the global textbox list
                    servantMaterialTextBoxes.Add(usedMatBox);
                    //add the button to the global decrement button list
                    servantMaterialDecrementButtons.Add(decrement);
                    //add the button to the global increment button list
                    servantMaterialIncrementButtons.Add(increment);
                }

                //increment the counter
                counter++;

                //adding the labels to the control earlier in the code ruins the layout

                //add the labels to the panel controls
                splitContainer1.Panel2.Controls.Add(serMatNames);
                splitContainer1.Panel2.Controls.Add(serMatNums);
            }
        }