diff --git a/modules/caninerabbit/room.go b/modules/caninerabbit/room.go index fa707faf7..3d3138fb1 100644 --- a/modules/caninerabbit/room.go +++ b/modules/caninerabbit/room.go @@ -52,10 +52,57 @@ 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 == 1 { + this.currside = 2 + } else { + this.currside = 1 + } + if err = this.Broadcast("gamehandle", &pb.CanineRabbitGameHandlePush{ + Roomid: this.data.Rid, + Uid: uid, + Chess: handle.Chess, + }); err != nil { + this.module.Errorln(err) + } return } +//玩家操作 +func (this *Room) PlayerWin(uid string, handle *pb.CanineRabbitWinReq) (err error) { + + if handle.Iswin { + if this.currside == 1 { + this.data.Red.Score = 1 + + this.module.model.Change(this.data.Red.Info.Uid, map[string]interface{}{ + "rabbitintegral": this.data.Red.Rabbitintegral, + "houndintegral": this.data.Red.Houndintegral, + }) + + } else { + this.data.Blue.Score = 1 + this.module.model.Change(this.data.Blue.Info.Uid, map[string]interface{}{ + "rabbitintegral": this.data.Red.Rabbitintegral, + "houndintegral": this.data.Red.Houndintegral, + }) + } + if err = this.Broadcast("gameover", &pb.CanineRabbitGameOverPush{ + Winside: this.currside, + RedIntegral: this.data.Red.Score, + BlueIntegral: this.data.Blue.Score, + }); err != nil { + this.module.Errorln(err) + } + } + + 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)