2017-10-13 00:31:12 +04:00
|
|
|
|
// i2_bot – Instinct PokememBro Bot
|
|
|
|
|
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
|
|
|
|
|
|
2017-11-21 06:06:32 +04:00
|
|
|
|
package statistics
|
2017-10-13 00:31:12 +04:00
|
|
|
|
|
2017-10-18 09:39:50 +04:00
|
|
|
|
// PossibilityRequiredPokeballs returns possibility of catching pokememe
|
|
|
|
|
// It's based on location, grade of pokememe and current level of player
|
2017-11-21 06:06:32 +04:00
|
|
|
|
func (s *Statistics) PossibilityRequiredPokeballs(location int, grade int, lvl int) (float64, int) {
|
2017-10-18 09:39:50 +04:00
|
|
|
|
var basePossibility float64
|
|
|
|
|
var requiredPokeballs int
|
|
|
|
|
var percentile float64
|
2017-10-13 00:31:12 +04:00
|
|
|
|
|
2017-10-18 07:03:34 +04:00
|
|
|
|
if lvl > 3 {
|
|
|
|
|
switch {
|
|
|
|
|
case grade == (lvl + 1):
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.05
|
2017-10-18 07:03:34 +04:00
|
|
|
|
case grade == lvl:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.5
|
2017-10-18 07:03:34 +04:00
|
|
|
|
case grade == (lvl - 1):
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.3
|
2017-10-18 07:03:34 +04:00
|
|
|
|
case grade == (lvl - 2):
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.1
|
2017-10-18 07:03:34 +04:00
|
|
|
|
case grade == (lvl - 3):
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.05
|
2017-10-18 07:03:34 +04:00
|
|
|
|
default:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.00
|
2017-10-18 07:03:34 +04:00
|
|
|
|
}
|
|
|
|
|
} else if lvl == 3 {
|
|
|
|
|
switch grade {
|
|
|
|
|
case 4:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.05
|
2017-10-18 07:03:34 +04:00
|
|
|
|
case 3:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.5
|
2017-10-18 07:03:34 +04:00
|
|
|
|
case 2:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.3
|
2017-10-18 07:03:34 +04:00
|
|
|
|
case 1:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.15
|
2017-10-18 07:03:34 +04:00
|
|
|
|
default:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.00
|
2017-10-18 07:03:34 +04:00
|
|
|
|
}
|
|
|
|
|
} else if lvl == 2 {
|
|
|
|
|
switch grade {
|
|
|
|
|
case 3:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.05
|
2017-10-18 07:03:34 +04:00
|
|
|
|
case 2:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.70
|
2017-10-18 07:03:34 +04:00
|
|
|
|
case 1:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.25
|
2017-10-18 07:03:34 +04:00
|
|
|
|
default:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.00
|
2017-10-18 07:03:34 +04:00
|
|
|
|
}
|
|
|
|
|
} else if lvl == 1 {
|
|
|
|
|
switch grade {
|
|
|
|
|
case 2:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.80
|
2017-10-18 07:03:34 +04:00
|
|
|
|
case 1:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.20
|
2017-10-18 07:03:34 +04:00
|
|
|
|
default:
|
2017-10-18 09:39:50 +04:00
|
|
|
|
basePossibility = 0.00
|
2017-10-18 07:03:34 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-13 00:31:12 +04:00
|
|
|
|
|
2018-05-02 00:47:55 +04:00
|
|
|
|
pokememesCount := c.DataCache.GetPokememesCountByGradeAndLocation(grade, location)
|
2017-10-13 00:31:12 +04:00
|
|
|
|
|
2017-10-18 09:39:50 +04:00
|
|
|
|
if basePossibility != 0 && pokememesCount != 0 {
|
|
|
|
|
percentile = basePossibility * 100.0 / float64(pokememesCount)
|
|
|
|
|
requiredPokeballs = int(100.0 / percentile)
|
2017-10-18 07:03:34 +04:00
|
|
|
|
}
|
2017-10-13 00:31:12 +04:00
|
|
|
|
|
2017-10-18 09:39:50 +04:00
|
|
|
|
return percentile, requiredPokeballs
|
2017-10-13 00:31:12 +04:00
|
|
|
|
}
|