Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Update StartGymBattleMessage.proto #97

Merged
merged 2 commits into from
Jul 31, 2016
Merged

Update StartGymBattleMessage.proto #97

merged 2 commits into from
Jul 31, 2016

Conversation

Grover-c13
Copy link
Contributor

Change defending pokemonID to fixed64, otherwise start gym battle fails.

@krzys-h
Copy link

krzys-h commented Jul 28, 2016

I can confirm this fixes the problem for me too

@Nostrademous
Copy link
Contributor

@Grover-c13 curious as I can't get it to work still - posted here:

def battleGym(fort):
    log.info("<>________________________________________________________________________<>")
    log.info("%s GYM NEARBY", TeamColor.DESCRIPTOR.values[fort.owned_by_team].name)
    # get gym details
    gym_proto = getGymDetails(fort)
    if not gym_proto: return 0
    log.info(gym_proto)
    log.info("<>________________________________________________________________________<>")

    ##############################################
    # gather necessary details to start a battle #
    ##############################################

    # check if gym is neutral/unowned - if so deploy to it
    if fort.owned_by_team == 0: # Neutral
        deployPokemonToGym(gym_proto)
        return 0

    # save a boolean checking if we are on the same team
    sameTeam = gl.my_team == fort.owned_by_team

    # find out who is defending
    defending_pokemon = []
    for defender in gym_proto.gym_state.memberships:
        defending_pokemon.append(defender.pokemon_data)

    # determine who we will attack with
    num = 6
    if sameTeam: num = 1
    my_attackers = pickAttackers(num) # this will be a list []

    #log.error('Function not finished, returning out...')
    #return 0

    # start the battle
    log.info('Gym ID: %s' % gym_proto.gym_state.fort_data.id)
    log.info('Attacker list: %s' % str(my_attackers))
    log.info('Defender: %d' % defending_pokemon[0].id)
    gl.api.start_gym_battle(gym_id=fort.id, attacking_pokemon_ids=my_attackers, defending_pokemon_id=defending_pokemon[0].id, player_latitude=gl.p_lat, player_longitude=gl.p_lng)

    start_reply = gl.api.call(False)
    start_payload = getPayload(start_reply)

Printing the request I see:

 [23:45:59] [ INFO] Gym ID: 555ba115a93546aca7851fed86d3ef6c.16
 [23:45:59] [ INFO] Attacker list: [17395715307789231292L] # one if my team, 6 if other
 [23:45:59] [ INFO] Defender: 568051736162843098
 [23:46:00] [ERROR] startGymBattle() request failed to get payload

and printing the gym_proto result:

 [23:45:59] [ INFO] gym_state {
  fort_data {
    id: "555ba115a93546aca7851fed86d3ef6c.16"
    last_modified_timestamp_ms: 1469762856688
    latitude: 38.854506
    longitude: -77.349488
    owned_by_team: RED
    guard_pokemon_id: FLAREON
    enabled: true
    gym_points: 2000
  }
  memberships {
    pokemon_data {
      id: 568051736162843098
      pokemon_id: FLAREON
      cp: 1002
      stamina: 130
      stamina_max: 130
      move_1: EMBER_FAST
      move_2: FLAMETHROWER
      owner_name: "Firehawk04xx"
      height_m: 0.884167253971
      weight_kg: 9.47041511536
      individual_attack: 15
      individual_defense: 14
      individual_stamina: 1
      cp_multiplier: 0.481684952974
      pokeball: ITEM_GREAT_BALL
      battles_attacked: 10
      battles_defended: 1
      creation_time_ms: 1469753995514
      num_upgrades: 2
      additional_cp_multiplier: 0.0181734859943
      nickname: "Flareon"
    }
    trainer_public_profile {
      name: "Firehawk04xx"
      level: 13
      avatar {
        skin: 2
        hair: 2
        shirt: 1
        hat: 2
        shoes: 1
        backpack: 2
      }
    }
  }
}

@Grover-c13
Copy link
Contributor Author

Are you sending the player lat/long in the StartGymBattleRequest and is your script/api handling the new rate limiting?

@rubenvereecken
Copy link
Contributor

I'm ok with merging in if you add a comment on the type.

@Nostrademous
Copy link
Contributor

@Grover-c13 yes, I am providing lat/long in double format. And yes. I am doing a lot more before the gym start without a rate-limit problem.

@rubenvereecken
Copy link
Contributor

Thanks for the added message Grover

@rubenvereecken rubenvereecken merged commit 333e547 into AeonLucid:master Jul 31, 2016
@Nostrademous
Copy link
Contributor

Nostrademous commented Jul 31, 2016

This still fails for me... here is the protoc of the request - do you see anything strange?
@rubenvereecken @Grover-c13

 [14:36:44] [ INFO] GymID: 555ba115a93546aca7851fed86d3ef6c.16
 [14:36:44] [ INFO] Attacker list: [2606127759218461685, 17395715301989231292L, 16501589199473057870L, 5160629308560943927, 15772050321341645625L, 7499108699471520736]
 [14:36:44] [ INFO] Defender: 12429075063652843444
 [14:36:44] [ERROR] Decode raw over protoc (protoc has to be in your PATH):
1: 2
3: 2557346066
4 {
  1: 135
  2 {
    1: "555ba115a93546aca7851fed86d3ef6c.16"
    2: 0x242ad3639f804bf5
    2: 0xf169fee694e52abc
    2: 0xe5016bf2a003a04e
    2: 0x479e3d03923eab37
    2: 0xdae194340f278339
    2: 0x68122fa1540aa3e0
    3: 0xac7cf1eb17b17fb4
    4: 0x40436d5fe3352274
    5: 0xc05356595ed4cba5
  }
}
7: 0x40436d5fe3352274
8: 0xc05356595ed4cba5
9: 0x0000000000000000
10 {
  1: "google"
  2 {
    1: "eyJhbGciOiJSUzI1NiIsImtpZ.......PjcFFxCbMTxJwAB0FlLVg"
    2: 59
  }
}
12: 989

 [14:36:44] [ERROR] startGymBattle() request failed to get payload

As you can see it is all as described... the only thing I'm missing is the "auth_ticket" for field 11: in outer Envelope, which perhaps is the issue? Doesn't seem to be a problem for all other requests I make.

@krzys-h
Copy link

krzys-h commented Jul 31, 2016

It may be that the server redirects you to another endpoint - I noticed StartGymBattle tends to do that quite often. See what the status_code of the response envelope is, and if it's 53, repeat the request (and all future ones) to the provided api_url instead.
Also see tejado/pgoapi#161

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants