2025-09-21 14:56:37 +00:00
|
|
|
|
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
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-15 22:17:43 +00:00
|
|
|
|
// // 计算整数的二进制1的个数(Integer.bitCount)
|
|
|
|
|
|
// func bitsCount(n int) int {
|
|
|
|
|
|
// count := 0
|
|
|
|
|
|
// for n > 0 {
|
|
|
|
|
|
// count += n & 1
|
|
|
|
|
|
// n >>= 1
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return count
|
|
|
|
|
|
// }
|