This commit is contained in:
meixiongfeng 2023-10-26 18:12:20 +08:00
commit adcd237cad
20 changed files with 2247 additions and 8 deletions

View File

@ -119,6 +119,7 @@ const (
ModuleMatchPool core.M_Modules = "matchpool" //匹配
ModuleTreasureMap core.M_Modules = "treasuremap" //藏宝图
ModuleGameInvite core.M_Modules = "gameinvite" //游戏邀请
ModuleCanineRabbit core.M_Modules = "caninerabbit" //犬兔游戏
)
// 数据表名定义处
@ -400,9 +401,11 @@ const (
//游戏邀请
TableGameInvite = "gameinvite"
//推送礼包
//藏宝图
TablekTreasuremap = "treasuremap"
TableDcolor = "dcolor"
TablekCanineRabbit = "caninerabbit"
TableEntertainm = "entertainm"
)

View File

@ -668,4 +668,8 @@ type (
IDColor interface {
CreateRoom(sessions []IUserSession, rulesStr string) (roomid string, err error)
}
//犬兔大战
ICanineRabbit interface {
CreateRoom(sessions []IUserSession, rulesStr string) (roomid string, err error)
}
)

View File

@ -0,0 +1,17 @@
package caninerabbit
import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
)
type apiComp struct {
modules.MCompGate
module *CanineRabbit
}
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
_ = this.MCompGate.Init(service, module, comp, options)
this.module = module.(*CanineRabbit)
return
}

View File

@ -0,0 +1,40 @@
package caninerabbit
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.CanineRabbitAwardReq) (errdata *pb.ErrorData) {
return
}
func (this *apiComp) Award(session comm.IUserSession, req *pb.CanineRabbitAwardReq) (errdata *pb.ErrorData) {
var (
info *pb.DBCanineRabbit
atno []*pb.UserAtno
ok bool
err error
)
if errdata = this.AwardCheck(session, req); errdata != nil {
return
}
if info, err = this.module.model.getModel(session.GetUserId()); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Message: err.Error(),
}
return
}
if _, ok = info.Award[req.Id]; ok {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Message: "Allaward Claimed!",
}
}
session.SendMsg(string(this.module.GetType()), "info", &pb.CanineRabbitAwardResp{Id: req.Id, Award: atno})
return
}

View File

@ -0,0 +1,48 @@
package caninerabbit
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
//接受切磋
func (this *apiComp) HandleCheck(session comm.IUserSession, req *pb.CanineRabbitHandleReq) (errdata *pb.ErrorData) {
if req.Roomid == "" {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
}
return
}
func (this *apiComp) Handle(session comm.IUserSession, req *pb.CanineRabbitHandleReq) (errdata *pb.ErrorData) {
var (
room *Room
err error
)
if errdata = this.HandleCheck(session, req); errdata != nil {
return
}
if room, err = this.module.rooms.queryRoom(req.Roomid); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.String(),
Message: err.Error(),
}
return
}
if err = room.PlayerHandle(session.GetUserId(), req); errdata != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.String(),
Message: err.Error(),
}
return
}
session.SendMsg(string(this.module.GetType()), "handle", &pb.DColorHandleResp{})
return
}

View File

@ -0,0 +1,30 @@
package caninerabbit
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.CanineRabbitInfoReq) (errdata *pb.ErrorData) {
return
}
func (this *apiComp) Info(session comm.IUserSession, req *pb.CanineRabbitInfoReq) (errdata *pb.ErrorData) {
var (
info *pb.DBCanineRabbit
err error
)
if errdata = this.InfoCheck(session, req); errdata != nil {
return
}
if info, err = this.module.model.getModel(session.GetUserId()); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Message: err.Error(),
}
return
}
session.SendMsg(string(this.module.GetType()), "info", &pb.CanineRabbitInfoResp{Info: info})
return
}

View File

@ -0,0 +1,61 @@
package caninerabbit
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"math"
)
//接受切磋
func (this *apiComp) SingleOverCheck(session comm.IUserSession, req *pb.DColorSingleOverReq) (errdata *pb.ErrorData) {
return
}
func (this *apiComp) SingleOver(session comm.IUserSession, req *pb.DColorSingleOverReq) (errdata *pb.ErrorData) {
var (
info *pb.DBCanineRabbit
conf *cfg.GameGColorGetfractionData
tconf *cfg.GameGColortTmedecayData
err error
)
if errdata = this.SingleOverCheck(session, req); errdata != nil {
return
}
if info, err = this.module.model.getModel(session.GetUserId()); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Message: err.Error(),
}
return
}
if conf, err = this.module.configure.getGameGColorGetfractionData(int32(req.Difficulty)+1, req.Repeat, len(req.Handles)-1); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Message: err.Error(),
}
return
}
if tconf, err = this.module.configure.getGameGColortTmedecayData(req.Time); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Message: err.Error(),
}
return
}
info.Integral += int32(math.Floor(float64(conf.Fraction) * float64(tconf.Pro) / float64(1000)))
if err = this.module.model.Change(session.GetUserId(), map[string]interface{}{
"integral": info.Integral,
}); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Message: err.Error(),
}
return
}
session.SendMsg(string(this.module.GetType()), "singleover", &pb.DColorSingleOverResp{Integral: info.Integral})
return
}

View File

@ -0,0 +1,132 @@
package caninerabbit
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"sync"
)
const (
game_gcolorgetfraction = "game_gcolorgetfraction.json"
game_gcolorreward = "game_gcolorreward.json"
game_gcolorttmedecay = "game_gcolorttmedecay.json"
)
type configureComp struct {
modules.MCompConfigure
module *CanineRabbit
lock sync.RWMutex
repeatMap map[int32][]*cfg.GameGColorGetfractionData
norepeatMap map[int32][]*cfg.GameGColorGetfractionData
}
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompConfigure.Init(service, module, comp, options)
this.module = module.(*CanineRabbit)
this.repeatMap = make(map[int32][]*cfg.GameGColorGetfractionData)
err = this.LoadMultiConfigure(map[string]interface{}{
game_gcolorreward: cfg.NewGameGColorReward,
game_gcolorttmedecay: cfg.NewGameGColortTmedecay,
})
configure.RegisterConfigure(game_gcolorgetfraction, cfg.NewGameGColorGetfraction, this.updateconfigure)
return
}
// 更新任务配置表
func (this *configureComp) updateconfigure() {
var (
v interface{}
conf *cfg.GameGColorGetfraction
ok bool
err error
)
if v, err = this.GetConfigure(game_gcolorgetfraction); err != nil {
return
}
if conf, ok = v.(*cfg.GameGColorGetfraction); !ok {
this.module.Error("日常任务配置异常!")
return
}
repeatMap := map[int32][]*cfg.GameGColorGetfractionData{}
norepeatMap := map[int32][]*cfg.GameGColorGetfractionData{}
for _, v := range conf.GetDataList() {
if v.Repeat == 1 {
if _, ok = repeatMap[v.Difficulty]; !ok {
repeatMap[v.Difficulty] = make([]*cfg.GameGColorGetfractionData, 0)
}
repeatMap[v.Difficulty] = append(repeatMap[v.Difficulty], v)
} else {
if _, ok = norepeatMap[v.Difficulty]; !ok {
norepeatMap[v.Difficulty] = make([]*cfg.GameGColorGetfractionData, 0)
}
norepeatMap[v.Difficulty] = append(norepeatMap[v.Difficulty], v)
}
}
this.lock.Lock()
this.repeatMap = repeatMap
this.norepeatMap = norepeatMap
this.lock.Unlock()
}
func (this *configureComp) getGameGColorGetfractionData(dif int32, repeat bool, index int) (conf *cfg.GameGColorGetfractionData, err error) {
var (
confs map[int32][]*cfg.GameGColorGetfractionData
ok bool
)
if repeat {
confs = this.repeatMap
} else {
confs = this.norepeatMap
}
if _, ok = confs[dif]; ok {
if len(confs[dif]) > index {
conf = confs[dif][index]
return
}
}
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_gcolorgetfraction, fmt.Sprintf("dif:%d repeat:%v index:%d", dif, repeat, index))
return
}
// 获取伤害对应的评分组
func (this *configureComp) getGameGColortTmedecayData(time int32) (conf *cfg.GameGColortTmedecayData, err error) {
var (
v interface{}
)
if v, err = this.GetConfigure(game_gcolorttmedecay); err != nil {
return
} else {
for _, v := range v.(*cfg.GameGColortTmedecay).GetDataList() {
if (time >= v.Min || v.Min == -1) && (time <= v.Max || v.Max == -1) {
conf = v
return
}
}
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_gcolorttmedecay, time)
this.module.Errorf("err:%v", err)
}
return
}
// 获取奖励列表
func (this *configureComp) getGameGColorRewardData(id int32) (conf *cfg.GameGColorRewardData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_gcolorreward); err != nil {
return
}
if conf, ok = v.(*cfg.GameGColorReward).GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_gcolorreward, id)
this.module.Errorln(err)
return
}
return
}

View File

@ -0,0 +1,8 @@
package caninerabbit
import "go_dreamfactory/pb"
type GameRules struct {
Difficulty pb.DBDColorDifficulty `json:"Difficulty"`
Repeat bool `json:"Repeat"`
}

View File

@ -0,0 +1,45 @@
package caninerabbit
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
)
type modelComp struct {
modules.MCompModel
module *CanineRabbit
}
func (this *modelComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompModel.Init(service, module, comp, options)
this.TableName = comm.TablekCanineRabbit
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
})
return
}
// 获取用户全部的埋点数据
func (this *modelComp) getModel(uid string) (info *pb.DBCanineRabbit, err error) {
info = &pb.DBCanineRabbit{}
if err = this.Get(uid, info); err != nil && err != mgo.MongodbNil {
this.module.Errorln(err)
return
}
if err == mgo.MongodbNil {
info = &pb.DBCanineRabbit{
Id: primitive.NewObjectID().Hex(),
Uid: uid,
Integral: 0,
}
err = this.Add(uid, info)
}
return
}

View File

@ -0,0 +1,103 @@
package caninerabbit
import (
"encoding/json"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson/primitive"
)
func NewModule() core.IModule {
m := new(CanineRabbit)
return m
}
/*
模块名称:猜颜色
*/
type CanineRabbit struct {
modules.ModuleBase
service comm.IService
api *apiComp
configure *configureComp
model *modelComp
rooms *roomsComp
gameInvite comm.IGameInvite
}
// 模块名
func (this *CanineRabbit) GetType() core.M_Modules {
return comm.ModuleCanineRabbit
}
// 模块初始化接口 注册用户创建角色事件
func (this *CanineRabbit) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options)
this.service = service.(comm.IService)
return
}
func (this *CanineRabbit) Start() (err error) {
if err = this.ModuleBase.Start(); err != nil {
return
}
var module core.IModule
if module, err = this.service.GetModule(comm.ModuleGameInvite); err != nil {
return
}
this.gameInvite = module.(comm.IGameInvite)
return
}
func (this *CanineRabbit) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
this.model = this.RegisterComp(new(modelComp)).(*modelComp)
this.rooms = this.RegisterComp(new(roomsComp)).(*roomsComp)
}
func (this *CanineRabbit) CreateRoom(sessions []comm.IUserSession, rulesStr string) (roomid string, err error) {
var (
rules *GameRules = &GameRules{}
red *pb.DBUser
blue *pb.DBUser
room *Room
)
if err = json.Unmarshal([]byte(rulesStr), rules); err != nil {
this.Error("解析规则json", log.Field{Key: "err", Value: err.Error()})
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
}
roomid = primitive.NewObjectID().Hex()
if room, err = this.rooms.newRoom(&pb.DBCanineRabbitRoom{
Rid: roomid,
Red: &pb.DBCanineRabbitRoomPlayer{
Info: comm.GetUserBaseInfo(red),
},
Blue: &pb.DBCanineRabbitRoomPlayer{
Info: comm.GetUserBaseInfo(blue),
},
}, sessions); err != nil {
this.Error("创建房间错误", log.Field{Key: "err", Value: err.Error()})
return
}
go room.GameStart()
return
}

View File

@ -0,0 +1,64 @@
package caninerabbit
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"time"
"google.golang.org/protobuf/proto"
)
type Room struct {
module *CanineRabbit
data *pb.DBCanineRabbitRoom
sessions []comm.IUserSession
starttime time.Time
currside int32
currindex int32
}
func (this *Room) GameStart() (err error) {
this.starttime = configure.Now()
if err = this.Broadcast("gameready", &pb.CanineRabbitGameReadyPush{
ServicePath: fmt.Sprintf("%s/%s", this.module.service.GetType(), this.module.service.GetId()),
Room: this.data,
Countdown: 60,
}); err != nil {
this.module.Errorln(err)
}
return
}
func (this *Room) PlayerLoadEnd(uid string) (err error) {
if uid == this.data.Red.Info.Uid {
this.data.Red.Ready = true
} else {
this.data.Blue.Ready = true
}
if this.data.Red.Ready && this.data.Blue.Ready { //两个人都准备了
this.currside = 1
if err = this.Broadcast("gamestart", &pb.DColorGameStartPush{
Roomid: this.data.Rid,
Side: 1,
}); err != nil {
this.module.Errorln(err)
}
}
return
}
//玩家操作
func (this *Room) PlayerHandle(uid string, handle *pb.CanineRabbitHandleReq) (err error) {
return
}
func (this *Room) Broadcast(stype string, msg proto.Message) (err error) {
if err = this.module.SendMsgToSession(string(this.module.GetType()), stype, msg, this.sessions...); err != nil {
this.module.Errorln(err)
}
return
}

View File

@ -0,0 +1,65 @@
package caninerabbit
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/pb"
"sync"
)
type roomsComp struct {
cbase.ModuleCompBase
module *CanineRabbit
lock sync.RWMutex
rooms map[string]*Room
}
func (this *roomsComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.ModuleCompBase.Init(service, module, comp, options)
this.module = module.(*CanineRabbit)
this.rooms = make(map[string]*Room)
return
}
func (this *roomsComp) queryRoom(rid string) (room *Room, err error) {
var (
ok bool
)
this.lock.Lock()
room, ok = this.rooms[rid]
this.lock.Unlock()
if !ok {
err = fmt.Errorf("no found room:%s", rid)
return
}
return
}
func (this *roomsComp) newRoom(data *pb.DBCanineRabbitRoom, session []comm.IUserSession) (room *Room, err error) {
room = &Room{
module: this.module,
data: data,
sessions: session,
}
this.lock.Lock()
this.rooms[data.Rid] = room
this.lock.Unlock()
return
}
func (this *roomsComp) removeRoom(rid string) {
var (
ok bool
room *Room
)
this.lock.Lock()
room, ok = this.rooms[rid]
delete(this.rooms, rid)
this.lock.Unlock()
if ok {
go this.module.gameInvite.GameInviteEnd(3, room.data.Red.Info.Uid)
}
}

View File

@ -3,6 +3,8 @@ package dcolor
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
)
func (this *apiComp) InfoCheck(session comm.IUserSession, req *pb.DColorInfoReq) (errdata *pb.ErrorData) {
@ -24,7 +26,16 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.DColorInfoReq) (err
}
return
}
if !utils.IsSameWeek(info.Weektime) {
info.Integral = 0
info.Weekaward = make(map[int32]bool)
info.Weektime = configure.Now().Unix()
this.module.model.Change(session.GetUserId(), map[string]interface{}{
"integral": info.Integral,
"weekaward": info.Weekaward,
"weektime": info.Weektime,
})
}
session.SendMsg(string(this.module.GetType()), "info", &pb.DColorInfoResp{Info: info})
return
}

View File

@ -19,7 +19,7 @@ type modelComp struct {
func (this *modelComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompModel.Init(service, module, comp, options)
this.TableName = comm.TablekfPushGiftbag
this.TableName = comm.TableDcolor
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
})

View File

@ -97,6 +97,16 @@ func (this *apiComp) Accept(session comm.IUserSession, req *pb.GameInviteAcceptR
sessions = append(sessions, redsession)
}
switch req.Gtype {
case 2:
if roomid, err = this.module.caninerabbit.CreateRoom(sessions, rules); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
break
case 3:
if roomid, err = this.module.dcolor.CreateRoom(sessions, rules); err != nil {
errdata = &pb.ErrorData{

View File

@ -12,6 +12,7 @@ type GameInvite struct {
api *apiComp
model *modelComp
dcolor comm.IDColor
caninerabbit comm.ICanineRabbit
}
func NewModule() core.IModule {
@ -44,6 +45,10 @@ func (this *GameInvite) Start() (err error) {
return
}
this.dcolor = module.(comm.IDColor)
if module, err = this.service.GetModule(comm.ModuleCanineRabbit); err != nil {
return
}
this.caninerabbit = module.(comm.ICanineRabbit)
return
}
func (this *GameInvite) GameInviteEnd(gtype int32, uid string) {

503
pb/caninerabbit_db.pb.go Normal file
View File

@ -0,0 +1,503 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.20.0
// source: caninerabbit/caninerabbit_db.proto
package pb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
//切磋请求记录
type DBCanineRabbit struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"`
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"`
Integral int32 `protobuf:"varint,3,opt,name=integral,proto3" json:"integral"`
Award map[int32]bool `protobuf:"bytes,4,rep,name=award,proto3" json:"award" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
}
func (x *DBCanineRabbit) Reset() {
*x = DBCanineRabbit{}
if protoimpl.UnsafeEnabled {
mi := &file_caninerabbit_caninerabbit_db_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DBCanineRabbit) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DBCanineRabbit) ProtoMessage() {}
func (x *DBCanineRabbit) ProtoReflect() protoreflect.Message {
mi := &file_caninerabbit_caninerabbit_db_proto_msgTypes[0]
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 DBCanineRabbit.ProtoReflect.Descriptor instead.
func (*DBCanineRabbit) Descriptor() ([]byte, []int) {
return file_caninerabbit_caninerabbit_db_proto_rawDescGZIP(), []int{0}
}
func (x *DBCanineRabbit) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *DBCanineRabbit) GetUid() string {
if x != nil {
return x.Uid
}
return ""
}
func (x *DBCanineRabbit) GetIntegral() int32 {
if x != nil {
return x.Integral
}
return 0
}
func (x *DBCanineRabbit) GetAward() map[int32]bool {
if x != nil {
return x.Award
}
return nil
}
type DBCanineRabbitChess struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"`
Stype int32 `protobuf:"varint,2,opt,name=stype,proto3" json:"stype"` //0兔子 1猎犬
X int32 `protobuf:"varint,3,opt,name=x,proto3" json:"x"`
Y int32 `protobuf:"varint,4,opt,name=y,proto3" json:"y"`
}
func (x *DBCanineRabbitChess) Reset() {
*x = DBCanineRabbitChess{}
if protoimpl.UnsafeEnabled {
mi := &file_caninerabbit_caninerabbit_db_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DBCanineRabbitChess) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DBCanineRabbitChess) ProtoMessage() {}
func (x *DBCanineRabbitChess) ProtoReflect() protoreflect.Message {
mi := &file_caninerabbit_caninerabbit_db_proto_msgTypes[1]
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 DBCanineRabbitChess.ProtoReflect.Descriptor instead.
func (*DBCanineRabbitChess) Descriptor() ([]byte, []int) {
return file_caninerabbit_caninerabbit_db_proto_rawDescGZIP(), []int{1}
}
func (x *DBCanineRabbitChess) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *DBCanineRabbitChess) GetStype() int32 {
if x != nil {
return x.Stype
}
return 0
}
func (x *DBCanineRabbitChess) GetX() int32 {
if x != nil {
return x.X
}
return 0
}
func (x *DBCanineRabbitChess) GetY() int32 {
if x != nil {
return x.Y
}
return 0
}
type DBCanineRabbitRoomPlayer struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Info *BaseUserInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info"` //发起者信息
Isai bool `protobuf:"varint,2,opt,name=isai,proto3" json:"isai"`
Ready bool `protobuf:"varint,3,opt,name=ready,proto3" json:"ready"`
Score int32 `protobuf:"varint,4,opt,name=score,proto3" json:"score"`
Integral int32 `protobuf:"varint,5,opt,name=integral,proto3" json:"integral"`
Maxintegral int32 `protobuf:"varint,6,opt,name=maxintegral,proto3" json:"maxintegral"`
}
func (x *DBCanineRabbitRoomPlayer) Reset() {
*x = DBCanineRabbitRoomPlayer{}
if protoimpl.UnsafeEnabled {
mi := &file_caninerabbit_caninerabbit_db_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DBCanineRabbitRoomPlayer) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DBCanineRabbitRoomPlayer) ProtoMessage() {}
func (x *DBCanineRabbitRoomPlayer) ProtoReflect() protoreflect.Message {
mi := &file_caninerabbit_caninerabbit_db_proto_msgTypes[2]
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 DBCanineRabbitRoomPlayer.ProtoReflect.Descriptor instead.
func (*DBCanineRabbitRoomPlayer) Descriptor() ([]byte, []int) {
return file_caninerabbit_caninerabbit_db_proto_rawDescGZIP(), []int{2}
}
func (x *DBCanineRabbitRoomPlayer) GetInfo() *BaseUserInfo {
if x != nil {
return x.Info
}
return nil
}
func (x *DBCanineRabbitRoomPlayer) GetIsai() bool {
if x != nil {
return x.Isai
}
return false
}
func (x *DBCanineRabbitRoomPlayer) GetReady() bool {
if x != nil {
return x.Ready
}
return false
}
func (x *DBCanineRabbitRoomPlayer) GetScore() int32 {
if x != nil {
return x.Score
}
return 0
}
func (x *DBCanineRabbitRoomPlayer) GetIntegral() int32 {
if x != nil {
return x.Integral
}
return 0
}
func (x *DBCanineRabbitRoomPlayer) GetMaxintegral() int32 {
if x != nil {
return x.Maxintegral
}
return 0
}
//犬兔大赛 房间
type DBCanineRabbitRoom struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Rid string `protobuf:"bytes,1,opt,name=rid,proto3" json:"rid"`
Randomposit bool `protobuf:"varint,2,opt,name=randomposit,proto3" json:"randomposit"` //随机位置
Headstart int32 `protobuf:"varint,3,opt,name=headstart,proto3" json:"headstart"` //先手 0 兔子 1 猎犬
Red *DBCanineRabbitRoomPlayer `protobuf:"bytes,5,opt,name=red,proto3" json:"red"`
Blue *DBCanineRabbitRoomPlayer `protobuf:"bytes,6,opt,name=blue,proto3" json:"blue"`
Chess []*DBCanineRabbitChess `protobuf:"bytes,7,rep,name=chess,proto3" json:"chess"` //棋子
}
func (x *DBCanineRabbitRoom) Reset() {
*x = DBCanineRabbitRoom{}
if protoimpl.UnsafeEnabled {
mi := &file_caninerabbit_caninerabbit_db_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DBCanineRabbitRoom) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DBCanineRabbitRoom) ProtoMessage() {}
func (x *DBCanineRabbitRoom) ProtoReflect() protoreflect.Message {
mi := &file_caninerabbit_caninerabbit_db_proto_msgTypes[3]
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 DBCanineRabbitRoom.ProtoReflect.Descriptor instead.
func (*DBCanineRabbitRoom) Descriptor() ([]byte, []int) {
return file_caninerabbit_caninerabbit_db_proto_rawDescGZIP(), []int{3}
}
func (x *DBCanineRabbitRoom) GetRid() string {
if x != nil {
return x.Rid
}
return ""
}
func (x *DBCanineRabbitRoom) GetRandomposit() bool {
if x != nil {
return x.Randomposit
}
return false
}
func (x *DBCanineRabbitRoom) GetHeadstart() int32 {
if x != nil {
return x.Headstart
}
return 0
}
func (x *DBCanineRabbitRoom) GetRed() *DBCanineRabbitRoomPlayer {
if x != nil {
return x.Red
}
return nil
}
func (x *DBCanineRabbitRoom) GetBlue() *DBCanineRabbitRoomPlayer {
if x != nil {
return x.Blue
}
return nil
}
func (x *DBCanineRabbitRoom) GetChess() []*DBCanineRabbitChess {
if x != nil {
return x.Chess
}
return nil
}
var File_caninerabbit_caninerabbit_db_proto protoreflect.FileDescriptor
var file_caninerabbit_caninerabbit_db_proto_rawDesc = []byte{
0x0a, 0x22, 0x63, 0x61, 0x6e, 0x69, 0x6e, 0x65, 0x72, 0x61, 0x62, 0x62, 0x69, 0x74, 0x2f, 0x63,
0x61, 0x6e, 0x69, 0x6e, 0x65, 0x72, 0x61, 0x62, 0x62, 0x69, 0x74, 0x5f, 0x64, 0x62, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x22, 0xba, 0x01, 0x0a, 0x0e, 0x44, 0x42, 0x43, 0x61, 0x6e, 0x69, 0x6e, 0x65, 0x52, 0x61, 0x62,
0x62, 0x69, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61,
0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61,
0x6c, 0x12, 0x30, 0x0a, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x1a, 0x2e, 0x44, 0x42, 0x43, 0x61, 0x6e, 0x69, 0x6e, 0x65, 0x52, 0x61, 0x62, 0x62, 0x69,
0x74, 0x2e, 0x41, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x61, 0x77,
0x61, 0x72, 0x64, 0x1a, 0x38, 0x0a, 0x0a, 0x41, 0x77, 0x61, 0x72, 0x64, 0x45, 0x6e, 0x74, 0x72,
0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03,
0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01,
0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x57, 0x0a,
0x13, 0x44, 0x42, 0x43, 0x61, 0x6e, 0x69, 0x6e, 0x65, 0x52, 0x61, 0x62, 0x62, 0x69, 0x74, 0x43,
0x68, 0x65, 0x73, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18,
0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x04, 0x20,
0x01, 0x28, 0x05, 0x52, 0x01, 0x79, 0x22, 0xbb, 0x01, 0x0a, 0x18, 0x44, 0x42, 0x43, 0x61, 0x6e,
0x69, 0x6e, 0x65, 0x52, 0x61, 0x62, 0x62, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x6d, 0x50, 0x6c, 0x61,
0x79, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x0d, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f,
0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x61, 0x69, 0x18, 0x02,
0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x61, 0x69, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65,
0x61, 0x64, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79,
0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52,
0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72,
0x61, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72,
0x61, 0x6c, 0x12, 0x20, 0x0a, 0x0b, 0x6d, 0x61, 0x78, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61,
0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x6d, 0x61, 0x78, 0x69, 0x6e, 0x74, 0x65,
0x67, 0x72, 0x61, 0x6c, 0x22, 0xee, 0x01, 0x0a, 0x12, 0x44, 0x42, 0x43, 0x61, 0x6e, 0x69, 0x6e,
0x65, 0x52, 0x61, 0x62, 0x62, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x72,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x72, 0x69, 0x64, 0x12, 0x20, 0x0a,
0x0b, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01,
0x28, 0x08, 0x52, 0x0b, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x12,
0x1c, 0x0a, 0x09, 0x68, 0x65, 0x61, 0x64, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01,
0x28, 0x05, 0x52, 0x09, 0x68, 0x65, 0x61, 0x64, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x2b, 0x0a,
0x03, 0x72, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x44, 0x42, 0x43,
0x61, 0x6e, 0x69, 0x6e, 0x65, 0x52, 0x61, 0x62, 0x62, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x6d, 0x50,
0x6c, 0x61, 0x79, 0x65, 0x72, 0x52, 0x03, 0x72, 0x65, 0x64, 0x12, 0x2d, 0x0a, 0x04, 0x62, 0x6c,
0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x44, 0x42, 0x43, 0x61, 0x6e,
0x69, 0x6e, 0x65, 0x52, 0x61, 0x62, 0x62, 0x69, 0x74, 0x52, 0x6f, 0x6f, 0x6d, 0x50, 0x6c, 0x61,
0x79, 0x65, 0x72, 0x52, 0x04, 0x62, 0x6c, 0x75, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x63, 0x68, 0x65,
0x73, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x44, 0x42, 0x43, 0x61, 0x6e,
0x69, 0x6e, 0x65, 0x52, 0x61, 0x62, 0x62, 0x69, 0x74, 0x43, 0x68, 0x65, 0x73, 0x73, 0x52, 0x05,
0x63, 0x68, 0x65, 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_caninerabbit_caninerabbit_db_proto_rawDescOnce sync.Once
file_caninerabbit_caninerabbit_db_proto_rawDescData = file_caninerabbit_caninerabbit_db_proto_rawDesc
)
func file_caninerabbit_caninerabbit_db_proto_rawDescGZIP() []byte {
file_caninerabbit_caninerabbit_db_proto_rawDescOnce.Do(func() {
file_caninerabbit_caninerabbit_db_proto_rawDescData = protoimpl.X.CompressGZIP(file_caninerabbit_caninerabbit_db_proto_rawDescData)
})
return file_caninerabbit_caninerabbit_db_proto_rawDescData
}
var file_caninerabbit_caninerabbit_db_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_caninerabbit_caninerabbit_db_proto_goTypes = []interface{}{
(*DBCanineRabbit)(nil), // 0: DBCanineRabbit
(*DBCanineRabbitChess)(nil), // 1: DBCanineRabbitChess
(*DBCanineRabbitRoomPlayer)(nil), // 2: DBCanineRabbitRoomPlayer
(*DBCanineRabbitRoom)(nil), // 3: DBCanineRabbitRoom
nil, // 4: DBCanineRabbit.AwardEntry
(*BaseUserInfo)(nil), // 5: BaseUserInfo
}
var file_caninerabbit_caninerabbit_db_proto_depIdxs = []int32{
4, // 0: DBCanineRabbit.award:type_name -> DBCanineRabbit.AwardEntry
5, // 1: DBCanineRabbitRoomPlayer.info:type_name -> BaseUserInfo
2, // 2: DBCanineRabbitRoom.red:type_name -> DBCanineRabbitRoomPlayer
2, // 3: DBCanineRabbitRoom.blue:type_name -> DBCanineRabbitRoomPlayer
1, // 4: DBCanineRabbitRoom.chess:type_name -> DBCanineRabbitChess
5, // [5:5] is the sub-list for method output_type
5, // [5:5] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_caninerabbit_caninerabbit_db_proto_init() }
func file_caninerabbit_caninerabbit_db_proto_init() {
if File_caninerabbit_caninerabbit_db_proto != nil {
return
}
file_comm_proto_init()
if !protoimpl.UnsafeEnabled {
file_caninerabbit_caninerabbit_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DBCanineRabbit); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_caninerabbit_caninerabbit_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DBCanineRabbitChess); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_caninerabbit_caninerabbit_db_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DBCanineRabbitRoomPlayer); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_caninerabbit_caninerabbit_db_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DBCanineRabbitRoom); 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{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_caninerabbit_caninerabbit_db_proto_rawDesc,
NumEnums: 0,
NumMessages: 5,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_caninerabbit_caninerabbit_db_proto_goTypes,
DependencyIndexes: file_caninerabbit_caninerabbit_db_proto_depIdxs,
MessageInfos: file_caninerabbit_caninerabbit_db_proto_msgTypes,
}.Build()
File_caninerabbit_caninerabbit_db_proto = out.File
file_caninerabbit_caninerabbit_db_proto_rawDesc = nil
file_caninerabbit_caninerabbit_db_proto_goTypes = nil
file_caninerabbit_caninerabbit_db_proto_depIdxs = nil
}

1088
pb/caninerabbit_msg.pb.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ import (
"go_dreamfactory/modules/battle"
"go_dreamfactory/modules/battlerecord"
"go_dreamfactory/modules/buried"
"go_dreamfactory/modules/caninerabbit"
"go_dreamfactory/modules/capturesheep"
"go_dreamfactory/modules/caravan"
"go_dreamfactory/modules/chat"
@ -178,6 +179,7 @@ func main() {
maincity.NewModule(),
treasuremap.NewModule(),
gameinvite.NewModule(),
caninerabbit.NewModule(),
)
}