三消上传

This commit is contained in:
meixiongfeng 2023-12-20 17:38:19 +08:00
parent a5f8e905c7
commit 2b9c0b828e
5 changed files with 80 additions and 75 deletions

View File

@ -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)
}
//武器模块

View File

@ -110,6 +110,7 @@ func (this *matchComp) MatchNotic(players map[string]interface{}) (err error) {
}
}
}
go func() {
this.module.gameMgr.CreateRoomByType(p1, p2, -1)
}()

View File

@ -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,55 +556,67 @@ 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 winner.Userinfo.Uid != "999" {
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{}{}
@ -626,28 +636,6 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) {
}
}
}
// 查看能不能获得箱子
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
}
}
}
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

View File

@ -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()
}

View File

@ -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
}