feat: 增加宠物蛋结果计算和金币检查逻辑
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -35,7 +35,7 @@ func (s *EggService) GetData(p1 uint32) []int32 {
|
|||||||
return petIDs
|
return petIDs
|
||||||
|
|
||||||
}
|
}
|
||||||
func (s *EggService) GetResult(m, f uint32) (uint32, bool) {
|
func (s *EggService) GetResult(m, f, level uint32) (uint32, bool) {
|
||||||
//cacheKey := strings.Join([]string{fmt.Sprintf("%d", p1), fmt.Sprintf("%d", p2)}, ":")
|
//cacheKey := strings.Join([]string{fmt.Sprintf("%d", p1), fmt.Sprintf("%d", p2)}, ":")
|
||||||
md := dbm_enable(s.Model)
|
md := dbm_enable(s.Model)
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ func (s *EggService) GetResult(m, f uint32) (uint32, bool) {
|
|||||||
md.Wheref(`male_pet_ids @> ARRAY[?]::integer[]`, m).
|
md.Wheref(`male_pet_ids @> ARRAY[?]::integer[]`, m).
|
||||||
Wheref(`female_pet_ids @> ARRAY[?]::integer[]`, f).Scan(&pet)
|
Wheref(`female_pet_ids @> ARRAY[?]::integer[]`, f).Scan(&pet)
|
||||||
if pet != nil {
|
if pet != nil {
|
||||||
|
pet.OutputMons[len(pet.OutputMons)-1] += int32(level)
|
||||||
t, _ := utils.RandomByWeight(pet.OutputMons, pet.Probs)
|
t, _ := utils.RandomByWeight(pet.OutputMons, pet.Probs)
|
||||||
if pet.OutputMons[len(pet.OutputMons)-1] == int32(t) {
|
if pet.OutputMons[len(pet.OutputMons)-1] == int32(t) {
|
||||||
return uint32(t), true
|
return uint32(t), true
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package admin
|
|||||||
import (
|
import (
|
||||||
"blazing/common/data"
|
"blazing/common/data"
|
||||||
"blazing/cool"
|
"blazing/cool"
|
||||||
|
base "blazing/modules/base/service"
|
||||||
config "blazing/modules/config/service"
|
config "blazing/modules/config/service"
|
||||||
"blazing/modules/player/model"
|
"blazing/modules/player/model"
|
||||||
"blazing/modules/player/service"
|
"blazing/modules/player/service"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
)
|
)
|
||||||
@@ -98,6 +100,14 @@ func (c *PetBagController) ModPrise(ctx context.Context, req *PriseReq) (res *co
|
|||||||
if req.Price < 5 {
|
if req.Price < 5 {
|
||||||
req.Price = 5
|
req.Price = 5
|
||||||
}
|
}
|
||||||
|
if req.IsSale == 1 {
|
||||||
|
|
||||||
|
if base.NewBaseSysUserService().GetFreeGold(admin.UserId) < 0 {
|
||||||
|
err = fmt.Errorf("金币不足")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
err = service.NewPetService(uint32(admin.UserId)).UPdatePrice(req.Ctime, req.Price, req.IsSale)
|
err = service.NewPetService(uint32(admin.UserId)).UPdatePrice(req.Ctime, req.Price, req.IsSale)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ func (s *EggService) GetEgg() *model.PetInfo {
|
|||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
mpets, isshiny := service.NewEggService().GetResult(tt.CurEgg.MalePetID, tt.CurEgg.FeMalePetID)
|
mpets, isshiny := service.NewEggService().GetResult(tt.CurEgg.MalePetID, tt.CurEgg.FeMalePetID,tt.CurEgg.EggID+tt.Data.Intimacy)
|
||||||
if mpets == 0 {
|
if mpets == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func (s *PetService) PetCount(flag int) int {
|
|||||||
|
|
||||||
func (s *PetService) UPdateFree(ctime uint32, free uint32) {
|
func (s *PetService) UPdateFree(ctime uint32, free uint32) {
|
||||||
|
|
||||||
s.dbm(s.Model).Where("catch_time", ctime).Data(
|
s.dbm(s.Model).Where("catch_time", ctime).Where("is_sale", 0).Data(
|
||||||
|
|
||||||
"free", free,
|
"free", free,
|
||||||
).Update()
|
).Update()
|
||||||
|
|||||||
Reference in New Issue
Block a user