feat(capture): 重构捕捉系统,实现状态倍率计算和保底机制

This commit is contained in:
1
2025-09-21 14:56:37 +00:00
parent bb9b0510ce
commit 691cfc878b
17 changed files with 563 additions and 539 deletions

View File

@@ -0,0 +1,50 @@
package player
import (
"blazing/logic/service/common"
"blazing/logic/service/fight/info"
"blazing/modules/blazing/model"
"math/rand"
"time"
)
type baseplayer struct {
Info *model.PlayerInfo
FightC common.FightI //绑定战斗标识 替代本身的是否战斗标记 //IsFighting bool
*info.PlayerCaptureContext
}
// NewPlayerCaptureContext 创建用户捕捉上下文(每次登录调用)
func newbaseplayer() baseplayer {
rng := rand.New(rand.NewSource(time.Now().UnixNano() + int64(rand.Intn(1000000))))
ret := baseplayer{}
ret.PlayerCaptureContext = &info.PlayerCaptureContext{
rng,
1000,
0.10, // 15%衰减率
1,
make(map[int]int),
}
return ret
}
func (p *baseplayer) GetInfo() *model.PlayerInfo {
return p.Info
}
func (f *baseplayer) SetFightC(ff common.FightI) {
f.FightC = ff
}
func (f *baseplayer) GetPlayerCaptureContext() *info.PlayerCaptureContext {
return f.PlayerCaptureContext
}
// 计算整数的二进制1的个数Integer.bitCount
func bitsCount(n int) int {
count := 0
for n > 0 {
count += n & 1
n >>= 1
}
return count
}