public BettingManager(BusinessManager businessManager)
        {
            this.businessManager = businessManager;
            rand = new Random();

            joueur1 = new Joueur("player1", 0);
            joueur2 = new Joueur("player2", 0);

            List<Jedi> allJedis = businessManager.getJedis();
            List<Jedi> jedis_to_pool = new List<Jedi>();


            //Creation de la liste a mettre dans la pool
            for (int i = 0; i < 16; i++)
            {
                int index = rand.Next() % allJedis.Count;
                jedis_to_pool.Add(allJedis[index]);
                allJedis.Remove(allJedis[index]);
            }

            jedis = jedis_to_pool;
            pool = new Pool(jedis_to_pool, businessManager.getStades());

        }
        public void lancerPhaseTournoi(int parisJoueur1, Jedi jediParisJoueur1, int parisJoueur2, Jedi jediParisJoueur2)
        {
            foreach (Match match in pool.Matches)
            {
                PlayingMatch pMatch = new PlayingMatch(match);
                while (!pMatch.MatchOver)
                {
                    pMatch.playTurn(pMatch.automaticChoose(), pMatch.automaticChoose());
                }
                if (match.JediVainqueur.Id == jediParisJoueur1.Id)
                {
                    joueur1.Score += parisJoueur1;
                }
                if (match.JediVainqueur.Id == jediParisJoueur2.Id)
                {
                    joueur2.Score += parisJoueur2;
                }
            }

            //Maj bdd
            List<Match> oldMatches = businessManager.getMatches();
            oldMatches.Concat(pool.Matches);
            businessManager.updateMatch(oldMatches);
            pool = pool.nextPool();
            jedis = new List<Jedi>();
            foreach (Match match in pool.Matches)
            {
                jedis.Add(match.Jedi1);
                jedis.Add(match.Jedi2);
            }
            end = pool.PoolVide;
        }
        public void LancerMatch(Jedi jedi, int nbJediDepart)
        {
            end = false;
            win = false;
            playerJedi = jedi;
            
            List<Jedi> jedis = businessManager.getJedis();
            Jedi jediToRemove = jedis.Find(x => x.Id == jedi.Id);
            jedis.Remove(jediToRemove);
            List<Jedi> jedis_to_pool = new List<Jedi>();
            jedis_to_pool.Add(jedi);

            Random rand = new Random();

            //Creation de la liste a mettre dans la pool
            for (int i = 0; i < nbJediDepart-1; i++)
            {
                int index = rand.Next() % jedis.Count;
                jedis_to_pool.Add(jedis[index]);
                jedis.Remove(jedis[index]);
            }

            //Premiere pool a jouer
            //Le premier match de la list sera celui du joueur
            pool = new Pool(jedis_to_pool, businessManager.getStades());

            //On joue tout les autres matches
            foreach (Match match in pool.Matches)
            {
                PlayingMatch pMatch = new PlayingMatch(match);
                while (!pMatch.MatchOver)
                {
                    pMatch.playTurn(pMatch.automaticChoose(), pMatch.automaticChoose());
                }
            }
            pool.Matches[0].JediVainqueur = null;
            playerPlayingMatch = new PlayingMatch(pool.Matches[0]);
        }
 private void checkContinue()
 {
     statLastTurn = turn();
     if (playerPlayingMatch.MatchOver)
     {
         if (playerPlayingMatch.Match.JediVainqueur.Id != playerJedi.Id)
         {
             //player loose
             end = true;
             win = false;
         }else{
             //Maj bdd
             List<Match> oldMatches = businessManager.getMatches();
             oldMatches.Concat(pool.Matches);
             businessManager.updateMatch(oldMatches);
             pool = pool.nextPool();
             foreach (Match match in pool.Matches)
             {
                 PlayingMatch pMatch = new PlayingMatch(match);
                 while (!pMatch.MatchOver)
                 {
                     pMatch.playTurn(pMatch.automaticChoose(), pMatch.automaticChoose());
                 }
             }
             if (pool.PoolVide)
             {
                 end = true;
                 win = true;
             }
             else
             {
                 pool.Matches[0].JediVainqueur = null;
                 playerPlayingMatch = new PlayingMatch(pool.Matches[0]);
             }
         }
     }
 }