重构 Talk 方法中物品奖励的获取方式,使用新的配置服务以支持多物品 ID 奖励机制。 移除了对 github.com/gogf/gf/v2/util/grand 包的依赖,改为通过服务获取实际物品数量。 同时更新了相关模型定义: - 修改 MineralCollectionConfig 中 ItemID 为数组形式以支持多个物品配置 - 调整 ItemGift 模型字段
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/logic/service/item"
|
|
"blazing/logic/service/player"
|
|
"blazing/modules/config/service"
|
|
)
|
|
|
|
func (h Controller) Talk(data *item.TalkCountInboundInfo, c *player.Player) (result *item.TalkCountOutboundInfo, err errorcode.ErrorCode) {
|
|
result = &item.TalkCountOutboundInfo{}
|
|
cid, ok := c.Service.Talk.Cheak(c.Info.MapID, int(data.ID))
|
|
if !ok {
|
|
return result, 0
|
|
}
|
|
result.GiftCount = uint32(cid)
|
|
|
|
return result, 0
|
|
}
|
|
|
|
//var talkcacche = make(map[string]uint32)
|
|
|
|
func (h Controller) TalkCate(data *item.TalkCateInboundInfo, c *player.Player) (result *item.DayTalkInfo, err errorcode.ErrorCode) {
|
|
result = &item.DayTalkInfo{}
|
|
result.OutList = make([]item.CateInfo, 0)
|
|
|
|
_, ok := c.Service.Talk.Cheak(c.Info.MapID, int(data.ID))
|
|
if !ok {
|
|
return result, errorcode.ErrorCodes.ErrResourceUnavailable
|
|
}
|
|
//更新次数
|
|
config := service.NewTalkConfigService().GetCache(int(data.ID))
|
|
|
|
//service.NewItemService().GetItemCount(config.ItemID)
|
|
|
|
for _, itemid := range config.ItemID {
|
|
ritemcount := service.NewItemService().GetItemCount(itemid)
|
|
ret := c.ItemAdd(uint32(itemid), uint32(ritemcount))
|
|
if ret {
|
|
result.OutList = append(result.OutList, item.CateInfo{ID: itemid, Count: uint32(ritemcount)})
|
|
|
|
}
|
|
}
|
|
|
|
c.Service.Talk.Update(int(data.ID))
|
|
|
|
return result, 0
|
|
}
|