-
5public static class Facade
-
-
10 private static WaitingList WaitingList {
get; } =
new WaitingList();
-
-
15 private static GameList GameList {
get; } =
new GameList();
-
-
24 public static string ChooseTeam(
string playerName,
string cPokemon)
-
-
26 PokemonCatalogue.SetCatalogue();
-
-
-
-
-
31 return "Para poder elegir un equipo, primero debes estar en una batalla";
-
-
-
34 if (player.GetPokemonTeam().Count < 6)
-
-
-
-
38 foreach (Pokemon pokemon
in PokemonCatalogue.SetCatalogue())
-
-
40 if (pokemon.Name == cPokemon && !player.GetPokemonTeam().Contains(pokemon))
-
-
-
43 if (player.GetPokemonTeam().Count == 1)
-
-
45 player.SetActivePokemon(pokemon);
-
-
47 return $
"El pokemon {cPokemon} fue añadido al equipo";
-
-
-
50 if (pokemon.Name == cPokemon && player.GetPokemonTeam().Contains(pokemon))
-
-
52 return $
"El pokemon {cPokemon} ya está en el equipo, no puedes volver a añadirlo";
-
-
-
55 return $
"El pokemon {cPokemon} no fue encontrado";
-
-
-
58 return "Ya tienes 6 pokemones en el equipo, no puedes elegir más";
-
-
-
-
69 public static string ShowAtacks(
string playerName)
-
-
-
-
-
74 return $
"El jugador {playerName} no está en ninguna partida.";
-
-
-
-
-
87 public static string ShowPokemonsHp(
string playerName,
string playerToCheckName =
null)
-
-
-
-
91 return $
"El jugador {playerName} no está en ninguna partida.";
-
92 if (playerToCheckName ==
null)
-
-
-
95 foreach (Pokemon pokemon
in player.GetPokemonTeam())
-
96 result += pokemon.Name +
": " + pokemon.GetLife() +
"\n";
-
-
-
-
-
-
-
-
104 if (game !=
null && game.CheckPlayerInGame(player) && game.CheckPlayerInGame(playerToCheck) &&
-
105 playerToCheck !=
null)
-
-
107 foreach (Pokemon pokemon
in playerToCheck.GetPokemonTeam())
-
108 result += pokemon.Name +
": " + pokemon.GetLife() +
"\n";
-
-
-
-
112 return $
"El jugador {playerToCheckName} no está en tu partida.";
-
-
-
-
125 public static string ChooseAttack(
string playerName,
string attackName)
-
-
-
-
-
130 return "Para poder atacar necesitas estar en una batalla";
-
-
-
133 if (player.GetPokemonTeam().Count < 6)
-
-
135 return "El equipo está incompleto, por favor elige 6 pokemones para poder comenzar la batalla";
-
-
-
138 Attack attack = player.
FindAttack(attackName);
-
-
-
141 return $
"El ataque {attackName} no pudo ser encontrado";
-
-
-
-
145 if (actualGame ==
null)
-
-
147 return "Esa partida no está en curso";
-
-
-
-
-
152 if (game.CheckPlayerInGame(player))
-
-
154 if (game.GetPlayers()[game.ActivePlayer].Name == player.Name)
-
-
-
-
158 string nextTurn = CheckGameStatus(game);
-
159 return gameResult +
" " + nextTurn;
-
-
161 return "No eres el jugador activo";
-
-
-
-
165 return "Error inesperado";
-
-
-
174 public static string CheckTurn(
string playerName)
-
-
-
-
-
179 return $
"El jugador {playerName} no está en ninguna partida.";
-
-
-
-
-
184 $
"1- !Attack (ver los ataques con el pokemon activo)\n 2- !Item (ver los items disponibles)\n 3- !Change (ver pokemons disp. a cambiar)";
-
-
-
187 if (game.CheckPlayerInGame(player))
-
-
-
190 Player activePlayer = game.GetPlayers()[activePlayerIndex];
-
191 if (activePlayer.Name == playerName)
-
192 return "Es tu turno:\n" + opciones;
-
193 return "No es tu turno," +
" " +
"las opciones disponibles cuando sea tu turno son:\n" + opciones;
-
-
-
-
-
-
-
207 public static string CheckGameStatus(Game game)
-
-
-
-
211 if (game.GameStatus())
-
-
213 return $
"Próximo turno, ahora es el turno de {game.GetPlayers()[game.ActivePlayer].Name}";
-
-
-
216 return game.Winner();
-
-
-
219 return "La partida no pudo ser encontrada";
-
-
-
-
232 public static string ChangePokemon(
string playerName,
string pokemonName)
-
-
-
-
-
237 return $
"El jugador {playerName} no está en ninguna partida.";
-
-
-
-
-
-
243 return "La partida no pudo ser encontrada";
-
-
-
246 if (game.GetPlayers()[game.ActivePlayer].Name == playerName)
-
-
248 if (game.GetPlayers()[game.ActivePlayer].GetPokemonTeam().Count < 6)
-
-
250 return "Tu equipo pokemon está incompleto, elige hasta tener 6 pokemones en tu equipo";
-
-
-
253 Pokemon choosenPokemon = player.FindPokemon(pokemonName);
-
254 if (choosenPokemon ==
null)
-
-
256 return $
"El pokemon {pokemonName} no fue encontrado en tu equipo";
-
-
-
-
260 if (result ==
"Ese Pokemon no está en tu equipo.")
-
-
-
-
-
-
266 string nextTurn = CheckGameStatus(game);
-
267 return result +
"\n" + nextTurn;
-
-
-
270 return "No eres el jugador activo, no puedes realizar acciones";
-
-
-
281 public static string UseAnItem(
string playerName,
string item,
string pokemon)
-
-
-
-
-
-
-
288 return $
"El jugador {playerName} no está en ninguna partida.";
-
-
-
-
-
293 return "Partida inexistente.";
-
-
295 return game.
UseItem(player.FindItem(item), player.FindPokemon(pokemon));
-
-
-
-
305 public static string AddPlayerToWaitingList(
string playerName)
-
-
-
-
309 return $
"{playerName} agregado a la lista de espera";
-
-
-
312 return $
"{playerName} ya está en la lista de espera";
-
-
-
321 public static string RemovePlayerFromWaitingList(
string playerName)
-
-
-
324 return $
"{playerName} removido de la lista de espera";
-
325 return $
"{playerName} no está en la lista de espera";
-
-
-
333 public static string GetAllPlayersWaiting()
-
-
335 if (WaitingList.
Count == 0)
-
-
337 return "No hay nadie esperando";
-
-
-
340 string result =
"Esperan: ";
-
-
-
343 result = result + player.Name +
"; ";
-
-
-
-
-
-
-
358 public static string CreateGame(
string playerName,
string opponentName)
-
-
-
-
-
-
364 GameList.
AddGame(player, opponent);
-
365 return $
"Comienza {playerName} vs {opponentName}";
-
-
-
375 public static string StartBattle(
string playerName,
string opponentName)
-
-
-
378 if (!OpponentProvided() && !SomebodyIsWaiting())
-
379 return "No hay nadie esperando";
-
380 if (!OpponentProvided())
-
-
-
383 return CreateGame(playerName, opponent!.Name);
-
-
-
-
387 if (!OpponentFound())
-
-
389 return $
"{opponentName} no está esperando";
-
-
-
392 return CreateGame(playerName, opponent!.Name);
-
-
394 bool OpponentProvided()
-
-
396 return !
string.IsNullOrEmpty(opponentName);
-
-
-
399 bool SomebodyIsWaiting()
-
-
401 return WaitingList.Count != 0;
-
-
-
-
-
406 return opponent !=
null;
-
-
-
-
-
415 public static string ShowCatalogue()
-
-
417 PokemonCatalogue.SetCatalogue();
-
418 return PokemonCatalogue.ShowCatalogue();
-
-
-
Player? FindPlayerByName(string playerName)
Devuelve un jugador buscandolo por su nombre.
-
bool RemoveGame(Game game)
Elimina una partida de la lista de partidas.
-
List< Game > GetGameList()
Devuelve la lista de partidas.
-
Game AddGame(Player player1, Player player2)
Agrega una partida a la lista de partidas.
-
Game? FindGameByPlayer(Player player)
Devuelve la partida en la que se encuentra un jugador.
-
int ActivePlayer
Obtiene el valor del índice del jugador activo de la partida.
-
string UseItem(IItem item, Pokemon pokemon)
Permite que un jugador use un item en un Pokemon específico de su equipo, verificando la validez del ...
-
string ExecuteAttack(Attack attack)
Ejecuta un ataque por parte del Pokemon activo del jugador actual, siempre y cuando no se encuentre d...
-
string ChangePokemon(Pokemon pokemon)
Cambia el Pokemon activo del jugador actual por otro de su equipo, verificando si el cambio es válido...
-
string GetPokemonAttacks()
Devuelve un string con los nombres de todos los ataques del pokemon activo.
-
void AddToTeam(Pokemon pokemon)
Agrega un pokemon a la lista de pokemons del jugador.
-
Attack FindAttack(string strAttack)
Devuelve un ataque de la lista de ataques del pokemon activo.
-
bool AddPlayer(string playerName)
Agrega un jugador a la lista de espera.
-
List< Player > GetWaitingList()
Devuelve la lista de jugadores en espera.
-
Player? FindPlayerByName(string playerName)
Devuelve un jugador de la lista de espera buscandolo por su nombre.
-
bool RemovePlayer(string playerName)
Elimina un jugador de la lista de espera.
-
Player? GetAnyoneWaiting()
Devuelve un jugador al azar de la lista de espera.
-
int Count
Devuelve el número de jugadores en espera.
-
-