feat(game): 实现扭蛋系统批量物品添加功能并优化地图逻辑 - 新增ItemAddBatch方法用于批量添加物品,支持普通道具和特殊道具的分别处理 - 优化扭蛋游戏玩法中的物品添加逻辑,使用新的批量接口提升性能 - 在扭蛋机器人命令中实现完整的物品检查和批量添加流程 refactor(map): 重构地图控制器代码结构并添加注释 - 为EnterMap、LeaveMap、GetMapPlayerList等方法添加中文注释 - 统一地图相关的命名规范,如enter
This commit is contained in:
@@ -22,34 +22,31 @@ import (
|
||||
"github.com/tnnmigga/enum"
|
||||
)
|
||||
|
||||
// 定义天气状态枚举实例
|
||||
var WeatherStatus = enum.New[struct {
|
||||
Normal uint32 `enum:"0"` // 正常
|
||||
Rain uint32 `enum:"1"` // 下雨
|
||||
Snow uint32 `enum:"2"` // 下雪
|
||||
Normal uint32 `enum:"0"`
|
||||
Rain uint32 `enum:"1"`
|
||||
Snow uint32 `enum:"2"`
|
||||
}]()
|
||||
|
||||
// Space 针对Player的并发安全map,键为uint32类型
|
||||
type Space struct {
|
||||
User *csmap.CsMap[uint32, common.PlayerI] // 存储玩家数据的map,键为玩家ID
|
||||
User *csmap.CsMap[uint32, common.PlayerI]
|
||||
UserInfo *csmap.CsMap[uint32, info.SimpleInfo]
|
||||
CanRefresh bool //是否能够刷怪
|
||||
CanRefresh bool
|
||||
Super uint32
|
||||
//SuperValue *int32
|
||||
ID uint32 // 地图ID
|
||||
Name string //地图名称
|
||||
|
||||
ID uint32
|
||||
Name string
|
||||
Owner ARENA
|
||||
info.MapBossSInfo
|
||||
//IsChange bool
|
||||
|
||||
WeatherType []uint32
|
||||
TimeBoss info.S2C_2022
|
||||
//Weather uint32
|
||||
|
||||
IsTime bool
|
||||
DropItemIds []uint32
|
||||
PitS *csmap.CsMap[int, []model.MapPit]
|
||||
}
|
||||
|
||||
// NewSyncMap 创建一个新的玩家同步map
|
||||
func NewSpace() *Space {
|
||||
|
||||
ret := &Space{
|
||||
@@ -60,7 +57,6 @@ func NewSpace() *Space {
|
||||
return ret
|
||||
}
|
||||
|
||||
// 获取星球
|
||||
func GetSpace(id uint32) *Space {
|
||||
|
||||
planet, ok := planetmap.Load(id)
|
||||
@@ -78,30 +74,26 @@ func GetSpace(id uint32) *Space {
|
||||
var planetmap = csmap.New[uint32, *Space]()
|
||||
|
||||
func ParseCoordinateString(s string) []infomodel.Pos {
|
||||
// 存储解析后的坐标
|
||||
|
||||
var points []infomodel.Pos
|
||||
|
||||
// 空字符串处理
|
||||
if strings.TrimSpace(s) == "" {
|
||||
return points
|
||||
}
|
||||
|
||||
// 第一步:按竖线分割成单个坐标字符串
|
||||
coordStrs := strings.Split(s, "|")
|
||||
for _, coordStr := range coordStrs {
|
||||
// 去除首尾空格(兼容可能的格式不规范)
|
||||
|
||||
coordStr = strings.TrimSpace(coordStr)
|
||||
if coordStr == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 第二步:按逗号分割X、Y值
|
||||
xy := strings.Split(coordStr, ",")
|
||||
if len(xy) != 2 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 第三步:转换为整数
|
||||
xStr := strings.TrimSpace(xy[0])
|
||||
yStr := strings.TrimSpace(xy[1])
|
||||
|
||||
@@ -115,7 +107,6 @@ func ParseCoordinateString(s string) []infomodel.Pos {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 添加到切片
|
||||
points = append(points, infomodel.Pos{X: uint32(x), Y: uint32(y)})
|
||||
}
|
||||
|
||||
@@ -128,10 +119,10 @@ func (t *Space) Next(time.Time) time.Time {
|
||||
}
|
||||
func (ret *Space) init() {
|
||||
|
||||
if ret.ID < 10000 { //说明是玩家地图GetSpace
|
||||
if ret.ID < 10000 {
|
||||
|
||||
for _, v := range xmlres.MapConfig.Maps {
|
||||
if v.ID == int(ret.ID) { //找到这个地图
|
||||
if v.ID == int(ret.ID) {
|
||||
|
||||
ret.Super = uint32(v.Super)
|
||||
if ret.Super == 0 {
|
||||
@@ -148,7 +139,6 @@ func (ret *Space) init() {
|
||||
|
||||
ret.Name = v.Name
|
||||
|
||||
//ogreconfig := service.NewMapPitService().GetData(ret.ID, uint32(i))
|
||||
break
|
||||
}
|
||||
|
||||
@@ -197,7 +187,7 @@ func (ret *Space) init() {
|
||||
ret.MapBossSInfo.INFO = make([]info.MapBossInfo, 0)
|
||||
if len(r.WeatherType) > 1 {
|
||||
ret.WeatherType = r.WeatherType
|
||||
// ret.CanWeather = 1
|
||||
|
||||
cool.Cron.CustomFunc(ret, ret.GenWer)
|
||||
}
|
||||
for _, v := range service.NewMapNodeService().GetDataB(ret.ID) {
|
||||
@@ -208,7 +198,7 @@ func (ret *Space) init() {
|
||||
}
|
||||
info := info.MapBossInfo{
|
||||
Id: uint32(r.ID),
|
||||
Region: v.NodeID, //这个是注册的index
|
||||
Region: v.NodeID,
|
||||
Hp: r.HP,
|
||||
PosInfo: ParseCoordinateString(r.Pos),
|
||||
Config: v,
|
||||
@@ -235,7 +225,7 @@ func (p *Space) IsMatch(t model.Event) bool {
|
||||
return item == int32(p.MapBossSInfo.Wer)
|
||||
})
|
||||
if !ok {
|
||||
// 不在同一天气下
|
||||
|
||||
return false
|
||||
|
||||
}
|
||||
@@ -285,7 +275,6 @@ func (ret *Space) HealHP() {
|
||||
}
|
||||
func (ret *Space) GenWer() {
|
||||
|
||||
//if ret.CanWeather == 1 {
|
||||
var neww uint32 = 0
|
||||
|
||||
if len(ret.WeatherType) == 2 {
|
||||
@@ -298,13 +287,11 @@ func (ret *Space) GenWer() {
|
||||
|
||||
ret.MapBossSInfo.Wer = int32(neww)
|
||||
|
||||
ret.Broadcast(nil, 2021, ret.GenBoss(true))
|
||||
ret.Broadcast(nil, 2022, ret.GenBoss(true))
|
||||
println(ret.Name, "change weather", neww)
|
||||
|
||||
}
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
func (ret *Space) GetDrop() int64 {
|
||||
|
||||
Reference in New Issue
Block a user