modify 踢出房间规则
This commit is contained in:
parent
cfed6154bc
commit
2176efcdf0
|
@ -337,7 +337,7 @@ func (this *Player) OnRehold(newSid int64, newSess *netlib.Session) {
|
||||||
|
|
||||||
func (this *Player) OnDropLine() {
|
func (this *Player) OnDropLine() {
|
||||||
this.UnmarkFlag(PlayerState_Online)
|
this.UnmarkFlag(PlayerState_Online)
|
||||||
if !this.scene.Gaming && this.IsReady() && !this.scene.IsMatchScene() {
|
if !this.scene.Gaming && this.IsReady() && !this.scene.IsMatchScene() && !this.scene.IsCustom() {
|
||||||
this.UnmarkFlag(PlayerState_Ready)
|
this.UnmarkFlag(PlayerState_Ready)
|
||||||
}
|
}
|
||||||
this.SyncFlag()
|
this.SyncFlag()
|
||||||
|
|
|
@ -32,6 +32,7 @@ type TienLenPlayerData struct {
|
||||||
cardScore int // 手牌评分
|
cardScore int // 手牌评分
|
||||||
playerPool int // 个人水池分
|
playerPool int // 个人水池分
|
||||||
handlId timer.TimerHandle
|
handlId timer.TimerHandle
|
||||||
|
isPlaying bool // 本局参与游戏
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *TienLenPlayerData) init() {
|
func (this *TienLenPlayerData) init() {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
"mongo.games.com/goserver/core/timer"
|
||||||
|
|
||||||
tienlenApi "mongo.games.com/game/api3th/smart/tienlen"
|
tienlenApi "mongo.games.com/game/api3th/smart/tienlen"
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
|
@ -260,6 +261,9 @@ func (this *TienLenSceneData) delPlayer(p *base.Player) {
|
||||||
if p, exist := this.players[p.SnId]; exist {
|
if p, exist := this.players[p.SnId]; exist {
|
||||||
this.seats[p.GetPos()] = nil
|
this.seats[p.GetPos()] = nil
|
||||||
delete(this.players, p.SnId)
|
delete(this.players, p.SnId)
|
||||||
|
if p.handlId > 0 {
|
||||||
|
timer.StopTimer(p.handlId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (this *TienLenSceneData) OnPlayerLeave(p *base.Player, reason int) {
|
func (this *TienLenSceneData) OnPlayerLeave(p *base.Player, reason int) {
|
||||||
|
|
|
@ -167,22 +167,28 @@ func (this *ScenePolicyTienLen) OnPlayerDropLine(s *base.Scene, p *base.Player)
|
||||||
p.MarkFlag(base.PlayerState_Auto)
|
p.MarkFlag(base.PlayerState_Auto)
|
||||||
p.SyncFlag()
|
p.SyncFlag()
|
||||||
} else {
|
} else {
|
||||||
if sceneEx.IsCustom() {
|
|
||||||
// 如果是等待状态,付费且准备的玩家不踢出,付费没有准备的延迟踢出,未付费的直接踢出
|
|
||||||
switch sceneEx.GetSceneState().GetState() {
|
|
||||||
case rule.TienLenSceneStateWaitPlayer:
|
|
||||||
playerEx, ok := p.GetExtraData().(*TienLenPlayerData)
|
playerEx, ok := p.GetExtraData().(*TienLenPlayerData)
|
||||||
if !ok || playerEx == nil {
|
if !ok || playerEx == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if sceneEx.IsCustom() {
|
||||||
|
// 如果是等待状态,付费且准备的玩家不踢出,付费没有准备的延迟踢出,未付费的直接踢出
|
||||||
|
switch sceneEx.GetSceneState().GetState() {
|
||||||
|
case rule.TienLenSceneStateWaitPlayer:
|
||||||
if s.GetCustom().GetCostType() == 2 && playerEx.GetSnId() != s.GetCreator() {
|
if s.GetCustom().GetCostType() == 2 && playerEx.GetSnId() != s.GetCreator() {
|
||||||
s.PlayerLeave(p, common.PlayerLeaveReason_DropLine, true)
|
s.PlayerLeave(p, common.PlayerLeaveReason_DropLine, true)
|
||||||
} else if !playerEx.IsMarkFlag(base.PlayerState_Ready) {
|
} else {
|
||||||
playerEx.handlId, _ = timer.AfterTimer(func(h timer.TimerHandle, ud interface{}) bool {
|
playerEx.handlId, _ = timer.AfterTimer(func(h timer.TimerHandle, ud interface{}) bool {
|
||||||
s.PlayerLeave(p, common.PlayerLeaveReason_DropLine, true)
|
s.PlayerLeave(p, common.PlayerLeaveReason_DropLine, true)
|
||||||
return true
|
return true
|
||||||
}, nil, time.Minute)
|
}, nil, time.Minute)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case rule.TienLenSceneStateBilled:
|
||||||
|
if (s.GetCustom().GetCostType() == 2 && playerEx.GetSnId() != s.GetCreator()) || !playerEx.IsMarkFlag(base.PlayerState_Ready) {
|
||||||
|
s.PlayerLeave(p, common.PlayerLeaveReason_DropLine, true)
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -713,7 +719,7 @@ func (this *SceneBaseStateTienLen) OnPlayerOp(s *base.Scene, p *base.Player, opc
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if sceneEx.IsCustom() && sceneEx.GetSceneState().GetState() == rule.TienLenSceneStateWaitPlayer {
|
if sceneEx.IsCustom() && sceneEx.GetSceneState().GetState() == rule.TienLenSceneStateBilled {
|
||||||
// 玩家继续
|
// 玩家继续
|
||||||
if !playerEx.IsMarkFlag(base.PlayerState_Ready) {
|
if !playerEx.IsMarkFlag(base.PlayerState_Ready) {
|
||||||
playerEx.MarkFlag(base.PlayerState_Ready)
|
playerEx.MarkFlag(base.PlayerState_Ready)
|
||||||
|
@ -1040,6 +1046,7 @@ func (this *SceneHandCardStateTienLen) OnEnter(s *base.Scene) {
|
||||||
// 首次进入赠送记牌器
|
// 首次进入赠送记牌器
|
||||||
sceneEx.SendFirstGiveTimeItem(playerEx.Player)
|
sceneEx.SendFirstGiveTimeItem(playerEx.Player)
|
||||||
|
|
||||||
|
playerEx.isPlaying = true
|
||||||
playerEx.GameTimes++
|
playerEx.GameTimes++
|
||||||
sceneEx.curGamingPlayerNum++
|
sceneEx.curGamingPlayerNum++
|
||||||
if playerEx.IsRob {
|
if playerEx.IsRob {
|
||||||
|
@ -2930,6 +2937,16 @@ func (this *SceneBilledStateTienLen) OnLeave(s *base.Scene) {
|
||||||
if sceneEx.IsMatchScene() {
|
if sceneEx.IsMatchScene() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 没有继续的踢出房间
|
||||||
|
if !player_data.IsRobot() && sceneEx.IsCustom() &&
|
||||||
|
!player_data.IsMarkFlag(base.PlayerState_Ready) && player_data.isPlaying {
|
||||||
|
sceneEx.PlayerLeave(player_data.Player, common.PlayerLeaveReason_LongTimeNoOp, true)
|
||||||
|
hasLeave = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
player_data.isPlaying = false
|
||||||
|
|
||||||
if !player_data.IsOnLine() {
|
if !player_data.IsOnLine() {
|
||||||
sceneEx.PlayerLeave(player_data.Player, common.PlayerLeaveReason_DropLine, true)
|
sceneEx.PlayerLeave(player_data.Player, common.PlayerLeaveReason_DropLine, true)
|
||||||
hasLeave = true
|
hasLeave = true
|
||||||
|
@ -3020,6 +3037,28 @@ func (this *SceneBilledStateTienLen) OnTick(s *base.Scene) {
|
||||||
//if sceneEx.IsCustom() && sceneEx.NumOfGames >= int(sceneEx.TotalOfGames) {
|
//if sceneEx.IsCustom() && sceneEx.NumOfGames >= int(sceneEx.TotalOfGames) {
|
||||||
// newTime += time.Second * 20
|
// newTime += time.Second * 20
|
||||||
//}
|
//}
|
||||||
|
if sceneEx.IsCustom() {
|
||||||
|
newTime = 60 * time.Second
|
||||||
|
}
|
||||||
|
|
||||||
|
if sceneEx.IsCustom() {
|
||||||
|
// 所有参与游戏的玩家都准备了
|
||||||
|
var has bool
|
||||||
|
for _, player := range sceneEx.players {
|
||||||
|
if player.isPlaying && !player.IsMarkFlag(base.PlayerState_Ready) {
|
||||||
|
has = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !has {
|
||||||
|
if sceneEx.CanStart() == true {
|
||||||
|
s.ChangeSceneState(rule.TienLenSceneStateWaitStart)
|
||||||
|
} else {
|
||||||
|
s.ChangeSceneState(rule.TienLenSceneStateWaitPlayer)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if time.Now().Sub(sceneEx.StateStartTime) > newTime {
|
if time.Now().Sub(sceneEx.StateStartTime) > newTime {
|
||||||
//开始前再次检查开始条件
|
//开始前再次检查开始条件
|
||||||
|
|
Loading…
Reference in New Issue