diff --git a/comm/imodule.go b/comm/imodule.go index fcc10aec0..d25bf80e4 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -210,7 +210,7 @@ type ( ChangeUserMoonLv(session IUserSession, lv int32) (errdata *pb.ErrorData) //GM创号 GMCreatePlayer(session IUserSession, req *pb.UserCreateReq) (errdata *pb.ErrorData) - // 清除玩家赛季积分 + // 清除玩家赛季积分 ---需要清除 CleanUserConsumeexp(session IUserSession) (err error) } //武器模块 diff --git a/modules/entertainment/match.go b/modules/entertainment/match.go index da2a698c8..9d68a780b 100644 --- a/modules/entertainment/match.go +++ b/modules/entertainment/match.go @@ -110,6 +110,7 @@ func (this *matchComp) MatchNotic(players map[string]interface{}) (err error) { } } } + go func() { this.module.gameMgr.CreateRoomByType(p1, p2, -1) }() diff --git a/modules/entertainment/room.go b/modules/entertainment/room.go index 44b55f1d6..ed27b0acf 100644 --- a/modules/entertainment/room.go +++ b/modules/entertainment/room.go @@ -253,9 +253,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr if errdata = this.UserCardSkill(curPlayer, color, req.Itype, req.Curid); errdata != nil { return } - this.module.model.modifyEntertainmList(session.GetUserId(), map[string]interface{}{ - "skill": curPlayer.Skill, - }) + return } if req.Itype == 0 && req.Curid == 0 && req.Targetid == 0 { @@ -558,95 +556,85 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) { var ( atno []*pb.UserAtno winindex int32 - bReward bool res []*cfg.Gameatn lostPlayer *pb.PlayerData // 输的玩家 box *pb.BoxData // 是否可以获得宝箱奖励 ) - bReward = true if winner == nil { if this.player1.Score < this.player2.Score { winner = this.player2 winindex = 1 - if this.RoomType == 2 { // 赢家是AI 的话不发奖 - bReward = false - } } else { winner = this.player1 } } - - if bReward { // 发奖 - if user, err := this.module.ModuleUser.GetUser(winner.Userinfo.Uid); err == nil { - if conf, err := this.module.configure.GetGameConsumeintegral(user.Consumeexp); err == nil { - res = append(res, conf.Rewards...) - for _, v := range res { - if v.A == "attr" && v.T == "consumeexp" { - if winner.Userinfo.Uid == this.player1.Userinfo.Uid { - this.player1.Consumeexp += v.N - } else { - this.player2.Consumeexp += v.N - } - } - } - if errdata, atno = this.module.DispenseAtno(this.szSession[winindex], res, true); errdata != nil { - return - } - go this.module.WriteUserLog(winner.Userinfo.Uid, "gameover", comm.GMResAddType, "xxlGameReward", atno) - - this.szSession[winindex].Push() - } - } - } - - // 失败的一方扣除卡 if this.player1 != winner { lostPlayer = this.player1 } else { lostPlayer = this.player2 } - // 失败卡类型 - if conf, err := this.module.configure.GetGameConsumeHero(lostPlayer.Cardid); err == nil && lostPlayer.Userinfo.Uid != "999" { - - if list, err := this.module.model.getEntertainmList(lostPlayer.Userinfo.Uid); err == nil { - update := map[string]interface{}{} - if list.Liansheng != 0 { - list.Liansheng = 0 // 修改连胜 - update["liansheng"] = list.Liansheng - } - - if conf.Type != 1 { //卡片类型不为1 - if list.Card[lostPlayer.Cardid] >= 1 { //删除卡片 - list.Card[lostPlayer.Cardid] -= 1 - update["card"] = list.Card - } - } - if len(update) > 0 { - this.module.model.modifyEntertainmList(lostPlayer.Userinfo.Uid, update) - } - } - } - // 查看能不能获得箱子 if winner.Userinfo.Uid != "999" { - if list, err := this.module.model.getEntertainmList(winner.Userinfo.Uid); err == nil { - update := map[string]interface{}{} - // 修改连胜 - list.Liansheng += 1 - update["liansheng"] = list.Liansheng - if len(list.Box) < 3 { // 可以获得一个宝箱 - if c, err := this.module.configure.GetGameRandomConsumeBoxConf(); err == nil { - if c.Color != 0 { - box = &pb.BoxData{ - Boxid: c.Boxid, - Opentime: int64(c.Cd) + configure.Now().Unix(), - } - list.Box = append(list.Box, box) - update["box"] = list.Box - + var ( + list *pb.DBXXLData + err error + update map[string]interface{} + ) + update = make(map[string]interface{}) + if list, err = this.module.model.getEntertainmList(winner.Userinfo.Uid); err == nil { + return + } + if user, err := this.module.ModuleUser.GetUser(winner.Userinfo.Uid); err == nil { + if conf, err := this.module.configure.GetGameConsumeintegral(user.Consumeexp); err == nil { + res = append(res, conf.Rewards...) + for _, v := range res { + if v.A == "attr" && v.T == "consumeexp" { + this.player2.Consumeexp += v.N + list.Consumeexp += v.N + update["consumeexp"] = list.Consumeexp } } + this.szSession[winindex].Push() + } + } + + // 修改连胜 + list.Liansheng += 1 + update["liansheng"] = list.Liansheng + if len(list.Box) < 3 { // 可以获得一个宝箱 + if c, err := this.module.configure.GetGameRandomConsumeBoxConf(); err == nil { + if c.Color != 0 { + box = &pb.BoxData{ + Boxid: c.Boxid, + Opentime: int64(c.Cd) + configure.Now().Unix(), + } + list.Box = append(list.Box, box) + update["box"] = list.Box + + } + } + } + this.module.model.modifyEntertainmList(winner.Userinfo.Uid, update) + } + if lostPlayer.Userinfo.Uid != "999" { + if conf, err := this.module.configure.GetGameConsumeHero(lostPlayer.Cardid); err == nil { + + if list, err := this.module.model.getEntertainmList(lostPlayer.Userinfo.Uid); err == nil { + update := map[string]interface{}{} + if list.Liansheng != 0 { + list.Liansheng = 0 // 修改连胜 + update["liansheng"] = list.Liansheng + } + + if conf.Type != 1 { //卡片类型不为1 + if list.Card[lostPlayer.Cardid] >= 1 { //删除卡片 + list.Card[lostPlayer.Cardid] -= 1 + update["card"] = list.Card + } + } + if len(update) > 0 { + this.module.model.modifyEntertainmList(lostPlayer.Userinfo.Uid, update) + } } - this.module.model.modifyEntertainmList(winner.Userinfo.Uid, update) } } @@ -953,7 +941,7 @@ func (this *Room) UserCardSkill(curPlayer *pb.PlayerData, color int32, skillid i if conf.Skilltype == 1 { // 技能类型为1 szMap = this.chessboard.HitElem(color, curid) } else if conf.Skilltype == 2 { - this.chessboard.SetIndelibilityPlat() + this.chessboard.ShuffleElem() // 初始化棋盘 szMap = append(szMap, &pb.MapData{ Data: this.chessboard.Plat, }) @@ -971,6 +959,7 @@ func (this *Room) UserCardSkill(curPlayer *pb.PlayerData, color int32, skillid i this.player2.Energy += v.CurEnergy v.CurEnergy = this.player2.Energy } + v.ChangeType = 1 } this.NexPower = this.curPower diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index cb0137288..588091053 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -1284,7 +1284,6 @@ func (this *MapData) SpecialElem(id int, s int32) (x map[int]struct{}) { } func (this *MapData) HitElem(color int32, curid int32) (szMap []*pb.MapData) { this.Plat[curid] = &pb.GirdeData{} - if this.DropGirde() { szMap = append(szMap, &pb.MapData{ Data: this.GetPalatData(), @@ -1294,5 +1293,21 @@ func (this *MapData) HitElem(color int32, curid int32) (szMap []*pb.MapData) { } sz, _ := this.CheckMap(color, false) szMap = append(szMap, sz...) + return } + +func (this *MapData) ShuffleElem() { + + for i := 0; i < Total; i++ { + n1, _ := rand.Int(rand.Reader, big.NewInt(Total)) + newId := n1.Int64() + if i != int(n1.Int64()) { + tmp := new(pb.GirdeData) + *tmp = *this.Plat[newId] + this.Plat[newId] = this.Plat[i] + this.Plat[i] = tmp + } + } + this.SetIndelibilityPlat() +} diff --git a/pb/entertain_msg.pb.go b/pb/entertain_msg.pb.go index 463570646..d9e06589c 100644 --- a/pb/entertain_msg.pb.go +++ b/pb/entertain_msg.pb.go @@ -409,7 +409,7 @@ type EntertainOperatorReq struct { unknownFields protoimpl.UnknownFields Roomid string `protobuf:"bytes,1,opt,name=roomid,proto3" json:"roomid"` // 房间id - Itype int32 `protobuf:"varint,2,opt,name=itype,proto3" json:"itype"` // 操作类型 0 默认交换元素 999 技能 + Itype int32 `protobuf:"varint,2,opt,name=itype,proto3" json:"itype"` // 操作类型 0 默认交换元素 1 卡片技能 Curid int32 `protobuf:"varint,3,opt,name=curid,proto3" json:"curid"` // 当前key Targetid int32 `protobuf:"varint,4,opt,name=targetid,proto3" json:"targetid"` // 目标key }