2025-09-21 14:56:37 +00:00
|
|
|
package player
|
|
|
|
|
|
|
|
|
|
import (
|
2026-03-03 23:40:21 +08:00
|
|
|
"blazing/common/socket/errorcode"
|
2025-11-23 23:38:03 +00:00
|
|
|
"blazing/common/utils"
|
2025-09-21 14:56:37 +00:00
|
|
|
"blazing/logic/service/common"
|
|
|
|
|
"blazing/logic/service/fight/info"
|
2026-04-05 07:41:50 +08:00
|
|
|
spaceinfo "blazing/logic/service/space/info"
|
2026-01-19 18:51:56 +08:00
|
|
|
"blazing/modules/player/model"
|
2026-04-08 01:28:55 +08:00
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/util/grand"
|
2025-09-21 14:56:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type baseplayer struct {
|
2025-12-29 14:26:46 +00:00
|
|
|
//Fightinfo info.Fightinfo
|
2025-11-19 00:09:12 +00:00
|
|
|
Info *model.PlayerInfo
|
|
|
|
|
//canFight uint32
|
|
|
|
|
FightC common.FightI //绑定战斗标识 替代本身的是否战斗标记 //IsFighting bool
|
2025-09-21 14:56:37 +00:00
|
|
|
*info.PlayerCaptureContext
|
2026-04-05 07:45:51 +08:00
|
|
|
Prop [6]int8
|
2025-09-21 14:56:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewPlayerCaptureContext 创建用户捕捉上下文(每次登录调用)
|
|
|
|
|
func newbaseplayer() baseplayer {
|
|
|
|
|
ret := baseplayer{}
|
2026-04-05 07:45:51 +08:00
|
|
|
|
2025-09-21 14:56:37 +00:00
|
|
|
return ret
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
// GetInfo 获取玩家基础信息
|
|
|
|
|
func (p *baseplayer) GetInfo() *model.PlayerInfo {
|
2025-09-21 14:56:37 +00:00
|
|
|
return p.Info
|
|
|
|
|
}
|
2025-11-18 22:16:55 +00:00
|
|
|
|
2026-03-22 23:41:51 +08:00
|
|
|
func (p *baseplayer) GetPetInfo(limitlevel uint32) []model.PetInfo {
|
|
|
|
|
|
|
|
|
|
var ret []model.PetInfo
|
|
|
|
|
|
|
|
|
|
for _, pet := range p.Info.PetList {
|
|
|
|
|
if limitlevel > 0 {
|
|
|
|
|
pet.Level = utils.Min(pet.Level, limitlevel)
|
|
|
|
|
|
2026-03-23 01:02:49 +08:00
|
|
|
}
|
2026-03-25 23:29:52 +08:00
|
|
|
|
2026-03-23 01:02:49 +08:00
|
|
|
ret = append(ret, pet)
|
2026-03-22 23:41:51 +08:00
|
|
|
}
|
|
|
|
|
return ret
|
|
|
|
|
}
|
2026-04-06 03:11:38 +08:00
|
|
|
|
|
|
|
|
func (p *baseplayer) AddBattleProp(index int, level int8) {
|
|
|
|
|
if p == nil || index < 0 || index >= len(p.Prop) || level == 0 {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p.Prop[index] += level
|
|
|
|
|
if p.Prop[index] > 6 {
|
|
|
|
|
p.Prop[index] = 6
|
|
|
|
|
}
|
|
|
|
|
if p.Prop[index] < -6 {
|
|
|
|
|
p.Prop[index] = -6
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *baseplayer) ApplyBattleProps(target *model.AttackValue) {
|
|
|
|
|
if p == nil || target == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
target.Prop = p.Prop
|
|
|
|
|
}
|
2025-12-29 14:26:46 +00:00
|
|
|
func (f *baseplayer) InvitePlayer(ff common.PlayerI) {
|
|
|
|
|
|
2026-03-23 01:03:49 +08:00
|
|
|
}
|
|
|
|
|
func (p *baseplayer) CanFight() errorcode.ErrorCode {
|
|
|
|
|
return 0
|
2025-12-29 14:26:46 +00:00
|
|
|
}
|
|
|
|
|
func (p *baseplayer) QuitFight() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
// SetFightC 设置玩家战斗控制器
|
|
|
|
|
func (f *baseplayer) SetFightC(fightController common.FightI) {
|
|
|
|
|
f.FightC = fightController
|
2025-09-21 14:56:37 +00:00
|
|
|
}
|
2025-11-18 23:41:31 +00:00
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
// GetPlayerCaptureContext 获取玩家捕捉上下文
|
2025-09-21 14:56:37 +00:00
|
|
|
func (f *baseplayer) GetPlayerCaptureContext() *info.PlayerCaptureContext {
|
|
|
|
|
return f.PlayerCaptureContext
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-08 01:28:55 +08:00
|
|
|
func (f *baseplayer) Roll(numerator, denominator int) (bool, float64, float64) {
|
|
|
|
|
if denominator <= 0 {
|
|
|
|
|
return false, 0, 0
|
|
|
|
|
}
|
|
|
|
|
if numerator < 0 {
|
|
|
|
|
numerator = 0
|
|
|
|
|
}
|
|
|
|
|
if numerator > denominator {
|
|
|
|
|
numerator = denominator
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base := float64(numerator) / float64(denominator) * 100
|
|
|
|
|
return grand.Intn(denominator) < numerator, base, 0
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
// FindPet 根据捕捉时间查找宠物
|
|
|
|
|
// 返回值: (索引, 宠物信息, 是否找到)
|
|
|
|
|
func (f *baseplayer) FindPet(catchTime uint32) (int, *model.PetInfo, bool) {
|
2025-11-23 23:38:03 +00:00
|
|
|
return utils.FindWithIndex(f.Info.PetList, func(item model.PetInfo) bool {
|
2025-12-24 19:03:11 +08:00
|
|
|
return item.CatchTime == catchTime
|
2025-11-23 23:38:03 +00:00
|
|
|
})
|
|
|
|
|
}
|
2025-12-24 19:03:11 +08:00
|
|
|
|
2026-03-03 23:40:21 +08:00
|
|
|
func (p *baseplayer) Getfightinfo() info.Fightinfo {
|
|
|
|
|
return info.Fightinfo{}
|
|
|
|
|
}
|
|
|
|
|
func (f *baseplayer) SendPack(b []byte) error {
|
|
|
|
|
return nil
|
2025-12-30 02:15:33 +00:00
|
|
|
|
2026-03-03 23:40:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (f *baseplayer) MessWin(b bool) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (f *baseplayer) SendPackCmd(_ uint32, _ any) {
|
|
|
|
|
|
|
|
|
|
//fmt.Println("战斗结束")
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 20:21:02 +08:00
|
|
|
func (p *baseplayer) ItemAdd(ItemId, ItemCnt int64) (result bool) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
2026-03-03 23:40:21 +08:00
|
|
|
|
|
|
|
|
func (lw *baseplayer) SendLoadPercent(info.LoadPercentOutboundInfo) {
|
|
|
|
|
|
|
|
|
|
}
|
2026-04-05 07:41:50 +08:00
|
|
|
func (p *baseplayer) ApplyPetDisplayInfo(out *spaceinfo.SimpleInfo) {}
|