modify 踢出房间规则

This commit is contained in:
sk 2024-12-23 14:53:07 +08:00
parent aabdd36720
commit cfed6154bc
3 changed files with 34 additions and 8 deletions

View File

@ -164,7 +164,7 @@ func (this *CSPlayerSwitchFlagHandler) Process(s *netlib.Session, packetid int,
return nil
}
flag := int(msg.GetFlag())
logger.Logger.Trace("CSPlayerSwitchFlagHandler Process recv SnId(%v) Mark is %v", p.SnId, msg.GetMark())
logger.Logger.Tracef("CSPlayerSwitchFlagHandler Process recv SnId(%v) Mark is %v", p.SnId, msg.GetMark())
if msg.GetMark() == 0 { //0取消状态 1设置状态
oldFlag := p.GetFlag()
if p.IsMarkFlag(flag) {

View File

@ -2,6 +2,7 @@ package tienlen
import (
"math/rand"
"mongo.games.com/goserver/core/timer"
"strconv"
"time"
@ -30,6 +31,7 @@ type TienLenPlayerData struct {
isNotOverLastHand bool //手牌不能压过上家出牌标志
cardScore int // 手牌评分
playerPool int // 个人水池分
handlId timer.TimerHandle
}
func (this *TienLenPlayerData) init() {

View File

@ -10,6 +10,7 @@ import (
"mongo.games.com/goserver/core"
"mongo.games.com/goserver/core/logger"
"mongo.games.com/goserver/core/timer"
"mongo.games.com/game/common"
rule "mongo.games.com/game/gamerule/tienlen"
@ -166,7 +167,27 @@ func (this *ScenePolicyTienLen) OnPlayerDropLine(s *base.Scene, p *base.Player)
p.MarkFlag(base.PlayerState_Auto)
p.SyncFlag()
} else {
s.PlayerLeave(p, common.PlayerLeaveReason_DropLine, true)
if sceneEx.IsCustom() {
// 如果是等待状态,付费且准备的玩家不踢出,付费没有准备的延迟踢出,未付费的直接踢出
switch sceneEx.GetSceneState().GetState() {
case rule.TienLenSceneStateWaitPlayer:
playerEx, ok := p.GetExtraData().(*TienLenPlayerData)
if !ok || playerEx == nil {
return
}
if s.GetCustom().GetCostType() == 2 && playerEx.GetSnId() != s.GetCreator() {
s.PlayerLeave(p, common.PlayerLeaveReason_DropLine, true)
} else if !playerEx.IsMarkFlag(base.PlayerState_Ready) {
playerEx.handlId, _ = timer.AfterTimer(func(h timer.TimerHandle, ud interface{}) bool {
s.PlayerLeave(p, common.PlayerLeaveReason_DropLine, true)
return true
}, nil, time.Minute)
}
default:
}
} else {
s.PlayerLeave(p, common.PlayerLeaveReason_DropLine, true)
}
}
s.FirePlayerEvent(p, base.PlayerEventDropLine, nil)
@ -185,6 +206,14 @@ func (this *ScenePolicyTienLen) OnPlayerRehold(s *base.Scene, p *base.Player) {
p.SyncFlag()
}
// 停止定时器
if playerEx, ok := p.GetExtraData().(*TienLenPlayerData); ok {
if playerEx.handlId > 0 {
timer.StopTimer(playerEx.handlId)
playerEx.handlId = 0
}
}
//发送房间信息给自己
TienLenSendRoomInfo(s, p, sceneEx)
s.FirePlayerEvent(p, base.PlayerEventRehold, nil)
@ -596,11 +625,6 @@ func (this *SceneBaseStateTienLen) CanChangeTo(s base.SceneState) bool {
// 当前状态能否换桌
func (this *SceneBaseStateTienLen) CanChangeCoinScene(s *base.Scene, p *base.Player) bool {
if s.IsCustom() {
if s.NumOfGames > 0 && s.NumOfGames < int(s.TotalOfGames) {
return false
}
}
return !p.IsGameing() || s.GetDestroyed() || !s.GetGaming()
}
@ -869,7 +893,7 @@ func (this *SceneWaitStartStateTienLen) CanChangeTo(s base.SceneState) bool {
// 当前状态能否换桌
func (this *SceneWaitStartStateTienLen) CanChangeCoinScene(s *base.Scene, p *base.Player) bool {
if s.IsMatchScene() || (s.IsCustom() && s.GetNumOfGames() > 0) {
if s.IsMatchScene() {
return false
}
return true