public async Task <MethodResult> FavoritePokemon(IEnumerable <PokemonData> pokemonToFavorite, bool favorite = true) { foreach (PokemonData pokemon in pokemonToFavorite) { bool isFavorited = true; string message = "unfavorited"; if (pokemon.Favorite == 0) { isFavorited = false; message = "favorited"; } if (isFavorited == favorite) { continue; } try { var response = await _client.ClientSession.RpcClient.SendRemoteProcedureCallAsync(new Request { RequestType = RequestType.SetFavoritePokemon, RequestMessage = new SetFavoritePokemonMessage { PokemonId = (long)pokemon.Id, IsFavorite = favorite }.ToByteString() }); SetFavoritePokemonResponse setFavoritePokemonResponse = null; setFavoritePokemonResponse = SetFavoritePokemonResponse.Parser.ParseFrom(response); LogCaller(new LoggerEventArgs( String.Format("Successully {3} {0}. Cp: {1}. IV: {2:0.00}%", pokemon.PokemonId, pokemon.Cp, CalculateIVPerfection(pokemon), message), LoggerTypes.Info)); await Task.Delay(CalculateDelay(UserSettings.DelayBetweenPlayerActions, UserSettings.PlayerActionDelayRandom)); return(new MethodResult { Success = true }); } catch (Exception ex) { LogCaller(new LoggerEventArgs("Favorite request failed", LoggerTypes.Exception, ex)); return(new MethodResult()); } } return(new MethodResult()); }
private async void setFavorite(ulong id, bool favorite, bool updateAfter = true) { SetFavoritePokemonResponse favResp = await this._session.Client.Inventory.SetFavoritePokemon(id, favorite); Logger.Write($"Favorited pokemon: {favResp.Result}"); if (updateAfter) { await this.getPokemons(); } }
public async Task <MethodResult> FavoritePokemon(IEnumerable <PokemonData> pokemonToFavorite, bool favorite = true) { foreach (PokemonData pokemon in pokemonToFavorite) { bool isFavorited = true; string message = "unfavorited"; if (pokemon.Favorite == 0) { isFavorited = false; message = "favorited"; } if (isFavorited == favorite) { continue; } try { SetFavoritePokemonResponse favoriteResponse = await _client.Inventory.SetFavoritePokemon(pokemon.Id, favorite); if (favoriteResponse.Result != SetFavoritePokemonResponse.Types.Result.Success) { LogCaller(new LoggerEventArgs(String.Format("Failed to favorite/unfavorite pokemon {0}. Response: {1}", pokemon.PokemonId, favoriteResponse.Result), LoggerTypes.Warning)); } else { LogCaller(new LoggerEventArgs( String.Format("Successully {3} {0}. Cp: {1}. IV: {2:0.00}%", pokemon.PokemonId, pokemon.Cp, CalculateIVPerfection(pokemon).Data, message), LoggerTypes.Info)); } await Task.Delay(CalculateDelay(UserSettings.DelayBetweenPlayerActions, UserSettings.PlayerActionDelayRandom)); } catch (Exception ex) { LogCaller(new LoggerEventArgs("Favorite request failed", LoggerTypes.Exception, ex)); } } return(new MethodResult { Success = true }); }
protected ByteString GetPlayerPacket(RequestType typ, object msg) { switch (typ) { case RequestType.SetFavoritePokemon: SetFavoritePokemonResponse sfp = new SetFavoritePokemonResponse(); SetFavoritePokemonMessage m = (SetFavoritePokemonMessage)msg; var owned = this.GetPokemonById((ulong)m.PokemonId); if (owned != null) { m.IsFavorite = true; owned.favorite = true; this.Database.OwnedPokemons.Update(owned); sfp.Result = SetFavoritePokemonResponse.Types.Result.Success; } else { sfp.Result = SetFavoritePokemonResponse.Types.Result.ErrorPokemonNotFound; } //this.Log.Dbg($"TypeOfResponseMessage: {nameof(SetFavoritePokemonResponse)}"); return(sfp.ToByteString()); case RequestType.LevelUpRewards: LevelUpRewardsResponse lur = new LevelUpRewardsResponse(); lur.Result = LevelUpRewardsResponse.Types.Result.Success; lur.ItemsAwarded.AddRange(new RepeatedField <ItemAward>() { new ItemAward() { ItemId = ItemId.ItemPokeBall, ItemCount = 2 }, new ItemAward() { ItemId = ItemId.ItemTroyDisk, ItemCount = 2 } }); //this.Log.Dbg($"TypeOfResponseMessage: {nameof(LevelUpRewardsResponse)}"); return(lur.ToByteString()); case RequestType.ReleasePokemon: ReleasePokemonResponse rp = this.ReleasePokemon((ReleasePokemonMessage)msg); //this.Log.Dbg($"TypeOfResponseMessage: {nameof(ReleasePokemonResponse)}"); return(rp.ToByteString()); case RequestType.UpgradePokemon: UpgradePokemonResponse up = new UpgradePokemonResponse(); //UpgradePokemonMessage upm = (UpgradePokemonMessage)msg; //var uptpkmn = brc.GetPokemonById(upm.PokemonId); //if (uptpkmn!=null) //{ //} //else //{ // up.Result = UpgradePokemonResponse.Types.Result.ErrorPokemonNotFound; //} //this.Log.Dbg($"TypeOfResponseMessage: {nameof(UpgradePokemonResponse)}"); return(up.ToByteString()); //https://github.com/msx752/PoGoEmulator/issues/24 case RequestType.GetPlayerProfile: GetPlayerProfileResponse gpp = new GetPlayerProfileResponse(); gpp.Result = GetPlayerProfileResponse.Types.Result.Success; gpp.StartTime = (long)DateTime.Now.ToUnixTime(); gpp.Badges.Add(new POGOProtos.Data.PlayerBadge() { BadgeType = BadgeType.BadgeTravelKm, EndValue = 2674, CurrentValue = 1337 }); return(gpp.ToByteString()); //case RequestType.SetAvatar: // LevelUpRewardsResponse sa = new LevelUpRewardsResponse(); // return sa.ToByteString(); case RequestType.GetPlayer: //this.Log.Dbg($"TypeOfResponseMessage: {nameof(GetPlayerResponse)}"); return(this.GetPlayer()); case RequestType.GetInventory: RepeatedField <InventoryItem> items = new RepeatedField <InventoryItem>(); //ADD ITEMSS GetInventoryResponse gi = new GetInventoryResponse(); gi.Success = true; gi.InventoryDelta = new POGOProtos.Inventory.InventoryDelta() { NewTimestampMs = (long)DateTime.Now.ToUnixTime() }; gi.InventoryDelta.InventoryItems.AddRange(items); //this.Log.Dbg($"TypeOfResponseMessage: {nameof(GetInventoryResponse)}"); return(gi.ToByteString()); case RequestType.GetAssetDigest: var gad = GlobalSettings.GameAssets[this.CurrentPlayer.Platform].Value; //this.Log.Dbg($"TypeOfResponseMessage: {nameof(GetAssetDigestResponse)}"); return(gad.ToByteString()); //case RequestType.NicknamePokemon: // LevelUpRewardsResponse np = new LevelUpRewardsResponse(); // return np.ToByteString(); case RequestType.GetHatchedEggs: GetHatchedEggsResponse ghe = new GetHatchedEggsResponse(); ghe.Success = true; //this.Log.Dbg($"TypeOfResponseMessage: {nameof(GetHatchedEggsResponse)}"); return(ghe.ToByteString()); case RequestType.CheckAwardedBadges: CheckAwardedBadgesResponse cab = new CheckAwardedBadgesResponse(); cab.Success = true; //this.Log.Dbg($"TypeOfResponseMessage: {nameof(CheckAwardedBadgesResponse)}"); return(cab.ToByteString()); //case RequestType.RecycleInventoryItem: // LevelUpRewardsResponse rii = new LevelUpRewardsResponse(); // return rii.ToByteString(); //case RequestType.ClaimCodename: // LevelUpRewardsResponse cc = new LevelUpRewardsResponse(); // return cc.ToByteString(); default: throw new Exception($"unknown (Player) Returns type: {typ}"); } }
public FavoriteEvent(PokemonData pkm, SetFavoritePokemonResponse res) { Pokemon = pkm; FavoritePokemonResponse = res; }
/// <summary> /// Provides a safe way to invoke the <see cref="FavoritePokemonReceived" /> event. /// </summary> /// <param name="value"></param> public void RaiseFavoritePokemonReceived(SetFavoritePokemonResponse value) => FavoritePokemonReceived?.Invoke(this, value);