Exemple #1
0
        public HomeMercatoAdmin(Lega legaPass, Squadra squadra)
        {
            InitializeComponent();
            this.lega                = legaPass;
            this.squadra             = squadra;
            this.mercato             = lega.MercatoAttivo;
            textBoxCrediti.Text      = "" + lega.SquadraAdmin.CreditiResidui;
            buttonCrea.Enabled       = false;
            buttonPartecipa.Enabled  = false;
            textBoxGiocatore.Enabled = false;
            textBoxCrediti.Enabled   = false;
            textBoxOfferta.Enabled   = false;
            if (lega.SquadraAdmin.Giocatori.Count != 0)
            {
                foreach (Giocatore g in lega.SquadraAdmin.Giocatori)
                {
                    listBoxAcquisti.Items.Add(g.Nome.ToString());
                }
            }

            if (lega.MercatoAttivo.AstaAttiva != null)
            {
                textBoxGiocatore.Text = lega.MercatoAttivo.AstaAttiva.Giocatore.Nome;
                textBoxOfferta.Text   = "" + lega.MercatoAttivo.AstaAttiva.UltimaOfferta;
            }

            ServerLegaSoapClient myGestioneAdminController = new ServerLegaSoapClient();
            Turno result = new Turno();

            result = myGestioneAdminController.GestisciAsta(lega, squadra);
            if (result == null)
            {
                MessageBox.Show("Errore durante la gestione dell'asta.");
            }
            if (result.Ruolo == "FINITO")
            {
                MessageBox.Show("Il mercato è stato completato.");
                new HomeLegaAdmin(lega).Show();
            }
            if (result.Ruolo == "ALTRI")
            {
                MessageBox.Show("Altri utenti devono finire di fare l'asta.");
                Thread.Sleep(3000);
                result = myGestioneAdminController.GestisciAsta(lega, squadra);
            }

            if (result.Tipo == true)
            {
                labelAttesa.Visible = false;
                MessageBox.Show("E' il tuo turno devi creare una asta.");
                buttonCrea.Enabled = true;
            }
            else
            {
                labelAttesa.Visible = false;
                MessageBox.Show("E' il tuo turno devi partecipare ad una asta.");
                buttonPartecipa.Enabled = true;
            }
        }
Exemple #2
0
 public Boolean UniscitiAMercato(Mercato mercato, Squadra squadra)
 {
     if (mercato.Squadre.Contains(squadra))
     {
         return(false);
     }
     return(true);
 }
        public GestioneMercato(Lega legaPass, Squadra squadra)
        {
            InitializeComponent();
            this.lega    = legaPass;
            mercato      = lega.MercatoAttivo;
            this.squadra = squadra;
            buttonVisualizzaReport.Enabled = false;
            buttonCreaPausa.Enabled        = false;
            textBox1.Enabled = false;
            textBox2.Enabled = false;
            textBox3.Enabled = false;
            textBox4.Enabled = false;
            textBox5.Enabled = false;
            textBox6.Enabled = false;
            textBox7.Enabled = false;

            foreach (Squadra s in mercato.Squadre)
            {
                comboBox1.Items.Add(s.Nome);
            }
        }
Exemple #4
0
        public Lega CreaMercato(Lega lega)
        {
            SqlConnection conn = null;

            try
            {
                //JACOPO
                //conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Jacopo\Source\Repos\progettoIngegneriaDelSoftware\MyFantalega\ServerLega\App_Data\DBMyFantalegaJacopo.mdf;Integrated Security=True");
                //LORENZO
                conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Lorenzo\Source\Repos\progettoIngegneriaDelSoftware\MyFantalega\ServerLega\App_Data\DBMyFantalegaLori.mdf;Integrated Security=True");
                //ALAN
                //conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Alan\Documents\universita\terzo anno\secondo semestre\progetto\MyFantalega\ServerLega\App_Data\DBMyFantalega.mdf;Integrated Security=True");
                conn.Open();
                Random  random = new Random();
                int     id     = random.Next(0, 1000);
                Mercato m      = new Mercato();
                m.IdMercato = id;
                //aggiungiamo squadre per l'esposizione del progetto
                //ATTENZIONE: AGGIUNGERE A MANO AL DB NELLA TABELLA UTENTE 3 Utenti con username rispettivamente userMock1, userMock2, userMock3
                m.addSquadra(lega.SquadraAdmin);

                Utente  a1     = new Utente();
                Squadra s1     = new Squadra();
                int     codice = random.Next(0, 9999);
                s1.Nome   = "SquadraMock" + codice;
                s1.Utente = a1;
                String     userMock     = "UserMock" + codice;
                SqlCommand insertUtente = new SqlCommand("INSERT INTO Utente (username, [e-mail] ) VALUES ( '" + userMock + "', '*****@*****.**')", conn);
                insertUtente.ExecuteNonQuery();
                SqlCommand insert = new SqlCommand("INSERT INTO Squadra(nome, creditiResidui, lega, utente) VALUES('" + s1.Nome + "' ," + lega.CreditiInizialiSquadra + ", '" + lega.NomeLega + "' , '" + userMock + "')", conn);
                insert.ExecuteNonQuery();
                m.addSquadra(s1);
                lega.AggiungiSquadra(s1);


                Utente  a2 = new Utente();
                Squadra s2 = new Squadra();
                codice       = random.Next(0, 9999);
                s2.Nome      = "SquadraMock" + codice;
                s2.Utente    = a2;
                userMock     = "UserMock" + codice;
                insertUtente = new SqlCommand("INSERT INTO Utente (username, [e-mail] ) VALUES ( '" + userMock + "', '*****@*****.**')", conn);
                insertUtente.ExecuteNonQuery();
                insert = new SqlCommand("INSERT INTO Squadra(nome, creditiResidui, lega, utente) VALUES('" + s2.Nome + "' ," + lega.CreditiInizialiSquadra + ", '" + lega.NomeLega + "' , '" + userMock + "')", conn);
                insert.ExecuteNonQuery();
                m.addSquadra(s2);
                lega.AggiungiSquadra(s2);


                Utente  a3 = new Utente();
                Squadra s3 = new Squadra();
                codice       = random.Next(0, 9999);
                s3.Nome      = "SquadraMock" + codice;
                s3.Utente    = a3;
                userMock     = "UserMock" + codice;
                insertUtente = new SqlCommand("INSERT INTO Utente (username, [e-mail] ) VALUES ( '" + userMock + "', '*****@*****.**')", conn);
                insertUtente.ExecuteNonQuery();
                insert = new SqlCommand("INSERT INTO Squadra(nome, creditiResidui, lega, utente) VALUES('" + s3.Nome + "' ," + lega.CreditiInizialiSquadra + ", '" + lega.NomeLega + "' , '" + userMock + "')", conn);
                insert.ExecuteNonQuery();
                m.addSquadra(s3);
                lega.AggiungiSquadra(s3);


                /*
                 * m.addSquadra( new Squadra("Foizasteam", lega, new Utente()));
                 * m.addSquadra( new Squadra("TagliesterUnited", lega, new Utente()));
                 * m.addSquadra( new Squadra("TaglionsporKulubu", lega, new Utente()));
                 * m.addSquadra( new Squadra("Stefanese1997", lega, new Utente()));
                 * m.addSquadra( new Squadra("DeportivoAperitivo", lega, new Utente()));
                 * m.addSquadra( new Squadra("CRFantasia7", lega, new Utente()));
                 * m.addSquadra( new Squadra("MercedesAMG", lega, new Utente()));
                 * m.addSquadra( new Squadra("SanGallo", lega, new Utente()));
                 */
                lega.MercatoAttivo = m;
                return(lega);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                lega.MercatoAttivo = null;
                return(lega);
            }
            finally
            {
                conn.Close();
            }
        }
Exemple #5
0
        public Lega ChiudiMercato(Mercato mercato, Lega lega)
        {
            IGestioneMercatoController gestioneMercatoController = new GestioneMercatoController();

            return(gestioneMercatoController.ChiudiMercato(mercato, lega));
        }
Exemple #6
0
        public Boolean uniscitiAMercato(Mercato mercato, Squadra squadra)
        {
            IGestioneUtenteController gestioneUtenteController = new GestioneUtenteController();

            return(gestioneUtenteController.UniscitiAMercato(mercato, squadra));
        }
Exemple #7
0
        public Turno GestisciAsta(Lega lega, Squadra squadra)
        {
            Boolean        por = true;
            Boolean        dif = true;
            Boolean        cen = true;
            Boolean        att = true;
            String         ruolo;
            Turno          turno         = new Turno();
            Mercato        mercatoAttivo = lega.MercatoAttivo;
            List <Squadra> squadre       = lega.Squadre;

            if (mercatoAttivo.AstaAttiva == null)
            {
                //foreach (Squadra s in _lega.Squadre)
                //per la presentazione sarà sempre la squadra admin a chiamare il giocatore
                {
                    if (!squadra.VerificaReparto("POR", lega))
                    {
                        por = false;
                    }
                    if (!squadra.VerificaReparto("DIF", lega))
                    {
                        dif = false;
                    }
                    if (!squadra.VerificaReparto("CEN", lega))
                    {
                        cen = false;
                    }
                    if (!squadra.VerificaReparto("ATT", lega))
                    {
                        att = false;
                    }
                }
                if (por == false)
                {
                    ruolo = "POR";
                }
                else if (dif == false)
                {
                    ruolo = "DIF";
                }
                else if (cen == false)
                {
                    ruolo = "CEN";
                }
                else if (att == false)
                {
                    ruolo = "ATT";
                }
                else
                {
                    ruolo = "FINITO";
                }
                return(AssegnaTurnoChiamata(turno, ruolo));
            }
            else
            {
                ruolo = lega.MercatoAttivo.AstaAttiva.Giocatore.Ruolo;
                if (squadra.VerificaReparto(ruolo, lega))
                {
                    ruolo = "ALTRI";
                    foreach (Squadra s in lega.MercatoAttivo.AstaAttiva.Squadre)
                    {
                        if (!s.Equals(squadra))
                        {
                            while (lega.MercatoAttivo.AstaAttiva == null)
                            {
                                int    result;
                                Random r = new Random();
                                result = r.Next(0, 1);
                                if (result == 0)
                                {
                                    lega = AbbandonaMock(s, lega);
                                }
                                else
                                {
                                    lega = RialzaMock(s, lega);
                                }
                            }
                        }
                    }
                }
                return(AssegnaTurnoAsta(turno, ruolo));
            }
        }
 public Lega ChiudiMercato(Mercato mercato, Lega lega)
 {
     lega.MercatoAttivo = null;
     return(lega);
 }