Ejemplo n.º 1
0
        private void battleButton_Click(object sender, EventArgs e)
        {
            try
            {
                Battle newBattle = new Battle();
                if (PlayerListBox.SelectedIndex == PlayerListBox2.SelectedIndex)
                {
                    PlayerListBox.ClearSelected();
                    PlayerListBox2.ClearSelected();
                    textBox1.Show();
                    textBox1.Clear();
                    textBox1.AppendText("Players can't be same");
                }
                else
                {
                    newBattle.getResults(newpeeps.peeps[PlayerListBox.SelectedIndex], newpeeps.peeps[PlayerListBox2.SelectedIndex]);

                    string        dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    StringBuilder ns  = new StringBuilder();
                    ns.Append(dir + "\\Player Lists\\person.txt");
                    XmlSerialization.WriteToXmlFile <peopleList>(ns.ToString(), newpeeps);

                    textBox1.Clear();
                    textBox1.AppendText(newpeeps.peeps[PlayerListBox.SelectedIndex].name.ToString() + " after " + "a win now has a rating of: " + newpeeps.peeps[PlayerListBox.SelectedIndex].MMR.ToString());
                    textBox1.AppendText(Environment.NewLine);
                    textBox1.AppendText(Environment.NewLine + newpeeps.peeps[PlayerListBox2.SelectedIndex].name.ToString() + " after a loss now has a rating of: " + newpeeps.peeps[PlayerListBox2.SelectedIndex].MMR.ToString());

                    textBox1.Show();
                }
            }
            catch (IndexOutOfRangeException) { PlayerListBox.SelectedIndex = 0; PlayerListBox2.SelectedIndex = 0; }
            catch (ArgumentOutOfRangeException) { PlayerListBox.SelectedIndex = 0; PlayerListBox2.SelectedIndex = 0; }
        }
Ejemplo n.º 2
0
        private void ViewCurrentButton_Click(object sender, EventArgs e)
        {
            hideComponents();
            textBox1.Show();
            try
            {
                if (newpeeps.peeps.Count < 1)
                {
                    textBox1.Clear();
                    textBox1.Show();
                    textBox1.AppendText("Please load a player list first!");
                }

                else
                {
                    foreach (BasePlayerClass loadPlayer in newpeeps.peeps)
                    {
                        PlayerListBox.Items.Remove(loadPlayer.name);

                        textBox1.AppendText("Name: " + loadPlayer.name.ToString());
                        textBox1.AppendText(Environment.NewLine + "MMR: " + loadPlayer.MMR.ToString());
                        textBox1.AppendText(Environment.NewLine + "Total games played: " + loadPlayer.gamesplayed.ToString());
                        textBox1.AppendText(Environment.NewLine + "Win %  " + loadPlayer.winPercent);
                        textBox1.AppendText(Environment.NewLine);
                        textBox1.AppendText(Environment.NewLine);

                        PlayerListBox.Show();
                        PlayerListBox.ClearSelected();
                        PlayerListBox.Items.Add(loadPlayer.name);
                    }
                }
            }
            catch (ArgumentOutOfRangeException) { }
        }
Ejemplo n.º 3
0
 private void HomeButton_Click(object sender, EventArgs e)
 {
     newPlayerButton.Show();
     removePlayerButton.Show();
     AddResultsButton.Show();
     ViewCurrentButton.Show();
     battleButton.Hide();
     nameLabel.Hide();
     nameTextBox.Hide();
     addPlayerButton.Hide();
     textBox1.Clear();
     textBox1.Hide();
     HomeButton.Hide();
     PlayerListBox.Hide();
     PlayerListBox2.Hide();
     deleteSinglePlayerButton.Hide();
     deleteAllPlayersButton.Hide();
     foreach (BasePlayerClass loadPlayer in newpeeps.peeps)
     {
         PlayerListBox.ClearSelected();
         PlayerListBox2.ClearSelected();
         PlayerListBox2.Items.Clear();
     }
 }