This commit is contained in:
@@ -2,14 +2,14 @@ package space
|
||||
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/common/utils"
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/space/info"
|
||||
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
csmap "github.com/mhmtszr/concurrent-swiss-map"
|
||||
"github.com/samber/lo"
|
||||
"github.com/tnnmigga/enum"
|
||||
)
|
||||
|
||||
@@ -20,9 +20,6 @@ var WeatherStatus = enum.New[struct {
|
||||
Snow uint32 `enum:"2"` // 下雪
|
||||
}]()
|
||||
|
||||
// 定义天气地图
|
||||
var wermap = []uint32{32}
|
||||
|
||||
// Space 针对Player的并发安全map,键为uint32类型
|
||||
type Space struct {
|
||||
User *csmap.CsMap[uint32, common.PlayerI] // 存储玩家数据的map,键为玩家ID
|
||||
@@ -112,28 +109,33 @@ func GetSpace(id uint32) *Space {
|
||||
}
|
||||
}
|
||||
|
||||
if _, ok := lo.Find(wermap, func(mapID uint32) bool { return mapID == ret.ID }); ok {
|
||||
// ret.CanWeather = 1
|
||||
cool.Cron.CustomFunc(ret, func() {
|
||||
//if ret.CanWeather == 1 {
|
||||
var neww uint32 = 0
|
||||
r := service.NewMapService().GetData(ret.ID)
|
||||
if r != nil {
|
||||
if len(r.WeatherType) > 1 {
|
||||
// ret.CanWeather = 1
|
||||
cool.Cron.CustomFunc(ret, func() {
|
||||
//if ret.CanWeather == 1 {
|
||||
var neww uint32 = 0
|
||||
|
||||
if grand.Meet(1, 10) {
|
||||
neww = uint32(grand.N(1, 2))
|
||||
if len(r.WeatherType) == 2 {
|
||||
neww, _ = utils.RandomByWeight(r.WeatherType, []uint32{9, 1})
|
||||
} else {
|
||||
neww, _ = utils.RandomByWeight(r.WeatherType, []uint32{8, 1, 1})
|
||||
}
|
||||
|
||||
}
|
||||
if neww != ret.Weather {
|
||||
ret.Broadcast(nil, 50004, &info.S2C_50004{Id: uint32(neww)})
|
||||
ret.Weather = neww
|
||||
ret.getwerboss()
|
||||
}
|
||||
|
||||
if neww != ret.Weather {
|
||||
ret.Broadcast(nil, 50004, &info.S2C_50004{Id: uint32(neww)})
|
||||
ret.Weather = neww
|
||||
ret.getwerboss()
|
||||
}
|
||||
//}
|
||||
|
||||
//}
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
planetmap.Store(id, ret)
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ func init() {
|
||||
// 初始化控制器,配置路由前缀、支持的API、绑定Service
|
||||
var petFusionController = &PetFusionController{
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/pet/fusion", // 路由前缀(按模块分类:宠物-融合配方)
|
||||
Prefix: "/admin/config/fusion", // 路由前缀(按模块分类:宠物-融合配方)
|
||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"}, // 支持的基础CRUD接口
|
||||
Service: service.NewPetFusionService(), // 绑定主表Service
|
||||
},
|
||||
|
||||
@@ -14,9 +14,9 @@ func init() {
|
||||
// 初始化控制器,配置路由前缀、支持的API、绑定Service
|
||||
var petFusionMaterialController = &PetFusionMaterialController{
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/pet/fusionmaterial", // 路由前缀(主表路由+子表名,层级清晰)
|
||||
Prefix: "/admin/config/fusionmaterial", // 路由前缀(主表路由+子表名,层级清晰)
|
||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"}, // 支持的基础CRUD接口
|
||||
Service: service.NewPetFusionMaterialService(), // 绑定子表Service
|
||||
Service: service.NewPetFusionMaterialService(), // 绑定子表Service
|
||||
},
|
||||
}
|
||||
// 注册控制器到框架
|
||||
|
||||
@@ -11,17 +11,15 @@ const (
|
||||
|
||||
// MapConfig 地图核心配置模型(包含地图基础属性、刷怪配置、天气配置、掉落物配置)
|
||||
type MapConfig struct {
|
||||
*BaseConfig
|
||||
|
||||
*cool.Model // 保留通用Model(ID/创建时间/更新时间等)
|
||||
// 核心字段
|
||||
MapID uint32 `gorm:"not null;primaryKey;comment:'地图唯一ID(主键)'" json:"map_id" description:"地图ID"`
|
||||
|
||||
IsSpawnMonster int32 `gorm:"not null;default:0;comment:'是否开启刷怪(1:开启,0:关闭)'" json:"is_spawn_monster" description:"是否开启刷怪"`
|
||||
//`gorm:"type:int[];comment:'副宠物IDs(如:1,2,3)'" json:"sub_pet_ids"`
|
||||
WeatherType []uint32 `gorm:"type:int[];comment:'天气类型( 1-雨天,2-雪天)'" json:"weather_type"`
|
||||
|
||||
// 掉落物配置
|
||||
DropItemIds []uint32 `gorm:"type:int[];comment:'掉落物IDs" json:"drop_item_ids"`
|
||||
Remark string `gorm:"type:varchar(255);default:'';comment:'性别配置备注(如:默认性别规则)'" json:"remark"` // 调整注释
|
||||
}
|
||||
|
||||
// -------------------------- 核心配套方法(遵循项目规范)--------------------------
|
||||
@@ -35,7 +33,7 @@ func (*MapConfig) GroupName() string {
|
||||
|
||||
func NewMapConfig() *MapConfig {
|
||||
return &MapConfig{
|
||||
BaseConfig: NewBaseConfig(),
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ func NewMapService() *MapService {
|
||||
|
||||
func (s *MapService) GetData(p1 uint32) (ret *model.MapConfig) {
|
||||
//cacheKey := strings.Join([]string{fmt.Sprintf("%d", p1), fmt.Sprintf("%d", p2)}, ":")
|
||||
m := dbm_enable(s.Model)
|
||||
m := dbm_notenable(s.Model)
|
||||
|
||||
m.Wheref(`male_pet_ids @> ARRAY[?]::integer[]`, p1).Scan(&ret)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user