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