消耗的资源数正数处理

This commit is contained in:
wh_zcy 2022-12-01 14:39:34 +08:00
parent 2c12e6ae26
commit cfc5d4f396

View File

@ -284,14 +284,14 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn
for k, v := range attrs {
if this.ModuleUser.QueryAttributeValue(session.GetUserId(), k) < -int64(v) { // -v 负负得正
code = pb.ErrorCode_ResNoEnough
this.Errorf("资源不足: A: attr, T: %s, N: %d", k, v)
this.Error("资源不足", log.Fields{"uid": session.GetUserId(), "T": k, "N": v})
return
}
}
for k, v := range items {
if int32(this.ModuleItems.QueryItemAmount(session.GetUserId(), k)) < -v {
code = pb.ErrorCode_ResNoEnough
this.Errorf("道具不足: A: item, T:%s, N:%d", k, v)
this.Errorf("道具不足", log.Fields{"uid": session.GetUserId(), "T": k, "N": v})
return
}
}
@ -301,9 +301,9 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn
if code != pb.ErrorCode_Success {
return
}
this.Debugf("消耗玩家资源: %v", attrs)
this.Debug("消耗玩家资源", log.Fields{"uid": session.GetUserId(), "attrs": attrs})
if count, ok := attrs[comm.ResDiamond]; ok {
this.ModuleRtask.SendToRtask(session, comm.Rtype104, count)
this.ModuleRtask.SendToRtask(session, comm.Rtype104, -count)
}
}
if len(items) > 0 {
@ -311,7 +311,7 @@ func (this *ModuleBase) ConsumeRes(session comm.IUserSession, res []*cfg.Gameatn
if code != pb.ErrorCode_Success {
return
}
this.Debugf("消耗道具资源: %v", items)
this.Debug("消耗道具资源", log.Fields{"uid": session.GetUserId(), "items": items})
}
return