public async Task <MethodResult> TransferPokemon(IEnumerable <PokemonData> pokemonToTransfer) { //TODO: Revise //return new MethodResult { Message = "Dev mode sorry" }; foreach (PokemonData pokemon in pokemonToTransfer) { if (pokemon.Favorite == 1 || pokemon.IsEgg || !string.IsNullOrEmpty(pokemon.DeployedFortId) || PlayerData.BuddyPokemon.Id == pokemon.Id) { continue; } ReleasePokemonMessage message = new ReleasePokemonMessage { PokemonId = pokemon.Id }; try { var response = await ClientSession.RpcClient.SendRemoteProcedureCallAsync(new Request { RequestType = RequestType.ReleasePokemon, RequestMessage = message.ToByteString() }); ReleasePokemonResponse releasePokemonResponse = null; releasePokemonResponse = ReleasePokemonResponse.Parser.ParseFrom(response); if (releasePokemonResponse.Result == ReleasePokemonResponse.Types.Result.Success) { LogCaller(new LoggerEventArgs( String.Format("Successully transferred {0}. Cp: {1}. IV: {2:0.00}%", pokemon.PokemonId, pokemon.Cp, CalculateIVPerfection(pokemon).Data), LoggerTypes.Transfer)); await Task.Delay(CalculateDelay(UserSettings.DelayBetweenPlayerActions, UserSettings.PlayerActionDelayRandom)); } else { LogCaller(new LoggerEventArgs(String.Format("Faill to transfer {0}. Because: {1}.", pokemon.PokemonId, releasePokemonResponse.Result), LoggerTypes.Warning)); } } catch (Exception ex) { LogCaller(new LoggerEventArgs("ReleasePokemonResponse parsing failed because response was empty", LoggerTypes.Exception, ex)); return(new MethodResult()); } } return(new MethodResult { Success = true }); }
public async Task <ReleasePokemonResponse> TransferPokemon(ulong pokemonId) { var message = new ReleasePokemonMessage { PokemonId = pokemonId }; return(await PostProtoPayload <Request, ReleasePokemonResponse>(RequestType.ReleasePokemon, message)); }
public async Task <ReleasePokemonResponse> TransferPokemon(List <ulong> pokemonId) // Transfer a list of pokemon (BULK Transfer) { var message = new ReleasePokemonMessage { }; message.PokemonIds.AddRange(pokemonId); return(await PostProtoPayload <Request, ReleasePokemonResponse>(RequestType.ReleasePokemon, message).ConfigureAwait(false)); }
public ReleasePokemonResponse TransferPokemon(List <ulong> pokemonId) // Transfer a list of pokemon (BULK Transfer) { var message = new ReleasePokemonMessage { }; message.PokemonIds.AddRange(pokemonId); return(PostProtoPayload <Request, ReleasePokemonResponse>(RequestType.ReleasePokemon, message)); }
public ReleasePokemonResponse TransferPokemon(ulong pokemonId) // Transfer one pokemon { var message = new ReleasePokemonMessage { PokemonId = pokemonId }; return(PostProtoPayload <Request, ReleasePokemonResponse>(RequestType.ReleasePokemon, message)); }
public async Task <ReleasePokemonResponse> TransferPokemon(ulong pokemonId) { ReleasePokemonMessage releasePokemonMessage = new ReleasePokemonMessage() { PokemonId = pokemonId }; return(await AwaitableOnResponseFor <ReleasePokemonMessage, ReleasePokemonResponse>(releasePokemonMessage, RequestType.ReleasePokemon)); }
public async Task<ReleasePokemonResponse> TransferPokemon(ulong pokemonId) { var message = new ReleasePokemonMessage { PokemonId = pokemonId }; return await PostProtoPayload<Request, ReleasePokemonResponse>(RequestType.ReleasePokemon, message); }
/// <summary> /// /// </summary> /// <param name="pokemonId"></param> /// <returns></returns> public bool QueueTransferPokemonRequest(ulong pokemonId) { var message = new ReleasePokemonMessage { PokemonId = pokemonId }; return(Client.QueueRequest(RequestType.ReleasePokemon, message)); }
public async Task <ReleasePokemonResponse> TransferPokemons(List <ulong> pokemonIds) { var message = new ReleasePokemonMessage { //PokemonIds = new Google.Protobuf.Collections.RepeatedField<ulong>() }; message.PokemonIds.AddRange(pokemonIds); return(await PostProtoPayload <Request, ReleasePokemonResponse>(RequestType.ReleasePokemon, message)); }
public ReleasePokemonResponse TransferPokemons(List <ulong> pokemonId) // Transfer a list of pokemon (BULK Transfer) { var message = new ReleasePokemonMessage { }; message.PokemonIds.AddRange(pokemonId); var result = PostProtoPayloadCommonR <Request, ReleasePokemonResponse>(RequestType.ReleasePokemon, message).Result; if (result.Result == ReleasePokemonResponse.Types.Result.Success) { DeletePokemons(pokemonId); } return(result); }
protected ReleasePokemonResponse ReleasePokemon(ReleasePokemonMessage msg) { var owned = this.GetPokemonById(msg.PokemonId); ReleasePokemonResponse rsp = new ReleasePokemonResponse(); if (owned != null) { rsp.Result = ReleasePokemonResponse.Types.Result.Success; rsp.CandyAwarded = 3; } else { rsp.Result = ReleasePokemonResponse.Types.Result.Failed; } return(rsp); }
public async Task <ReleasePokemonResponse> TransferPokemons(List <ulong> pokemonIds) { // Filter out all pokemons that don't exist and duplicates. pokemonIds = GetPokemons().Where(p => pokemonIds.Contains(p.Id)).Select(p => p.Id).Distinct().ToList(); var message = new ReleasePokemonMessage(); message.PokemonIds.AddRange(pokemonIds); var transferPokemonRequest = new Request { RequestType = RequestType.ReleasePokemon, RequestMessage = message.ToByteString() }; var request = await GetRequestBuilder().GetRequestEnvelope(CommonRequest.FillRequest(transferPokemonRequest, Client)).ConfigureAwait(false); Tuple <ReleasePokemonResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetHoloInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse> response = await PostProtoPayload <Request, ReleasePokemonResponse, CheckChallengeResponse, GetHatchedEggsResponse, GetHoloInventoryResponse, CheckAwardedBadgesResponse, DownloadSettingsResponse, GetBuddyWalkedResponse>(request).ConfigureAwait(false); CheckChallengeResponse checkChallengeResponse = response.Item2; CommonRequest.ProcessCheckChallengeResponse(Client, checkChallengeResponse); GetHoloInventoryResponse getHoloInventoryResponse = response.Item4; CommonRequest.ProcessGetHoloInventoryResponse(Client, getHoloInventoryResponse); DownloadSettingsResponse downloadSettingsResponse = response.Item6; CommonRequest.ProcessDownloadSettingsResponse(Client, downloadSettingsResponse); ReleasePokemonResponse releaseResponse = response.Item1; if (releaseResponse.Result == ReleasePokemonResponse.Types.Result.Success) { foreach (var pokemonId in pokemonIds) { RemoveInventoryItem(GetPokemonHashKey(pokemonId)); } } return(releaseResponse); }
public ReleasePokemonResponse TransferPokemon(ulong pokemonId) // Transfer one pokemon { var message = new ReleasePokemonMessage { PokemonId = pokemonId }; var result = PostProtoPayloadCommonR <Request, ReleasePokemonResponse>(RequestType.ReleasePokemon, message).Result; if (result.Result == ReleasePokemonResponse.Types.Result.Success) { DeletePokemons(new List <ulong> { pokemonId }); } return(result); }
public async Task <MethodResult> TransferPokemon(IEnumerable <PokemonData> pokemonsToTransfer) { var pokemonToTransfer = pokemonsToTransfer.Where(x => x.Favorite != 1 && !x.IsEgg && string.IsNullOrEmpty(x.DeployedFortId) && x.Id != PlayerData.BuddyPokemon?.Id); if (!UserSettings.TransferAtOnce) { foreach (PokemonData pokemon in pokemonToTransfer) { var message = new ReleasePokemonMessage { PokemonId = pokemon.Id }; try { var response = await _client.ClientSession.RpcClient.SendRemoteProcedureCallAsync(new Request { RequestType = RequestType.ReleasePokemon, RequestMessage = message.ToByteString() }); ReleasePokemonResponse releasePokemonResponse = null; releasePokemonResponse = ReleasePokemonResponse.Parser.ParseFrom(response); if (releasePokemonResponse.Result == ReleasePokemonResponse.Types.Result.Success) { LogCaller(new LoggerEventArgs( String.Format("Successully transferred {0}. Cp: {1}. IV: {2:0.00}%", pokemon.PokemonId, pokemon.Cp, CalculateIVPerfection(pokemon)), LoggerTypes.Transfer)); await Task.Delay(CalculateDelay(UserSettings.DelayBetweenPlayerActions, UserSettings.PlayerActionDelayRandom)); UpdateInventory(); // <- should not be needed } else { LogCaller(new LoggerEventArgs(String.Format("Faill to transfer {0}. Because: {1}.", pokemon.PokemonId, releasePokemonResponse.Result), LoggerTypes.Warning)); } } catch (Exception ex) { LogCaller(new LoggerEventArgs("ReleasePokemonResponse parsing failed because response was empty", LoggerTypes.Exception, ex)); return(new MethodResult()); } } return(new MethodResult { Success = true }); } else { var message = new ReleasePokemonMessage { PokemonIds = { pokemonToTransfer.Where(x => x != null && x.PokemonId != PokemonId.Missingno).Select(x => x.Id) } }; try { var response = await _client.ClientSession.RpcClient.SendRemoteProcedureCallAsync(new Request { RequestType = RequestType.ReleasePokemon, RequestMessage = message.ToByteString() }); ReleasePokemonResponse releasePokemonResponse = null; releasePokemonResponse = ReleasePokemonResponse.Parser.ParseFrom(response); if (releasePokemonResponse.Result == ReleasePokemonResponse.Types.Result.Success) { LogCaller(new LoggerEventArgs( String.Format("Successully candy awarded {0} of {1} Pokemons.", releasePokemonResponse.CandyAwarded, pokemonToTransfer.Count()), LoggerTypes.Transfer)); await Task.Delay(CalculateDelay(UserSettings.DelayBetweenPlayerActions, UserSettings.PlayerActionDelayRandom)); UpdateInventory(); // <- should not be needed } else { LogCaller(new LoggerEventArgs(String.Format("Faill to transfer {0} Pokemons.", pokemonToTransfer.Count()), LoggerTypes.Warning)); } } catch (Exception ex) { LogCaller(new LoggerEventArgs("ReleasePokemonResponse parsing failed because response was empty", LoggerTypes.Exception, ex)); return(new MethodResult()); } return(new MethodResult { Success = true }); } }