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