2025-12-13 22:51:39 +08:00
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/cool"
|
2026-01-19 18:51:56 +08:00
|
|
|
"blazing/modules/player/model"
|
2025-12-13 22:51:39 +08:00
|
|
|
"context"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func (s *RoomService) Get(userid uint32) model.BaseHouseEx {
|
|
|
|
|
|
|
|
|
|
//todo待测试
|
|
|
|
|
var ttt model.BaseHouseEx
|
2026-01-08 03:30:18 +08:00
|
|
|
m := s.TestModel(s.Model)
|
2025-12-13 22:51:39 +08:00
|
|
|
|
2026-01-08 03:30:18 +08:00
|
|
|
m.Where("player_id", userid).Scan(&ttt)
|
2025-12-13 22:51:39 +08:00
|
|
|
|
|
|
|
|
return ttt
|
|
|
|
|
|
|
|
|
|
}
|
2026-01-08 03:30:18 +08:00
|
|
|
|
2026-01-19 18:51:56 +08:00
|
|
|
// 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)
|
|
|
|
|
|
|
|
|
|
// }
|
2025-12-13 22:51:39 +08:00
|
|
|
func (s *RoomService) Set(id []model.FitmentShowInfo) {
|
|
|
|
|
//todo待测试
|
2026-01-20 04:40:36 +08:00
|
|
|
if cool.Config.ServerInfo.IsVip != 0 {
|
2026-02-02 18:32:41 +08:00
|
|
|
|
2026-01-20 04:40:36 +08:00
|
|
|
return
|
|
|
|
|
}
|
2025-12-13 22:51:39 +08:00
|
|
|
var ttt model.BaseHouseEx
|
2026-01-08 03:30:18 +08:00
|
|
|
m := s.TestModel(s.Model)
|
|
|
|
|
|
2025-12-13 22:51:39 +08:00
|
|
|
m.Scan(&ttt)
|
|
|
|
|
ttt.PlacedItems = id
|
2026-01-19 18:51:56 +08:00
|
|
|
ttt.UsedItems = make(map[uint32]uint32)
|
|
|
|
|
for _, ids := range id {
|
|
|
|
|
_, ok := ttt.UsedItems[ids.Id]
|
|
|
|
|
if !ok {
|
|
|
|
|
ttt.UsedItems[ids.Id] = 1
|
|
|
|
|
} else {
|
|
|
|
|
ttt.UsedItems[ids.Id] = ttt.UsedItems[ids.Id] + 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2025-12-13 22:51:39 +08:00
|
|
|
|
|
|
|
|
ttt.PlayerID = uint64(s.userid)
|
|
|
|
|
m.Save(ttt)
|
|
|
|
|
|
|
|
|
|
}
|
2025-12-13 23:25:04 +08:00
|
|
|
func (s *RoomService) Show(cactime []uint32) {
|
|
|
|
|
|
2025-12-13 22:51:39 +08:00
|
|
|
//todo待测试
|
|
|
|
|
var ttt model.BaseHouseEx
|
2026-01-08 03:30:18 +08:00
|
|
|
m := s.TestModel(s.Model)
|
|
|
|
|
|
2025-12-13 22:51:39 +08:00
|
|
|
m.Scan(&ttt)
|
2025-12-13 23:25:04 +08:00
|
|
|
ttt.ShowPokemon = cactime
|
2025-12-13 22:51:39 +08:00
|
|
|
|
|
|
|
|
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},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|