private void ButtonRegister_Click(object sender, RoutedEventArgs e) { string username = TextBoxUsername.Text; string password = PasswordBoxPassword.Password; string repeatPassword = PasswordBoxRepeatPassword.Password; if (!isFieldsFilled()) { MessageBox.Show("Please fill in all fields to register", "Information", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (!isRepeatEqualsPassword()) { MessageBox.Show("Secrets must be the same", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return; } try { Pokedex playerPokedex = Pokedexes.Add(new Pokedex()); Player player = new Player(); player.Password = password; player.Username = username; player.PokedexID = playerPokedex.ID; Players.Add(player); MessageBox.Show("Welcome " + username + "! Now, type your data to enter to the Pokémon world!", "", MessageBoxButton.OK); Close(); } catch { MessageBox.Show("An error has occurred, please try again later.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ButtonRow_Click(object sender, RoutedEventArgs e) { PokedexPokemon pokedexPokemon = ((PokedexPokemonData)((Button)e.Source).DataContext).PokedexPokemon; MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure you want to kill " + pokedexPokemon.Pokemon.Name + " (lvl. " + pokedexPokemon.Level + ")?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.Yes) { Pokedexes.DisablePokemon(pokedexPokemon); Session.UpdatePlayer(); RefreshData(); } }
private void ButtonRegister_Click(object sender, RoutedEventArgs e) { PokedexPokemon pokemonCaught = PokemonAlreadyCaught(); if (pokemonCaught == null) { pokemonCaught = new PokedexPokemon(); pokemonCaught.PokemonID = PokemonEncountered.LocalPokemon.PokemonID; pokemonCaught.EncountersCount = 1; pokemonCaught.Level = PokemonEncountered.Level; } else { MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure you want to replace your " + PokemonEncountered.LocalPokemon.Pokemon.Name + " (lvl. " + PokemonEncountered.Level + ") with this one?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question); if (messageBoxResult == MessageBoxResult.Yes) { pokemonCaught.Level = PokemonEncountered.Level; } pokemonCaught.EncountersCount = pokemonCaught.EncountersCount + 1; } pokemonCaught.Nickname = TextBoxPokemonNickname.Text; pokemonCaught.Notes = TextBoxPokemonNotes.Text; pokemonCaught.Catched = true; pokemonCaught.Enabled = true; try { if (PokemonAlreadyCaught() == null) { pokemonCaught = Pokedexes.AddPokemon(pokemonCaught, Session.Player.Pokedex); } else { pokemonCaught = Pokedexes.UpdatePokemon(pokemonCaught, Session.Player.Pokedex); } // If is the first pokemon set as main if (Session.Player.Pokedex.Pokemons.Count == 0) { Session.Player.MainPokedexPokemonID = pokemonCaught.ID; Players.UpdatePlayer(Session.Player); } Session.UpdatePlayer(); Close(); } catch { MessageBox.Show("An error has occurred, please try again later.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ButtonBattle_Click(object sender, RoutedEventArgs e) { PokedexPokemon pokedexPokemon = Session.Player.Pokedex.Pokemons.FirstOrDefault(pokemon => Session.Player.MainPokedexPokemonID == pokemon.ID); bool win = PokemonEncounter.Battle(pokedexPokemon, PokemonEncountered); try { if (win) { pokedexPokemon.Level += 1; MessageBox.Show(pokedexPokemon.Pokemon.Name + " grew to lvl " + pokedexPokemon.Level + "!", "Win", MessageBoxButton.OK); Pokedexes.UpdatePokemon(pokedexPokemon, Session.Player.Pokedex); Session.UpdatePlayer(); } else { MessageBox.Show(pokedexPokemon.Pokemon.Name + " was fainted.", "Lose", MessageBoxButton.OK, MessageBoxImage.Warning); } BackToRegion(false); } catch { MessageBox.Show("An error has occurred, please try again later.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public static void Initialize(string CacheFolder = "") { if (Connector.isInitialized) { throw new Exception("PokeAPI is initialized and can only be initialized once"); //May seems a bit over kill but this is nessecery for corrent usage. } #region "Structure" Connector.Berries = new Berries(); Connector.BerryFirmnesses = new BerryFirmnesses(); Connector.BerryFlavors = new BerryFlavors(); Connector.ContestNames = new ContestNames(); Connector.ContestEffects = new ContestEffects(); Connector.SuperContestEffects = new SuperContestEffects(); Connector.EncounterMethods = new EncounterMethods(); Connector.EncounterConditions = new EncounterConditions(); Connector.EncounterConditionValues = new EncounterConditionValues(); Connector.EvolutionChains = new EvolutionChains(); Connector.EvolutionTrigger = new EvolutionTrigger(); Connector.Generations = new Generations(); Connector.Pokedexes = new Pokedexes(); Connector.Versions = new Versions(); Connector.VersionGroups = new VersionGroups(); Connector.Items = new Items(); Connector.ItemAttributes = new ItemAttributes(); Connector.ItemCategories = new ItemCategories(); Connector.ItemFlingEffects = new ItemFlingEffects(); Connector.ItemPockets = new ItemPockets(); Connector.Locations = new Locations(); Connector.LocationAreas = new LocationAreas(); Connector.PalParkAreas = new PalParkAreas(); Connector.Regions = new Regions(); Connector.Machines = new Machines(); Connector.Moves = new Moves(); Connector.MoveAilments = new MoveAilments(); Connector.MoveBattleStyles = new MoveBattleStyles(); Connector.MoveCategories = new MoveCategories(); Connector.MoveDamageClasses = new MoveDamageClasses(); Connector.MoveLearnMethods = new MoveLearnMethods(); Connector.MoveTargets = new MoveTargets(); Connector.Abilities = new Abilities(); Connector.Characteristics = new Characteristics(); Connector.EggGroups = new EggGroups(); Connector.Genders = new Genders(); Connector.GrowthRates = new GrowthRates(); Connector.Natures = new Natures(); Connector.PokeathlonStats = new PokeathlonStats(); Connector.Pokemons = new Pokemons(); Connector.PokemonColors = new PokemonColors(); Connector.PokemonForms = new PokemonForms(); Connector.PokemonHabitats = new PokemonHabitats(); Connector.PokemonShapes = new PokemonShapes(); Connector.PokemonSpecies = new PokemonSpecies(); Connector.Stats = new Stats(); Connector.Types = new Types(); Connector.Languages = new Languages(); #endregion if (CacheFolder == "") { Connector.CacheFolder = AppDomain.CurrentDomain.BaseDirectory + "pokeAPI//"; } else { if (!System.IO.Directory.Exists(CacheFolder)) { throw new Exception("Directory : " + CacheFolder + " was not found"); } Connector.CacheFolder = CacheFolder; } Cacher.Initialize(); Connector.isInitialized = true; }
public PlayersController(Players players, Pokedexes pokedexes) { Players = players; Pokedexes = pokedexes; }
public GameController(Locals locals, Players players, Pokedexes pokedexes) { Locals = locals; Players = players; Pokedexes = pokedexes; }