Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
4d154361df
@ -687,6 +687,12 @@ type (
|
||||
IEntertainment interface {
|
||||
// 添加三消卡片资源
|
||||
AddXxlCard(session IUserSession, cards map[string]int32, bPush bool) (errdata *pb.ErrorData)
|
||||
|
||||
CreateRoom(sessions []IUserSession, rulesStr string) (roomid string, err error)
|
||||
//用户离线
|
||||
UserOffline(roomid string, uid string) (err error)
|
||||
//主动认输
|
||||
AdmitDefeat(roomid string, uid string) (err error)
|
||||
}
|
||||
IMoonlv interface {
|
||||
IBuriedUpdateNotify
|
||||
|
@ -62,11 +62,13 @@ func (this *gameMgrComp) CreateMasterRoom(p *pb.PlayerData) (room *Room, err err
|
||||
return
|
||||
}
|
||||
|
||||
// 匹配加入房间
|
||||
func (this *gameMgrComp) MatchJoinRoom(p1 *pb.PlayerData, p2 *pb.PlayerData) (room *Room) {
|
||||
// 创建一个玩法类型的房间(itype :-1 表示随机玩法)
|
||||
func (this *gameMgrComp) CreateRoomByType(p1 *pb.PlayerData, p2 *pb.PlayerData, itype int32) (room *Room, err error) {
|
||||
room = new(Room) //初始化房间
|
||||
room = room.InitRoom(this.module, p1, p2)
|
||||
|
||||
room, err = room.InitRoom(this.module, p1, p2, itype)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
this.lock.Lock()
|
||||
this.rooms[room.Id] = room
|
||||
this.lock.Unlock()
|
||||
|
@ -108,7 +108,7 @@ func (this *matchComp) MatchNotic(players map[string]interface{}) (err error) {
|
||||
}
|
||||
}
|
||||
go func() {
|
||||
this.module.gameMgr.MatchJoinRoom(p1, p2)
|
||||
this.module.gameMgr.CreateRoomByType(p1, p2, -1)
|
||||
}()
|
||||
|
||||
return
|
||||
|
@ -2,10 +2,12 @@ package entertainment
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
@ -162,3 +164,77 @@ func (this *Entertainment) useroffline(ctx context.Context, req *pb.RPCGeneralRe
|
||||
this.gameMgr.RoomDistribute(req.Param1, nil, "offline", req)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Entertainment) CreateRoom(sessions []comm.IUserSession, rulesStr string) (roomid string, err error) {
|
||||
var (
|
||||
rules *pb.DBXxlRules = &pb.DBXxlRules{}
|
||||
red *pb.DBUser
|
||||
blue *pb.DBUser
|
||||
p1 *pb.PlayerData
|
||||
p2 *pb.PlayerData
|
||||
room *Room
|
||||
)
|
||||
|
||||
if err = json.Unmarshal([]byte(rulesStr), rules); err != nil {
|
||||
this.Error("解析规则json", log.Field{Key: "err", Value: err.Error()})
|
||||
return
|
||||
}
|
||||
// 参数校验
|
||||
if rules.Card1 == "" || rules.Card2 == "" {
|
||||
this.Error("未找到卡片信息",
|
||||
log.Field{Key: "uid", Value: sessions[0].GetUserId()},
|
||||
log.Field{Key: "card1", Value: rules.Card1},
|
||||
log.Field{Key: "uid", Value: sessions[1].GetUserId()},
|
||||
log.Field{Key: "card2", Value: rules.Card2})
|
||||
return
|
||||
}
|
||||
//发起者 red
|
||||
red, err = this.ModuleUser.GetUser(sessions[0].GetUserId())
|
||||
if err != nil {
|
||||
this.Error("未找到红方信息", log.Field{Key: "uid", Value: sessions[0].GetUserId()})
|
||||
return
|
||||
}
|
||||
blue, err = this.ModuleUser.GetUser(sessions[1].GetUserId())
|
||||
if err != nil {
|
||||
this.Error("未找到蓝方信息", log.Field{Key: "uid", Value: sessions[1].GetUserId()})
|
||||
return
|
||||
}
|
||||
p1 = &pb.PlayerData{
|
||||
Userinfo: &pb.BaseUserInfo{
|
||||
Uid: red.Uid,
|
||||
Sid: red.Sid,
|
||||
Name: red.Name,
|
||||
Gender: red.Gender,
|
||||
Skin: red.CurSkin,
|
||||
Aframe: red.Curaframe,
|
||||
Title: red.Curtitle,
|
||||
Lv: red.Lv,
|
||||
},
|
||||
Cardid: rules.Card1,
|
||||
}
|
||||
p2 = &pb.PlayerData{
|
||||
Userinfo: &pb.BaseUserInfo{
|
||||
Uid: blue.Uid,
|
||||
Sid: blue.Sid,
|
||||
Name: blue.Name,
|
||||
Gender: blue.Gender,
|
||||
Skin: blue.CurSkin,
|
||||
Aframe: blue.Curaframe,
|
||||
Title: blue.Curtitle,
|
||||
Lv: blue.Lv,
|
||||
},
|
||||
Cardid: rules.Card2,
|
||||
}
|
||||
|
||||
if room, err = this.gameMgr.CreateRoomByType(p1, p2, rules.RoomType); err != nil {
|
||||
roomid = room.Id
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Entertainment) UserOffline(roomid string, uid string) (err error) {
|
||||
return
|
||||
}
|
||||
func (this *Entertainment) AdmitDefeat(sessions []comm.IUserSession, rulesStr string) (roomid string, err error) {
|
||||
return
|
||||
}
|
||||
|
@ -61,11 +61,22 @@ func (this *Room) RandomPlayType() (itype int32) {
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Room) InitRoom(module *Entertainment, p1 *pb.PlayerData, p2 *pb.PlayerData) *Room {
|
||||
var room *Room
|
||||
func (this *Room) InitRoom(module *Entertainment, p1 *pb.PlayerData, p2 *pb.PlayerData, itype int32) (room *Room, err error) {
|
||||
this.module = module
|
||||
this.chessboard = new(MapData)
|
||||
if itype == -1 {
|
||||
this.Playtype = this.RandomPlayType()
|
||||
} else {
|
||||
if itype == 0 {
|
||||
itype = 1 // 测试数据 后面删
|
||||
}
|
||||
this.Playtype = itype
|
||||
// 校验类型
|
||||
if _, err = this.module.configure.GetGameConsumeIntegralByKey(this.Playtype); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
this.chessboard.InitMap(module, this.Playtype) // 初始化棋盘
|
||||
if s1, ok := this.module.GetUserSession(p1.Userinfo.Uid); !ok {
|
||||
this.module.PutUserSession(s1)
|
||||
@ -97,7 +108,7 @@ func (this *Room) InitRoom(module *Entertainment, p1 *pb.PlayerData, p2 *pb.Play
|
||||
RoomType: this.RoomType,
|
||||
}
|
||||
|
||||
if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "enterroom", &pb.EntertainEnterRoomPush{
|
||||
if err = this.module.SendMsgSyncToSession(string(this.module.GetType()), "enterroom", &pb.EntertainEnterRoomPush{
|
||||
Rooid: room.Id,
|
||||
Servepath: fmt.Sprintf("%s/%s", this.module.service.GetType(), this.module.service.GetId()),
|
||||
User1: room.player1,
|
||||
@ -105,7 +116,7 @@ func (this *Room) InitRoom(module *Entertainment, p1 *pb.PlayerData, p2 *pb.Play
|
||||
}, this.szSession...); err != nil {
|
||||
this.module.Errorln(err)
|
||||
}
|
||||
return room
|
||||
return
|
||||
}
|
||||
|
||||
// AI 操作了
|
||||
|
@ -160,6 +160,16 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.GameInviteAcceptR
|
||||
return
|
||||
}
|
||||
break
|
||||
case 5: // 三消类型
|
||||
if roomid, err = this.module.entertain.CreateRoom(sessions, req.Rules); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
redRecord.Status = 1
|
||||
redRecord.Roomid = roomid
|
||||
|
@ -56,6 +56,16 @@ func (this *apiComp) AdmitDefeat(session comm.IUserSession, req *pb.GameInviteAd
|
||||
return
|
||||
}
|
||||
break
|
||||
case 5:
|
||||
if err = this.module.entertain.AdmitDefeat(req.Roomid, session.GetUserId()); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "admitdefeat", &pb.GameInviteAdmitDefeatResp{})
|
||||
return
|
||||
|
@ -19,6 +19,7 @@ type GameInvite struct {
|
||||
dcolor comm.IDColor
|
||||
caninerabbit comm.ICanineRabbit
|
||||
catchBugs comm.ICatchBugs
|
||||
entertain comm.IEntertainment
|
||||
}
|
||||
|
||||
func NewModule() core.IModule {
|
||||
@ -63,6 +64,11 @@ func (this *GameInvite) Start() (err error) {
|
||||
return
|
||||
}
|
||||
this.catchBugs = module.(comm.ICatchBugs)
|
||||
|
||||
if module, err = this.service.GetModule(comm.ModuleEntertainment); err != nil {
|
||||
return
|
||||
}
|
||||
this.entertain = module.(comm.IEntertainment)
|
||||
this.service.RegisterFunctionName(string(comm.RPC_GameinviteOffline), this.trusteeship)
|
||||
event.RegisterGO(comm.EventUserOffline, this.Useroffline)
|
||||
return
|
||||
@ -108,6 +114,8 @@ func (this *GameInvite) trusteeship(ctx context.Context, req *pb.RPC_GameInviteO
|
||||
err = this.caninerabbit.UserOffline(req.Roomid, req.Offuid)
|
||||
case 3:
|
||||
err = this.dcolor.UserOffline(req.Roomid, req.Offuid)
|
||||
// case 5: // 暂不监听
|
||||
// err = this.entertain.UserOffline(req.Roomid, req.Offuid)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -498,6 +498,70 @@ func (x *DBXXLData) GetEtime() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
// 三消游戏规则
|
||||
type DBXxlRules struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
RoomType int32 `protobuf:"varint,1,opt,name=RoomType,proto3" json:"RoomType"` // 房间类型
|
||||
Card1 string `protobuf:"bytes,2,opt,name=card1,proto3" json:"card1"` // player1 卡
|
||||
Card2 string `protobuf:"bytes,3,opt,name=card2,proto3" json:"card2"` // player2 卡
|
||||
}
|
||||
|
||||
func (x *DBXxlRules) Reset() {
|
||||
*x = DBXxlRules{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_entertain_entertain_db_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DBXxlRules) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DBXxlRules) ProtoMessage() {}
|
||||
|
||||
func (x *DBXxlRules) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_entertain_entertain_db_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DBXxlRules.ProtoReflect.Descriptor instead.
|
||||
func (*DBXxlRules) Descriptor() ([]byte, []int) {
|
||||
return file_entertain_entertain_db_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *DBXxlRules) GetRoomType() int32 {
|
||||
if x != nil {
|
||||
return x.RoomType
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DBXxlRules) GetCard1() string {
|
||||
if x != nil {
|
||||
return x.Card1
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DBXxlRules) GetCard2() string {
|
||||
if x != nil {
|
||||
return x.Card2
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_entertain_entertain_db_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_entertain_entertain_db_proto_rawDesc = []byte{
|
||||
@ -567,8 +631,13 @@ var file_entertain_entertain_db_proto_rawDesc = []byte{
|
||||
0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38,
|
||||
0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
0x01, 0x22, 0x54, 0x0a, 0x0a, 0x44, 0x42, 0x58, 0x78, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12,
|
||||
0x1a, 0x0a, 0x08, 0x52, 0x6f, 0x6f, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x08, 0x52, 0x6f, 0x6f, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63,
|
||||
0x61, 0x72, 0x64, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63, 0x61, 0x72, 0x64,
|
||||
0x31, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x61, 0x72, 0x64, 0x32, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x05, 0x63, 0x61, 0x72, 0x64, 0x32, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -583,7 +652,7 @@ func file_entertain_entertain_db_proto_rawDescGZIP() []byte {
|
||||
return file_entertain_entertain_db_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_entertain_entertain_db_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_entertain_entertain_db_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||
var file_entertain_entertain_db_proto_goTypes = []interface{}{
|
||||
(*MapData)(nil), // 0: MapData
|
||||
(*GirdeData)(nil), // 1: GirdeData
|
||||
@ -591,16 +660,17 @@ var file_entertain_entertain_db_proto_goTypes = []interface{}{
|
||||
(*DBXXLMatch)(nil), // 3: DBXXLMatch
|
||||
(*BoxData)(nil), // 4: BoxData
|
||||
(*DBXXLData)(nil), // 5: DBXXLData
|
||||
nil, // 6: DBXXLData.RewardEntry
|
||||
nil, // 7: DBXXLData.CardEntry
|
||||
(*BaseUserInfo)(nil), // 8: BaseUserInfo
|
||||
(*DBXxlRules)(nil), // 6: DBXxlRules
|
||||
nil, // 7: DBXXLData.RewardEntry
|
||||
nil, // 8: DBXXLData.CardEntry
|
||||
(*BaseUserInfo)(nil), // 9: BaseUserInfo
|
||||
}
|
||||
var file_entertain_entertain_db_proto_depIdxs = []int32{
|
||||
1, // 0: MapData.data:type_name -> GirdeData
|
||||
8, // 1: PlayerData.userinfo:type_name -> BaseUserInfo
|
||||
8, // 2: DBXXLMatch.userinfo:type_name -> BaseUserInfo
|
||||
6, // 3: DBXXLData.reward:type_name -> DBXXLData.RewardEntry
|
||||
7, // 4: DBXXLData.card:type_name -> DBXXLData.CardEntry
|
||||
9, // 1: PlayerData.userinfo:type_name -> BaseUserInfo
|
||||
9, // 2: DBXXLMatch.userinfo:type_name -> BaseUserInfo
|
||||
7, // 3: DBXXLData.reward:type_name -> DBXXLData.RewardEntry
|
||||
8, // 4: DBXXLData.card:type_name -> DBXXLData.CardEntry
|
||||
4, // 5: DBXXLData.box:type_name -> BoxData
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
@ -688,6 +758,18 @@ func file_entertain_entertain_db_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_entertain_entertain_db_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DBXxlRules); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -695,7 +777,7 @@ func file_entertain_entertain_db_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_entertain_entertain_db_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 8,
|
||||
NumMessages: 9,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user