This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/common/utils"
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
)
|
||||
@@ -20,13 +21,36 @@ func NewEggService() *EggService {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *EggService) Get(id uint32) *model.Egg {
|
||||
if id == 0 {
|
||||
return nil
|
||||
}
|
||||
var item *model.Egg
|
||||
dbm(s.Model).Where("id", id).Scan(&item)
|
||||
func (s *EggService) GetData(p1 uint32) []int32 {
|
||||
//cacheKey := strings.Join([]string{fmt.Sprintf("%d", p1), fmt.Sprintf("%d", p2)}, ":")
|
||||
m := dbm(s.Model)
|
||||
|
||||
return item
|
||||
var pet []model.Egg //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
m.Wheref(`male_pet_ids @> ARRAY[?]::integer[]`, p1).
|
||||
Where("is_enable", 1).Scan(&pet)
|
||||
var petIDs []int32
|
||||
for _, p := range pet {
|
||||
petIDs = append(petIDs, p.FemalePetIDs...)
|
||||
}
|
||||
|
||||
return petIDs
|
||||
|
||||
}
|
||||
func (s *EggService) GetResult(m, f uint32) uint32 {
|
||||
//cacheKey := strings.Join([]string{fmt.Sprintf("%d", p1), fmt.Sprintf("%d", p2)}, ":")
|
||||
md := dbm(s.Model)
|
||||
|
||||
var pet *model.Egg //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
md.Wheref(`male_pet_ids @> ARRAY[?]::integer[]`, m).
|
||||
Wheref(`female_pet_ids @> ARRAY[?]::integer[]`, f).
|
||||
Where("is_enable", 1).Scan(&pet)
|
||||
if pet != nil {
|
||||
|
||||
t, _ := utils.RandomByWeight(pet.OutputMons, pet.Probs)
|
||||
return uint32(t)
|
||||
|
||||
}
|
||||
|
||||
return 0
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user