This commit is contained in:
liwei1dao 2023-12-04 10:48:27 +08:00
commit f77e9c80f9
13 changed files with 78 additions and 11 deletions

View File

@ -150,8 +150,31 @@ func GetLotterConfById(id int32) (data *cfg.GameLotteryData) {
return
}
type t20190107 struct {
v int
}
func (t t20190107) F() int {
return t.v
}
func (t t20190107) A(a int) int {
return t.v + a
}
func Test_Main(t *testing.T) {
i := t20190107{678}
t1 := reflect.TypeOf(i)
for it := 0; it < t1.NumMethod(); it++ {
fmt.Println(t1.Method(it).Name)
}
f1, _ := t1.MethodByName("F")
fmt.Println(f1.Name)
r := f1.Func.Call([]reflect.Value{reflect.ValueOf(i), reflect.ValueOf(1)})[0].Int()
fmt.Println(r)
sz := make(map[string]*pb.DBHero)
fmt.Printf("%v", sz["1"])
hero := &pb.DBHero{}

View File

@ -46,6 +46,9 @@ func (this *modelUserLog) AddUserLog(uid string, itype int32, tag string, data i
jsonStr []byte
logType string
)
if data == nil { // 过滤空数据
return
}
if jsonStr, err = json.Marshal(data); err != nil {
log.Errorln(err)
return
@ -54,7 +57,10 @@ func (this *modelUserLog) AddUserLog(uid string, itype int32, tag string, data i
logType = "add" // 新增资源类型
} else if itype == 1 {
logType = "sub" // 消耗资源类型
} else {
logType = "undefine"
}
if db.IsCross() { //如果是跨服 直接找到对应的本服
if tag, _, b := utils.UIdSplit(uid); b {
if conn, err := db.ServerDBConn(tag); err == nil {

View File

@ -25,11 +25,14 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.SmithySellReq) (err
var (
rewardId int32
atno []*pb.UserAtno
recycle []*pb.UserAtno
)
//校验customer类型因为有的类型是不能进入交易逻辑的
this.module.ModuleEquipment.RecycleEquipments(session, req.EquipIds, this.module.modelStove.StoveToolsSellUp(session.GetUserId()))
if errdata, recycle = this.module.ModuleEquipment.RecycleEquipments(session, req.EquipIds, this.module.modelStove.StoveToolsSellUp(session.GetUserId())); errdata != nil {
return
}
atno = append(atno, recycle...)
cus, rewardId, err := this.module.modelTrade.updateCustomer(session.GetUserId(), req.CustomerId)
if err != nil {
var customErr = new(comm.CustomError)
@ -55,10 +58,10 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.SmithySellReq) (err
}
// 发奖励
if errdata, atno = this.module.DispenseAtno(session, conf.Reword, true); errdata != nil {
if errdata, recycle = this.module.DispenseAtno(session, conf.Reword, true); errdata != nil {
return
}
atno = append(atno, recycle...)
rsp := &pb.SmithySellResp{
CustomerId: req.CustomerId,
EquipIds: req.EquipIds,

View File

@ -622,6 +622,9 @@ func (this *apiComp) Event(session comm.IUserSession, req *pb.StonehengeEventReq
}
if len(reward) > 0 {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "StonehengeEventReq", reward)
if len(eventConf.CostItem) > 0 {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "StonehengeEventReq", eventConf.CostItem)
}
}
})

View File

@ -84,6 +84,7 @@ func (this *apiComp) Draw(session comm.IUserSession, req *pb.TurntableDrawReq) (
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "TurntableDrawReq", atno)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "TurntableDrawReq", need)
})
return
}

View File

@ -26,6 +26,8 @@ func (this *apiComp) MinerKey(session comm.IUserSession, req *pb.UiGameMinerKeyR
var (
atno []*pb.UserAtno
res []*cfg.Gameatn
conf *cfg.GameUiGameConsumData
err error
)
list, _ := this.module.modelMiner.getMinerList(session.GetUserId(), req.Hdid)
if _, ok := list.Gotarr[req.Cid]; ok { // 重复拼图
@ -33,7 +35,7 @@ func (this *apiComp) MinerKey(session comm.IUserSession, req *pb.UiGameMinerKeyR
}
// 校验消耗
if conf, err := this.module.configure.GetMinerConsumConf(); err == nil {
if conf, err = this.module.configure.GetMinerConsumConf(); err == nil {
if conf.Cost.N > 0 {
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{conf.Cost}, true); errdata != nil {
return
@ -62,6 +64,7 @@ func (this *apiComp) MinerKey(session comm.IUserSession, req *pb.UiGameMinerKeyR
})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "UiGameMinerKeyReq", atno)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "UiGameMinerKeyReq", conf.Cost)
})
return
}

View File

@ -24,8 +24,10 @@ func (this *apiComp) PuzzleGrid(session comm.IUserSession, req *pb.UiGamePuzzleG
return // 参数校验失败直接返回
}
var (
conf *cfg.GameUiGameConsumData
atno []*pb.UserAtno
res []*cfg.Gameatn
err error
)
list, _ := this.module.modelPuzzle.getPuzzleList(session.GetUserId(), req.Hdid)
if _, ok := list.Puzzle[req.Grid]; ok { // 重复拼图
@ -33,7 +35,7 @@ func (this *apiComp) PuzzleGrid(session comm.IUserSession, req *pb.UiGamePuzzleG
}
// 校验消耗
if conf, err := this.module.configure.GetPuzzleConsumConf(); err == nil {
if conf, err = this.module.configure.GetPuzzleConsumConf(); err == nil {
if conf.Cost.N > 0 {
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{conf.Cost}, true); errdata != nil {
return
@ -68,6 +70,7 @@ func (this *apiComp) PuzzleGrid(session comm.IUserSession, req *pb.UiGamePuzzleG
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "UiGamePuzzleGridReq", atno)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "UiGamePuzzleGridReq", conf.Cost)
})
return
}

View File

@ -14,12 +14,14 @@ func (this *apiComp) ChangeTipsCheck(session comm.IUserSession, req *pb.UserChan
// 修改提示次数
func (this *apiComp) ChangeTips(session comm.IUserSession, req *pb.UserChangeTipsReq) (errdata *pb.ErrorData) {
var (
consume *cfg.Gameatn
)
update := make(map[string]interface{}, 0)
if sign, err := this.module.modelSign.GetUserSign(session.GetUserId()); err == nil {
if conf := this.module.ModuleTools.GetGlobalConf().DailyTips; conf.N > 0 {
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{conf}, true); errdata != nil {
if consume = this.module.ModuleTools.GetGlobalConf().DailyTips; consume.N > 0 {
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{consume}, true); errdata != nil {
return
}
}
@ -31,6 +33,9 @@ func (this *apiComp) ChangeTips(session comm.IUserSession, req *pb.UserChangeTip
session.SendMsg(string(this.module.GetType()), "changetips", &pb.UserChangeTipsResp{
Data: sign,
})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "UserChangeTipsReq", consume)
})
}
return

View File

@ -98,6 +98,8 @@ func (this *apiComp) Modifyname(session comm.IUserSession, req *pb.UserModifynam
//resp.Count = uint32(left)
this.sendMsg(session, UserSubTypeModifyName, resp)
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "UserModifynameReq", this.module.globalConf.ChangeName)
})
return
}

View File

@ -129,5 +129,16 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng
BossId: req.BossId,
Difficulty: req.Difficulty,
})
if ps > 0 {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
psAnt := &cfg.Gameatn{ // 构建一个atn 对象
A: "attr",
T: "ps",
N: ps,
}
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "VikingChallengeReq", psAnt)
})
}
return
}

View File

@ -22,6 +22,7 @@ func (this *apiComp) BuyLv(session comm.IUserSession, req *pb.WarorderBuyLvReq)
exp int32
err error
ok bool
consum *cfg.Gameatn
)
if errdata = this.BuyLvCheck(session, req); errdata != nil {
return
@ -73,7 +74,8 @@ func (this *apiComp) BuyLv(session comm.IUserSession, req *pb.WarorderBuyLvReq)
need := this.module.ModuleTools.GetGlobalConf().Passcheck4GetLvCos
lv := req.Lv - dwarorder.Lv
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{{A: need.A, T: need.T, N: need.N * lv}}, true); errdata != nil {
consum = &cfg.Gameatn{A: need.A, T: need.T, N: need.N * lv}
if errdata = this.module.ConsumeRes(session, []*cfg.Gameatn{consum}, true); errdata != nil {
return
}
@ -106,5 +108,8 @@ func (this *apiComp) BuyLv(session comm.IUserSession, req *pb.WarorderBuyLvReq)
return
}
session.SendMsg(string(this.module.GetType()), "buylv", &pb.WarorderBuyLvResp{Rtype: req.Rtype, Lv: req.Lv, Info: dwarorder})
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "WarorderBuyLvReq", consum)
})
return
}

View File

@ -88,6 +88,7 @@ func (this *apiComp) Exchange(session comm.IUserSession, req *pb.WTaskExchangeRe
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "WTaskExchangeReq", award)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "WTaskExchangeReq", money)
})
return
}

View File

@ -153,6 +153,7 @@ func (this *apiComp) Finish(session comm.IUserSession, req *pb.WTaskFinishReq) (
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleSys.CheckOpenCond(session.Clone(), comm.OpencondTypeWorldtaskid, req.Tid)
this.module.WriteUserLog(session.GetUserId(), comm.GMResAddType, "WTaskFinishReq", award)
this.module.WriteUserLog(session.GetUserId(), comm.GMResDelType, "WTaskFinishReq", conf.TaskendRemoveitem)
})
return
}