feat(controller): 增强命令注册逻辑并修复试炼塔关卡限制 - 在命令注册时检查重复方法,如果存在则panic提示错误 - 移除CurrentFreshStage和CurrentStage的默认值设置逻辑 - 添加关卡等级验证,确保用户不能挑战超过最大关卡数的关卡 - 修复试炼之塔和勇者之塔的关卡计算逻辑 fix(item): 修复道具使用返回值类型转换问题 - 将ThreeTimes和TwoTimes字段从int32转为uint32返回 - 为能量吸收道具使用函数添加结果结构体初始化 refactor(fight): 清理战斗服务中的注释和字段定义 - 移除C2S_FRESH_CHOICE_FIGHT_LEVEL结构体中冗余的注释说明 - 统一FightOverInfo结构体的格式 fix(item): 修复宠物道具使用的条件判断 - 为道具300790添加DV值大于等于31时不能使用的限制 fix(player): 修复玩家经验加成次数的判断逻辑 - 将TwoTimes和ThreeTimes的判断从不等于0改为大于0 - 将EnergyTime的判断从不等于0改为大于0 - 统一所有次数字段的类型为int32以避免负数问题 chore(admin): 清理无用代码 - 移除未使用的context包导入 - 注释掉未完成的TimeMap接口实现 ```
97 lines
2.1 KiB
Go
97 lines
2.1 KiB
Go
package player
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/common/utils"
|
|
"blazing/logic/service/common"
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/modules/player/model"
|
|
"math/rand"
|
|
"time"
|
|
|
|
"github.com/gogf/gf/v2/util/grand"
|
|
)
|
|
|
|
type baseplayer struct {
|
|
//Fightinfo info.Fightinfo
|
|
Info *model.PlayerInfo
|
|
//canFight uint32
|
|
FightC common.FightI //绑定战斗标识 替代本身的是否战斗标记 //IsFighting bool
|
|
*info.PlayerCaptureContext
|
|
}
|
|
|
|
// NewPlayerCaptureContext 创建用户捕捉上下文(每次登录调用)
|
|
func newbaseplayer() baseplayer {
|
|
rng := rand.New(rand.NewSource(time.Now().UnixNano() + int64(grand.Intn(1000000))))
|
|
ret := baseplayer{}
|
|
ret.PlayerCaptureContext = &info.PlayerCaptureContext{
|
|
Random: rng,
|
|
Denominator: 1000,
|
|
DecayFactor: 0.10, // 15%衰减率
|
|
MinDecayNum: 1,
|
|
Guarantees: make(map[int]int),
|
|
}
|
|
return ret
|
|
}
|
|
|
|
// GetInfo 获取玩家基础信息
|
|
func (p *baseplayer) GetInfo() *model.PlayerInfo {
|
|
return p.Info
|
|
}
|
|
|
|
func (f *baseplayer) InvitePlayer(ff common.PlayerI) {
|
|
|
|
}
|
|
func (p *baseplayer) QuitFight() {
|
|
|
|
}
|
|
|
|
// SetFightC 设置玩家战斗控制器
|
|
func (f *baseplayer) SetFightC(fightController common.FightI) {
|
|
f.FightC = fightController
|
|
}
|
|
|
|
// GetPlayerCaptureContext 获取玩家捕捉上下文
|
|
func (f *baseplayer) GetPlayerCaptureContext() *info.PlayerCaptureContext {
|
|
return f.PlayerCaptureContext
|
|
}
|
|
|
|
// FindPet 根据捕捉时间查找宠物
|
|
// 返回值: (索引, 宠物信息, 是否找到)
|
|
func (f *baseplayer) FindPet(catchTime uint32) (int, *model.PetInfo, bool) {
|
|
return utils.FindWithIndex(f.Info.PetList, func(item model.PetInfo) bool {
|
|
return item.CatchTime == catchTime
|
|
})
|
|
}
|
|
|
|
func (p *baseplayer) Getfightinfo() info.Fightinfo {
|
|
return info.Fightinfo{}
|
|
}
|
|
func (f *baseplayer) SendPack(b []byte) error {
|
|
return nil
|
|
|
|
}
|
|
|
|
func (f *baseplayer) MessWin(b bool) {
|
|
|
|
}
|
|
|
|
func (f *baseplayer) SendPackCmd(_ uint32, _ any) {
|
|
|
|
//fmt.Println("战斗结束")
|
|
|
|
}
|
|
|
|
func (p *baseplayer) GetPetInfo() []model.PetInfo {
|
|
|
|
return p.Info.PetList
|
|
}
|
|
|
|
func (lw *baseplayer) SendLoadPercent(info.LoadPercentOutboundInfo) {
|
|
|
|
}
|
|
|
|
func (p *baseplayer) CanFight() errorcode.ErrorCode {
|
|
return 0
|
|
}
|