From 5a746b524b1864c7e7ebdf80eed21bdca8f062b0 Mon Sep 17 00:00:00 2001 From: Vladimir Hodakov Date: Wed, 7 Feb 2018 13:39:34 +0400 Subject: [PATCH] /best pokememes are now filtered by defence and purchaseability --- lib/pokedexer/getters.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/pokedexer/getters.go b/lib/pokedexer/getters.go index e01cb70..ce2e6f4 100644 --- a/lib/pokedexer/getters.go +++ b/lib/pokedexer/getters.go @@ -30,8 +30,12 @@ func (p *Pokedexer) getBestPokememes(playerID int) (map[int]*dbmapping.PokememeF allPokememes := c.DataCache.GetAllPokememes() if profileRaw.LevelID < 4 { for i := range allPokememes { - if allPokememes[i].Pokememe.Grade == profileRaw.LevelID+1 { - pokememesArray[allPokememes[i].Pokememe.Attack] = allPokememes[i] + if (allPokememes[i].Pokememe.Defence < profileRaw.Power) || (allPokememes[i].Pokememe.Purchaseable) { + if len(pokememesArray) < 5 { + if allPokememes[i].Pokememe.Grade == profileRaw.LevelID+1 { + pokememesArray[allPokememes[i].Pokememe.Attack] = allPokememes[i] + } + } } } } else if profileRaw.LevelID > 8 { @@ -45,7 +49,11 @@ func (p *Pokedexer) getBestPokememes(playerID int) (map[int]*dbmapping.PokememeF } } if matchLeague { - pokememesArray[allPokememes[i].Pokememe.Attack] = allPokememes[i] + if (allPokememes[i].Pokememe.Defence < profileRaw.Power) || (allPokememes[i].Pokememe.Purchaseable) { + if len(pokememesArray) < 5 { + pokememesArray[allPokememes[i].Pokememe.Attack] = allPokememes[i] + } + } } } } @@ -59,7 +67,11 @@ func (p *Pokedexer) getBestPokememes(playerID int) (map[int]*dbmapping.PokememeF } } if matchLeague { - pokememesArray[allPokememes[i].Pokememe.Attack] = allPokememes[i] + if (allPokememes[i].Pokememe.Defence < profileRaw.Power) || (allPokememes[i].Pokememe.Purchaseable) { + if len(pokememesArray) < 5 { + pokememesArray[allPokememes[i].Pokememe.Attack] = allPokememes[i] + } + } } } }