Skip to content

Commit

Permalink
Merge branch 'UnownHash:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ReuschelCGN authored Nov 22, 2024
2 parents d3ad94b + 1dc2f4b commit ba5f2a5
Showing 1 changed file with 8 additions and 7 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

0 comments on commit ba5f2a5

Please sign in to comment.