playroom优化
This commit is contained in:
parent
bf34ec773a
commit
e79d7b6729
@ -290,7 +290,7 @@ func ReqGmCommand_(player *Player, Command string) error {
|
||||
}
|
||||
case "playroomDress":
|
||||
PlayroomMod := player.PlayMod.getPlayroomMod()
|
||||
PlayroomMod.Dress = make(map[int][]int)
|
||||
PlayroomMod.NewDress = make(map[int]*playroom.DressInfo, 0)
|
||||
DressList := playroomCfg.GetDressList()
|
||||
for _, v := range DressList {
|
||||
Part := playroomCfg.GetDressPart(v)
|
||||
|
||||
@ -23,7 +23,17 @@ func PlayroomBackData(p *Player) {
|
||||
r.Items = item.ItemToMsg(PlayroomMod.Reward)
|
||||
Opponent := make([]*proto.RoomOpponent, 0)
|
||||
FriendList := make([]*proto.FriendRoom, 0)
|
||||
|
||||
Targer := GetVisitorPlayer(p)
|
||||
TargerRoom := &proto.FriendRoom{}
|
||||
if Targer != 0 {
|
||||
PlayerData := G_GameLogicPtr.GetSimplePlayerByUid(Targer)
|
||||
if PlayerData != nil {
|
||||
TargerRoom.Uid = int64(PlayerData.Uid)
|
||||
TargerRoom.Name = PlayerData.Name
|
||||
TargerRoom.Face = int32(PlayerData.Face)
|
||||
TargerRoom.Avatar = int32(PlayerData.Avatar)
|
||||
}
|
||||
}
|
||||
for k, v := range PlayroomMod.Visitor {
|
||||
ps := G_GameLogicPtr.GetSimplePlayerByUid(k)
|
||||
if ps == nil {
|
||||
@ -56,6 +66,7 @@ func PlayroomBackData(p *Player) {
|
||||
}
|
||||
r.Opponent = Opponent
|
||||
r.Friend = FriendList
|
||||
r.Target = TargerRoom
|
||||
Collect := make([]int32, 0)
|
||||
for k, v := range PlayroomMod.GetCollect() {
|
||||
if v > 0 {
|
||||
@ -64,10 +75,17 @@ func PlayroomBackData(p *Player) {
|
||||
}
|
||||
r.Collect = Collect
|
||||
Dress := make(map[int32]*proto.PlayroomDress)
|
||||
for k, v := range PlayroomMod.GetDress() {
|
||||
Dress[int32(k)] = &proto.PlayroomDress{
|
||||
List: GoUtil.IntToInt32(v),
|
||||
for _, v := range PlayroomMod.GetDress() {
|
||||
PlayroomDress, ok := Dress[int32(v.Part)]
|
||||
if !ok {
|
||||
PlayroomDress = &proto.PlayroomDress{}
|
||||
}
|
||||
PlayroomDress.List = append(PlayroomDress.List, &proto.PlayroomDressInfo{
|
||||
Id: int32(v.Id),
|
||||
AddTime: int64(v.AddTime),
|
||||
EndTime: int64(v.EndTime),
|
||||
Label: v.Label,
|
||||
})
|
||||
}
|
||||
ChipMessage := make([]*proto.ChipInfo, 0)
|
||||
for _, v := range PlayroomMod.ChipList {
|
||||
|
||||
@ -15,6 +15,7 @@ type PlayroomMod struct {
|
||||
Collect map[int]int // 装饰
|
||||
Room map[int]int // 房间
|
||||
Dress map[int][]int // 服装仓库
|
||||
NewDress map[int]*DressInfo
|
||||
DressSet map[int]int // 服装穿戴
|
||||
PetAir []int // 宠物空气背包
|
||||
PetAirSet int // 宠物空气背包穿戴
|
||||
@ -59,6 +60,15 @@ type PlayroomMod struct {
|
||||
ADItem map[int]*ItemInfo
|
||||
}
|
||||
|
||||
type DressInfo struct {
|
||||
Id int // 服装ID
|
||||
Part int // 服装部位
|
||||
AddTime int64 // 添加时间
|
||||
EndTime int64 // 结束时间
|
||||
Label string // 标签
|
||||
Num int // 数量
|
||||
}
|
||||
|
||||
type ItemInfo struct {
|
||||
Watch int // 观看次数
|
||||
LastTime int64 // 上次观看时间
|
||||
@ -184,12 +194,40 @@ func (p *PlayroomMod) InitData() {
|
||||
InitPetAir := playroomCfg.GetInitAirList()
|
||||
p.PetAir = append(p.PetAir, InitPetAir...)
|
||||
}
|
||||
if len(p.Dress) == 0 {
|
||||
p.Dress = make(map[int][]int)
|
||||
if p.NewDress == nil {
|
||||
p.NewDress = make(map[int]*DressInfo)
|
||||
}
|
||||
// Dress仓库重构
|
||||
if len(p.Dress) != 0 {
|
||||
for _, v := range p.Dress {
|
||||
for _, id := range v {
|
||||
if _, ok := p.NewDress[id]; !ok {
|
||||
Part := playroomCfg.GetDressPart(id)
|
||||
p.NewDress[id] = &DressInfo{
|
||||
Id: id,
|
||||
Part: Part,
|
||||
AddTime: GoUtil.Now(),
|
||||
EndTime: 0,
|
||||
Label: "",
|
||||
Num: 1,
|
||||
}
|
||||
} else {
|
||||
p.NewDress[id].Num++
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
InitDressList := playroomCfg.GetInitDressList()
|
||||
for _, v := range InitDressList {
|
||||
Part := playroomCfg.GetDressPart(v)
|
||||
p.Dress[Part] = append(p.Dress[Part], v)
|
||||
p.NewDress[v] = &DressInfo{
|
||||
Id: v,
|
||||
Part: Part,
|
||||
AddTime: GoUtil.Now(),
|
||||
EndTime: 0,
|
||||
Label: "",
|
||||
Num: 1,
|
||||
}
|
||||
}
|
||||
}
|
||||
if p.ADItem == nil {
|
||||
@ -487,10 +525,18 @@ func (p *PlayroomMod) AddCollect(Id int) {
|
||||
|
||||
func (p *PlayroomMod) AddDress(Id int) {
|
||||
Part := playroomCfg.GetDressPart(Id)
|
||||
if _, ok := p.Dress[Part]; !ok {
|
||||
p.Dress[Part] = make([]int, 0)
|
||||
if _, ok := p.NewDress[Id]; !ok {
|
||||
p.NewDress[Id] = &DressInfo{
|
||||
Id: Id,
|
||||
Part: Part,
|
||||
AddTime: GoUtil.Now(),
|
||||
EndTime: 0,
|
||||
Label: "",
|
||||
Num: 1,
|
||||
}
|
||||
} else {
|
||||
p.NewDress[Id].Num++
|
||||
}
|
||||
p.Dress[Part] = append(p.Dress[Part], Id)
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) ResetGame() {
|
||||
@ -813,11 +859,14 @@ func (p *PlayroomMod) ShopBuy(Id, Num int) ([]*item.Item, []*item.Item, error) {
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) UnlockDress(Type, Id int) error {
|
||||
_, ok := p.Dress[Type]
|
||||
if !ok {
|
||||
p.Dress[Type] = make([]int, 0)
|
||||
p.NewDress[Id] = &DressInfo{
|
||||
Id: Id,
|
||||
Part: Type,
|
||||
AddTime: GoUtil.Now(),
|
||||
EndTime: 0,
|
||||
Label: "",
|
||||
Num: 1,
|
||||
}
|
||||
p.Dress[Type] = append(p.Dress[Type], Id)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -834,15 +883,15 @@ func (p *PlayroomMod) PlayroomDressSet(DressSet map[int]int) ([]int, map[int]int
|
||||
Part := make([]int, 0)
|
||||
Diff := GoUtil.DiffMap(DressSet, p.DressSet)
|
||||
for Type, Id := range DressSet {
|
||||
dresses, ok := p.Dress[Type]
|
||||
if Id == 0 {
|
||||
continue
|
||||
}
|
||||
dressInfo, ok := p.NewDress[Type]
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("dress type not found")
|
||||
}
|
||||
if !GoUtil.InArray(Id, dresses) {
|
||||
return nil, nil, fmt.Errorf("dress not found")
|
||||
if dressInfo.EndTime < GoUtil.Now() && dressInfo.EndTime != 0 {
|
||||
return nil, nil, fmt.Errorf("dress timeout")
|
||||
}
|
||||
if p.DressSet[Type] == 0 && Id != 0 {
|
||||
Part = append(Part, Type)
|
||||
@ -897,8 +946,8 @@ func (p *PlayroomMod) GetPetAirSet() int {
|
||||
return p.PetAirSet
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) GetDress() map[int][]int {
|
||||
return p.Dress
|
||||
func (p *PlayroomMod) GetDress() map[int]*DressInfo {
|
||||
return p.NewDress
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) GetPetAir() []int {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user