private void RunPhaseOfTournament(EPhaseTournoi phase) { for (int i = PokemonsRestants.Count - 1; i >= 0; i -= 2) { Match match; if (FastestPokemon(PokemonsRestants[i], PokemonsRestants[i - 1])) { match = RunMatch(PokemonsRestants[i], PokemonsRestants[i - 1], phase); } else { match = RunMatch(PokemonsRestants[i - 1], PokemonsRestants[i], phase); } Matches.Add(match); if (PokemonsRestants[i].ID == match.IdPokemonVainqueur) { PokemonsRestants.RemoveAt(i - 1); } else { PokemonsRestants.RemoveAt(i); } } }
//Obligé de surcharger le constructeur si on veut faire // Match match = new Match(new Pokemon(...), new Pokemon(...)) ? public Match(Pokemon pokemon1, Pokemon pokemon2, Stade stade, EPhaseTournoi phase) : base(pokemon1.Nom.ToString() + " VS " + pokemon2.Nom.ToString()) { PhaseTournoi = phase; Pokemon1 = pokemon1; Pokemon2 = pokemon2; Stade = stade; }
public Match(Tournoi tournoi, EPhaseTournoi phase, Pokemon p1, Pokemon p2) { Tournoi = tournoi; PhaseTournoi = phase; Pokemon1 = p1; Pokemon2 = p2; }
public void TestBDD_AjoutSupprMatch() { List <Match> lm = new List <Match>(data.getAllMatch()); // Création du match int id = 42; Jedi pJedi1 = data.getAllJedi().Find(j => j.Id == 8); Jedi pJedi2 = data.getAllJedi().Find(j => j.Id == 13); EPhaseTournoi phase = EPhaseTournoi.Finale; Stade stade = data.getAllStade().Find(c => c.Id == 5); Match match = new Match(id, pJedi1, pJedi2, phase, stade); // Modifications BDD Assert.IsFalse(data.getAllMatch().Any(m => m.Id == id), "Ce match est déjà présent dans la BDD !"); // On vérifie que le match n'est pas déjà présent dans la BDD lm.Add(match); data.updateMatch(lm); Assert.IsTrue(data.getAllMatch().Any(m => m.Id == id), "Le match n'a pas été ajouté"); // On vérifie que le match a bien été rajouté Assert.AreEqual(data.getAllMatch().Find(m => m.Id == id).Jedi1.Id, pJedi1.Id); Assert.AreEqual(data.getAllMatch().Find(m => m.Id == id).Jedi2.Id, pJedi2.Id); Assert.AreEqual(data.getAllMatch().Find(m => m.Id == id).PhaseTournoi, phase); Assert.AreEqual(data.getAllMatch().Find(m => m.Id == id).Stade.Id, stade.Id); lm.Remove(lm.Find(m => m.Id == id)); data.updateMatch(lm); Assert.IsFalse(data.getAllMatch().Any(m => m.Id == id), "Le match n'a pas été supprimé"); // On vérifie que le match a bien été supprimé }
public Match(Pokemon ppokemon1, Pokemon ppokemon2, EPhaseTournoi pphase = EPhaseTournoi.QuartFinale) { PhaseTournoi = pphase; Pokemon1 = ppokemon1; Pokemon2 = ppokemon2; IdPokemonVainqueur = -1; }
private List <Pokemon> RunPhaseOfTournament(List <Pokemon> pokemons, EPhaseTournoi phase) { for (int i = pokemons.Count - 1; i >= 0; i -= 2) { Match match; if (FasterPokemon(pokemons[i], pokemons[i - 1])) { match = RunMatch(pokemons[i], pokemons[i - 1], phase); } else { match = RunMatch(pokemons[i - 1], pokemons[i], phase); } dalManagerStub.AddMatchToList(match); if (pokemons[i].ID == match.IdPokemonVainqueur) { pokemons.RemoveAt(i - 1); } else { pokemons.RemoveAt(i); } } return(pokemons); }
public Match(int id, Tournoi tournoi, EPhaseTournoi phase, Pokemon p1, Pokemon p2) : base(id) { Tournoi = tournoi; PhaseTournoi = phase; Pokemon1 = p1; Pokemon2 = p2; }
public Match(int idJediVainqueur,Jedi jedi1,Jedi jedi2,EPhaseTournoi phaseTournoi,Stade stade,int id):base(id) { this.idJediVainqueur = 0; this.jedi1 = jedi1; this.jedi2 = jedi2; this.phaseTournoi = phaseTournoi; this.stade = stade; }
public Match(int idWinner, EPhaseTournoi phase, Dresseur d1, Dresseur d2, Stade stade) { IdPokemonVainqueur = idWinner; PhaseTournoi = phase; Dresseur1 = d1; Dresseur2 = d2; Arene = stade; }
public GamePage(Tournoi t, bool b) { InitializeComponent(); m_tournament = t; m_manual = b; m_current_match = 0; m_currentPhase = EPhaseTournoi.HuitiemeFinale; }
public Match(int idJediVainqueur, Jedi jedi1, Jedi jedi2, EPhaseTournoi phaseTournoi, Stade stade, int id) : base(id) { this.idJediVainqueur = 0; this.jedi1 = jedi1; this.jedi2 = jedi2; this.phaseTournoi = phaseTournoi; this.stade = stade; }
public Match(int id, Jedi vainqueur, Jedi jedi1, Jedi jedi2, EPhaseTournoi phaseTournoi, Stade stade) : base(id) { Vainqueur = vainqueur; Jedi1 = jedi1; Jedi2 = jedi2; PhaseTournoi = phaseTournoi; Stade = stade; }
public Match(int id,Jedi vainqueur,Jedi jedi1,Jedi jedi2,EPhaseTournoi phaseTournoi,Stade stade):base(id) { Vainqueur = vainqueur; Jedi1 = jedi1; Jedi2 = jedi2; PhaseTournoi = phaseTournoi; Stade = stade; }
/// <summary> /// Constructeur. /// </summary> /// <param name="id">Id du match.</param> /// <param name="jedi1">Premier jedi concurrent.</param> /// <param name="jedi2">Second jedi concurrent.</param> /// <param name="phase">Phase lors de laquelle se déroule le match.</param> /// <param name="stade">Stade dans lequel se déroule le match.</param> public Match(int id, Jedi jedi1, Jedi jedi2, EPhaseTournoi phase, Stade stade) : base(id) { Jedi1 = jedi1; Jedi2 = jedi2; PhaseTournoi = phase; Stade = stade; IdJediVainqueur = -1; // Initialisation de l'ID à -1 => vainqueur non déterminé }
public MatchWS(int pId, JediWS pJedi1, JediWS pJedi2, JediWS pJediV, StadeWS pStade, EPhaseTournoi pPhase) { this.Id = pId; this.Jedi1 = pJedi1; this.Jedi2 = pJedi2; this.JediVainqueur = pJediV; this.Stade = pStade; this.Phase = (EPhaseTournoiWS)pPhase; }
public Match(int pIdJediVainqueur, Jedi pJedi1, Jedi pJedi2, EPhaseTournoi pPhaseTournoi, Stade pStade, int pID) { ID = pID; IdJediVainqueur = pIdJediVainqueur; Jedi1 = pJedi1; Jedi2 = pJedi2; PhaseTournoi = pPhaseTournoi; Stade = pStade; }
public Match(int id, Jedi jedi1, Jedi jedi2, EPhaseTournoi phaseTournoi, Stade stade, Jedi vainqueur = null) { this.Id = id; this.jedi1 = jedi1; this.jedi2 = jedi2; this.phaseTournoi = phaseTournoi; this.stade = stade; this.jediVainqueur = vainqueur; }
public Match(int pId, Pokemon ppokemon1, Pokemon ppokemon2, Stade pArene, int pIdTournoi, EPhaseTournoi pphase = EPhaseTournoi.QuartFinale) { ID = pId; PhaseTournoi = pphase; Pokemon1 = ppokemon1; Pokemon2 = ppokemon2; Arene = pArene; IdPokemonVainqueur = -1; IdTournoi = pIdTournoi; }
public MatchWCF(Match match) : base(match) { this.jedi1 = new JediWCF(match.Jedi1); this.jedi2 = new JediWCF(match.Jedi2); if (match.JediVainqueur != null) { this.jediVainqueur = new JediWCF(match.JediVainqueur); } this.stade = new StadeWCF(match.Stade); this.phaseTournoi = match.PhaseTournoi; }
public Match(Jedi pJedi1, Jedi pJedi2, EPhaseTournoi pPhaseTournoi, Stade pStade) { countId++; Id = countId; JediVainqueur = null; Jedi1 = pJedi1; Jedi2 = pJedi2; PhaseTournoi = pPhaseTournoi; Stade = pStade; }
public Match(int _id, Jedi pJedi1, Jedi pJedi2, EPhaseTournoi pPhaseTournoi, Stade pStade) : base(_id) { if (_id > countId) { countId = _id; } JediVainqueur = null; Jedi1 = pJedi1; Jedi2 = pJedi2; PhaseTournoi = pPhaseTournoi; Stade = pStade; }
private Pokemon[] JouerPhaseTournoi(Pokemon[] tablpokemon, EPhaseTournoi phase) { Pokemon[] pokevainqueur = new Pokemon[(int)((tablpokemon.Length) / 2)]; for (int i = 0; i < (tablpokemon.Length) / 2; i++) { Stade stade = getRandomStade(); Match match = new Match(tablpokemon[i * 2], tablpokemon[(i * 2) + 1], stade, phase); match.JouerMatch(); Matchs.Add(match); pokevainqueur[i] = match.Vainqueur; } return(pokevainqueur); }
private Match RunMatch(Pokemon pokemon1, Pokemon pokemon2, EPhaseTournoi phase) { Caracteristique oldCaracP1 = new Caracteristique(pokemon1.Caracteristiques); Caracteristique oldCaracP2 = new Caracteristique(pokemon2.Caracteristiques); Match match = new Match(PokemonDataAccessLayerStub.DalManager.LastId, phase, pokemon1, pokemon2); PokemonDataAccessLayerStub.DalManager.LastId++; match.Stade = dalManagerStub.GetAllStades()[rng.Next(0, 6)]; BuffNerfPokemonByStade(pokemon1, match.Stade); BuffNerfPokemonByStade(pokemon2, match.Stade); decimal multiplicatorP1 = GetMultiplicatorBetweenType(pokemon1.Type, pokemon2.Type); decimal multiplicatorP2 = GetMultiplicatorBetweenType(pokemon2.Type, pokemon1.Type); while (pokemon1.Caracteristiques.PV > 0 && pokemon2.Caracteristiques.PV > 0) { if (!EsquiveOrNot(pokemon2)) { pokemon2.Caracteristiques.PV -= (int)Math.Ceiling(multiplicatorP1 * (decimal)pokemon1.Caracteristiques.Attaque / (decimal)pokemon2.Caracteristiques.Defense * 4m); } if (!EsquiveOrNot(pokemon1)) { pokemon1.Caracteristiques.PV -= (int)Math.Ceiling(multiplicatorP2 * (decimal)pokemon2.Caracteristiques.Attaque / (decimal)pokemon1.Caracteristiques.Defense * 4m); } } if (pokemon1.Caracteristiques.PV <= 0 && pokemon2.Caracteristiques.PV <= 0) { match.IdPokemonVainqueur = pokemon1.ID; } else if (pokemon1.Caracteristiques.PV <= 0) { match.IdPokemonVainqueur = pokemon2.ID; } else { match.IdPokemonVainqueur = pokemon1.ID; } pokemon1.Caracteristiques = oldCaracP1; pokemon2.Caracteristiques = oldCaracP2; return(match); }
private Match RunMatch(Pokemon pokemon1, Pokemon pokemon2, EPhaseTournoi phase) { Caracteristique newCaracP1 = new Caracteristique(pokemon1.Caracteristiques); Caracteristique newCaracP2 = new Caracteristique(pokemon2.Caracteristiques); Match match = new Match(this, phase, pokemon1, pokemon2); match.Stade = Stades[rng.Next(0, Stades.Count)]; BuffNerfPokemonByStade(pokemon1.Type, newCaracP1, match.Stade); BuffNerfPokemonByStade(pokemon2.Type, newCaracP2, match.Stade); decimal multiplicatorP1 = GetMultiplicatorBetweenType(pokemon1.Type, pokemon2.Type); decimal multiplicatorP2 = GetMultiplicatorBetweenType(pokemon2.Type, pokemon1.Type); while (newCaracP1.PV > 0 && newCaracP2.PV > 0) { int i = (int)Math.Ceiling(multiplicatorP1 * (decimal)newCaracP1.Attaque / (decimal)newCaracP2.Defense * 4m); int y = (int)Math.Ceiling(multiplicatorP2 * (decimal)newCaracP2.Attaque / (decimal)newCaracP1.Defense * 4m); if (!EsquiveOrNot(pokemon2)) { newCaracP2.PV -= (int)Math.Ceiling(multiplicatorP1 * (decimal)newCaracP1.Attaque / (decimal)newCaracP2.Defense * 4m); } if (!EsquiveOrNot(pokemon1)) { newCaracP1.PV -= (int)Math.Ceiling(multiplicatorP2 * (decimal)newCaracP2.Attaque / (decimal)newCaracP1.Defense * 4m); } } if (newCaracP1.PV <= 0 && newCaracP2.PV <= 0) { match.IdPokemonVainqueur = pokemon1.ID; } else if (newCaracP1.PV <= 0) { match.IdPokemonVainqueur = pokemon2.ID; } else { match.IdPokemonVainqueur = pokemon1.ID; } return(match); }
public Tournoi(List <Jedi> jedis, List <Stade> _stades) { countId++; Id = countId; nom = "TournoiDefault"; stades = _stades; poolVide = false; int nb_jedis = jedis.Count; int matche_a_creer = jedis.Count / 2; Random rand = new Random(); matches = new List <Match>(); switch (nb_jedis) { case 1: poolVide = true; break; case 2: phase = EPhaseTournoi.Finale; break; case 4: phase = EPhaseTournoi.DemiFinale; break; case 8: phase = EPhaseTournoi.QuartFinale; break; case 16: phase = EPhaseTournoi.HuitiemeFinale; break; default: throw new Exception("Nombre de jedi dans le pool incorrecte : " + jedis.Count); } for (int i = 0; i < matche_a_creer && !poolVide; i++) { matches.Add(new Match(jedis[i * 2], jedis[i * 2 + 1], phase, stades[rand.Next() % stades.Count])); } }
public Tournoi(List<Jedi> jedis, List<Stade> _stades) { countId++; Id = countId; nom = "TournoiDefault"; stades = _stades; poolVide = false; int nb_jedis = jedis.Count; int matche_a_creer = jedis.Count / 2; Random rand = new Random(); matches = new List<Match>(); switch (nb_jedis) { case 1: poolVide = true; break; case 2: phase = EPhaseTournoi.Finale; break; case 4: phase = EPhaseTournoi.DemiFinale; break; case 8: phase = EPhaseTournoi.QuartFinale; break; case 16: phase = EPhaseTournoi.HuitiemeFinale; break; default: throw new Exception("Nombre de jedi dans le pool incorrecte : " + jedis.Count); } for (int i = 0; i < matche_a_creer && !poolVide; i++) { matches.Add(new Match(jedis[i * 2], jedis[i * 2 + 1], phase, stades[rand.Next() % stades.Count])); } }
private List <Match> getAllTournoiMatchs(int idTournoi) { List <Match> listMatch = new List <Match>(); using (SqlConnection sqlConnection = new SqlConnection(m_connexionString)) { SqlCommand sqlCommandMatch = new SqlCommand("SELECT m.id, m.id_vainqueur, m.id_jedi1, m.id_jedi2, m.phaseTournoi, m.id_tournoi, m.id_stade FROM dbo.match m WHERE id_tournoi=" + idTournoi, sqlConnection); sqlConnection.Open(); SqlDataReader sqlDataReaderMatch = sqlCommandMatch.ExecuteReader(); List <Jedi> listJedis = getAllJedis(); List <Stade> listStades = getAllStades(); while (sqlDataReaderMatch.Read()) { EPhaseTournoi phaseTournoi = (EPhaseTournoi)Enum.Parse(typeof(EPhaseTournoi), sqlDataReaderMatch.GetString(4)); listMatch.Add(new Match(sqlDataReaderMatch.GetInt32(0), listJedis.Where(j => j.ID == sqlDataReaderMatch.GetInt32(2)).First(), listJedis.Where(j => j.ID == sqlDataReaderMatch.GetInt32(3)).First(), phaseTournoi, listStades.Where(s => s.ID == sqlDataReaderMatch.GetInt32(6)).First())); } sqlConnection.Close(); } return(listMatch); }
public List<Match> GetAllMatchs() { List<Match> listMatch = new List<Match>(); string request = "Select * from Match;"; DataTable dataTable = SelectByDataAdapter(request); foreach (DataRow item in dataTable.Rows) { EPhaseTournoi phase = (EPhaseTournoi)Convert.ToInt32(item["PhaseTournoi"]); Pokemon pokemon1 = GetPokemonById(Convert.ToInt32(item["Pokemon1"])); Pokemon pokemon2 = GetPokemonById(Convert.ToInt32(item["Pokemon2"])); Stade stade = GetStadeById(Convert.ToInt32(item["Stade"])); int idVainqueur = Convert.ToInt32(item["idPokemonVainqueur"]); Match match = new Match(pokemon1,pokemon2,stade,phase); match.ID = Convert.ToInt32(item["Id"]); match.Vainqueur = GetPokemonById(idVainqueur); listMatch.Add(match); } return listMatch; }
/// <summary> /// Adapte un EPhaseTournoi en EPhaseTournoi Contract. /// </summary> /// <param name="phase">EPhaseTournoi à adapter.</param> /// <returns>EPhaseTournoi contract.</returns> public static EPhaseTournoiContract fromPhaseTournoi(EPhaseTournoi phase) { switch (phase) { case EPhaseTournoi.QuartFinale: return EPhaseTournoiContract.QuartFinale; case EPhaseTournoi.DemiFinale: return EPhaseTournoiContract.DemiFinale; case EPhaseTournoi.Finale: return EPhaseTournoiContract.Finale; default: return EPhaseTournoiContract.QuartFinale; } }
public Match(Pokemon ppokemon1, Pokemon ppokemon2, EPhaseTournoi pphase = EPhaseTournoi.HuitiemeFinale) { PhaseTournoi = pphase; Pokemon1 = ppokemon1; Pokemon2 = ppokemon2; }