feat(config): 重构配置结构并添加服务器列表支持 - 重命名PortBL字段为GameOnlineID,改进命名语义 - 添加ServerList结构体用于管理服务器配置 - 移除七牛云配置相关字段 - 更新ID生成器使用GameOnlineID参数 fix(server): 调整服务器启动参数和VIP逻辑 - 将启动参数从-port改为-id,统一参数命名 - 更新服务器启动逻辑,基于GameOnlineID获取服务器信息 - 为VIP服务器启用调试模式 - 优化端口可用性检查逻辑 refactor(model): 统一模型基类结构 - 将各模型中的*cool.Model嵌入改为Base基类 - 移除soul.go
95 lines
1.7 KiB
Go
95 lines
1.7 KiB
Go
package service
|
|
|
|
import (
|
|
"blazing/cool"
|
|
"blazing/modules/blazing/model"
|
|
"context"
|
|
)
|
|
|
|
func (s *RoomService) Get(userid uint32) model.BaseHouseEx {
|
|
|
|
//todo待测试
|
|
var ttt model.BaseHouseEx
|
|
m := s.TestModel(s.Model)
|
|
|
|
m.Where("player_id", userid).Scan(&ttt)
|
|
|
|
return ttt
|
|
|
|
}
|
|
func (s *RoomService) Add(id, count uint32) {
|
|
//todo待测试
|
|
var ttt model.BaseHouseEx
|
|
m := s.TestModel(s.Model)
|
|
|
|
m.Scan(&ttt)
|
|
if ttt.OwnedItems == nil {
|
|
ttt.OwnedItems = make(map[uint32]uint32)
|
|
|
|
}
|
|
t, ok := ttt.OwnedItems[id]
|
|
if ok {
|
|
ttt.OwnedItems[id] = t + count
|
|
} else {
|
|
ttt.OwnedItems[id] = count
|
|
}
|
|
ttt.PlayerID = uint64(s.userid)
|
|
m.Save(ttt)
|
|
|
|
}
|
|
func (s *RoomService) Set(id []model.FitmentShowInfo) {
|
|
//todo待测试
|
|
var ttt model.BaseHouseEx
|
|
m := s.TestModel(s.Model)
|
|
|
|
m.Scan(&ttt)
|
|
ttt.PlacedItems = id
|
|
|
|
ttt.PlayerID = uint64(s.userid)
|
|
m.Save(ttt)
|
|
|
|
}
|
|
func (s *RoomService) Show(cactime []uint32) {
|
|
|
|
//todo待测试
|
|
var ttt model.BaseHouseEx
|
|
m := s.TestModel(s.Model)
|
|
|
|
m.Scan(&ttt)
|
|
ttt.ShowPokemon = cactime
|
|
|
|
ttt.PlayerID = uint64(s.userid)
|
|
m.Save(ttt)
|
|
|
|
}
|
|
|
|
// /添加进来的物品一定是保证存在的
|
|
type RoomService struct {
|
|
BaseService
|
|
}
|
|
|
|
func NewRoomService(id uint32) *RoomService {
|
|
return &RoomService{
|
|
|
|
BaseService: BaseService{userid: id,
|
|
|
|
Service: &cool.Service{Model: model.NewBaseHouse(), UniqueKey: map[string]string{
|
|
"player_id": "角色名称不能重复",
|
|
}, PageQueryOp: &cool.QueryOp{
|
|
KeyWordField: []string{"player_id"},
|
|
Where: func(ctx context.Context) [][]interface{} {
|
|
var (
|
|
//admin = cool.GetAdmin(ctx)
|
|
//userId = admin.UserId
|
|
)
|
|
return [][]interface{}{
|
|
// {"player_id", userId, true},
|
|
// {"free", 0, true},
|
|
}
|
|
},
|
|
}},
|
|
},
|
|
}
|
|
|
|
}
|