using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;

namespace FF12RandoJobGUI
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //generate random jobs
            vj1.Text = ReturnJob(SelectJobs(0));
            baj1.Text = ReturnJob(SelectJobs(0));
            fj1.Text = ReturnJob(SelectJobs(0));
            basj1.Text = ReturnJob(SelectJobs(0));
            aj1.Text = ReturnJob(SelectJobs(0));
            pj1.Text = ReturnJob(SelectJobs(0));
            button2.Enabled = true;

            for (int i = 0; i <= 5; i++)
            {
                switch (i)
                {
                    case 0:
                        while (vj1.Text == vj2.Text)
                        {
                            vj1.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                    case 1:
                        while (baj1.Text == baj2.Text)
                        {
                            baj1.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                    case 2:
                        while (fj1.Text == fj2.Text)
                        {
                            fj1.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                    case 3:
                        while (basj1.Text == basj2.Text)
                        {
                            basj1.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                    case 4:
                        while (aj1.Text == aj2.Text)
                        {
                            aj1.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                    case 5:
                        while (pj1.Text == pj2.Text)
                        {
                            pj1.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                }

            }
        }

        private static int SelectJobs(int Selection)
        {
            //int Selection = 0;
            Thread.Sleep(40);
            Random rnd = new Random((int)DateTime.Now.Ticks);
            int Selected = rnd.Next(1, 12);
            while (Selected == Selection)
            {
                Selected = rnd.Next(1, 12);
            }

            return Selected;
        }

        private static string ReturnJob(int Selection)
        {
            switch (Selection)
            {
                case 1:
                    return "Uhlan (Taurus)         ";
                case 2:
                    return "Bushi (Aquarius)       ";
                case 3:
                    return "Machinist (Gemini)     ";
                case 4:
                    return "Shikari (Pisces)       ";
                case 5:
                    return "White Mage (Aries)     ";
                case 6:
                    return "Red Battlemage (Cancer)";
                case 7:
                    return "Monk (Virgo)           ";
                case 8:
                    return "Foebreaker (Scorpio)   ";
                case 9:
                    return "Archer (Sagittarius)   ";
                case 10:
                    return "Knight (Leo)           ";
                case 11:
                    return "Time Battlemage (Libra)";
                case 12:
                    return "Black Mage (Capricorn) ";
            }
            return "None";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            vj2.Text = ReturnJob(SelectJobs(0));
            baj2.Text = ReturnJob(SelectJobs(0));
            fj2.Text = ReturnJob(SelectJobs(0));
            basj2.Text = ReturnJob(SelectJobs(0));
            aj2.Text = ReturnJob(SelectJobs(0));
            pj2.Text = ReturnJob(SelectJobs(0));

            //make sure none of them are equal to their current values.
            for (int i = 0; i <= 5; i++)
            {
                switch (i)
                {
                    case 0:
                        while (vj1.Text == vj2.Text)
                        {
                            vj2.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                    case 1:
                        while (baj1.Text == baj2.Text)
                        {
                            baj2.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                    case 2:
                        while (fj1.Text == fj2.Text)
                        {
                            fj2.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                    case 3:
                        while (basj1.Text == basj2.Text)
                        {
                            basj2.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                    case 4:
                        while (aj1.Text == aj2.Text)
                        {
                            aj2.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                    case 5:
                        while (pj1.Text == pj2.Text)
                        {
                            pj2.Text = ReturnJob(SelectJobs(0));
                        }
                        break;
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(
               "Character :          Job1           :        Job2" + System.Environment.NewLine +
               "Vaan      : " + vj1.Text + " : " + vj2.Text + System.Environment.NewLine +
               "Balthier  : " + baj1.Text + " : " + baj2.Text + System.Environment.NewLine +
               "Fran      : " + fj1.Text + " : " + fj2.Text + System.Environment.NewLine +
               "Basch     : " + basj1.Text + " : " + basj2.Text + System.Environment.NewLine +
               "Ashe      : " + aj1.Text + " : " + aj2.Text + System.Environment.NewLine +
               "Penelo    : " + pj1.Text + " : " + pj2.Text + System.Environment.NewLine +
               System.Environment.NewLine +
               "Coded by Ryubasteon, for Neko. Enjoy!");
        }
    }
}
