parent
30d3ba1cc0
commit
7a7baa9568
|
@ -826,38 +826,34 @@ func (this *StateOp) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, param
|
|||
return false
|
||||
}
|
||||
|
||||
returnFunc := func(code thirteen.OpResultCode) {
|
||||
returnFunc := func(code thirteen.OpResultCode, broadcast bool) {
|
||||
pack := &thirteen.SCThirteenPlayerOp{
|
||||
OpRetCode: code,
|
||||
OpCode: int32(opcode),
|
||||
OpParam: params,
|
||||
Pos: int32(playerEx.GetPos()),
|
||||
}
|
||||
if code == thirteen.OpResultCode_OPRC_Error {
|
||||
proto.SetDefaults(pack)
|
||||
logger.Logger.Trace("SCThirteenPlayerOp:", pack)
|
||||
if broadcast {
|
||||
playerEx.Broadcast(int(thirteen.TWMmoPacketID_PACKET_SCThirteenPlayerOp), pack, 0)
|
||||
} else {
|
||||
playerEx.SendToClient(int(thirteen.TWMmoPacketID_PACKET_SCThirteenPlayerOp), pack)
|
||||
return
|
||||
}
|
||||
logger.Logger.Trace("SCThirteenPlayerOp:", pack)
|
||||
}
|
||||
|
||||
if !playerEx.IsGameing() {
|
||||
returnFunc(thirteen.OpResultCode_OPRC_Error)
|
||||
returnFunc(thirteen.OpResultCode_OPRC_Error, false)
|
||||
return true
|
||||
}
|
||||
|
||||
switch opcode {
|
||||
case rule.ThirteenWaterPlayerOpMS: //确定牌
|
||||
//if playerEx.deterMine { // 确认牌型
|
||||
// returnFunc(thirteen.OpResultCode_OPRC_Error)
|
||||
// return false
|
||||
//}
|
||||
if len(params) == 13 {
|
||||
//校验牌
|
||||
a := rule.DelCards(playerEx.cards[:], common.Int64Toint(params))
|
||||
if len(a) != 0 {
|
||||
logger.Logger.Error("the cards is error.")
|
||||
returnFunc(thirteen.OpResultCode_OPRC_Error)
|
||||
returnFunc(thirteen.OpResultCode_OPRC_Error, false)
|
||||
return true
|
||||
}
|
||||
//牌赋值
|
||||
|
@ -892,38 +888,59 @@ func (this *StateOp) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, param
|
|||
playerEx.cardsO = &rule.Group{Head: [3]int{-1, -1, -1}, Mid: [5]int{-1, -1, -1, -1, -1}, End: [5]int{-1, -1, -1, -1, -1}, PokerType: -1}
|
||||
playerEx.Trusteeship = 0
|
||||
playerEx.UnmarkFlag(base.PlayerState_Auto)
|
||||
pack := &thirteen.SCThirteenPlayerOp{
|
||||
OpRetCode: thirteen.OpResultCode_OPRC_Sucess,
|
||||
OpCode: int32(opcode),
|
||||
OpParam: params,
|
||||
Pos: int32(playerEx.GetPos()),
|
||||
}
|
||||
if len(params) == 13 {
|
||||
//校验牌
|
||||
a := rule.DelCards(playerEx.cards[:], common.Int64Toint(params))
|
||||
if len(a) != 0 {
|
||||
remain := len(playerEx.cards)
|
||||
remainCards := make([]int, remain)
|
||||
copy(remainCards, playerEx.cards[:])
|
||||
for _, v := range params {
|
||||
if v >= 0 {
|
||||
a := rule.DelCards(remainCards, []int{int(v)})
|
||||
if len(a) == remain {
|
||||
logger.Logger.Error("the cards is error.")
|
||||
returnFunc(thirteen.OpResultCode_OPRC_Error)
|
||||
returnFunc(thirteen.OpResultCode_OPRC_Error, false)
|
||||
return true
|
||||
}
|
||||
remain = len(a)
|
||||
remainCards = a
|
||||
}
|
||||
}
|
||||
|
||||
//牌赋值
|
||||
copy(playerEx.preCardsO.Head[:], common.Int64Toint(params[:3]))
|
||||
copy(playerEx.preCardsO.Mid[:], common.Int64Toint(params[3:8]))
|
||||
copy(playerEx.preCardsO.End[:], common.Int64Toint(params[8:]))
|
||||
playerEx.preCardsO.PokerType = 0
|
||||
|
||||
for k, v := range playerEx.preCardsO.Head {
|
||||
if v < 0 {
|
||||
playerEx.preCardsO.Head[k] = remainCards[0]
|
||||
remainCards = remainCards[1:]
|
||||
}
|
||||
playerEx.SendToClient(int(thirteen.TWMmoPacketID_PACKET_SCThirteenPlayerOp), pack)
|
||||
}
|
||||
for k, v := range playerEx.preCardsO.Mid {
|
||||
if v < 0 {
|
||||
playerEx.preCardsO.Mid[k] = remainCards[0]
|
||||
remainCards = remainCards[1:]
|
||||
}
|
||||
}
|
||||
for k, v := range playerEx.preCardsO.End {
|
||||
if v < 0 {
|
||||
playerEx.preCardsO.End[k] = remainCards[0]
|
||||
remainCards = remainCards[1:]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(params) == 0 {
|
||||
playerEx.preCardsO = &rule.Group{Head: [3]int{-1, -1, -1}, Mid: [5]int{-1, -1, -1, -1, -1}, End: [5]int{-1, -1, -1, -1, -1}, PokerType: -1}
|
||||
}
|
||||
returnFunc(thirteen.OpResultCode_OPRC_Sucess, true)
|
||||
|
||||
case rule.ThirteenWaterPlayerOpReset:
|
||||
// 取消确认
|
||||
playerEx.deterMine = false
|
||||
pack := &thirteen.SCThirteenPlayerOp{
|
||||
OpRetCode: thirteen.OpResultCode_OPRC_Sucess,
|
||||
OpCode: int32(opcode),
|
||||
OpParam: params,
|
||||
Pos: int32(playerEx.GetPos()),
|
||||
}
|
||||
playerEx.Broadcast(int(thirteen.TWMmoPacketID_PACKET_SCThirteenPlayerOp), pack, 0)
|
||||
returnFunc(thirteen.OpResultCode_OPRC_Sucess, true)
|
||||
|
||||
default:
|
||||
return false
|
||||
|
|
Loading…
Reference in New Issue