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

feat(fight): 新增疲惫状态并优化睡眠状态机制

- 实现疲惫状态(StatusTired),仅限制攻击技能,允许属性技能正常使用
- 重构睡眠状态,改为在被攻击且未miss时立即解除,而非技能使用后
- 修复寄生种子效果触发时机,改为回合开始时触发
- 调整寄生效果的目标为技能施放者而非
This commit is contained in:
昔念
2026-04-13 21:06:45 +08:00
parent ce1a2a3588
commit f95fd49efd
12 changed files with 322 additions and 42 deletions

View File

@@ -2,9 +2,11 @@ package service
import (
"blazing/cool"
"blazing/modules/base/service"
"blazing/modules/config/model"
"context"
"crypto/rand"
"database/sql"
"fmt"
"math/big"
"time"
@@ -170,14 +172,15 @@ type ServerNamingCDKResult struct {
// UseServerNamingCDK 使用服务器冠名类型CDK并原子化更新服务器归属和到期时间。
func (s *CdkService) UseServerNamingCDK(ctx context.Context, code string, ownerID, serverID uint32, serverName string) (*ServerNamingCDKResult, error) {
if ctx == nil {
ctx = context.TODO()
execCtx := context.Background()
if ctx != nil && ctx.Err() != nil {
ctx = nil
}
now := time.Now()
serverService := NewServerService()
var updated model.ServerShow
err := g.DB(s.Model.GroupName()).Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
err := g.DB(s.Model.GroupName()).Transaction(execCtx, func(ctx context.Context, tx gdb.TX) error {
var cfg model.CDKConfig
if err := tx.Model(s.Model).Where("cdk_code", code).WhereNot("exchange_remain_count", 0).Scan(&cfg); err != nil {
return err
@@ -185,7 +188,7 @@ func (s *CdkService) UseServerNamingCDK(ctx context.Context, code string, ownerI
if cfg.ID == 0 {
return gerror.New("cdk不存在")
}
if cfg.CDKType != CDKTypeServerNaming {
if cfg.Type != CDKTypeServerNaming {
return gerror.New("cdk类型不匹配")
}
if cfg.BindUserId != 0 && cfg.BindUserId != ownerID {
@@ -222,6 +225,11 @@ func (s *CdkService) UseServerNamingCDK(ctx context.Context, code string, ownerI
OrderDesc("id").
Limit(1).
Scan(&currentShow); err != nil {
if err == sql.ErrNoRows {
err = nil
}
}
if err != nil {
return err
}
@@ -264,6 +272,7 @@ func (s *CdkService) UseServerNamingCDK(ctx context.Context, code string, ownerI
g.DB(s.Model.GroupName()).GetCore().ClearCache(context.TODO(), s.Model.TableName())
g.DB(model.NewServerList().GroupName()).GetCore().ClearCache(context.TODO(), model.NewServerList().TableName())
g.DB(model.NewServerShow().GroupName()).GetCore().ClearCache(context.TODO(), model.NewServerShow().TableName())
service.NewBaseSysUserService().UpdateGold(updated.Owner, int64(200*100))
return &ServerNamingCDKResult{
ServerID: updated.ServerID,
ServerName: updated.Name,