上传犬兔游戏调试代码

This commit is contained in:
liwei1dao 2023-11-02 21:18:05 +08:00
parent 3cc0d746f9
commit dc1fdefcda
6 changed files with 60 additions and 10 deletions

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) { 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) err = this.MCompModel.Init(service, module, comp, options)
this.TableName = comm.TableDailytask this.TableName = comm.TableAchieve
this.module = module.(*Achieve) this.module = module.(*Achieve)
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},

View File

@ -43,6 +43,6 @@ func (this *apiComp) Handle(session comm.IUserSession, req *pb.CanineRabbitHandl
} }
return return
} }
session.SendMsg(string(this.module.GetType()), "handle", &pb.DColorHandleResp{}) session.SendMsg(string(this.module.GetType()), "handle", &pb.CanineRabbitHandleResp{})
return return
} }

View File

@ -0,0 +1,48 @@
package caninerabbit
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
//接受切磋
func (this *apiComp) LoadCompleteCheck(session comm.IUserSession, req *pb.CanineRabbitLoadCompleteReq) (errdata *pb.ErrorData) {
if req.Roomid == "" {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
}
return
}
func (this *apiComp) LoadComplete(session comm.IUserSession, req *pb.CanineRabbitLoadCompleteReq) (errdata *pb.ErrorData) {
var (
room *Room
err error
)
if errdata = this.LoadCompleteCheck(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.PlayerLoadEnd(session.GetUserId()); errdata != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.String(),
Message: err.Error(),
}
return
}
session.SendMsg(string(this.module.GetType()), "loadcomplete", &pb.CanineRabbitLoadCompleteResp{Roomid: req.Roomid, Issucc: true})
return
}

View File

@ -43,6 +43,6 @@ func (this *apiComp) Win(session comm.IUserSession, req *pb.CanineRabbitWinReq)
} }
return return
} }
session.SendMsg(string(this.module.GetType()), "handle", &pb.DColorHandleResp{}) session.SendMsg(string(this.module.GetType()), "win", &pb.CanineRabbitWinResp{})
return return
} }

View File

@ -125,6 +125,7 @@ func (this *CanineRabbit) CreateRoom(sessions []comm.IUserSession, rulesStr stri
if room, err = this.rooms.newRoom(&pb.DBCanineRabbitRoom{ if room, err = this.rooms.newRoom(&pb.DBCanineRabbitRoom{
Rid: roomid, Rid: roomid,
Rules: rules,
Red: &pb.DBCanineRabbitRoomPlayer{ Red: &pb.DBCanineRabbitRoomPlayer{
Info: comm.GetUserBaseInfo(red), Info: comm.GetUserBaseInfo(red),
Ctype: redtype, Ctype: redtype,

View File

@ -65,12 +65,7 @@ func (this *Room) PlayerLoadEnd(uid string) (err error) {
//玩家操作 //玩家操作
func (this *Room) PlayerHandle(uid string, handle *pb.CanineRabbitHandleReq) (err error) { func (this *Room) PlayerHandle(uid string, handle *pb.CanineRabbitHandleReq) (err error) {
for _, v := range this.data.Chess {
if v.Id == handle.Chess.Id {
v.X = handle.Chess.X
v.Y = handle.Chess.Y
}
}
if this.currside == uid { if this.currside == uid {
if this.currside == this.data.Red.Info.Uid { if this.currside == this.data.Red.Info.Uid {
this.currside = this.data.Blue.Info.Uid this.currside = this.data.Blue.Info.Uid
@ -81,6 +76,12 @@ func (this *Room) PlayerHandle(uid string, handle *pb.CanineRabbitHandleReq) (er
err = fmt.Errorf("It's not you who shoot!") err = fmt.Errorf("It's not you who shoot!")
return return
} }
for _, v := range this.data.Chess {
if v.Id == handle.Chess.Id {
v.X = handle.Chess.X
v.Y = handle.Chess.Y
}
}
if err = this.Broadcast("gamehandle", &pb.CanineRabbitGameHandlePush{ if err = this.Broadcast("gamehandle", &pb.CanineRabbitGameHandlePush{
Roomid: this.data.Rid, Roomid: this.data.Rid,
Uid: uid, Uid: uid,