From cc4125fee5c518458413aba848b62c335d7de2bc Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Sun, 28 Apr 2024 14:59:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E4=BA=92=E5=8A=A8?= =?UTF-8?q?=E8=A1=A8=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- robot/base/interaction.go | 2 +- robot/base/scenemgr.go | 7 +++++++ robot/tienlen/sctienlen.go | 19 ++++++++++++++----- robot/tienlen/tienlenplayer.go | 11 ++++++++--- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/robot/base/interaction.go b/robot/base/interaction.go index 985f7e3..ac516e8 100644 --- a/robot/base/interaction.go +++ b/robot/base/interaction.go @@ -54,5 +54,5 @@ func SendEmote(s *netlib.Session, p IPlayer, arr []int) { Param: []int32{int32(e)}, } - DelaySendSecond(s, int(gamehall.GameHallPacketID_PACKET_CSRoomEvent), pack, 2, 3) + DelaySendSecond(s, int(gamehall.GameHallPacketID_PACKET_CSRoomEvent), pack, 3, 5) } diff --git a/robot/base/scenemgr.go b/robot/base/scenemgr.go index ce2c62f..b8a1164 100644 --- a/robot/base/scenemgr.go +++ b/robot/base/scenemgr.go @@ -47,6 +47,13 @@ func (sm *SceneMgr) GetSceneDBGameFree(sceneId, gamefreeId int32) *server_proto. return srvdata.PBDB_GameFreeMgr.GetData(gamefreeId) } +func (sm *SceneMgr) IsFreeMode(sceneId int32) bool { + if data, exist := sm.sceneDBGameFree[sceneId]; exist { + return data.GetFreeMode() == 1 + } + return false +} + // ////////////////////////////////////////////////////////////////// // / Module Implement [beg] // ////////////////////////////////////////////////////////////////// diff --git a/robot/tienlen/sctienlen.go b/robot/tienlen/sctienlen.go index 929839d..57bab5e 100644 --- a/robot/tienlen/sctienlen.go +++ b/robot/tienlen/sctienlen.go @@ -20,6 +20,15 @@ import ( "strings" ) +func SendEmote(s *netlib.Session, scene *TienLenScene, p *TienLenPlayer, arr []int, tp int) { + if !base.SceneMgrSingleton.IsFreeMode(scene.GetRoomId()) && !scene.IsMatchScene() { + if p.EmoteTimes[tp] == 0 { + base.SendEmote(s, p, arr) + } + p.EmoteTimes[tp]++ + } +} + type SCTienLenRoomInfoPacketFactory struct { } @@ -95,7 +104,7 @@ func (this *SCTienLenPlayerOpHandler) Process(s *netlib.Session, packid int, pac if lastPlayer != nil && lastPlayer.IsRobot() && me.SnId != lastPlayer.GetSnId() && (tienlen.IsTwo(scene.LastCards) || tienlen.IsBomb(scene.LastCards, !common.IsTienLenYuLe(int(scene.GetGameId())))) { // 机器人出2/炸弹被压制 - base.SendEmote(base.PlayerMgrSingleton.GetPlayerSession(scene.LastOpSnid), lastPlayer, base.Emote1) + SendEmote(base.PlayerMgrSingleton.GetPlayerSession(scene.LastOpSnid), scene, lastPlayer.(*TienLenPlayer), base.Emote1, 1) } scene.LastCards = delC scene.LastOpSnid = me.SnId @@ -105,7 +114,7 @@ func (this *SCTienLenPlayerOpHandler) Process(s *netlib.Session, packid int, pac if me.PassTimes >= 2 { me.PassTimes = 0 // 机器人过牌两次 - base.SendEmote(s, me, base.Emote2) + SendEmote(s, scene, me, base.Emote2, 2) } } @@ -461,7 +470,7 @@ func (this *SCTienLenCurOpPosHandler) Process(s *netlib.Session, packid int, pac minS = notExDelayminS maxS = notExDelaymaxS if scene.FirstWinSnid == 0 { - base.SendEmote(s, p, base.Emote5) + SendEmote(s, scene, me, base.Emote5, 5) scene.FirstWinSnid = me.SnId } } @@ -628,9 +637,9 @@ func SCRoomEvent(s *netlib.Session, packid int, pack interface{}) error { switch msg.Param[0] { case common.ItemIDBucket, common.ItemIDSlippers: - base.SendEmote(s, p, base.Emote3) + SendEmote(s, scene, p.(*TienLenPlayer), base.Emote3, 3) case common.ItemIDLike, common.ItemIDCoffee: - base.SendEmote(s, p, base.Emote4) + SendEmote(s, scene, p.(*TienLenPlayer), base.Emote4, 3) } return nil diff --git a/robot/tienlen/tienlenplayer.go b/robot/tienlen/tienlenplayer.go index a05257a..230959a 100644 --- a/robot/tienlen/tienlenplayer.go +++ b/robot/tienlen/tienlenplayer.go @@ -12,12 +12,16 @@ var TienLenNilPlayer *TienLenPlayer = nil type TienLenPlayer struct { base.BasePlayer *proto_tienlen.TienLenPlayerData - data *tienlenApi.PredictRequest - PassTimes int + data *tienlenApi.PredictRequest + PassTimes int + EmoteTimes map[int]int // 事件触发次数 } func NewTienLenPlayer(data *proto_tienlen.TienLenPlayerData) *TienLenPlayer { - p := &TienLenPlayer{TienLenPlayerData: data} + p := &TienLenPlayer{ + TienLenPlayerData: data, + EmoteTimes: make(map[int]int), + } p.Init() return p } @@ -28,6 +32,7 @@ func (p *TienLenPlayer) Init() { func (p *TienLenPlayer) Clear() { p.PassTimes = 0 + p.EmoteTimes = make(map[int]int) } func (p *TienLenPlayer) MarkFlag(flag int32) {