上传协议代码
This commit is contained in:
parent
65591dd0f6
commit
b078353ee1
@ -35,7 +35,7 @@ func (this *apiComp) Handle(session comm.IUserSession, req *pb.CatchbugsHandleRe
|
||||
return
|
||||
}
|
||||
|
||||
if err = room.PlayerHandle(session.GetUserId(), req); errdata != nil {
|
||||
if err = room.PlayerHandle(session.GetUserId(), req); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_SystemError,
|
||||
Title: pb.ErrorCode_SystemError.String(),
|
||||
|
@ -130,6 +130,10 @@ func (this *Room) PlayerHandle(uid string, handle *pb.CatchbugsHandleReq) (err e
|
||||
Issucc: issucc,
|
||||
Coiled: coiled,
|
||||
})
|
||||
|
||||
if this.checkGameOver() == 3 {
|
||||
this.gameover()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -142,6 +146,9 @@ func (this *Room) PlayerHandleEnd(uid string, handle *pb.CatchbugsHandleEndReq)
|
||||
|
||||
var (
|
||||
card []*pb.DBCatchBugsCard
|
||||
roundendpush = &pb.CatchbugsRoundEndPush{
|
||||
Changes: make([]*pb.CatchbugsTablesChangePush, 0),
|
||||
}
|
||||
)
|
||||
this.handleplayers++
|
||||
if uid == this.data.Red.Info.Uid {
|
||||
@ -157,11 +164,15 @@ func (this *Room) PlayerHandleEnd(uid string, handle *pb.CatchbugsHandleEndReq)
|
||||
if state == 2 { //需要补拍
|
||||
this.ReplenishCard()
|
||||
card = this.data.Card
|
||||
this.SendAllSessions("tableschange", &pb.CatchbugsTablesChangePush{
|
||||
roundendpush.Changes = append(roundendpush.Changes, &pb.CatchbugsTablesChangePush{
|
||||
Changetype: 1,
|
||||
Card: card,
|
||||
})
|
||||
this.SendAllSessions("roundend", &pb.CatchbugsRoundEndPush{})
|
||||
// this.SendAllSessions("tableschange", &pb.CatchbugsTablesChangePush{
|
||||
// Changetype: 1,
|
||||
// Card: card,
|
||||
// })
|
||||
// this.SendAllSessions("roundend", &pb.CatchbugsRoundEndPush{})
|
||||
}
|
||||
if this.handleplayers == 2 {
|
||||
this.round++
|
||||
@ -172,15 +183,19 @@ func (this *Room) PlayerHandleEnd(uid string, handle *pb.CatchbugsHandleEndReq)
|
||||
case 1:
|
||||
this.data.Card = Skill1Effect(this.data.Card)
|
||||
card = this.data.Card
|
||||
this.SendAllSessions("tableschange", &pb.CatchbugsTablesChangePush{
|
||||
roundendpush.Changes = append(roundendpush.Changes, &pb.CatchbugsTablesChangePush{
|
||||
Changetype: 0,
|
||||
Card: card,
|
||||
})
|
||||
// this.SendAllSessions("tableschange", &pb.CatchbugsTablesChangePush{
|
||||
// Changetype: 0,
|
||||
// Card: card,
|
||||
// })
|
||||
break
|
||||
case 2:
|
||||
this.data.Card = Skill2Effect(this.data.Card)
|
||||
card = this.data.Card
|
||||
this.SendAllSessions("tableschange", &pb.CatchbugsTablesChangePush{
|
||||
roundendpush.Changes = append(roundendpush.Changes, &pb.CatchbugsTablesChangePush{
|
||||
Changetype: 0,
|
||||
Card: card,
|
||||
})
|
||||
@ -188,7 +203,7 @@ func (this *Room) PlayerHandleEnd(uid string, handle *pb.CatchbugsHandleEndReq)
|
||||
case 4:
|
||||
this.data.Card = Skill4Effect(this.data.Card)
|
||||
card = this.data.Card
|
||||
this.SendAllSessions("tableschange", &pb.CatchbugsTablesChangePush{
|
||||
roundendpush.Changes = append(roundendpush.Changes, &pb.CatchbugsTablesChangePush{
|
||||
Changetype: 0,
|
||||
Card: card,
|
||||
})
|
||||
@ -200,14 +215,14 @@ func (this *Room) PlayerHandleEnd(uid string, handle *pb.CatchbugsHandleEndReq)
|
||||
return
|
||||
}
|
||||
}
|
||||
this.SendAllSessions("roundend", &pb.CatchbugsRoundEndPush{})
|
||||
this.SendAllSessions("roundend", roundendpush)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//检测游戏是否结束 1 正常 2 补拍 3结束
|
||||
func (this *Room) checkGameOver() (state int32) {
|
||||
if this.round >= 6 {
|
||||
if this.round > 6 {
|
||||
state = 3
|
||||
return
|
||||
}
|
||||
@ -232,6 +247,7 @@ func (this *Room) ReplenishCard() {
|
||||
this.round = 4
|
||||
for _, v := range this.data.Card {
|
||||
if v.Isopen {
|
||||
v.Isopen = false
|
||||
v.Cid = this.data.Backup[index].Cid
|
||||
v.Id = this.data.Backup[index].Id
|
||||
index++
|
||||
|
@ -976,6 +976,8 @@ type CatchbugsRoundEndPush struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Changes []*CatchbugsTablesChangePush `protobuf:"bytes,1,rep,name=changes,proto3" json:"changes"`
|
||||
}
|
||||
|
||||
func (x *CatchbugsRoundEndPush) Reset() {
|
||||
@ -1010,6 +1012,13 @@ func (*CatchbugsRoundEndPush) Descriptor() ([]byte, []int) {
|
||||
return file_catchbugs_catchbugs_msg_proto_rawDescGZIP(), []int{18}
|
||||
}
|
||||
|
||||
func (x *CatchbugsRoundEndPush) GetChanges() []*CatchbugsTablesChangePush {
|
||||
if x != nil {
|
||||
return x.Changes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//游戏结束推送12
|
||||
type CatchbugsGameOverPush struct {
|
||||
state protoimpl.MessageState
|
||||
@ -1197,24 +1206,27 @@ var file_catchbugs_catchbugs_msg_proto_rawDesc = []byte{
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x74,
|
||||
0x79, 0x70, 0x65, 0x12, 0x24, 0x0a, 0x04, 0x63, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28,
|
||||
0x0b, 0x32, 0x10, 0x2e, 0x44, 0x42, 0x43, 0x61, 0x74, 0x63, 0x68, 0x42, 0x75, 0x67, 0x73, 0x43,
|
||||
0x61, 0x72, 0x64, 0x52, 0x04, 0x63, 0x61, 0x72, 0x64, 0x22, 0x17, 0x0a, 0x15, 0x43, 0x61, 0x74,
|
||||
0x61, 0x72, 0x64, 0x52, 0x04, 0x63, 0x61, 0x72, 0x64, 0x22, 0x4d, 0x0a, 0x15, 0x43, 0x61, 0x74,
|
||||
0x63, 0x68, 0x62, 0x75, 0x67, 0x73, 0x52, 0x6f, 0x75, 0x6e, 0x64, 0x45, 0x6e, 0x64, 0x50, 0x75,
|
||||
0x73, 0x68, 0x22, 0xe5, 0x01, 0x0a, 0x15, 0x43, 0x61, 0x74, 0x63, 0x68, 0x62, 0x75, 0x67, 0x73,
|
||||
0x47, 0x61, 0x6d, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x50, 0x75, 0x73, 0x68, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x77, 0x69, 0x6e, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x77, 0x69,
|
||||
0x6e, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x64, 0x73, 0x63, 0x65, 0x6e, 0x65,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65, 0x64, 0x73, 0x63, 0x65, 0x6e, 0x65,
|
||||
0x12, 0x1c, 0x0a, 0x09, 0x62, 0x6c, 0x75, 0x65, 0x73, 0x63, 0x65, 0x6e, 0x65, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x09, 0x62, 0x6c, 0x75, 0x65, 0x73, 0x63, 0x65, 0x6e, 0x65, 0x12, 0x20,
|
||||
0x0a, 0x0b, 0x72, 0x65, 0x64, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x0b, 0x72, 0x65, 0x64, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c,
|
||||
0x12, 0x22, 0x0a, 0x0c, 0x62, 0x6c, 0x75, 0x65, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c,
|
||||
0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x62, 0x6c, 0x75, 0x65, 0x69, 0x6e, 0x74, 0x65,
|
||||
0x67, 0x72, 0x61, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x64, 0x63, 0x61, 0x72, 0x64, 0x18,
|
||||
0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x72, 0x65, 0x64, 0x63, 0x61, 0x72, 0x64, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x62, 0x6c, 0x75, 0x65, 0x63, 0x61, 0x72, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x08, 0x62, 0x6c, 0x75, 0x65, 0x63, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
|
||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x73, 0x68, 0x12, 0x34, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x18, 0x01, 0x20,
|
||||
0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x43, 0x61, 0x74, 0x63, 0x68, 0x62, 0x75, 0x67, 0x73, 0x54,
|
||||
0x61, 0x62, 0x6c, 0x65, 0x73, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x75, 0x73, 0x68, 0x52,
|
||||
0x07, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x22, 0xe5, 0x01, 0x0a, 0x15, 0x43, 0x61, 0x74,
|
||||
0x63, 0x68, 0x62, 0x75, 0x67, 0x73, 0x47, 0x61, 0x6d, 0x65, 0x4f, 0x76, 0x65, 0x72, 0x50, 0x75,
|
||||
0x73, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x77, 0x69, 0x6e, 0x75, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x06, 0x77, 0x69, 0x6e, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65,
|
||||
0x64, 0x73, 0x63, 0x65, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x72, 0x65,
|
||||
0x64, 0x73, 0x63, 0x65, 0x6e, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x6c, 0x75, 0x65, 0x73, 0x63,
|
||||
0x65, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x62, 0x6c, 0x75, 0x65, 0x73,
|
||||
0x63, 0x65, 0x6e, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x64, 0x69, 0x6e, 0x74, 0x65, 0x67,
|
||||
0x72, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x72, 0x65, 0x64, 0x69, 0x6e,
|
||||
0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x12, 0x22, 0x0a, 0x0c, 0x62, 0x6c, 0x75, 0x65, 0x69, 0x6e,
|
||||
0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x62, 0x6c,
|
||||
0x75, 0x65, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65,
|
||||
0x64, 0x63, 0x61, 0x72, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x72, 0x65, 0x64,
|
||||
0x63, 0x61, 0x72, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x6c, 0x75, 0x65, 0x63, 0x61, 0x72, 0x64,
|
||||
0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x62, 0x6c, 0x75, 0x65, 0x63, 0x61, 0x72, 0x64,
|
||||
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -1265,11 +1277,12 @@ var file_catchbugs_catchbugs_msg_proto_depIdxs = []int32{
|
||||
23, // 3: CatchbugsSingleGameReq.rules:type_name -> DBCatchBugsRules
|
||||
24, // 4: CatchbugsGameReadyPush.room:type_name -> DBCatchBugsRoom
|
||||
25, // 5: CatchbugsTablesChangePush.card:type_name -> DBCatchBugsCard
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
17, // 6: CatchbugsRoundEndPush.changes:type_name -> CatchbugsTablesChangePush
|
||||
7, // [7:7] is the sub-list for method output_type
|
||||
7, // [7:7] is the sub-list for method input_type
|
||||
7, // [7:7] is the sub-list for extension type_name
|
||||
7, // [7:7] is the sub-list for extension extendee
|
||||
0, // [0:7] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_catchbugs_catchbugs_msg_proto_init() }
|
||||
|
Loading…
Reference in New Issue
Block a user