This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user