``feat(item): 新增物品出售价格属性(SellPrice)并实现物品出售功能,优化宠物面板计算和时区判断逻辑``
This commit is contained in:
@@ -2,7 +2,7 @@ package space
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/logic/service/maps/info"
|
||||
"blazing/logic/service/space/info"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
|
||||
@@ -2,8 +2,9 @@ package space
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/maps/info"
|
||||
maps "blazing/logic/service/maps/info"
|
||||
|
||||
"blazing/logic/service/space/info"
|
||||
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
@@ -68,7 +69,7 @@ func (s *Space) EnterMap(c common.PlayerI) {
|
||||
}
|
||||
|
||||
}
|
||||
func (s *Space) GetInfo(c common.PlayerI) []maps.OutInfo {
|
||||
func (s *Space) GetInfo(c common.PlayerI) []info.OutInfo {
|
||||
|
||||
if atomic.LoadUint32(&s.TimeBoss.Flag) == 1 {
|
||||
defer c.SendPackCmd(2022, &s.TimeBoss)
|
||||
@@ -80,8 +81,8 @@ func (s *Space) GetInfo(c common.PlayerI) []maps.OutInfo {
|
||||
|
||||
}
|
||||
defer c.SendPackCmd(50004, &info.S2C_50004{Id: uint32(s.Weather)}) //获取天气
|
||||
ret := make([]maps.OutInfo, 0)
|
||||
s.UserInfo.Range(func(k uint32, v maps.OutInfo) (stop bool) {
|
||||
ret := make([]info.OutInfo, 0)
|
||||
s.UserInfo.Range(func(k uint32, v info.OutInfo) (stop bool) {
|
||||
ret = append(ret, v)
|
||||
return len(ret) > 30
|
||||
})
|
||||
|
||||
41
logic/service/space/info.go
Normal file
41
logic/service/space/info.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package space
|
||||
|
||||
import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/modules/blazing/model"
|
||||
)
|
||||
|
||||
type ListMapPlayerInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2003" struc:"skip"` //切换地图
|
||||
}
|
||||
|
||||
type AttackBossInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2412" struc:"skip"` //切换地图
|
||||
}
|
||||
type LeaveMapInboundInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2002" struc:"skip"` //切换地图
|
||||
}
|
||||
|
||||
type InInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2001" struc:"skip"` //切换地图
|
||||
// 地图类型
|
||||
MapType uint32
|
||||
|
||||
MapId uint32
|
||||
// Point: 直接给坐标x,y
|
||||
Point model.Pos `fieldDesc:"直接给坐标x,y"`
|
||||
|
||||
// Reverse2: 暂定 占位字符2
|
||||
//Reverse2 string `struc:"[2]byte"`
|
||||
}
|
||||
type WalkInInfo struct {
|
||||
Head common.TomeeHeader `cmd:"2101" struc:"skip"` //走路包
|
||||
// Flag: 0为走,1为飞行模式,@UInt long
|
||||
Flag uint32
|
||||
|
||||
// Point: 直接给坐标x,y
|
||||
Point model.Pos `fieldDesc:"直接给坐标x,y"`
|
||||
|
||||
PathLen uint32 `struc:"sizeof=Path" `
|
||||
Path string
|
||||
}
|
||||
177
logic/service/space/info/info.go
Normal file
177
logic/service/space/info/info.go
Normal file
@@ -0,0 +1,177 @@
|
||||
package info
|
||||
|
||||
import (
|
||||
"blazing/modules/blazing/model"
|
||||
|
||||
"github.com/creasty/defaults"
|
||||
)
|
||||
|
||||
type ListMapPlayerOutboundInfo struct {
|
||||
PlayersLen uint32 `struc:"sizeof=Player" json:"player_len"`
|
||||
|
||||
// 穿戴装备的信息
|
||||
Player []OutInfo ` json:"player"`
|
||||
}
|
||||
|
||||
// PeopleWalkOutboundInfo PeopleWalkOutboundInfo类,实现OutboundMessage接口
|
||||
type WalkOutInfo struct {
|
||||
// Flag: 0为走,1为飞行模式
|
||||
Flag uint32 `fieldDesc:"0为走,1为飞行模式" codec:"uint"`
|
||||
|
||||
// UserID: 走动的人的米米号
|
||||
UserID uint32 `fieldDesc:"走动的人的米米号" codec:"uint"`
|
||||
|
||||
// Point: 直接给坐标x,y
|
||||
Point model.Pos `fieldDesc:"直接给坐标x,y"`
|
||||
|
||||
PathLen uint32 `struc:"sizeof=Path" `
|
||||
Path string
|
||||
}
|
||||
|
||||
type MapBossSInfo struct {
|
||||
InfoLen uint32 `struc:"sizeof=INFO" json:"info_len"`
|
||||
|
||||
INFO []MapBossInfo
|
||||
}
|
||||
type MapBossInfo struct {
|
||||
Id uint32 `json:"id" protobuf:"1,req,name=id"` // 需要刷新的BOSS精灵ID
|
||||
Region uint32 `json:"region" protobuf:"2,req,name=region"` // 刷新区域(蘑菇怪为0)
|
||||
Hp int32 `struc:"uint32" json:"hp" protobuf:"3,req,name=hp"` // HP值(蘑菇怪为A,其他BOSS暂未明确用途,可能无实际作用)
|
||||
Pos int `struc:"uint32" json:"pos" protobuf:"4,req,name=pos"` // 刷新坐标(类似野怪的位置ID,蘑菇怪初始为2; pos==200时候将会删除boss显示
|
||||
}
|
||||
|
||||
// 这里存储星球的map
|
||||
//var planetmap utils.SyncMap[] //= space.NewSyncMap()
|
||||
|
||||
// PeopleInfo PeopleInfo类,实现OutboundMessage接口
|
||||
type OutInfo struct {
|
||||
UserID uint32 `struc:"uint32" fieldDesc:"米米号" json:"user_id"`
|
||||
|
||||
// 16字节昵称
|
||||
Nick string `struc:"[16]byte" fieldDesc:"16字节昵称" json:"nick"`
|
||||
|
||||
// 机器人人物颜色 00 rgb
|
||||
Color uint32 `struc:"uint32" fieldDesc:"机器人人物颜色 00 rgb" json:"color"`
|
||||
|
||||
// 固定值0
|
||||
Texture uint32 `struc:"uint32" fieldDesc:"固定值0" json:"texture"`
|
||||
|
||||
// 暂时不明建议先给固定值0
|
||||
Vip uint16 ` json:"vip"`
|
||||
|
||||
// 暂时不明建议先给固定值15
|
||||
Viped uint16 ` default:"15" json:"viped"`
|
||||
|
||||
// 暂时不明建议先给固定值1
|
||||
VipStage uint32 `struc:"uint32" fieldDesc:"暂时不明建议先给固定值1" json:"vip_stage"`
|
||||
|
||||
// 人物状态 =0 步行 !=0 飞行
|
||||
ActionType uint32 `struc:"uint32" fieldDesc:"人物状态 =0 步行 !=0 飞行" json:"action_type"`
|
||||
|
||||
// 上线的地图id
|
||||
Pos model.Pos `fieldDesc:"上线的地图id" json:"pos"`
|
||||
|
||||
// 动作, 大于10000时为蹲下
|
||||
Action uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"action"`
|
||||
|
||||
// 动作, 默认情况下为2, 蹲下为3
|
||||
Direction uint32 `struc:"uint32" default:"2" fieldDesc:"暂时不明给2" json:"direction"`
|
||||
|
||||
// 变形套装ID
|
||||
ChangeShape uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"change_shape"`
|
||||
|
||||
// 暂时不明给0
|
||||
SpiritTime uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"spirit_time"`
|
||||
|
||||
// 暂时不明给0
|
||||
SpiritID uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"spirit_id"`
|
||||
|
||||
// 宠物 ID 暂时无法测试,给 0
|
||||
PetDV uint32 `struc:"uint32" fieldDesc:"宠物ID暂时无法测试, 给0" json:"pet_dv"`
|
||||
// 宠物闪光暂时无法测试,给 0
|
||||
PetShiny uint32 `struc:"uint32" fieldDesc:"宠物闪光暂时无法测试, 给0" json:"pet_shiny"`
|
||||
// 宠物皮肤暂时无法测试,给 0
|
||||
PetSkin uint32 `struc:"uint32" fieldDesc:"宠物皮肤暂时无法测试, 给0" json:"pet_skin"`
|
||||
// 填充字符
|
||||
Reserved uint32 `struc:"uint32" fieldDesc:"填充字符" json:"reserved"`
|
||||
// 填充字符
|
||||
Reserved1 uint32 `struc:"uint32" fieldDesc:"填充字符" json:"reserved1"`
|
||||
// 填充字符
|
||||
Reserved2 uint32 `struc:"uint32" fieldDesc:"填充字符" json:"reserved2"`
|
||||
|
||||
// 暂时不明给0
|
||||
FightFlag uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"fight_flag"`
|
||||
|
||||
// 教官ID
|
||||
TeacherID uint32 `struc:"uint32" fieldDesc:"教官ID" json:"teacher_id"`
|
||||
|
||||
// 学员ID
|
||||
StudentID uint32 `struc:"uint32" fieldDesc:"学员ID" json:"student_id"`
|
||||
|
||||
// nono状态 固定值-1
|
||||
NonoState uint32 `struc:"uint32" default:"0xFFFFFFFF" fieldDesc:"nono状态 固定值-1" json:"nono_state"`
|
||||
|
||||
// nono颜色 00 FF FF FF
|
||||
NonoColor uint32 `struc:"uint32" fieldDesc:"nono颜色 00 FF FF FF" json:"nono_color"`
|
||||
|
||||
// 是不是超能nono 固定值1
|
||||
SuperNono uint32 `struc:"uint32" default:"1" fieldDesc:"是不是超能nono 固定值1" json:"super_nono"`
|
||||
|
||||
// 暂时不明给0
|
||||
PlayerForm uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"player_form"`
|
||||
|
||||
// 暂时不明给0
|
||||
TransTime uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"trans_time"`
|
||||
|
||||
// 暂时不明给0
|
||||
TeamID uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"team_id"`
|
||||
|
||||
// 暂时不明给0
|
||||
TeamCoreCount uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"team_core_count"`
|
||||
|
||||
// 暂时不明给0
|
||||
TeamIsShow uint32 `struc:"uint32" fieldDesc:"暂时不明给0" json:"team_is_show"`
|
||||
|
||||
// 暂时不明给0
|
||||
LogoBg uint16 `json:"logo_bg"`
|
||||
|
||||
// 暂时不明给0
|
||||
LogoIcon uint16 ` json:"logo_icon"`
|
||||
|
||||
// 暂时不明给0
|
||||
LogoColor uint16 `json:"logo_color"`
|
||||
|
||||
// 暂时不明给0
|
||||
TxtColor uint16 `json:"txt_color"`
|
||||
|
||||
// 4字节
|
||||
LogoWord [4]byte `struc:"[4]byte" fieldDesc:"4字节" json:"logo_word"`
|
||||
ClothesLen uint32 `struc:"sizeof=Clothes" fieldDesc:"穿戴装备的信息" json:"clothes_len"`
|
||||
|
||||
// 穿戴装备的信息
|
||||
Clothes []model.PeopleItemInfo `fieldDesc:"穿戴装备的信息" json:"clothes"`
|
||||
}
|
||||
|
||||
func NewOutInfo() *OutInfo {
|
||||
l := &OutInfo{}
|
||||
|
||||
// 自动填充 struct tag 里的 default 值
|
||||
if err := defaults.Set(l); err != nil {
|
||||
panic(err) // 方便发现 default 设置错误
|
||||
}
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
type LeaveMapOutboundInfo struct {
|
||||
// 米米号
|
||||
UserID uint32 `struc:"uint32" fieldDesc:"米米号" json:"user_id"`
|
||||
}
|
||||
type S2C_50004 struct {
|
||||
Id uint32 `json:"id" protobuf:"1,req,name=id"` // 天气0没有,1是雨.2是雪
|
||||
|
||||
}
|
||||
type S2C_2022 struct {
|
||||
Flag uint32 `json:"flag" protobuf:"1,req,name=flag"`
|
||||
ID uint32 `json:"id" protobuf:"2,req,name=id"`
|
||||
}
|
||||
@@ -6,8 +6,7 @@ import (
|
||||
"blazing/cool"
|
||||
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/maps/info"
|
||||
maps "blazing/logic/service/maps/info"
|
||||
"blazing/logic/service/space/info"
|
||||
|
||||
csmap "github.com/mhmtszr/concurrent-swiss-map"
|
||||
"github.com/tnnmigga/enum"
|
||||
@@ -23,7 +22,7 @@ var WeatherStatus = enum.New[struct {
|
||||
// Space 针对Player的并发安全map,键为uint32类型
|
||||
type Space struct {
|
||||
User *csmap.CsMap[uint32, common.PlayerI] // 存储玩家数据的map,键为玩家ID
|
||||
UserInfo *csmap.CsMap[uint32, maps.OutInfo]
|
||||
UserInfo *csmap.CsMap[uint32, info.OutInfo]
|
||||
CanRefresh bool //是否能够刷怪
|
||||
Super uint32
|
||||
//SuperValue *int32
|
||||
@@ -53,10 +52,10 @@ func NewSpace() *Space {
|
||||
// set the total capacity, every shard map has total capacity/shard count capacity. the default value is 0.
|
||||
// csmap.WithSize[string, int](1000),
|
||||
),
|
||||
UserInfo: csmap.New[uint32, maps.OutInfo](
|
||||
UserInfo: csmap.New[uint32, info.OutInfo](
|
||||
// set the number of map shards. the default value is 32.
|
||||
csmap.WithShardCount[uint32, maps.OutInfo](32),
|
||||
csmap.WithCustomHasher[uint32, maps.OutInfo](func(key uint32) uint64 {
|
||||
csmap.WithShardCount[uint32, info.OutInfo](32),
|
||||
csmap.WithCustomHasher[uint32, info.OutInfo](func(key uint32) uint64 {
|
||||
|
||||
return uint64(key)
|
||||
}),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package space
|
||||
|
||||
import (
|
||||
"blazing/logic/service/maps/info"
|
||||
"blazing/logic/service/space/info"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user