上传犬兔游戏调试代码
This commit is contained in:
parent
3cc0d746f9
commit
dc1fdefcda
@ -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.TableDailytask
|
||||
this.TableName = comm.TableAchieve
|
||||
this.module = module.(*Achieve)
|
||||
this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
|
||||
Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
|
||||
|
@ -43,6 +43,6 @@ func (this *apiComp) Handle(session comm.IUserSession, req *pb.CanineRabbitHandl
|
||||
}
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "handle", &pb.DColorHandleResp{})
|
||||
session.SendMsg(string(this.module.GetType()), "handle", &pb.CanineRabbitHandleResp{})
|
||||
return
|
||||
}
|
||||
|
48
modules/caninerabbit/api_loadcomplete.go
Normal file
48
modules/caninerabbit/api_loadcomplete.go
Normal 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
|
||||
}
|
@ -43,6 +43,6 @@ func (this *apiComp) Win(session comm.IUserSession, req *pb.CanineRabbitWinReq)
|
||||
}
|
||||
return
|
||||
}
|
||||
session.SendMsg(string(this.module.GetType()), "handle", &pb.DColorHandleResp{})
|
||||
session.SendMsg(string(this.module.GetType()), "win", &pb.CanineRabbitWinResp{})
|
||||
return
|
||||
}
|
||||
|
@ -125,6 +125,7 @@ func (this *CanineRabbit) CreateRoom(sessions []comm.IUserSession, rulesStr stri
|
||||
|
||||
if room, err = this.rooms.newRoom(&pb.DBCanineRabbitRoom{
|
||||
Rid: roomid,
|
||||
Rules: rules,
|
||||
Red: &pb.DBCanineRabbitRoomPlayer{
|
||||
Info: comm.GetUserBaseInfo(red),
|
||||
Ctype: redtype,
|
||||
|
@ -65,12 +65,7 @@ func (this *Room) PlayerLoadEnd(uid string) (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 == this.data.Red.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!")
|
||||
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{
|
||||
Roomid: this.data.Rid,
|
||||
Uid: uid,
|
||||
|
Loading…
Reference in New Issue
Block a user