三消优化

This commit is contained in:
meixiongfeng 2023-12-20 19:13:21 +08:00
parent 3f06003852
commit 97b1328fa4
9 changed files with 71 additions and 81 deletions

View File

@ -210,8 +210,6 @@ type (
ChangeUserMoonLv(session IUserSession, lv int32) (errdata *pb.ErrorData)
//GM创号
GMCreatePlayer(session IUserSession, req *pb.UserCreateReq) (errdata *pb.ErrorData)
// 清除玩家赛季积分 ---需要清除
CleanUserConsumeexp(session IUserSession) (err error)
}
//武器模块
IEquipment interface {

View File

@ -66,9 +66,9 @@ func (this *apiComp) CreateRoom(session comm.IUserSession, req *pb.EntertainCrea
return
}
p1 := &pb.PlayerData{
Userinfo: comm.GetUserBaseInfo(user),
Cardid: req.Idcard,
Consumeexp: user.Consumeexp,
Userinfo: comm.GetUserBaseInfo(user),
Cardid: req.Idcard,
//Consumeexp: user.Consumeexp,
}
if room, err = this.module.gameMgr.CreateMasterRoom(p1); err != nil {
errdata = &pb.ErrorData{

View File

@ -33,10 +33,10 @@ func (this *apiComp) Reward(session comm.IUserSession, req *pb.EntertainRewardRe
return
}
user, err := this.module.ModuleUser.GetUser(session.GetUserId())
//user, err := this.module.ModuleUser.GetUser(session.GetUserId())
if err == nil {
if conf, err := this.module.configure.GetGameConsumeintegralReward(req.Key); err == nil {
if user.Consumeexp < conf.Key {
if list.Consumeexp < conf.Key {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_UserRepeadReward,
Title: pb.ErrorCode_UserRepeadReward.ToString(),

View File

@ -64,9 +64,9 @@ func (this *apiComp) JoinRoom(session comm.IUserSession, req *pb.EntertainJoinRo
return
}
p := &pb.PlayerData{
Userinfo: comm.GetUserBaseInfo(user),
Cardid: req.Idcard,
Consumeexp: user.Consumeexp,
Userinfo: comm.GetUserBaseInfo(user),
Cardid: req.Idcard,
//Consumeexp: user.Consumeexp,
}
if _, err = this.module.gameMgr.JoinMasterRoom(req.Roomid, p); err != nil {

View File

@ -85,7 +85,7 @@ func (this *apiComp) Match(session comm.IUserSession, req *pb.EntertainMatchReq)
this.module.match.MatchReq(&pb.DBXXLMatch{
Userinfo: comm.GetUserBaseInfo(user),
Cardid: req.Idcard,
Consumeexp: user.Consumeexp,
Consumeexp: list.Consumeexp,
Skill: mySkill,
})

View File

@ -583,18 +583,20 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) {
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
}
if conf, err := this.module.configure.GetGameConsumeintegral(list.Consumeexp); err == nil {
for _, v := range conf.Rewards {
if v.A == "attr" && v.T == "consumeexp" {
list.Consumeexp += v.N
update["consumeexp"] = list.Consumeexp
winner.Consumeexp = list.Consumeexp
} else {
res = append(res, v)
}
this.szSession[winindex].Push()
}
if errdata, atno = this.module.DispenseAtno(this.szSession[winindex], res, true); errdata != nil {
return
}
this.szSession[winindex].Push()
}
// 修改连胜
@ -609,7 +611,6 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) {
}
list.Box = append(list.Box, box)
update["box"] = list.Box
}
}
}
@ -617,9 +618,8 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) {
}
if lostPlayer.Userinfo.Uid != "999" {
if conf, err := this.module.configure.GetGameConsumeHero(lostPlayer.Cardid); err == nil {
update := map[string]interface{}{}
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
@ -631,6 +631,18 @@ func (this *Room) GameOver(winner *pb.PlayerData) (errdata *pb.ErrorData) {
update["card"] = list.Card
}
}
if conf, err := this.module.configure.GetGameConsumeintegral(list.Consumeexp); err == nil { // 战败扣除积分
for _, v := range conf.Rewards {
if v.A == "attr" && v.T == "consumeexp" {
list.Consumeexp -= v.N
if list.Consumeexp <= 0 {
list.Consumeexp = 0
}
lostPlayer.Consumeexp = list.Consumeexp
update["consumeexp"] = list.Consumeexp
}
}
}
if len(update) > 0 {
this.module.model.modifyEntertainmList(lostPlayer.Userinfo.Uid, update)
}

View File

@ -173,14 +173,7 @@ func (this *MapData) CheckSpecialElemChange(oldId, newId int32, color int32) (bS
}
var energy int32
var curScore int32
for id := range x {
if this.Plat[id].Color == color {
energy++
}
curScore += this.Plat[id].Score
this.Plat[id] = &pb.GirdeData{}
this.operElem = append(this.operElem, int32(id))
}
for id := range x {
if this.Plat[id].Color == color {
energy++
@ -190,7 +183,6 @@ func (this *MapData) CheckSpecialElemChange(oldId, newId int32, color int32) (bS
this.operElem = append(this.operElem, int32(id))
}
if this.DropGirde() {
szMap = append(szMap, &pb.MapData{
Data: this.GetPalatData(),
CurSocre: curScore,
@ -1283,17 +1275,41 @@ func (this *MapData) SpecialElem(id int, s int32) (x map[int]struct{}) {
return
}
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(),
CurSocre: 0,
CurEnergy: 0,
})
var energy int32
var curScore int32
if this.Plat[curid].Special == 0 {
if this.Plat[curid].Color == color {
energy++
}
curScore = this.Plat[curid].Score
this.Plat[curid] = &pb.GirdeData{}
if this.DropGirde() {
szMap = append(szMap, &pb.MapData{
Data: this.GetPalatData(),
CurSocre: curScore,
CurEnergy: 0,
})
}
sz, _ := this.CheckMap(color, false)
szMap = append(szMap, sz...)
} else {
x := this.SpecialElem(int(curid), this.Plat[curid].Special)
for id := range x {
if this.Plat[id].Color == color {
energy++
}
curScore += this.Plat[id].Score
this.Plat[id] = &pb.GirdeData{}
this.operElem = append(this.operElem, int32(id))
}
if this.DropGirde() {
szMap = append(szMap, &pb.MapData{
Data: this.GetPalatData(),
CurSocre: curScore,
CurEnergy: energy,
})
}
}
sz, _ := this.CheckMap(color, false)
szMap = append(szMap, sz...)
return
}

View File

@ -353,39 +353,6 @@ func (this *ModelUser) CleanUserMerchantmoney(session comm.IUserSession) (err er
return
}
func (this *ModelUser) CleanUserConsumeexp(session comm.IUserSession) (err error) {
var (
model *db.DBModel
update map[string]interface{}
uid string
)
uid = session.GetUserId()
user := &pb.DBUser{}
update = make(map[string]interface{}, 0)
update["consumeexp"] = 0
if db.IsCross() {
if model, err = this.module.GetDBModelByUid(uid, this.TableName); err == nil {
if err := this.Get(uid, user); err == nil {
err = model.Change(uid, update)
} else {
this.module.Errorf("err:%v", err)
}
} else {
this.module.Errorln(err)
}
} else {
if err := this.Get(uid, user); err == nil {
err = this.Change(uid, update)
} else {
this.module.Errorf("err:%v", err)
}
}
return
}
///资源自动恢复
func (this *ModelUser) ResAutoReplies(session comm.IUserSession, resreplies map[int32]int64) {
var (

View File

@ -527,8 +527,8 @@ func (this *User) change(session comm.IUserSession, attrs map[string]int32) (atn
Integral: user.Integral,
Profit: user.Profit,
Deposit: user.Deposit,
Consumeexp: user.Consumeexp,
Consumemoney: user.Consumemoney,
Consumemoney: user.Consumemoney,
}
atno = make([]*pb.UserAtno, 0, len(attrs))
for attr, add := range attrs {
@ -1517,6 +1517,3 @@ func (this *User) GMCreatePlayer(session comm.IUserSession, req *pb.UserCreateRe
errdata = this.api.Create(session, req)
return
}
func (this *User) CleanUserConsumeexp(session comm.IUserSession) (err error) {
return this.modelUser.CleanUserConsumeexp(session)
}