三消投降
This commit is contained in:
parent
020e1304a3
commit
b4b68cbf85
@ -17,10 +17,33 @@ func (this *apiComp) SurrenderCheck(session comm.IUserSession, req *pb.Entertain
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *apiComp) Surrender(session comm.IUserSession, req *pb.EntertainSurrenderReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) Surrender(session comm.IUserSession, req *pb.EntertainSurrenderReq) (errdata *pb.ErrorData) {
|
||||||
|
var (
|
||||||
|
list *pb.DBXXLData
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if list, err = this.module.model.getEntertainmList(session.GetUserId()); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 操作消息返回
|
||||||
|
if list.Touxiang <= 0 {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_EntertainMaxTouxiangCount,
|
||||||
|
Title: pb.ErrorCode_EntertainMaxTouxiangCount.ToString(),
|
||||||
|
}
|
||||||
|
}
|
||||||
if errdata = this.module.gameMgr.RoomDistribute(req.Roomid, session, "surrender", req); errdata == nil {
|
if errdata = this.module.gameMgr.RoomDistribute(req.Roomid, session, "surrender", req); errdata == nil {
|
||||||
// 操作消息返回
|
list.Touxiang -= 1
|
||||||
session.SendMsg(string(this.module.GetType()), "surrender", &pb.EntertainSurrenderResp{})
|
this.module.model.modifyEntertainmList(session.GetUserId(), map[string]interface{}{
|
||||||
|
"touxiang": list.Touxiang,
|
||||||
|
})
|
||||||
|
session.SendMsg(string(this.module.GetType()), "surrender", &pb.EntertainSurrenderResp{
|
||||||
|
Leftcount: list.Touxiang,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -506,32 +506,13 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if list, err := this.module.model.getEntertainmList(session.GetUserId()); err == nil {
|
var winner *pb.PlayerData
|
||||||
if list.Touxiang <= 0 {
|
if this.player1.Userinfo.Uid == session.GetUserId() {
|
||||||
errdata = &pb.ErrorData{
|
winner = this.player2
|
||||||
Code: pb.ErrorCode_EntertainMaxTouxiangCount,
|
|
||||||
Title: pb.ErrorCode_EntertainMaxTouxiangCount.ToString(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list.Touxiang -= 1
|
|
||||||
this.module.model.modifyEntertainmList(session.GetUserId(), map[string]interface{}{
|
|
||||||
"touxiang": list.Touxiang,
|
|
||||||
})
|
|
||||||
var winner *pb.PlayerData
|
|
||||||
if this.player1.Userinfo.Uid == session.GetUserId() {
|
|
||||||
winner = this.player2
|
|
||||||
} else {
|
|
||||||
winner = this.player1
|
|
||||||
}
|
|
||||||
this.GameOver(winner)
|
|
||||||
} else {
|
} else {
|
||||||
errdata = &pb.ErrorData{
|
winner = this.player1
|
||||||
Code: pb.ErrorCode_DBError,
|
|
||||||
Title: pb.ErrorCode_DBError.ToString(),
|
|
||||||
Message: err.Error(),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
this.GameOver(winner)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2208,6 +2208,8 @@ type EntertainSurrenderResp struct {
|
|||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Leftcount int32 `protobuf:"varint,1,opt,name=leftcount,proto3" json:"leftcount"` // 投降剩余次数
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *EntertainSurrenderResp) Reset() {
|
func (x *EntertainSurrenderResp) Reset() {
|
||||||
@ -2242,6 +2244,13 @@ func (*EntertainSurrenderResp) Descriptor() ([]byte, []int) {
|
|||||||
return file_entertain_entertain_msg_proto_rawDescGZIP(), []int{39}
|
return file_entertain_entertain_msg_proto_rawDescGZIP(), []int{39}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *EntertainSurrenderResp) GetLeftcount() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Leftcount
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
var File_entertain_entertain_msg_proto protoreflect.FileDescriptor
|
var File_entertain_entertain_msg_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_entertain_entertain_msg_proto_rawDesc = []byte{
|
var file_entertain_entertain_msg_proto_rawDesc = []byte{
|
||||||
@ -2459,9 +2468,11 @@ var file_entertain_entertain_msg_proto_rawDesc = []byte{
|
|||||||
0x0a, 0x15, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x74, 0x61, 0x69, 0x6e, 0x53, 0x75, 0x72, 0x72, 0x65,
|
0x0a, 0x15, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x74, 0x61, 0x69, 0x6e, 0x53, 0x75, 0x72, 0x72, 0x65,
|
||||||
0x6e, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x69,
|
0x6e, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x69,
|
||||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x69, 0x64, 0x22,
|
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x6f, 0x6f, 0x6d, 0x69, 0x64, 0x22,
|
||||||
0x18, 0x0a, 0x16, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x74, 0x61, 0x69, 0x6e, 0x53, 0x75, 0x72, 0x72,
|
0x36, 0x0a, 0x16, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x74, 0x61, 0x69, 0x6e, 0x53, 0x75, 0x72, 0x72,
|
||||||
0x65, 0x6e, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
|
0x65, 0x6e, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x65, 0x66,
|
||||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x74, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6c, 0x65,
|
||||||
|
0x66, 0x74, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
|
||||||
|
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user