Exemplo n.º 1
0
        public void lancerPhaseTournoi(List <int> paris, List <Jedi> jedis_paris)
        {
            foreach (Match match in pool.Matches)
            {
                PlayingMatch pMatch = new PlayingMatch(match);
                while (!pMatch.MatchOver)
                {
                    pMatch.playTurn(pMatch.automaticChoose(), pMatch.automaticChoose());
                }
                for (int i = 0; i < joueurs.Count; i++)
                {
                    if (match.JediVainqueur.Id == jedis_paris[i].Id)
                    {
                        joueurs[i].Score += paris[i];
                    }
                }
            }

            //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;
        }
Exemplo n.º 2
0
        public void playTestMatch()
        {
            Match        match  = data.getAllMatch()[0];
            PlayingMatch pMatch = new PlayingMatch(match);
            int          i      = 0;

            //Description match
            Console.Out.WriteLine("Match Test on {0}", match.Stade.Planete);
            Console.Out.WriteLine(match.Stade.ToString());

            Console.Out.WriteLine("{0} contre {1}", match.Jedi1.Nom, match.Jedi2.Nom);
            Console.Out.WriteLine(match.Jedi1.ToString());
            Console.Out.WriteLine(match.Jedi2.ToString());

            while (!pMatch.MatchOver)
            {
                // Ici utilisation d'un choix Automatique (aléatoire)
                EDefCaracteristique j1Caract = pMatch.automaticChoose();
                EDefCaracteristique j2Caract = pMatch.automaticChoose();

                pMatch.playTurn(j1Caract, j2Caract);
                Console.Out.WriteLine("--------------------------", i);
                Console.Out.WriteLine("Tour {0}", i);
                Console.Out.WriteLine("{0} utilise : {1}", match.Jedi1.Nom, j1Caract.ToString());
                Console.Out.WriteLine("{0} utilise : {1}", match.Jedi2.Nom, j2Caract.ToString());
                Console.Out.WriteLine("{0} inflige {1} degats a {2}", pMatch.WinnerJedi.Nom, pMatch.DamageInflicted, pMatch.LooserJedi.Nom);
                Console.Out.WriteLine("Point de vie restant a {0} : {1}", match.Jedi1.Nom, pMatch.PJedi1.HpJedi);
                Console.Out.WriteLine("Point de vie restant a {0} : {1}", match.Jedi2.Nom, pMatch.PJedi2.HpJedi);
                i++;
            }
            //Resultat
            Console.Out.WriteLine("Match termine, gagnant : {0}", match.JediVainqueur.ToString());
            Console.Out.WriteLine("({0} = {1}, {2} = {3})", match.Jedi1.Nom, match.Jedi1.Id, match.Jedi2.Nom, match.Jedi2.Id);
        }
        public void lancerPhaseTournoi(List<int> paris, List<Jedi> jedis_paris)
        {
            foreach (Match match in pool.Matches)
            {
                PlayingMatch pMatch = new PlayingMatch(match);
                while (!pMatch.MatchOver)
                {
                    pMatch.playTurn(pMatch.automaticChoose(), pMatch.automaticChoose());
                }
                for (int i= 0;i < joueurs.Count;i++)
                {
                    if (match.JediVainqueur.Id == jedis_paris[i].Id)
                    {
                        joueurs[i].Score += paris[i];
                    }
                }
            }

            //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 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 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 playTestMatch()
        {
            Match match = data.getAllMatch()[0];
            PlayingMatch pMatch = new PlayingMatch(match);
            int i = 0;

            //Description match
            Console.Out.WriteLine("Match Test on {0}", match.Stade.Planete);
            Console.Out.WriteLine(match.Stade.ToString());

            Console.Out.WriteLine("{0} contre {1}", match.Jedi1.Nom, match.Jedi2.Nom);
            Console.Out.WriteLine(match.Jedi1.ToString());
            Console.Out.WriteLine(match.Jedi2.ToString());

            while (!pMatch.MatchOver)
            {
                // Ici utilisation d'un choix Automatique (aléatoire)
                EDefCaracteristique j1Caract = pMatch.automaticChoose();
                EDefCaracteristique j2Caract = pMatch.automaticChoose();

                pMatch.playTurn(j1Caract, j2Caract);
                Console.Out.WriteLine("--------------------------", i);
                Console.Out.WriteLine("Tour {0}", i);
                Console.Out.WriteLine("{0} utilise : {1}", match.Jedi1.Nom, j1Caract.ToString());
                Console.Out.WriteLine("{0} utilise : {1}", match.Jedi2.Nom, j2Caract.ToString());
                Console.Out.WriteLine("{0} inflige {1} degats a {2}", pMatch.WinnerJedi.Nom, pMatch.DamageInflicted, pMatch.LooserJedi.Nom);
                Console.Out.WriteLine("Point de vie restant a {0} : {1}", match.Jedi1.Nom, pMatch.PJedi1.HpJedi);
                Console.Out.WriteLine("Point de vie restant a {0} : {1}", match.Jedi2.Nom, pMatch.PJedi2.HpJedi);
                i++;
            }
            //Resultat
            Console.Out.WriteLine("Match termine, gagnant : {0}", match.JediVainqueur.ToString());
            Console.Out.WriteLine("({0} = {1}, {2} = {3})", match.Jedi1.Nom, match.Jedi1.Id, match.Jedi2.Nom, match.Jedi2.Id);
        }
 public Tournoi playTournoi(Tournoi tournoi)
 {
     foreach (Match match in tournoi.Matches)
     {
         PlayingMatch pMatch = new PlayingMatch(match);
         while (!pMatch.MatchOver)
         {
             pMatch.playTurn(pMatch.automaticChoose(), pMatch.automaticChoose());
         }
     }
     return(tournoi.nextPool());
 }
 public void TestTurn_MaitreYodaDefense_PalpatineChance_onEndor()
 {
     Jedi yoda = data.getAllJedi().Find(j => j.Nom == "Maitre Yoda");
     Jedi palpatine = data.getAllJedi().Find(j => j.Nom == "Palpatine");
     Stade stade = data.getAllStade().Find(s => s.Planete == "Endor");
     Match chezLesPetits = new Match(42, yoda, palpatine, EPhaseTournoi.DemiFinale, stade);
     PlayingMatch match = new PlayingMatch(chezLesPetits);
     match.playTurn(EDefCaracteristique.Defense, EDefCaracteristique.Chance);
     Assert.AreEqual(match.WinnerJedi, yoda);
     Assert.AreEqual(match.LooserJedi, palpatine);
     Assert.AreEqual(match.DamageInflicted, 470); //palpatine se prend 470 !
     Assert.AreEqual(match.PJedi1.HpJedi, 30);
     Assert.AreEqual(match.PJedi2.HpJedi, -420);
     Assert.IsTrue(match.MatchOver);
     Assert.AreEqual(chezLesPetits.JediVainqueur, yoda);
 }
 public void TestTurn_DarthVaderForce_LukeDefense_onJakku()
 {
     Jedi papa = data.getAllJedi().Find(j => j.Nom == "Darth Vader");
     Jedi fiston = data.getAllJedi().Find(j => j.Nom == "Luke");
     Stade stade = data.getAllStade().Find(s => s.Planete == "Jakku");
     Match leDuelDelAnnee = new Match(42, papa, fiston, EPhaseTournoi.Finale, stade);
     PlayingMatch match = new PlayingMatch(leDuelDelAnnee);
     match.playTurn(EDefCaracteristique.Force, EDefCaracteristique.Defense);
     Assert.AreEqual(match.WinnerJedi, papa);
     Assert.AreEqual(match.LooserJedi, fiston);
     Assert.AreEqual(match.DamageInflicted, 280); //Le fiston se prend 280 !
     Assert.AreEqual(match.PJedi1.HpJedi, 90);
     Assert.AreEqual(match.PJedi2.HpJedi, -250);
     Assert.IsTrue(match.MatchOver);
     Assert.AreEqual(leDuelDelAnnee.JediVainqueur, papa);
 }
Exemplo n.º 10
0
        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 Tournoi(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]);
        }
Exemplo n.º 11
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]);
             }
         }
     }
 }
Exemplo n.º 12
0
        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]);
        }
Exemplo n.º 13
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]);
             }
         }
     }
 }
 public Tournoi playTournoi(Tournoi tournoi)
 {
     foreach (Match match in tournoi.Matches)
     {
         PlayingMatch pMatch = new PlayingMatch(match);
         while (!pMatch.MatchOver)
         {
             pMatch.playTurn(pMatch.automaticChoose(), pMatch.automaticChoose());
         }
     }
     return tournoi.nextPool();
 }