Merge branch 'ma' of https://git.pogorockgames.com/mango-games/server/game into ma
This commit is contained in:
commit
14b78495f6
|
|
@ -15,7 +15,7 @@ const (
|
|||
const (
|
||||
ClawDollSceneWaitTimeout = time.Second * 6 //等待倒计时
|
||||
ClawDollSceneStartTimeout = time.Second * 5 //开始倒计时
|
||||
ClawDollScenePlayTimeout = time.Second * 30 //娃娃机下抓倒计时
|
||||
ClawDollScenePlayTimeout = time.Second * 10 //娃娃机下抓倒计时
|
||||
ClawDollSceneBilledTimeout = time.Second * 2 //结算
|
||||
ClawDollSceneWaitPayCoinimeout = time.Second * 10 //等待下一局投币
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,11 @@ func (this *PlayerEx) CanGrab() bool {
|
|||
// 游戏新一局 设置数据
|
||||
func (this *PlayerEx) ReStartGame() {
|
||||
this.ReDataStartGame()
|
||||
|
||||
this.UnmarkFlag(base.PlayerState_WaitNext)
|
||||
this.UnmarkFlag(base.PlayerState_GameBreak)
|
||||
this.MarkFlag(base.PlayerState_Ready)
|
||||
|
||||
this.gainCoin = 0
|
||||
this.taxCoin = 0
|
||||
this.odds = 0
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ type SceneEx struct {
|
|||
// 游戏是否能开始
|
||||
func (this *SceneEx) CanStart() bool {
|
||||
//人数>=1自动开始
|
||||
if len(this.players) >= 0 && (this.GetRealPlayerNum() >= 0 || this.IsPreCreateScene()) {
|
||||
if len(this.players) >= 1 && (this.GetRealPlayerNum() >= 1 || this.IsPreCreateScene() || this.IsHasPlaying()) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
@ -67,7 +67,7 @@ func (this *SceneEx) CanStart() bool {
|
|||
// 从房间删除玩家
|
||||
func (this *SceneEx) delPlayer(p *base.Player) {
|
||||
if p, exist := this.players[p.SnId]; exist {
|
||||
this.seats[p.GetPos()] = nil
|
||||
//this.seats[p.GetPos()] = nil
|
||||
delete(this.players, p.SnId)
|
||||
this.RemoveWaitPlayer(p.SnId)
|
||||
}
|
||||
|
|
@ -162,7 +162,6 @@ func NewClawdollSceneData(s *base.Scene) *SceneEx {
|
|||
Scene: s,
|
||||
logic: new(rule.Logic),
|
||||
players: make(map[int32]*PlayerEx),
|
||||
seats: make([]*PlayerEx, s.GetPlayerNum()),
|
||||
PlayerBackup: make(map[int32]*PlayerData),
|
||||
waitPlayers: list.New(),
|
||||
}
|
||||
|
|
@ -175,9 +174,40 @@ func (this *SceneEx) init() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// 检查上分是否合法
|
||||
func (this *SceneEx) CheckPayOp(betVal int64, takeMul int64) bool { //游戏底分
|
||||
// 检查上分投币是否合法
|
||||
func (this *SceneEx) CheckPayCoinOp(p *PlayerEx) bool {
|
||||
if p == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if p.SnId == this.playingSnid {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查移动是否合法
|
||||
func (this *SceneEx) CheckMoveOp(p *PlayerEx) bool {
|
||||
if p == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if p.SnId == this.playingSnid {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// 下抓是否合法
|
||||
func (this *SceneEx) CheckGrapOp(p *PlayerEx) bool {
|
||||
if p == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if p.SnId == this.playingSnid {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *SceneEx) Clear() {
|
||||
|
|
@ -191,13 +221,6 @@ func (this *SceneEx) Clear() {
|
|||
p.Clear(0)
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < this.GetPlayerNum(); i++ {
|
||||
if this.seats[i] != nil {
|
||||
this.seats[i].Clear(this.GetBaseScore())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 是否有玩家正在玩
|
||||
|
|
|
|||
|
|
@ -103,10 +103,11 @@ func (this *PolicyClawdoll) OnPlayerEnter(s *base.Scene, p *base.Player) {
|
|||
playerEx.Clear(baseScore)
|
||||
|
||||
if sceneEx.playingSnid == 0 {
|
||||
//sceneEx.playingSnid = p.GetSnId()
|
||||
}
|
||||
|
||||
p.MarkFlag(base.PlayerState_WaitNext)
|
||||
p.UnmarkFlag(base.PlayerState_Ready)
|
||||
sceneEx.playingSnid = p.GetSnId()
|
||||
}
|
||||
|
||||
sceneEx.AddWaitPlayer(playerEx)
|
||||
|
||||
|
|
@ -247,6 +248,7 @@ func (this *PolicyClawdoll) CanChangeCoinScene(s *base.Scene, p *base.Player) bo
|
|||
|
||||
func (this *PolicyClawdoll) SendRoomInfo(s *base.Scene, p *base.Player, sceneEx *SceneEx) {
|
||||
pack := sceneEx.ClawdollCreateRoomInfoPacket(s, p)
|
||||
|
||||
p.SendToClient(int(clawdoll.CLAWDOLLPacketID_PACKET_SC_CLAWDOLL_ROOMINFO), pack)
|
||||
}
|
||||
|
||||
|
|
@ -279,14 +281,14 @@ func (this *BaseState) CanChangeTo(s base.SceneState) bool {
|
|||
|
||||
func (this *BaseState) CanChangeCoinScene(s *base.Scene, p *base.Player) bool {
|
||||
|
||||
//playerEx, ok := p.ExtraData.(*PlayerEx)
|
||||
//if !ok {
|
||||
// return false
|
||||
//}
|
||||
//
|
||||
//if !playerEx.CanLeaveScene(s.GetSceneState().GetState()) {
|
||||
// return false
|
||||
//}
|
||||
playerEx, ok := p.ExtraData.(*PlayerEx)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
if !playerEx.CanLeaveScene(s.GetSceneState().GetState()) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
@ -335,17 +337,13 @@ func (this *StateWait) GetTimeout(s *base.Scene) int {
|
|||
|
||||
func (this *StateWait) OnEnter(s *base.Scene) {
|
||||
this.BaseState.OnEnter(s)
|
||||
if sceneEx, ok := s.ExtraData.(*SceneEx); ok {
|
||||
if _, ok := s.ExtraData.(*SceneEx); ok {
|
||||
if s.Gaming {
|
||||
s.NotifySceneRoundPause()
|
||||
}
|
||||
s.Gaming = false
|
||||
|
||||
ClawdollBroadcastRoomState(s, float32(0))
|
||||
|
||||
if sceneEx.CanStart() {
|
||||
s.ChangeSceneState(rule.ClawDollSceneStateStart)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -404,6 +402,7 @@ func (this *StateWait) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, par
|
|||
|
||||
if sceneEx.CanStart() {
|
||||
s.ChangeSceneState(rule.ClawDollSceneStateStart)
|
||||
sceneEx.playingSnid = playerEx.SnId
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -425,6 +424,7 @@ func (this *StateStart) GetState() int {
|
|||
func (this *StateStart) CanChangeTo(s base.SceneState) bool {
|
||||
switch s.GetState() {
|
||||
case rule.ClawDollSceneStatePlayGame:
|
||||
return true
|
||||
case rule.ClawDollSceneStateWait:
|
||||
return true
|
||||
}
|
||||
|
|
@ -526,6 +526,11 @@ func (this *PlayGame) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, para
|
|||
|
||||
switch opcode {
|
||||
case rule.ClawDollPlayerOpGo:
|
||||
|
||||
if !sceneEx.CheckGrapOp(playerEx) {
|
||||
return false
|
||||
}
|
||||
|
||||
if !playerEx.CanGrab() {
|
||||
return false
|
||||
}
|
||||
|
|
@ -537,6 +542,11 @@ func (this *PlayGame) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, para
|
|||
sceneEx.OnPlayerSMGrabOp(p.SnId, int32(sceneEx.machineId), grapType)
|
||||
|
||||
case rule.ClawDollPlayerOpMove:
|
||||
|
||||
if !sceneEx.CheckMoveOp(playerEx) {
|
||||
return false
|
||||
}
|
||||
|
||||
if !playerEx.CanMove() {
|
||||
return false
|
||||
}
|
||||
|
|
@ -581,7 +591,7 @@ func (this *StateBilled) GetState() int {
|
|||
|
||||
func (this *StateBilled) CanChangeTo(s base.SceneState) bool {
|
||||
switch s.GetState() {
|
||||
case rule.ClawDollSceneStateStart:
|
||||
case rule.ClawDollSceneWaitPayCoin:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
@ -636,6 +646,7 @@ func (this *StateWaitPayCoin) GetState() int {
|
|||
func (this *StateWaitPayCoin) CanChangeTo(s base.SceneState) bool {
|
||||
switch s.GetState() {
|
||||
case rule.ClawDollSceneStateStart:
|
||||
return true
|
||||
case rule.ClawDollSceneStateWait:
|
||||
return true
|
||||
}
|
||||
|
|
@ -674,6 +685,8 @@ func (this *StateWaitPayCoin) OnPlayerOp(s *base.Scene, p *base.Player, opcode i
|
|||
|
||||
sceneEx.OnPlayerSMPerateOp(p.SnId, int32(sceneEx.machineId), rule.ButtonPayCoin)
|
||||
|
||||
playerEx.ReStartGame()
|
||||
|
||||
s.ChangeSceneState(rule.ClawDollSceneStateStart)
|
||||
//sceneEx.OnPlayerSCOp(p, opcode, clawdoll.OpResultCode_OPRC_Success, params)
|
||||
}
|
||||
|
|
@ -703,7 +716,13 @@ func (this *StateWaitPayCoin) OnTick(s *base.Scene) {
|
|||
if sceneEx, ok := s.ExtraData.(*SceneEx); ok {
|
||||
if time.Now().Sub(sceneEx.StateStartTime) > rule.ClawDollSceneWaitPayCoinimeout {
|
||||
|
||||
// 时间到,重置scene数据
|
||||
// 先设置时间
|
||||
playingEx := sceneEx.players[sceneEx.playingSnid]
|
||||
if playingEx != nil {
|
||||
playingEx.ReStartGame()
|
||||
}
|
||||
|
||||
// 后重置scene数据
|
||||
sceneEx.WaitNextPlayer()
|
||||
|
||||
s.ChangeSceneState(rule.ClawDollSceneStateWait)
|
||||
|
|
|
|||
Loading…
Reference in New Issue