refactor(socket): 重构 ClientData 结构体并优化相关逻辑
- 简化 ClientData 结构体,移除不必要的方法 - 优化 Player 结构体,调整 Conn 类型 - 更新 wscodec.go 中的 Conn 结构体 - 删除未使用的 XML 相关文件和代码 - 调整 ServerEvent 和 controller 中的相关逻辑
This commit is contained in:
122
common/data/xmlres/mon.go
Normal file
122
common/data/xmlres/mon.go
Normal file
@@ -0,0 +1,122 @@
|
||||
package xmlres
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
)
|
||||
|
||||
// 根结构体:对应 <Maps> 节点
|
||||
type MonsterRoot struct {
|
||||
XMLName xml.Name `xml:"Maps"`
|
||||
WorldWildMons WorldWildMons `xml:"WorldWildMons"` // 世界野怪配置
|
||||
Maps []TMapConfig `xml:"Map"` // 所有地图配置(多个<Map>)
|
||||
DefaultMaps DefaultMaps `xml:"DefaultMaps"` // 默认登录场景
|
||||
VersionNumber VersionNumber `xml:"VersionNumber"` // 版本信息
|
||||
}
|
||||
|
||||
// 世界野怪容器:对应 <WorldWildMons>
|
||||
type WorldWildMons struct {
|
||||
WorldWildMonsters []WorldWildMonster `xml:"WorldWildMonster"` // 多个<WorldWildMonster>
|
||||
}
|
||||
|
||||
// 世界野怪配置:对应 <WorldWildMonster>
|
||||
type WorldWildMonster struct {
|
||||
WorldWildProb int `xml:"WorldWildProb,attr"` // 变身概率(分子)
|
||||
WorldWildMonId int `xml:"WorldWildMonId,attr"` // 野怪ID
|
||||
WorldWildMonLv int `xml:"WorldWildMonLv,attr"` // 野怪等级
|
||||
WorldWildStart int `xml:"WorldWildStart,attr"` // 出现起始时间(0-23)
|
||||
WorldWildEnd int `xml:"WorldWildEnd,attr"` // 出现结束时间(0-23)
|
||||
NewSeIdxs string `xml:"NewSeIdxs,attr"` // 特效ID(可能多个,空格分隔)
|
||||
}
|
||||
|
||||
// 单张地图配置:对应 <Map>
|
||||
type TMapConfig struct {
|
||||
ID int `xml:"ID,attr"` // 地图ID
|
||||
Name string `xml:"Name,attr"` // 地图名称
|
||||
InitX int `xml:"InitX,attr"` // 玩家初始X坐标
|
||||
InitY int `xml:"InitY,attr"` // 玩家初始Y坐标
|
||||
GameTriggerGrps []GameTriggerGrp `xml:"GameTriggerGrp"` // 触发点组(多个)
|
||||
Monsters *MonstersC `xml:"Monsters"` // 新增:野怪配置(可选,用指针处理“无该节点”的情况)
|
||||
Bosses []BossConfig `xml:"Bosses>Boss"` // BOSS配置(<Bosses>下的<Boss>)
|
||||
}
|
||||
|
||||
// ########################### 关键新增:MonstersConfig(对应 <Monsters>) ###########################
|
||||
// 野怪配置容器:包含野怪奖励概率和多只野怪
|
||||
type MonstersC struct {
|
||||
WildBonusProb int `xml:"WildBonusProb,attr"` // 打赢野怪给奖励的概率(分子,如300)
|
||||
WildBonusTotalProb int `xml:"WildBonusTotalProb,attr"` // 打赢野怪给奖励的概率(分母,如1000)
|
||||
BonusID int `xml:"BonusID,attr"` // 奖励ID(如5239)
|
||||
ItemBonusID int `xml:"ItemBonusID,attr"` // 物品奖励ID(如1)
|
||||
Monsters []Monster1 `xml:"Monster"` // 多只野怪(<Monster>子节点)
|
||||
}
|
||||
|
||||
// ########################### 关键新增:Monster(对应 <Monster>) ###########################
|
||||
// 单只野怪配置:ID可能是多个值(空格分隔),Lv是等级范围(空格分隔)
|
||||
type Monster1 struct {
|
||||
ID string `xml:"ID,attr"` // 野怪ID(如"164 0 0..."或"10")
|
||||
Lv string `xml:"Lv,attr"` // 等级范围(如"1 2"表示1-2级)
|
||||
}
|
||||
|
||||
// 游戏触发点组:对应 <GameTriggerGrp>
|
||||
type GameTriggerGrp struct {
|
||||
GameID string `xml:"GameID,attr"` // 游戏ID
|
||||
TriggerPts []TriggerPt `xml:"TriggerPt"` // 触发点(多个)
|
||||
}
|
||||
|
||||
// 触发点:对应 <TriggerPt>
|
||||
type TriggerPt struct {
|
||||
ID int `xml:"ID,attr"` // 触发点ID
|
||||
Name string `xml:"Name,attr"` // 触发点名称(可选)
|
||||
}
|
||||
|
||||
// BOSS配置:对应 <Boss>
|
||||
type BossConfig struct {
|
||||
Id *int `xml:"Id,attr"` // BOSSID(可选,用指针处理空值)
|
||||
BossCatchable int `xml:"BossCatchable,attr"` // 是否可捕捉(0/1,默认0)
|
||||
AppearTime string `xml:"AppearTime,attr"` // 出现时间(如"0 23")
|
||||
BossVisible int `xml:"BossVisible,attr"` // 是否可见(0/1,默认0)
|
||||
Name string `xml:"Name,attr"` // BOSS名称(可选)
|
||||
DailyKey *string `xml:"DailyKey,attr"` // 每日挑战次数Key(可选)
|
||||
MaxTimes *int `xml:"MaxTimes,attr"` // 非VIP每日挑战上限(可选)
|
||||
VipMaxTimes *int `xml:"VipMaxTimes,attr"` // VIP每日挑战上限(可选)
|
||||
WinBonusId *string `xml:"WinBonusId,attr"` // 胜利奖励ID(可选)
|
||||
WinOutId *int `xml:"WinOutId,attr"` // 胜利输出ID(可选)
|
||||
FailBonusId *string `xml:"FailBonusId,attr"` // 失败奖励ID(可选)
|
||||
FailOutId *int `xml:"FailOutId,attr"` // 失败输出ID(可选)
|
||||
BossMon []BossMon `xml:"BossMon"` // BOSS对应的精灵(多个)
|
||||
}
|
||||
|
||||
// BOSS精灵配置:对应 <BossMon>
|
||||
type BossMon struct {
|
||||
MonID string `xml:"MonID,attr"` // 精灵ID(可能多个,空格分隔)
|
||||
Hp int `xml:"Hp,attr"` // 生命值
|
||||
Lv int `xml:"Lv,attr"` // 等级
|
||||
NewSeIdxs string `xml:"NewSeIdxs,attr"` // 特效ID(可选,空格分隔)
|
||||
Atk *int `xml:"Atk,attr"` // 攻击(可选)
|
||||
Def *int `xml:"Def,attr"` // 防御(可选)
|
||||
Spatk *int `xml:"Spatk,attr"` // 特攻(可选)
|
||||
Spdef *int `xml:"Spdef,attr"` // 特防(可选)
|
||||
Spd *int `xml:"Spd,attr"` // 速度(可选)
|
||||
}
|
||||
|
||||
// 默认登录场景容器:对应 <DefaultMaps>
|
||||
type DefaultMaps struct {
|
||||
DefaultMaps []DefaultMap `xml:"DefaultMap"` // 多个默认场景
|
||||
}
|
||||
|
||||
// 默认登录场景:对应 <DefaultMap>
|
||||
type DefaultMap struct {
|
||||
ID int `xml:"ID,attr"` // 场景ID
|
||||
RandMaps string `xml:"RandMaps,attr"` // 随机场景列表(逗号分隔)
|
||||
Desc string `xml:"Desc,attr"` // 场景描述
|
||||
}
|
||||
|
||||
// 版本信息容器:对应 <VersionNumber>
|
||||
type VersionNumber struct {
|
||||
Version Version `xml:"Version"` // 版本详情
|
||||
}
|
||||
|
||||
// 版本详情:对应 <Version>
|
||||
type Version struct {
|
||||
ID string `xml:"ID,attr"` // 版本号(如"20190614")
|
||||
Desc string `xml:"Desc,attr"` // 版本描述
|
||||
}
|
||||
Reference in New Issue
Block a user