package realarena import ( "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" ) // /装备 数据组件 type Room struct { Id string module *RealArena sessions []comm.IUserSession members []*pb.DBRealArenaMember state int //0 无状态 1选择英雄阶段 2禁用英雄阶段 3选择队长阶段 4战斗中 step int //阶段 handle string // 操作玩家 } func (this *Room) init() (err error) { this.PushMessage("matchsucc", &pb.RealArenaMatchSuccPush{ Race: &pb.DBRealArenaRace{ Id: this.Id, ServicePath: fmt.Sprintf("%s", this.module.service.GetId()), Red: this.members[0], Bule: this.members[1], }, }) this.handle = this.members[0].User.Uid this.step = 1 this.PushMessage("startselecthero", &pb.RealArenaStartSelectHeroPush{ Uid: this.members[0].User.Uid, Num: 2, Countdown: 10, }) return } //选择英雄 func (this *Room) selectheros(uid string, heros []string) (err error) { if uid != this.handle { err = fmt.Errorf("cant handle!") return } for _, v := range this.members { if v.User.Uid == uid { v.Heros = heros } else { this.handle = v.User.Uid } } this.PushMessage("startselecthero", &pb.RealArenaSelectHeroPush{ Uid: this.members[0].User.Uid, Heros: heros, }) this.PushMessage("startselecthero", &pb.RealArenaStartSelectHeroPush{ Uid: this.handle, Num: 2, Countdown: 10, }) return } //禁用英雄 func (this *Room) disableheros(uid string, index int32) (err error) { return } //选择队长 func (this *Room) selectleader(uid string, index int32) (err error) { return } func (this *Room) PushMessage(stype string, msg proto.Message) { this.module.SendMsgToSession(string(this.module.GetType()), stype, msg, this.sessions...) }