资源统计+优化

This commit is contained in:
meixiongfeng 2023-11-21 16:07:51 +08:00
parent e800f618c6
commit 110ac5676a
36 changed files with 120 additions and 32 deletions

View File

@ -113,6 +113,7 @@ func (this *apiComp) Do(session comm.IUserSession, req *pb.DispatchDoReq) (errda
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype186, 1))
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "DispatchDoReq", ticketAtn) // 消耗资源
})
return
}

View File

@ -100,5 +100,11 @@ func (this *apiComp) Refresh(session comm.IUserSession, req *pb.DispatchRefreshR
}
session.SendMsg(string(this.module.GetType()), "refresh", rsp)
if len(need) > 0 {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "DispatchRefreshReq", need) // 消耗资源
})
}
return
}

View File

@ -95,5 +95,9 @@ func (this *apiComp) LvItem(session comm.IUserSession, req *pb.DragonLvItemReq)
Dragons: chanegList,
})
session.SendMsg(string(this.module.GetType()), "lvitem", rsp)
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "DragonLvItemReq", curLvConf.Item) // 消耗资源
})
return
}

View File

@ -171,6 +171,7 @@ func (this *apiComp) Train(session comm.IUserSession, req *pb.DragonTrainReq) (e
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype235, dragon.Lv, utils.ToInt32(dragon.Dragonid)))
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "DragonTrainReq", atno)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "DragonTrainReq", playConf.Deplete) // 消耗资源
})
}
return

View File

@ -63,11 +63,17 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.EnchantCha
return
}
session.SendMsg(string(this.module.GetType()), EnchantChallengeOverResp, &pb.EnchantChallengeOverResp{Data: enchant})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "EnchantChallengeOverReq", cfgEnchant[0].PsMg)
})
return
}
if errdata = this.module.ConsumeRes(session, cfgEnchant[0].PsConsume, true); errdata != nil {
return
}
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "EnchantChallengeOverReq", cfgEnchant[0].PsConsume)
})
userinfo, err := this.module.ModuleUser.GetUser(session.GetUserId())
if err != nil {
errdata = &pb.ErrorData{

View File

@ -51,6 +51,9 @@ func (this *apiComp) CreateRoom(session comm.IUserSession, req *pb.EntertainCrea
if errdata = this.module.ConsumeRes(session, conf.Consume, true); errdata != nil {
return
}
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "EntertainCreateRoomReq", conf.Consume)
})
list.Card[req.Idcard] += 1
this.module.model.modifyEntertainmList(session.GetUserId(), map[string]interface{}{
"card": list.Card,

View File

@ -49,6 +49,9 @@ func (this *apiComp) JoinRoom(session comm.IUserSession, req *pb.EntertainJoinRo
if errdata = this.module.ConsumeRes(session, conf.Consume, true); errdata != nil {
return
}
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "EntertainJoinRoomReq", conf.Consume)
})
list.Card[req.Idcard] += 1
this.module.model.modifyEntertainmList(session.GetUserId(), map[string]interface{}{
"card": list.Card,

View File

@ -49,6 +49,9 @@ func (this *apiComp) Match(session comm.IUserSession, req *pb.EntertainMatchReq)
if errdata = this.module.ConsumeRes(session, conf.Consume, true); errdata != nil {
return
}
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "EntertainMatchReq", conf.Consume)
})
list.Card[req.Idcard] += 1
this.module.model.modifyEntertainmList(session.GetUserId(), map[string]interface{}{
"card": list.Card,

View File

@ -116,6 +116,8 @@ func (this *apiComp) Ench(session comm.IUserSession, req *pb.EquipmentEnchReq) (
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype94, 1))
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "EquipmentEnchReq", need)
})
return
}

View File

@ -73,5 +73,9 @@ func (this *apiComp) Forg(session comm.IUserSession, req *pb.EquipmentForgReq) (
})
}
session.SendMsg(string(this.module.GetType()), "forg", &pb.EquipmentForgResp{Issucc: true, Reward: reward})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "EquipmentForgReq", need)
})
return
}

View File

@ -291,10 +291,9 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade
session.SendMsg(string(this.module.GetType()), "upgrade", &pb.EquipmentUpgradeResp{IsSucc: issucc, Equipment: modifyequipments})
if len(tasks) > 0 {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, tasks...)
})
}
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, tasks...)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "EquipmentUpgradeReq", intensify.Need)
})
return
}

View File

@ -83,6 +83,7 @@ func (this *apiComp) Wash(session comm.IUserSession, req *pb.EquipmentWashReq) (
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype95, 1))
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "EquipmentWashReq", &cfg.Gameatn{A: comm.AttrType, T: comm.ResGold, N: gole})
})
return
}

View File

@ -101,6 +101,7 @@ func (this *apiComp) CreateFood(session comm.IUserSession, req *pb.GourmetCreate
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, comm.GetBuriedParam(comm.Rtype150, 1))
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "GourmetCreateFoodReq", atn)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "GourmetCreateFoodReq", res)
})
return
}

View File

@ -74,6 +74,7 @@ func (this *apiComp) Roulette(session comm.IUserSession, req *pb.GuildGveRoulett
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "GuildGveRouletteReq", confs[index].Reward)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "GuildGveRouletteReq", need)
})
return
}

View File

@ -146,6 +146,7 @@ func (this *apiComp) Awaken(session comm.IUserSession, req *pb.HeroAwakenReq) (e
}
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, tasks...)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "HeroAwakenReq", awakenData.Phaseneed)
})
return
}

View File

@ -132,6 +132,10 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
}
rsp.FirstGet = firstGet
session.SendMsg(string(this.module.GetType()), DrawCard, rsp)
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "HeroDrawCardReq", atno)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "HeroDrawCardReq", costRes)
})
return
}
// 准备数据
@ -373,6 +377,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "HeroDrawCardReq", atno)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "HeroDrawCardReq", costRes)
})
return
}

View File

@ -155,6 +155,7 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype117, lvUpCount, utils.ToInt32(_hero.HeroID)))
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, tasks...)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "HeroStrengthenUpSkillReq", cost)
})
return
}

View File

@ -119,6 +119,7 @@ func (this *apiComp) StrengthenUpStar(session comm.IUserSession, req *pb.HeroStr
if len(starConf.Starup) > 0 {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "HeroStrengthenUpStarReq", starConf.Starup)
}
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "HeroStrengthenUpStarReq", starConf.Needrace)
})
return
}

View File

@ -101,5 +101,9 @@ func (this *apiComp) StrengthenUplv(session comm.IUserSession, req *pb.HeroStren
this.module.Errorf("no found userdata uid:%s", session.GetUserId())
}
session.SendMsg(string(this.module.GetType()), StrengthenUplv, &pb.HeroStrengthenUplvResp{Hero: _hero})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "HeroStrengthenUplvReq", cost)
})
return
}

View File

@ -218,6 +218,7 @@ func (this *apiComp) TalentLearn(session comm.IUserSession, req *pb.HeroTalentLe
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype199, 1))
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, tasks...)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "HeroTalentLearnReq", res)
})
}

View File

@ -98,5 +98,9 @@ func (this *apiComp) TalentReset(session comm.IUserSession, req *pb.HeroTalentRe
session.SendMsg(string(this.module.GetType()), HeroTalentResetResp, &pb.HeroTalentResetResp{
Telnet: _talent,
})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "HeroTalentResetReq", this.module.ModuleTools.GetGlobalConf().TalentReset)
})
return
}

View File

@ -44,8 +44,9 @@ func (this *ModelTalent) ChangeHeroTalent(talent *pb.DBHeroTalent, update map[st
if talent == nil || len(update) == 0 {
return errors.New("err")
}
if err := this.ChangeList(talent.Uid, talent.Id, update); err != nil {
if err = this.ChangeList(talent.Uid, talent.Id, update); err != nil {
this.module.Debugf("ChangeHeroTalent err %v", err)
return
}
return nil
}

View File

@ -72,6 +72,7 @@ func (this *apiComp) Reset(session comm.IUserSession, req *pb.HoroscopeResetReq)
session.SendMsg(string(this.module.GetType()), "reset", &pb.HoroscopeResetResp{Issucc: true, Info: info, Award: consume})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "HoroscopeResetReq", res)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "HoroscopeResetReq", conf.HoroscopeResetCost)
})
return

View File

@ -103,11 +103,13 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.HoroscopeUpgrade
}
session.SendMsg(string(this.module.GetType()), "upgrade", &pb.HoroscopeUpgradeResp{Nid: conf.NodeId, Lv: conf.Lv + 1})
if len(tasks) > 0 {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
if len(tasks) > 0 {
this.module.ModuleBuried.TriggerBuried(session, tasks...)
})
}
}
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "HoroscopeUpgradeReq", conf.CostItem)
})
return
}

View File

@ -131,5 +131,15 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.HuntingChallen
} else {
this.module.Errorf("no found userdata uid:%s", session.GetUserId())
}
if ps > 0 {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "HuntingChallengeReq", &cfg.Gameatn{
A: "attr",
T: "ps",
N: ps,
})
})
}
return
}

View File

@ -12,12 +12,21 @@ func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.HuntingGetL
}
func (this *apiComp) GetList(session comm.IUserSession, req *pb.HuntingGetListReq) (errdata *pb.ErrorData) {
var (
list *pb.DBHunting
err error
)
if errdata = this.GetListCheck(session, req); errdata != nil {
return // 参数校验失败直接返回
}
list, _ := this.module.modelHunting.getHuntingList(session.GetUserId())
if list, err = this.module.modelHunting.getHuntingList(session.GetUserId()); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
}
return
}
session.SendMsg(string(this.module.GetType()), HuntingGetListResp, &pb.HuntingGetListResp{Data: list})
return

View File

@ -45,8 +45,7 @@ func (this *modelHunting) getHuntingList(uid string) (result *pb.DBHunting, err
Ps: map[int32]int32{},
}
this.Add(uid, result)
err = nil
err = this.Add(uid, result)
}
return
}

View File

@ -114,5 +114,9 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.IsLandBuyReq) (errda
"heroshop": info.Heroshop,
})
session.SendMsg(string(this.module.GetType()), "buy", &pb.IsLandBuyResp{Hero: hero})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "IsLandBuyReq", coinconf.Need)
})
return
}

View File

@ -76,5 +76,8 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.IsLandUpgradeReq
"nodes": info.Nodes,
})
session.SendMsg(string(this.module.GetType()), "upgrade", &pb.IsLandUpgradeReq{Nid: conf.NodeId})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "IsLandUpgradeReq", conf.CostItem)
})
return
}

View File

@ -110,6 +110,7 @@ func (this *apiComp) BuyPhysical(session comm.IUserSession, req *pb.ItemsBuyPhys
session.SendMsg(string(this.module.GetType()), "buyphysical", &pb.ItemsBuyPhysicalResp{Issucc: true, PhysicalBuyNum: user.Physicalbuynum, Asets: atno})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "ItemsBuyPhysicalReq", atno)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "ItemsBuyPhysicalReq", need)
})
return
}

View File

@ -55,17 +55,6 @@ func (this *apiComp) Decompose(session comm.IUserSession, req *pb.ItemsDecompose
}
return
}
// sale = make([]*cfg.Gameatn, 0, len(itemcf.DecomposeDeplete))
// for _, v := range itemcf.DecomposeDeplete {
// sale = append(sale, &cfg.Gameatn{
// A: v.A,
// T: v.T,
// N: v.N * int32(req.Amount),
// })
// }
// if errdata = this.module.ConsumeRes(session, sale, true); errdata != nil {
// return
// }
if req.Amount > item.Amount {
this.module.Errorf("SellItemCheck over all amount:[%d:%d]", req.Amount, item.Amount)

View File

@ -547,6 +547,7 @@ func (this *ModelItemsComp) buyTicket(session comm.IUserSession, buy int32) (inf
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "buyTicket", res)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "buyTicket", needs)
})
return
}
@ -667,7 +668,9 @@ func (this *ModelItemsComp) useitem(session comm.IUserSession, gid string, amoun
if errdata = this.module.ConsumeRes(session, sale, true); errdata != nil {
return
}
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "itemuse_exchange", sale)
})
if errdata = this.module.AddItemforGrid(session, gid, -1*itemcf.SynthetizeNum*int32(amount), true); errdata != nil {
return
}
@ -711,7 +714,9 @@ func (this *ModelItemsComp) useitem(session comm.IUserSession, gid string, amoun
if errdata = this.module.ConsumeRes(session, sale, true); errdata != nil {
return
}
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "itemuse_heroexchange", sale)
})
if errdata = this.module.AddItemforGrid(session, gid, -1*int32(amount), true); errdata != nil {
return
}

View File

@ -48,5 +48,9 @@ func (this *apiComp) StartGame(session comm.IUserSession, req *pb.JielongStartGa
session.SendMsg(string(this.module.GetType()), "startgame", &pb.JielongStartGameResp{
Susses: true,
})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "JielongStartGameReq", jielongItem)
})
return
}

View File

@ -196,11 +196,13 @@ func (this *apiComp) UseGift(session comm.IUserSession, req *pb.LibraryUseGiftRe
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype134, upLv))
tasks = append(tasks, comm.GetBuriedParam2(comm.Rtype132, _heroObj.Heroid, _heroObj.Favorlv))
}
if len(tasks) > 0 {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
if len(tasks) > 0 {
this.module.ModuleBuried.TriggerBuried(session, tasks...)
})
}
}
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "LibraryUseGiftReq", res)
})
return
}

View File

@ -102,5 +102,10 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MainlineChalle
},
Level: req.Level,
})
if ps > 0 {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "MainlineChallengeReq", psAnt)
})
}
return
}

View File

@ -80,7 +80,7 @@ func (this *apiComp) ShopBuy(session comm.IUserSession, req *pb.MainlineShopBuyR
return
}
if errdata, atno = this.module.DispenseAtno(session, shopConf.Itemsell, true); errdata != nil {
this.module.DispenseRes(session, shopConf.Need, true) // ?????
this.module.DispenseRes(session, shopConf.Need, true) // 资源回退
return
}
this.module.modelShop.updateMainlineShopData(session.GetUserId(), info)
@ -93,6 +93,7 @@ func (this *apiComp) ShopBuy(session comm.IUserSession, req *pb.MainlineShopBuyR
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, tasks...)
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "MainlineShopBuyReq", atno)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "MainlineShopBuyReq", shopConf.Need)
})
return
}