Skip to content

Commit

Permalink
Merge branch 'UnownHash:main' into main-lvl20
Browse files Browse the repository at this point in the history
  • Loading branch information
ReuschelCGN authored Dec 12, 2024
2 parents b987a2f + 28e0f07 commit 6524e9e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
15 changes: 8 additions & 7 deletions decoder/pokemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"database/sql"
"encoding/json"
"fmt"
"math"
"strconv"
"time"

Expand Down Expand Up @@ -720,12 +719,14 @@ func (pokemon *Pokemon) addEncounterPokemon(ctx context.Context, db db.DbDetails
pokemon.EncounterWeather = EncounterWeather_UnboostedNotPartlyCloudy
}
}
cpMultiplier := float64(proto.CpMultiplier)
cpMultiplier := proto.CpMultiplier
var level int64
if cpMultiplier < 0.734 {
level = int64(math.Round((58.35178527*cpMultiplier-2.838007664)*cpMultiplier + 0.8539209906))
level = int64((58.215688455154954*cpMultiplier-2.7012478057856497)*cpMultiplier + 1.3220677708486794)
} else if cpMultiplier < .795 {
level = int64(171.34093607855277*cpMultiplier - 94.95626666368578)
} else {
level = int64(math.Round(171.0112688*cpMultiplier - 95.20425243))
level = int64(199.99995231630976*cpMultiplier - 117.55996066890287)
}

// Here comes the Ditto logic. Embrace yourself :)
Expand Down Expand Up @@ -823,7 +824,7 @@ func (pokemon *Pokemon) addEncounterPokemon(ctx context.Context, db db.DbDetails
case EncounterWeather_Invalid: // should only happen when upgrading with pre-existing data
if !pokemon.IvInactive.Valid {
setDittoAttributes("00/0N>0P", true, false, true)
} else if level > 30 {
} else if level > 30 && level <= 35 {
setDittoAttributes("BN/PN>0P", true, false, true)
} else {
setDittoAttributes("00/0N/BN/PN>0P or B0>00/[0N]", false, true, false)
Expand All @@ -836,7 +837,7 @@ func (pokemon *Pokemon) addEncounterPokemon(ctx context.Context, db db.DbDetails
uint8(pogo.GameplayWeatherProto_PARTLY_CLOUDY) | EncounterWeather_Rerolled:
setDittoAttributes("PN>0P", true, false, true)
default:
if level > 30 {
if level > 30 && level <= 35 {
setDittoAttributes("BN>0P", true, false, true)
} else if oldWeather&EncounterWeather_Rerolled != 0 {
// in case of BN>0P, we set Ditto to be a hidden 0P state, hoping we rediscover later
Expand Down Expand Up @@ -926,7 +927,7 @@ func (pokemon *Pokemon) addEncounterPokemon(ctx context.Context, db db.DbDetails
pokemon.calculateIv(int64(proto.IndividualAttack), int64(proto.IndividualDefense),
int64(proto.IndividualStamina))
}
} else if level > 30 {
} else if level > 30 && level <= 35 {
setDittoAttributes("0P", true, false, true)
} else {
pokemon.Level = null.IntFrom(level)
Expand Down
16 changes: 11 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,20 +429,26 @@ func decode(ctx context.Context, method int, protoData *ProtoData) {
result = decodeGetRoutes(protoData.Data)
processed = true
case pogo.Method_METHOD_GET_CONTEST_DATA:
// Request helps, but can be decoded without it
result = decodeGetContestData(ctx, protoData.Request, protoData.Data)
if getScanParameters(protoData).ProcessPokestops {
// Request helps, but can be decoded without it
result = decodeGetContestData(ctx, protoData.Request, protoData.Data)
}
processed = true
break
case pogo.Method_METHOD_GET_POKEMON_SIZE_CONTEST_ENTRY:
// Request is essential to decode this
if protoData.Request != nil {
result = decodeGetPokemonSizeContestEntry(ctx, protoData.Request, protoData.Data)
if getScanParameters(protoData).ProcessPokestops {
result = decodeGetPokemonSizeContestEntry(ctx, protoData.Request, protoData.Data)
}
processed = true
}
break
case pogo.Method_METHOD_GET_STATION_DETAILS:
// Request is essential to decode this
result = decodeGetStationDetails(ctx, protoData.Request, protoData.Data)
if getScanParameters(protoData).ProcessStations {
// Request is essential to decode this
result = decodeGetStationDetails(ctx, protoData.Request, protoData.Data)
}
processed = true

default:
Expand Down

0 comments on commit 6524e9e

Please sign in to comment.