예제 #1
0
        private void BtnInventory_Click(object sender, RoutedEventArgs e)
        {
            InventoryWindow inventoryWindow = new InventoryWindow();

            inventoryWindow.ShowDialog();
        }
        private void BtnBag_Click(object sender, RoutedEventArgs e)
        {
            DatabaseOperations.UpdatePlayerPokemon(playerPokemon);

            InventoryWindow inventory = new InventoryWindow(playerPokemon);

            //enemyPokemon, knownAttackList,

            inventory.ShowDialog();

            PlayerPokemonStatics.PlayerPokemon = DatabaseOperations.GetPlayerPokemon(playerPokemon.Id);//LoadPlayerPokemon(playerPokemon.Id);


            PlayerPokedex entry;

            if (InventoryWindow.catchRateMultiplier > 0)
            {
                caught = Catch((InventoryWindow.catchRateMultiplier), enemyPokemon, knownAttackList);

                playerPokedexList = DatabaseOperations.GetPlayerPokedexEntries(PlayerInformation.PlayerId);
            }
            else if (inventory.cancel == false)
            {
                txtInformation.Text = $"You healed {playerPokemon.Name}";
            }


            if (caught == true)
            {
                entry = new PlayerPokedex
                {
                    PokedexId   = pokemon.PokedexId,
                    PlayerId    = PlayerInformation.PlayerId,
                    Caught      = true,
                    Encountered = true
                };

                if (!playerPokedexList.Contains(entry))
                {
                    DatabaseOperations.AddCaughtPlayerPokedex(entry);
                }
                else
                {
                    foreach (var item in playerPokedexList)
                    {
                        if (item.PokedexId == entry.PokedexId && item.PlayerId == entry.PlayerId)
                        {
                            entry.Id = item.Id;
                            break;
                        }
                    }

                    DatabaseOperations.UpdatePlayerPokedex(entry);
                }

                EndBattle();
            }
            else
            {
                if (inventory.cancel == false)
                {
                    EndPlayerTurn(false);
                }
            }

            PlayerPokemonUi();
        }