1
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
昔念
2026-04-25 15:55:08 +08:00
parent fe9c82fd2d
commit 415315c288
2 changed files with 11 additions and 20 deletions

View File

@@ -1,7 +1,6 @@
package effect
import (
"blazing/logic/service/fight/action"
"blazing/logic/service/fight/input"
)
@@ -32,17 +31,9 @@ func (e *Effect91) Skill_Use() bool {
type Effect91Sub struct {
RoundEffectSideArg0Base
ready bool
}
func (e *Effect91Sub) TurnStart(_, _ *action.SelectSkillAction) {
e.ready = true
}
func (e *Effect91Sub) PropBefer(in *input.Input, prop int8, level int8) bool {
if !e.ready {
return true
}
func (e *Effect91Sub) PropBefer(_ *input.Input, prop int8, level int8) bool {
if prop < 0 || int(prop) >= len(e.Ctx().Our.Prop) {
return true
}

View File

@@ -13,7 +13,7 @@ import (
"github.com/gogf/gf/v2/os/gtime"
)
// nextCatchTime 鐢熸垚涓嬩竴涓敮涓€鎹曟崏鏃堕棿鎴筹紙鍘熷瓙閫掑 max_ts锛?
// nextCatchTime 生成下一个唯一捕捉时间戳(原子递增 max_ts
func (s *PetService) nextCatchTime(m ...*gdb.Model) (uint32, error) {
dbm := cool.DBM(service.NewBaseSysUserService().Model)
if len(m) > 0 {
@@ -30,7 +30,7 @@ RETURNING max_ts;`, service.NewBaseSysUserService().Model.TableName())
ret, err := dbm.Raw(sql, s.userid).All()
if err != nil {
return 0, fmt.Errorf("鐢熸垚鎹曟崏鏃堕棿澶辫触: %w", err)
return 0, fmt.Errorf("生成捕捉时间失败: %w", err)
}
arr := ret.Array()
if len(arr) == 0 {
@@ -39,14 +39,14 @@ RETURNING max_ts;`, service.NewBaseSysUserService().Model.TableName())
return arr[0].Uint32(), nil
}
// setCatchTime 灏?Pet.CatchTime 鍚屾鍒?Pet.Data.CatchTime
// setCatchTime Pet.CatchTime 同步到 Pet.Data.CatchTime
func setCatchTime(pet *model.Pet) {
if pet != nil {
pet.Data.CatchTime = pet.CatchTime
}
}
// 鑾峰彇绮剧伒淇℃伅 0鏄粨搴?1鏄斁鐢?
// 获取精灵信息 0是仓库 1是放生
func (s *PetService) PetInfo(flag int) []model.Pet {
var tt []model.Pet
if err := s.dbm(s.Model).Where("free", flag).Scan(&tt); err != nil {
@@ -145,14 +145,14 @@ func (s *PetService) UpdatePrice(catchTime, price, free uint32) error {
if free == 2 {
t, _ := s.dbm(s.Model).Where("free", 2).Count()
if t > 3 {
return fmt.Errorf("绮剧伒鏁伴噺宸叉弧")
return fmt.Errorf("超过3个上架限制无法修改价格")
}
} else {
if err := s.dbm(s.Model).Where("catch_time", catchTime).Scan(&item); err != nil {
return err
}
_, feeRate, _ = item.GetOffShelfFee()
_ = feeRate // feeRate 浠呭湪 non-2 鍒嗘敮浣跨敤锛屽湪姝ゅ0鏄庝互缁熶竴浣滅敤鍩?
_ = feeRate // feeRate 仅在 non-2 分支使用,在此声明以统一作用域
}
res, _ := s.dbm(s.Model).Where("catch_time", catchTime).Data(g.Map{
@@ -183,7 +183,7 @@ func (s *PetService) BuyPet(pid uint32) error {
return fmt.Errorf("pet sale price is not set")
}
if !tt.UpdateTime.AddDate(0, 0, 1).Before(gtime.Now()) {
return fmt.Errorf("鏈埌璐拱鏃堕棿")
return fmt.Errorf("未到购买时间")
}
return g.DB().Transaction(context.TODO(), func(ctx context.Context, tx gdb.TX) error {
@@ -194,7 +194,7 @@ func (s *PetService) BuyPet(pid uint32) error {
return err
}
if user.FreeGold < useGold {
return fmt.Errorf("浣欓涓嶈冻")
return fmt.Errorf("余额不足")
}
if _, err := tx.Model(basemodel.BaseSysUser{}).Where("id", s.userid).Increment("free_gold", -useGold); err != nil {
@@ -207,7 +207,7 @@ func (s *PetService) BuyPet(pid uint32) error {
}
affected, _ := res.RowsAffected()
if affected == 0 {
return fmt.Errorf("閲嶅璁㈠崟")
return fmt.Errorf("重复订单")
}
if _, err := tx.Model(basemodel.BaseSysUser{}).Where("id", tt.PlayerID).Increment("free_gold", int64(tt.SalePrice)*98); err != nil {
@@ -295,7 +295,7 @@ func (s *PetService) PetLevelAll() []model.Pet {
return tt
}
// PetAdd 绮剧伒鐪熸娣诲姞鍚庣殑鎹曟崏鏃堕棿鎵嶆槸鐪熸鐨勬椂闂?
// PetAdd 精灵真正添加后的捕捉时间才是真正的时间
func (s *PetService) PetAdd(y *model.PetInfo, saleCount uint32) (uint32, error) {
if y == nil {
return 0, nil