playroom优化

This commit is contained in:
hahwu 2025-04-17 19:09:30 +08:00
parent 331ec61294
commit 20e6023c5e
4 changed files with 4204 additions and 5268 deletions

View File

@ -770,7 +770,7 @@ func (p *Player) GetSimpleData(Uid int, simple *PlayerSimpleData) error {
simple.Playroom = p.PlayMod.getPlayroomMod().Room
simple.Chess = p.PlayMod.getChessMod().GetUnlockChessList()
simple.WorkStart = p.PlayMod.getPlayroomMod().Starttime
simple.Chip = p.PlayMod.getPlayroomMod().Chip
simple.Chip = p.PlayMod.getPlayroomMod().GetChip()
simple.PetName = p.PlayMod.getBaseMod().PetName
simple.Emoji = p.PlayMod.getEmojiMod().Set
return nil
@ -794,7 +794,7 @@ func (p *Player) UpdateUserInfo() {
simple.Playroom = p.PlayMod.getPlayroomMod().Room
simple.Chess = p.PlayMod.getChessMod().GetUnlockChessList()
simple.WorkStart = p.PlayMod.getPlayroomMod().Starttime
simple.Chip = p.PlayMod.getPlayroomMod().Chip
simple.Chip = p.PlayMod.getPlayroomMod().GetChip()
simple.PetName = p.PlayMod.getBaseMod().PetName
simple.Emoji = p.PlayMod.getEmojiMod().Set
value, _ := json.Marshal(simple)

View File

@ -201,7 +201,7 @@ func handle(p *Player, m *msg.Msg) error {
if m.Extra != nil {
Items = m.Extra.([]*item.Item)
}
PlayroomMod.AddChip()
PlayroomMod.AddChip(m.From, m.SendT)
PlayroomMod.AddMood(playroom.MOOD_TYPE_FOOD, -50)
PlayroomMod.AddMood(playroom.MOOD_TYPE_CLEAN, -50)
PlayroomMod.AddVisitor(m.From, m.SendT)
@ -713,11 +713,17 @@ func PlayroomBackData(p *Player) {
List: GoUtil.IntToInt32(v),
}
}
ChipMessage := make([]*proto.ChipInfo, 0)
for _, v := range PlayroomMod.ChipList {
ChipMessage = append(ChipMessage, &proto.ChipInfo{
Uid: int64(v.Uid),
})
}
r.Dress = Dress
r.DressSet = GoUtil.MapIntToInt32(PlayroomMod.GetDressSet())
r.PetAir = GoUtil.IntToInt32(PlayroomMod.GetPetAir())
r.PetAirSet = int32(PlayroomMod.GetPetAirSet())
r.Chip = int32(PlayroomMod.Chip)
r.Chip = ChipMessage
r.StartTime = int32(PlayroomMod.Starttime)
r.WorkStatus = int32(PlayroomMod.WorkStatus)
r.Playroom = GoUtil.MapIntToInt32(PlayroomMod.GetRoom())
@ -749,7 +755,13 @@ func PlayroomVisit(p *Player, Uid int) {
r.GameId = int32(PlayroomMod.GameId)
r.Defense = Work
r.Emoji = GoUtil.MapIntToInt32(PlayerData.Emoji)
r.Chip = int32(PlayerData.Chip)
// ChipMessage := make([]*proto.ChipInfo, 0)
// for _, v := range PlayroomMod.ChipList {
// ChipMessage = append(ChipMessage, &proto.ChipInfo{
// Uid: int64(v.Uid),
// })
// }
// r.Chip = ChipMessage
r.PetName = PlayerData.PetName
Items := make(map[int32]*proto.ItemInfo, 0)
for k, v := range PlayroomMod.GameReward {

View File

@ -36,7 +36,7 @@ type PlayroomMod struct {
GameInfo map[int]interface{} // 游戏信息
Exclude bool // 是否排除
LoseItem []*item.Item // 失去的物品
Chip int // 碎片
ChipList []*ChipInfo // 碎片列表
Flip map[int]int // 翻牌
FlipReward []*item.Item // 翻牌奖励
WorkOutline int // 是否离线
@ -79,6 +79,11 @@ const (
GAME_TYPE_HIDE = 3 // 捉迷藏
)
type ChipInfo struct {
Uid int
Time int64
}
type Mood struct {
Id int
Num int
@ -199,11 +204,11 @@ func (p *PlayroomMod) GetStatus() int {
}
func (p *PlayroomMod) GetChip() int {
return p.Chip
return len(p.ChipList)
}
func (p *PlayroomMod) AddChip() {
p.Chip = min(p.Chip+1, 5)
func (p *PlayroomMod) AddChip(Uid int, Time int64) {
p.ChipList = append(p.ChipList, &ChipInfo{Uid: Uid, Time: Time})
}
func (p *PlayroomMod) SetTarget(Target int) {
@ -420,9 +425,15 @@ func (p *PlayroomMod) NotifyWork() *msg.NotifyPlayroomWork {
}
func (p *PlayroomMod) NotifyLose() *msg.NotifyPlayroomLose {
ChipMessage := make([]*msg.ChipInfo, 0)
for _, v := range p.ChipList {
ChipMessage = append(ChipMessage, &msg.ChipInfo{
Uid: int64(v.Uid),
})
}
return &msg.NotifyPlayroomLose{
LoseItem: item.ItemToMsg(p.LoseItem),
Chip: int32(p.Chip),
Chip: ChipMessage,
}
}
@ -454,8 +465,16 @@ func (p *PlayroomMod) Fire(ChargeId int) []*item.Item {
}
func (p *PlayroomMod) RemoveChip(Num int) []*item.Item {
Num = min(Num, p.Chip)
p.Chip -= Num
len := len(p.ChipList)
Num = min(Num, len)
if Num == 0 {
return nil
}
if Num == len {
p.ChipList = make([]*ChipInfo, 0)
} else {
p.ChipList = p.ChipList[Num:len]
}
return []*item.Item{item.NewItem(item.ITEM_STAR_ID, Num*50)}
}

File diff suppressed because it is too large Load Diff