コード例 #1
0
ファイル: PokeEntity.cs プロジェクト: jbakeacake/PokeBot
 public PokeEntity(int id, PokemonForReturnDto pokemon, PokeTypeForReturnDto pokeType, Move[] moves)
 {
     Id                 = id;
     PokeId             = pokemon.PokeId;
     Name               = pokemon.Name;
     Moves              = moves;
     PokeType           = pokeType;
     Disabled           = false;
     CurrentAilments    = new Dictionary <string, Ailment>();
     Stats              = BuildStatsFromPokemon(pokemon);
     Half_Damage_From   = GetHalfDamageFromTypes(pokeType);
     Half_Damage_To     = GetHalfDamageToTypes(pokeType);
     Double_Damage_From = GetDoubleDamageFromTypes(pokeType);
     Double_Damage_To   = GetDoubleDamageToTypes(pokeType);
 }
コード例 #2
0
 public static Embed CreateWaitingForOtherPlayerEmbed(SocketSelfUser self, PokemonForReturnDto chosenPokemon, string thumbnailUrl)
 {
     return(new EmbedBuilder()
            .WithAuthor(self)
            .WithTitle("Your Opponent is waiting on you…")
            .WithThumbnailUrl(thumbnailUrl)
            .WithDescription($"Your Opponent's Pokemon:\n" +
                             $"► {chosenPokemon.Name}\n" +
                             $"► Lv. {chosenPokemon.Level}\n" +
                             $"► `{chosenPokemon.Type}`\n" +
                             $"► {chosenPokemon.MaxHP} / {chosenPokemon.MaxHP} HP\n" +
                             $"► {chosenPokemon.Experience} / {Math.Pow(chosenPokemon.Level + 1, 3)}")
            .WithFooter(footer => footer.Text = "Waiting Since ")
            .WithCurrentTimestamp()
            .Build());
 }
コード例 #3
0
        private Embed CreateEmbeddedMessage(PokemonForReturnDto pokemon)
        {
            var upperRule = "═════════════════╗";
            var lowerRule = "═════════════════╝";

            var embeddedMessage = new EmbedBuilder()
                                  .WithAuthor(_discord.CurrentUser)
                                  .WithTitle("A Pokemon Wanders Through this Channel...")
                                  .WithDescription($"{upperRule} \nA wild `{pokemon.Name}` appears!\n{lowerRule} \n\n Type `!catch` to capture it!")
                                  .WithImageUrl(pokemon.Url)
                                  .WithFooter(footer => footer.Text = "Appeared ")
                                  .WithCurrentTimestamp()
                                  .Build();

            return(embeddedMessage);
        }
コード例 #4
0
ファイル: PokeEntity.cs プロジェクト: jbakeacake/PokeBot
 private Stats BuildStatsFromPokemon(PokemonForReturnDto pokemon)
 {
     return(new StatsBuilder()
            .HP(pokemon.MaxHP)
            .Level(pokemon.Level)
            .Base_Experience(pokemon.Base_Experience)
            .Experience(pokemon.Experience)
            .Attack(pokemon.Attack)
            .Defense(pokemon.Defense)
            .SpecialAttack(pokemon.SpecialAttack)
            .SpecialDefense(pokemon.SpecialDefense)
            .Speed(pokemon.Speed)
            .Accuracy(1.0f) //Accuracy always starts at 100%
            .Evasion(1.0f)
            .Build());
 }
コード例 #5
0
ファイル: PokeCache.cs プロジェクト: jdimatt/PokeBot
        public async Task <PokemonForReturnDto> GetPokemon()
        {
            PokemonForReturnDto pokemonToReturn = null;
            Random rand   = new Random();
            var    pokeId = rand.Next(1, MAX_ID); // 1 - 151 : ids of original pokemon
            var    res    = await _pokemonController.PokemonExists(pokeId);

            System.Console.WriteLine($"RES: {res}");
            if (!res)
            {
                System.Console.WriteLine("Querying PokeAPI...");
                pokemonToReturn = await _pokemonController.GetPokemonAPI(pokeId);

                System.Console.WriteLine("Query Success.");
            }
            else
            {
                pokemonToReturn = await _pokemonController.GetPokemonByPokeId(pokeId);
            }
            return(pokemonToReturn);
        }
コード例 #6
0
        public async Task <PokemonForReturnDto> GetPokemonAPI(int pokeId)
        {
            var pokeDataUrl  = PokeApiUrl + pokeId;
            var pokePhotoUrl = PokeBastionBotApiUrl + pokeId + ".png";
            PokemonForReturnDto pokemonForReturnDto = null;

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    using (HttpResponseMessage res = await client.GetAsync(pokeDataUrl))
                    {
                        using (HttpContent content = res.Content)
                        {
                            var pokemonData = await content.ReadAsStringAsync();

                            if (pokemonData == null)
                            {
                                throw new NullReferenceException("PokeAPI call returned null. Check Pokemon Id or base URL being used.");
                            }

                            var dataObj = JObject.Parse(pokemonData);
                            pokemonForReturnDto = new PokemonForReturnDto(pokeId, dataObj["name"].ToString(), pokePhotoUrl);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}", ex.Message);
            }

            if (pokemonForReturnDto == null)
            {
                throw new NullReferenceException("PokemonForReturnDto is null. Check API call.");
            }

            return(pokemonForReturnDto);
        }
コード例 #7
0
ファイル: BattlePlayer.cs プロジェクト: jbakeacake/PokeBot
 public void InitializeCurrentPokemon(PokemonForReturnDto pokemonForReturn, PokeTypeForReturnDto pokeType, Move[] moves, int id)
 {
     CurrentPokemon = new PokeEntity(id, pokemonForReturn, pokeType, moves);
 }
コード例 #8
0
 public void SetPokemon(PokemonForReturnDto pokemon)
 {
     _pokemon = pokemon;
 }
コード例 #9
0
 public CurrentWanderingPokemon()
 {
     _pokemon    = new PokemonForReturnDto();
     _isCaptured = true;
 }
コード例 #10
0
 public CurrentWanderingPokemon(PokemonForReturnDto pokemon)
 {
     _pokemon    = pokemon;
     _isCaptured = false;
 }
コード例 #11
0
ファイル: GameHandler.cs プロジェクト: jbakeacake/PokeBot
        public async Task SendOpponentWaitingOnPlayer(ulong discordId, PokemonForReturnDto chosenPokemon, string thumbnailUrl)
        {
            var waitingMessage = EmbeddedMessageUtil.CreateWaitingForOtherPlayerEmbed(_discord.CurrentUser, chosenPokemon, thumbnailUrl);

            await SendPlayerMessage(waitingMessage, discordId);
        }