feat(item): 调整玄彩道具使用数量限制 玄彩道具检查逻辑从 items <= 0 修改为 items < 100, 确保玩家拥有至少100个道具才能使用。 fix(fight): 修复战斗操作通道阻塞问题 添加10秒超时机制到战斗操作通道发送逻辑中, 避免通道满载时的
This commit is contained in:
@@ -102,7 +102,7 @@ func (h Controller) handlexuancaiItem(currentPet *model.PetInfo, c *player.Playe
|
||||
return errorcode.ErrorCodes.ErrItemUnusable
|
||||
}
|
||||
items := c.Service.Item.CheakItem(uint32(xmlres.PetMAP[int(currentPet.ID)].Type) + 400686)
|
||||
if items <= 0 {
|
||||
if items < 100 {
|
||||
return errorcode.ErrorCodes.ErrInsufficientItems
|
||||
}
|
||||
c.Service.Item.UPDATE(uint32(items), -100)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
@@ -77,7 +78,7 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) {
|
||||
case f.actionChan <- ret:
|
||||
// 发送成功,可选记录日志
|
||||
// log.Printf("send skill success, userID: %d, skillID: %d", c.GetInfo().UserID, id)
|
||||
default:
|
||||
case <-time.After(time.Second * 10):
|
||||
// 通道满时的降级处理
|
||||
cool.Logger.Printf(context.Background(), "actionChan is full, failed to send skill, userID: %d, skillID: %d",
|
||||
c.GetInfo().UserID, id)
|
||||
@@ -119,7 +120,7 @@ func (f *FightC) UseSkill(c common.PlayerI, id uint32) {
|
||||
case f.actionChan <- ret:
|
||||
// 发送成功,可选记录日志
|
||||
// log.Printf("send skill success, userID: %d, skillID: %d", c.GetInfo().UserID, id)
|
||||
default:
|
||||
case <-time.After(time.Second * 10):
|
||||
// 通道满时的降级处理
|
||||
cool.Logger.Printf(context.Background(), "actionChan is full, failed to send skill, userID: %d, skillID: %d",
|
||||
c.GetInfo().UserID, id)
|
||||
@@ -136,7 +137,7 @@ func (f *FightC) Capture(c common.PlayerI, id uint32) {
|
||||
case f.actionChan <- &action.UseItemAction{BaseAction: action.NewBaseAction(c.GetInfo().UserID), ItemID: id}:
|
||||
// 发送成功,可选记录日志
|
||||
// log.Printf("send skill success, userID: %d, skillID: %d", c.GetInfo().UserID, id)
|
||||
default:
|
||||
case <-time.After(time.Second * 10):
|
||||
// 通道满时的降级处理
|
||||
cool.Logger.Printf(context.Background(), "actionChan is full, failed to send Capture, userID: %d ",
|
||||
c.GetInfo().UserID)
|
||||
@@ -154,7 +155,7 @@ func (f *FightC) UseItem(c common.PlayerI, cacthid, itemid uint32) {
|
||||
case f.actionChan <- &action.UseItemAction{BaseAction: action.NewBaseAction(c.GetInfo().UserID), ItemID: itemid, CacthTime: cacthid}:
|
||||
// 发送成功,可选记录日志
|
||||
// log.Printf("send skill success, userID: %d, skillID: %d", c.GetInfo().UserID, id)
|
||||
default:
|
||||
case <-time.After(time.Second * 10):
|
||||
// 通道满时的降级处理
|
||||
cool.Logger.Printf(context.Background(), "actionChan is full, failed to send UseItem, userID: %d, skillID: %d",
|
||||
c.GetInfo().UserID, cacthid)
|
||||
|
||||
@@ -3,24 +3,42 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/player/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
type GoldService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
func (s *GoldService) Cheak(pid, count uint32) {
|
||||
|
||||
}
|
||||
func (s *GoldService) Log(pid, count uint32) {
|
||||
if cool.Config.ServerInfo.IsVip != 0 {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// 获取当前时间
|
||||
now := time.Now()
|
||||
// 提取年份
|
||||
year := uint32(now.Year())
|
||||
// 构造消费时间数组 [月, 周, 日]
|
||||
// ISOWeek返回(年,周数),这里只取周数;Day()返回当月的第几天
|
||||
_, week := now.ISOWeek()
|
||||
consumeTime := []uint32{
|
||||
uint32(now.Month()), // 月份
|
||||
uint32(week), // 周数
|
||||
uint32(now.Day()), // 日期
|
||||
}
|
||||
|
||||
record := &model.GoldBeanConsume{
|
||||
PlayerID: uint64(s.userid),
|
||||
ConsumeNum: count,
|
||||
BizID: pid,
|
||||
Year: year, // 补充年份
|
||||
Consume: consumeTime, // 补充消费时间(月-周-日)
|
||||
}
|
||||
|
||||
return
|
||||
s.dbm(s.Model).Data(record).Insert()
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user