namespace _2024._04._15
{
    public partial class Form1 : Form
    {
        private string word;
        private List<TextBox> TextBoxes;
        private int wrong = 0;
        private int good = 0;
        private string[] words = { "akció", "város", "vidám", "majom", "bárka" };


        public Form1()
        {
            InitializeComponent();
            TextBoxes = new List<TextBox> { Letter1TextBox, Letter2TextBox, Letter3TextBox, Letter4TextBox, Letter5TextBox };

            Random rng = new Random();
            word = words[rng.Next(0, 5)];
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string currentWord = word;
            bool found = false;

            for (int i = 0; i < currentWord.Length; i++)
            {
                if (char.Equals(Convert.ToChar(LetterTextBox.Text), currentWord[i]))
                {
                    TextBoxes[i].Text = LetterTextBox.Text;
                    found = true;
                    good++;
                }

                for (int j = 1; j < 5; j++)
                {
                    if (char.Equals(Convert.ToChar(TextBoxes[0].Text), TextBoxes[j]  {

                    }
                }
            }

            if (good == 5)
            {
                MessageBox.Show("Nyertél!!", "Sikeres!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                LetterTextBox.Enabled = false;
                LetterButton.Enabled = false;
                good = 0;
            }

            if (!found)
            {
                wrong += 1;

                pictureBox1.Image = Image.FromFile($@"E:\Suli\12.b\Programozás (Tusjak Brigitta)\Gyakorlat\Órai\2024. 04. 15\Akasztófa\{wrong}.png");
                //pictureBox1.Image = Image.FromFile(@$"C:\Users\Ádám\Desktop\2024. 04. 15\Akasztófa\{wrong}.png");

                if (wrong == 11)
                {
                    MessageBox.Show("Vesztettél!!", "Sikertelen!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LetterTextBox.Enabled = false;
                    LetterButton.Enabled = false;
                    wrong = 0;

                    for (int i = 0; i < TextBoxes.Count; i++)
                    {
                        TextBoxes[i].Text = Convert.ToString(word[i]);
                    }
                }
            }

            LetterTextBox.Text = "";
        }

        private void RetryButton_Click(object sender, EventArgs e)
        {
            Random rng = new Random();
            word = words[rng.Next(0, 5)];

            LetterTextBox.Enabled = true;
            LetterButton.Enabled = true;

            wrong = 0;

            pictureBox1.Image = null;

            foreach(var i in TextBoxes)
            {
                i.Text = "";
            }
        }
    }
}