From 49a88288ec694f7b13dd60cfc9cb10e4b0a074c3 Mon Sep 17 00:00:00 2001 From: Fabio1988 Date: Tue, 16 Jan 2024 18:52:31 +0100 Subject: [PATCH 1/3] rework showcase and add logs for second pokemon type --- decoder/pokestop.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/decoder/pokestop.go b/decoder/pokestop.go index 8e23ecfb..0b658a04 100644 --- a/decoder/pokestop.go +++ b/decoder/pokestop.go @@ -567,7 +567,8 @@ func (stop *Pokestop) updatePokestopFromGetContestDataOutProto(contest *pogo.Con // Focus does not populate. We can only store 1 atm, so this just grabs the first // if there is one and falls back to Focus if Focuses is empty, just in case. var focussedPokemon *pogo.ContestPokemonFocusProto - var focussedPokemonType *pogo.ContestFocusProto + var focussedPokemonType *pogo.ContestPokemonTypeFocusProto + var focussedBuddy *pogo.ContestBuddyFocusProto if focuses := contest.GetFocuses(); len(focuses) > 0 { var numPokemon int @@ -582,7 +583,12 @@ func (stop *Pokestop) updatePokestopFromGetContestDataOutProto(contest *pogo.Con if pokType := focus.GetType(); pokType != nil { if focussedPokemonType == nil { - focussedPokemonType = focus + focussedPokemonType = pokType + } + } + if buddy := focus.GetBuddy(); buddy != nil { + if focussedBuddy == nil { + focussedBuddy = buddy } } } @@ -593,6 +599,8 @@ func (stop *Pokestop) updatePokestopFromGetContestDataOutProto(contest *pogo.Con } } else { focussedPokemon = contest.GetFocus().GetPokemon() + focussedPokemonType = contest.GetFocus().GetType() + focussedBuddy = contest.GetFocus().GetBuddy() } if focussedPokemon == nil { @@ -610,8 +618,14 @@ func (stop *Pokestop) updatePokestopFromGetContestDataOutProto(contest *pogo.Con if focussedPokemonType == nil { stop.ShowcasePokemonType = null.IntFromPtr(nil) } else { - stop.ShowcasePokemonType = null.IntFrom(int64(focussedPokemonType.GetType().GetPokemonType1())) + //TODO there is also a Type2 in the Proto + type2 := int64(focussedPokemonType.GetPokemonType2()) + if type2 != 0 { + log.Warnf("SHOWCASE: Stop: '%s' with Focussed Pokemon Type 2: %d", stop.Id, type2) + } + stop.ShowcasePokemonType = null.IntFrom(int64(focussedPokemonType.GetPokemonType1())) } + //TODO add logic for buddy } func (stop *Pokestop) updatePokestopFromGetPokemonSizeContestEntryOutProto(contestData *pogo.GetPokemonSizeLeaderboardEntryOutProto) { From 5c56cb547f7767f447aa377ef36db2e88c2cede8 Mon Sep 17 00:00:00 2001 From: Fabio1988 Date: Tue, 20 Feb 2024 21:25:29 +0100 Subject: [PATCH 2/3] add more focusses to test --- decoder/pokestop.go | 89 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 4 deletions(-) diff --git a/decoder/pokestop.go b/decoder/pokestop.go index 0b658a04..9d09c1b0 100644 --- a/decoder/pokestop.go +++ b/decoder/pokestop.go @@ -569,6 +569,13 @@ func (stop *Pokestop) updatePokestopFromGetContestDataOutProto(contest *pogo.Con var focussedPokemon *pogo.ContestPokemonFocusProto var focussedPokemonType *pogo.ContestPokemonTypeFocusProto var focussedBuddy *pogo.ContestBuddyFocusProto + var focussedPokemonAlignment *pogo.ContestPokemonAlignmentFocusProto + var focussedPokemonClass *pogo.ContestPokemonClassFocusProto + var focussedPokemonFamily *pogo.ContestPokemonFamilyFocusProto + var focussedGeneration *pogo.ContestGenerationFocusProto + var focussedHatched *pogo.ContestHatchedFocusProto + var focussedMega *pogo.ContestTemporaryEvolutionFocusProto + var focussedShiny *pogo.ContestShinyFocusProto if focuses := contest.GetFocuses(); len(focuses) > 0 { var numPokemon int @@ -591,6 +598,41 @@ func (stop *Pokestop) updatePokestopFromGetContestDataOutProto(contest *pogo.Con focussedBuddy = buddy } } + if alignment := focus.GetAlignment(); alignment != nil { + if focussedPokemonAlignment == nil { + focussedPokemonAlignment = alignment + } + } + if pokemonClass := focus.GetPokemonClass(); pokemonClass != nil { + if focussedPokemonClass == nil { + focussedPokemonClass = pokemonClass + } + } + if pokemonFamily := focus.GetPokemonFamily(); pokemonFamily != nil { + if focussedPokemonFamily == nil { + focussedPokemonFamily = pokemonFamily + } + } + if generation := focus.GetGeneration(); generation != nil { + if focussedGeneration == nil { + focussedGeneration = generation + } + } + if hatched := focus.GetHatched(); hatched != nil { + if focussedHatched == nil { + focussedHatched = hatched + } + } + if mega := focus.GetMega(); mega != nil { + if focussedMega == nil { + focussedMega = mega + } + } + if shiny := focus.GetShiny(); shiny != nil { + if focussedShiny == nil { + focussedShiny = shiny + } + } } if l := len(focuses); l > 1 { log.Warnf("pokestop '%s' contains %d focus entries (%d pokemon): using the first pokemon found", @@ -598,9 +640,18 @@ func (stop *Pokestop) updatePokestopFromGetContestDataOutProto(contest *pogo.Con ) } } else { - focussedPokemon = contest.GetFocus().GetPokemon() - focussedPokemonType = contest.GetFocus().GetType() - focussedBuddy = contest.GetFocus().GetBuddy() + log.Warnf("SHOWCASE: old contest.GetFocus used") + focus := contest.GetFocus() + focussedPokemon = focus.GetPokemon() + focussedPokemonType = focus.GetType() + focussedBuddy = focus.GetBuddy() + focussedPokemonAlignment = focus.GetAlignment() + focussedPokemonClass = focus.GetPokemonClass() + focussedPokemonFamily = focus.GetPokemonFamily() + focussedGeneration = focus.GetGeneration() + focussedHatched = focus.GetHatched() + focussedMega = focus.GetMega() + focussedShiny = focus.GetShiny() } if focussedPokemon == nil { @@ -625,7 +676,37 @@ func (stop *Pokestop) updatePokestopFromGetContestDataOutProto(contest *pogo.Con } stop.ShowcasePokemonType = null.IntFrom(int64(focussedPokemonType.GetPokemonType1())) } - //TODO add logic for buddy + //TODO add logic for new focuses + if focussedBuddy != nil { + minLevel := focussedBuddy.GetMinBuddyLevel() // level 0-5 + log.Infof("SHOWCASE: Stop: '%s' with Focussed Buddy: %s", stop.Id, minLevel.String()) + } + if focussedPokemonAlignment != nil { + alignment := focussedPokemonAlignment.GetRequiredAlignment() // unset, purified, shadow + log.Infof("SHOWCASE: Stop: '%s' with Focussed Pokemon Alignment: %s", stop.Id, alignment.String()) + } + if focussedPokemonClass != nil { + requiredClass := focussedPokemonClass.GetRequiredClass() // normal, legendary, mythic, ultra beast + log.Infof("SHOWCASE: Stop: '%s' with Focussed Pokemon Class: %s", stop.Id, requiredClass.String()) + } + if focussedPokemonFamily != nil { + requiredFamily := focussedPokemonFamily.GetRequiredFamily() // family pikachu, zubat e.g. + log.Infof("SHOWCASE: Stop: '%s' with Focussed Pokemon Family: %s", stop.Id, requiredFamily.String()) + } + if focussedGeneration != nil { + generation := focussedGeneration.GetPokemonGeneration() // gen 1 - 9 + log.Infof("SHOWCASE: Stop: '%s' with Focussed Pokemon Generation: %s", stop.Id, generation.String()) + } + if focussedHatched != nil { + hatched := focussedHatched.GetRequireToBeHatched() // true , false + log.Infof("SHOWCASE: Stop: '%s' with Focussed Hatched: %t", stop.Id, hatched) + } + if focussedMega != nil { + restriction := focussedMega.GetRestriction() // MEGA, NOT_TEMP_EVO + evolution := focussedMega.GetTemporaryEvolutionRequired() // MEGA, MEGA_X, MEGA_Y, PRIMAL + log.Infof("SHOWCASE: Stop: '%s' with Focussed Mega: %s %s", stop.Id, restriction.String(), evolution.String()) + } + } func (stop *Pokestop) updatePokestopFromGetPokemonSizeContestEntryOutProto(contestData *pogo.GetPokemonSizeLeaderboardEntryOutProto) { From 3cb23d07f49d82196c123fadd30b5451c8ed5f81 Mon Sep 17 00:00:00 2001 From: Fabio1988 Date: Tue, 20 Feb 2024 21:37:53 +0100 Subject: [PATCH 3/3] log --- decoder/pokestop.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decoder/pokestop.go b/decoder/pokestop.go index 9d09c1b0..b600ac4d 100644 --- a/decoder/pokestop.go +++ b/decoder/pokestop.go @@ -635,7 +635,7 @@ func (stop *Pokestop) updatePokestopFromGetContestDataOutProto(contest *pogo.Con } } if l := len(focuses); l > 1 { - log.Warnf("pokestop '%s' contains %d focus entries (%d pokemon): using the first pokemon found", + log.Warnf("SHOWCASE: pokestop '%s' contains %d focus entries (%d pokemon): using the first pokemon found", stop.Id, l, numPokemon, ) }