```
refactor(player): 重构OgreInfo数据结构并优化怪物生成逻辑 - 将Player结构体中的OgreInfo字段从[9]OgrePetInfo数组改为OgrePet结构体 - 更新所有OgreInfo的访问方式,使用OgreInfo.Data[index]替代OgreInfo[index] - 移除不再使用的common包
This commit is contained in:
@@ -165,7 +165,7 @@ func (h Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundI
|
||||
if !p.CanFight() {
|
||||
return nil, errorcode.ErrorCodes.ErrSystemError
|
||||
}
|
||||
refPet := p.OgreInfo[data1.Number]
|
||||
refPet := p.OgreInfo.Data[data1.Number]
|
||||
if refPet.Id == 0 {
|
||||
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||
|
||||
@@ -3,7 +3,6 @@ package player
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/cool"
|
||||
"blazing/logic/service/common"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -42,11 +41,11 @@ func (p *Player) genMonster() {
|
||||
replce = []int{newNum} //产生替换新的精灵
|
||||
if atomic.CompareAndSwapUint32(&p.Canmon, 2, 1) {
|
||||
p.MapNPC.Reset(10 * time.Second)
|
||||
p.OgreInfo = [9]OgrePetInfo{} //切地图清空
|
||||
replce = p.monsters[:] //产生替换新的精灵
|
||||
p.OgreInfo.Data = [9]OgrePetInfo{} //切地图清空
|
||||
replce = p.monsters[:] //产生替换新的精灵
|
||||
|
||||
}
|
||||
p.OgreInfo[oldnum] = OgrePetInfo{} //切地图清空
|
||||
p.OgreInfo.Data[oldnum] = OgrePetInfo{} //切地图清空
|
||||
mapss, ok := xmlres.MonsterMap[gconv.Int(p.Info.MapID)]
|
||||
|
||||
if ok && mapss.Monsters != nil {
|
||||
@@ -64,34 +63,34 @@ func (p *Player) genMonster() {
|
||||
id := strings.Split(m.ID, " ")
|
||||
lv := strings.Split(m.Lv, " ")
|
||||
|
||||
p.OgreInfo[i] = OgrePetInfo{}
|
||||
p.OgreInfo[i].Id = gconv.Uint32(RandomStringFromSlice(id))
|
||||
p.OgreInfo.Data[i] = OgrePetInfo{}
|
||||
p.OgreInfo.Data[i].Id = gconv.Uint32(RandomStringFromSlice(id))
|
||||
|
||||
if p.OgreInfo[i].Id != 0 {
|
||||
if p.OgreInfo.Data[i].Id != 0 {
|
||||
|
||||
p.OgreInfo[i].Lv = gconv.Uint32(RandomStringFromSlice(lv))
|
||||
p.OgreInfo.Data[i].Lv = gconv.Uint32(RandomStringFromSlice(lv))
|
||||
if cool.Config.PortBL == 2 { //测试服,百分百异色
|
||||
p.OgreInfo[i].RandSHiny(int64(i))
|
||||
p.OgreInfo.Data[i].RandSHiny()
|
||||
}
|
||||
if xmlres.PetMAP[int(p.OgreInfo[i].Id)].CatchRate != 0 && grand.Meet(1, 100) {
|
||||
p.OgreInfo[i].RandSHiny(int64(i))
|
||||
if xmlres.PetMAP[int(p.OgreInfo.Data[i].Id)].CatchRate != 0 && grand.Meet(1, 100) {
|
||||
p.OgreInfo.Data[i].RandSHiny()
|
||||
}
|
||||
if len(id) == 1 { //说明这里只固定刷一个,概率变尼尔尼奥
|
||||
|
||||
nieo, _, _ := p.Roll(20, 1000)
|
||||
if nieo {
|
||||
p.OgreInfo[i].Ext = 77
|
||||
p.OgreInfo.Data[i].Ext = 77
|
||||
if grand.Meet(1, 2) {
|
||||
p.OgreInfo[i].Ext = 416
|
||||
p.OgreInfo.Data[i].Ext = 416
|
||||
}
|
||||
|
||||
p.OgreInfo[i].Lv = 16
|
||||
p.OgreInfo.Data[i].Lv = 16
|
||||
}
|
||||
|
||||
}
|
||||
if ok {
|
||||
|
||||
p.OgreInfo[i].Item = uint32(mapss.Monsters.ItemBonusID)
|
||||
p.OgreInfo.Data[i].Item = uint32(mapss.Monsters.ItemBonusID)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -100,10 +99,7 @@ func (p *Player) genMonster() {
|
||||
|
||||
}
|
||||
|
||||
// 创建数据包
|
||||
tt := common.NewTomeeHeader(2004, p.Info.UserID)
|
||||
p.SendPack(tt.Pack(&p.OgreInfo))
|
||||
|
||||
p.SendPackCmd(2004, &p.OgreInfo)
|
||||
}
|
||||
|
||||
// 生成0-9之间三个不重复的随机数 进地图5s
|
||||
|
||||
@@ -45,7 +45,7 @@ type OgrePetInfo struct {
|
||||
Ext uint32 `struc:"skip"` //是否变尼尔尼奥
|
||||
}
|
||||
|
||||
func (o *OgrePetInfo) RandSHiny(t int64) {
|
||||
func (o *OgrePetInfo) RandSHiny() {
|
||||
// o.ShinyInfo = make([]data.GlowFilter, 1)
|
||||
// // 假设 t 是包含 ShinyInfo 字段的结构体,ShinyInfo 是 GlowFilter 类型的切片
|
||||
// o.ShinyInfo[0] = data.GlowFilter{
|
||||
@@ -90,7 +90,7 @@ type Player struct {
|
||||
Fightinfo info.Fightinfo // 当前邀请的玩家ID
|
||||
|
||||
Logintime uint32 // 当前登录时间
|
||||
OgreInfo [9]OgrePetInfo
|
||||
OgreInfo OgrePet
|
||||
|
||||
Service *blservice.UserService
|
||||
User *service.BaseSysUserService
|
||||
@@ -101,6 +101,10 @@ type Player struct {
|
||||
Canmon uint32 // 可以刷怪
|
||||
}
|
||||
|
||||
type OgrePet struct {
|
||||
Data [9]OgrePetInfo
|
||||
}
|
||||
|
||||
// PlayerOption 定义配置 Player 的函数类型
|
||||
type PlayerOption func(*Player)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user