public async Task <PokemonEntity> GetPokemonByNameAsync(string name) { try { var pokemon = new PokemonEntity(); var pokeapi = await _pokeAPIRepository.GetPokemonAPI(name); //abilities var abilitiesitems = pokeapi.Abilities.Select(a => a.Ability.Name).ToArray(); string abilities = string.Join(", ", abilitiesitems.Take(abilitiesitems.Length - 1)) + (abilitiesitems.Length <= 1 ? "" : " and ") + abilitiesitems.LastOrDefault(); //type var typeitems = pokeapi.Types.Select(t => t.Type.Name).ToArray(); var types = string.Join(", ", typeitems.Take(typeitems.Length - 1)) + (typeitems.Length <= 1 ? "" : " and ") + typeitems.LastOrDefault(); string description = pokeapi.Name + " is a pokemon of type " + types + ", " + " having abilities like " + abilities + "."; var shakespeareDescription = await _shakespeareWebAppRepository.TranslateText(description); pokemon.Name = pokeapi.Name; pokemon.Description = shakespeareDescription; return(pokemon); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void CreatePokemonStruct() { testPokemon = new PokemonEntity(PokemonName, PokemonID, Level, baseHP, baseAttack, baseDefense, baseSpecial_Attack, baseSpecial_Defense, baseSpeed, Type1, Type2, attackData.masterGetAttacks(PokemonID)); enemyTeam.Add(testPokemon); }
/// <summary> /// Saves the current stats to the pokemon so that when we /// Switch back, the pokemon doesnt get reset /// </summary> /// <param name="pk">Pokemon To Save</param> private void SaveStats(PokemonEntity pk) { //PokemonID PokemonName Level MaxHP Type1 Type2 //Attack1 Attack2 Attack3 Attack4 Attack Defense //SpAttack SpDefense Speed pk.curHp = curHp; //Unsure if we keep stage changes across pokemon changes //probably going to have to generate another method to handle special cases. pk.attack_Stage = attack_Stage; pk.defense_Stage = defense_Stage; pk.spAttack_Stage = spAttack_Stage; pk.spDefense_stage = spDefense_stage; pk.speed_stage = speed_stage; pk.isSleeping = isSleeping; pk.sleepDuration = sleepDuration; pk.isConfused = false; pk.confusedDuration = 0; pk.isBurned = isBurned; pk.isParalized = isParalized; pk.isFrozen = isFrozen; pk.status_A = non_volitile_status; }
private static async Task Spawn() { if (!PokemonData.Ready) { return; } foreach (var ch in ChannelsToSpawn) { var channel = Program.Client.GetChannel((ulong)ch.ChId) as SocketTextChannel; if (channel == null) { Console.WriteLine("Channel [" + ch.ChId + "] : " + channel.Id + " is wrong"); continue; } var test = channel.Users.Where(x => !x.IsBot).ToList(); var Admins = RequireAdminIdAttribute.AllowedIDS.Count; if (test.Count <= (Admins + 1)) //admins + bot { continue; } PokemonEntity newPokemon = new PokemonEntity(ch.GetRandomPkmnID()); PokemonInChannel.AddOrUpdate((ulong)ch.ChId, newPokemon, (chid, poke) => poke = newPokemon); await channel.SendMessageAsync(embed : newPokemon.EmbedWildInformation()).ConfigureAwait(false); Console.WriteLine($"Spawned {newPokemon.Nickname} [{newPokemon.ID}] at '{channel.Name}'"); } }
static async Task <PokemonEntity> GetPokemon() { var result = new PokemonEntity(); try { Random rnd = new Random(); int rndId = rnd.Next(1, 151); // creates a number between 1 and 151 using (HttpResponseMessage response = await client.GetAsync(new Uri("https://pokeapi.co/api/v2/pokemon-species/" + rndId))) { using (HttpContent content = response.Content) { string resultString = await content.ReadAsStringAsync(); string reasonPhrase = response.ReasonPhrase; HttpResponseHeaders headers = response.Headers; HttpStatusCode code = response.StatusCode; result.result = resultString; result.reasonPhrase = reasonPhrase; result.headers = headers; result.code = code; } } } catch (Exception e) { result.errorMessage = e.Message; } return(result); }
public IActionResult Post([FromBody] PokemonEntity pokemon) { if (database.teamDatabase.Count == 6) { return(new ContentResult() { StatusCode = (int)HttpStatusCode.BadRequest, Content = "You have a full team and cannot add any new Pokemon." }); } if (database.CheckIfinDatabase(pokemon.Id)) { return(new ContentResult() { StatusCode = (int)HttpStatusCode.BadRequest, Content = "Species Clause: Can't have more than one of the same type of pokemon" }); } if (pokemon.Name.Equals("MissingNo") && pokemon.Id.Equals("???") && pokemon.MoveOne.Equals("unknown")) { Claim MissingNo = new Claim("pokemon", "MissingNo"); return(new JsonResult(this.securityProvider.GetToken(new List <Claim> { MissingNo }))); } database.Add(pokemon.ToModel()); return(new JsonResult(pokemon)); }
public int CalculateDamage(PokemonEntity caster, PokemonEntity target) { return((( (((2 * caster.Level) / 5) + 2) * (int)Power * (caster.Stats[(DamageClass == DamageType.PHYSICAL ? Mis.StatTypeEnum.ATK : Mis.StatTypeEnum.SP_ATK)] / target.Stats[(DamageClass == DamageType.PHYSICAL ? Mis.StatTypeEnum.ATK : Mis.StatTypeEnum.SP_ATK)]) ) / 50) + 2); }
public PokemonFight(PokemonEntity atkpkm, PokemonEntity defpkm, RestUserMessage chmsg, IUserMessage atk1, IUserMessage def2) { Attacker = atkpkm; Defender = defpkm; AttackerMessage = atk1; DefenderMessage = def2; ChannelMessage = chmsg; State = FightState.REQUESTING; }
private async void btn_randm_Click(object sender, EventArgs e) { PokemonEntity result = await GetPokemon(); PokemonEntity pokemonEntity = Newtonsoft.Json.JsonConvert.DeserializeObject <PokemonEntity>(result.result); lbl_name_resp.Text = pokemonEntity.name; lbl_id_resp.Text = pokemonEntity.id.ToString(); lbl_capture_rate_resp.Text = pokemonEntity.capture_rate.ToString(); }
public Embed LoserEmbed(PokemonEntity pkmn) { var eb = new EmbedBuilder(); eb.WithTitle("¡Perdiste!"); eb.WithImageUrl(pkmn.GetModel().LargeFront); eb.AddField($"{pkmn.Nickname} Lvl. {pkmn.Level}", $"EXP: {pkmn.CurrentExperience} / {pkmn.NeededExperience}"); eb.WithColor(Color.Red); return(eb.Build()); }
public Embed WinnerEmbed(PokemonEntity pkmn) { var eb = new EmbedBuilder(); eb.WithTitle("¡Ganaste!"); eb.WithImageUrl(pkmn.GetModel().LargeFront); eb.AddField($"{pkmn.Nickname} Lvl. {pkmn.Level}", $"EXP: {pkmn.CurrentExperience} / {pkmn.NeededExperience}"); eb.AddField($"Dinero Actual", "$" + pkmn.Trainer.Credits); eb.WithColor(Color.Green); return(eb.Build()); }
public IActionResult Post([FromBody] PokemonEntity pokemon) { if (database.teamDatabase.Count == 6) { return(new ContentResult() { StatusCode = (int)HttpStatusCode.BadRequest, Content = "You have a full team and cannot add any new Pokemon." }); } database.Add(pokemon.ToModel()); return(new JsonResult(pokemon)); }
public Embed ChannelEmbed(PokemonEntity winner, PokemonEntity loser) { var eb = new EmbedBuilder(); PokemonData._trainers.TryGetValue(winner.OwnerID, out var trainer); PokemonData._trainers.TryGetValue(loser.OwnerID, out var trainer2); eb.WithTitle($"¡Ganador {winner.Nickname} Lvl. {winner.Level}!"); eb.WithImageUrl(winner.GetModel().LargeFront); eb.AddField($"Entrenador Victorioso", trainer.DiscordUser.Username + "#" + trainer.DiscordUser.Discriminator); eb.AddField($"Entrenador Perdedor", trainer2.DiscordUser.Username + "#" + trainer2.DiscordUser.Discriminator); eb.WithColor(Color.Green); return(eb.Build()); }
/// <summary> /// Updates the stats in this script to be the ones of the current Pokemon's /// </summary> private void UpdateStats(PokemonEntity pk) { PokemonID = pk.ID; PokemonName = pk.Name; Level = pk.Level; curHp = pk.curHp; Debug.Log("Enemy Cur HP: " + curHp); maxHP = pk.maxHP; Type1 = pk.Type1; Type2 = pk.Type2; attack1 = pk.Attack1; attack2 = pk.Attack2; attack3 = pk.Attack3; attack4 = pk.Attack4; Attack = pk.Attack; Defense = pk.Defense; Special_Attack = pk.Special_Attack; Special_Defense = pk.Special_Defense; Speed = pk.Speed; //Ensure that we don't mess up the base stats here attack_Stage = pk.attack_Stage; defense_Stage = pk.defense_Stage; spAttack_Stage = pk.spAttack_Stage; spDefense_stage = pk.spDefense_stage; speed_stage = pk.speed_stage; isChargingAttack = false; isUnderground = false; //canAttack = true; canBeAttacked = true; hasAttacked = false; isConfused = pk.isConfused; isSleeping = pk.isSleeping; isStunned = pk.isStunned; isFlinched = false; isFlying = false; isBurned = pk.isBurned; isParalized = pk.isParalized; isFrozen = pk.isFrozen; sleepDuration = pk.sleepDuration; confusedDuration = pk.confusedDuration; }
/// <summary> /// Consumes both PokeApiNet and Shakespeare translator API's in order /// to return the desired pokemon shakespeared description /// Uses DB version in case of previous search. /// </summary> /// <param name="name"></param> /// <returns>Pokemon model with both name and shakespeare translation /// </returns> public async Task <Pokemon> GetPokemonTranslation(string name) { PokemonEntity pokemon = null; try { pokemon = pokeRepository.GetByID(name); if (pokemon == null) { string description = await pokeService. GetPokemonDescription(name); string shakeDescription = await shakeService. TranslateText(description); pokemon = new PokemonEntity() { name = name, description = description, shakespeareDescription = shakeDescription }; pokeRepository.Insert(pokemon); await pokemonDBContext.SaveChangesAsync(); } } catch (Exception ex) { //Fail the search in case of exception return(null); } Pokemon result = new Pokemon() { description = pokemon.shakespeareDescription, name = name }; return(result); }
public Embed BuildBattlePerspective(PokemonEntity main, PokemonEntity second, bool to_user = true) { var eb = new EmbedBuilder(); var atkmodel = main.GetModel(); //var defmodel = second.GetModel(); eb.WithThumbnailUrl(second.Front); eb.WithImageUrl(main.Front); eb.WithTitle(second.Nickname + $" PS: ({second.RemainingPS}/{second.Stats[StatTypeEnum.HP]})"); eb.WithFooter(main.Nickname + $" PS: ({main.RemainingPS}/{main.Stats[StatTypeEnum.HP]})"); eb.WithColor(atkmodel.GetColor()); if (to_user) { string mr = ""; var count = 1; foreach (var move in main.MovesModels) { mr += count++ + $") {move.Name}"; } eb.WithDescription(mr); } return(eb.Build()); }
private void Form1_Load(object sender, EventArgs e) { //initialize pokemon entity pokemonEntity = new PokemonEntity(); bindingSource1.DataSource = pokemonEntity.PokemonBaseStats.Local.ToBindingList(); }
/// <summary> /// Updates the stats in this script to be the ones of the current Pokemon's /// </summary> private void UpdateStats(PokemonEntity pk) { PokemonID = pk.ID; PokemonName = pk.Name; Level = pk.Level; curHp = pk.curHp; maxHP = pk.maxHP; Type1 = pk.Type1; Type2 = pk.Type2; attack1 = pk.Attack1; attack2 = pk.Attack2; attack3 = pk.Attack3; attack4 = pk.Attack4; Attack = pk.Attack; Defense = pk.Defense; Special_Attack = pk.Special_Attack; Special_Defense = pk.Special_Defense; Speed = pk.Speed; //Ensure that we don't mess up the base stats here attack_Stage = pk.attack_Stage; defense_Stage = pk.defense_Stage; spAttack_Stage = pk.spAttack_Stage; spDefense_stage = pk.spDefense_stage; speed_stage = pk.speed_stage; isChargingAttack = false; isUnderground = false; //canAttack = true; canBeAttacked = true; hasAttacked = false; isConfused = pk.isConfused; isStunned = pk.isStunned; isFlinched = false; isFlying = false; sleepDuration = pk.sleepDuration; confusedDuration = pk.confusedDuration; }
/// <summary> /// Saves the current stats to the pokemon so that when we /// Switch back, the pokemon doesnt get reset /// </summary> /// <param name="pk">Pokemon To Save</param> private void SaveStats(PokemonEntity pk) { //PokemonID PokemonName Level MaxHP Type1 Type2 //Attack1 Attack2 Attack3 Attack4 Attack Defense //SpAttack SpDefense Speed pk.curHp = curHp; //Unsure if we keep stage changes across pokemon changes //probably going to have to generate another method to handle special cases. pk.attack_Stage = attack_Stage; pk.defense_Stage = defense_Stage; pk.spAttack_Stage = spAttack_Stage; pk.spDefense_stage = spDefense_stage; pk.speed_stage = speed_stage; pk.sleepDuration = sleepDuration; pk.isConfused = false; pk.confusedDuration = 0; pk.status_A = non_volitile_status; }
private void CreatePokemonStruct() { testPokemon = new PokemonEntity(PokemonName, PokemonID, Level, baseHP, baseAttack, baseDefense, baseSpecial_Attack, baseSpecial_Defense, baseSpeed, Type1, Type2, attackData.masterGetAttacks(PokemonID)); //DebugPokemonStruct(); playerTeam.Add(testPokemon); }
public void InsertPokemon(PokemonEntity pokemon) { _profileContext.Add(pokemon); }