52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/logic/service/item"
|
|
"blazing/logic/service/player"
|
|
"blazing/modules/config/service"
|
|
|
|
"github.com/gogf/gf/v2/util/grand"
|
|
)
|
|
|
|
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.TalkConfigServiceS.GetCache(int(data.ID))
|
|
|
|
for _, v := range config {
|
|
count := grand.N(int(v.ItemMinCount), int(v.ItemMaxCount))
|
|
|
|
// r := dict.DictInfoServiceS.DataID("fusion")
|
|
// trueitemid := gconv.Uint32(r[gconv.Uint32(v.ItemID)].Remark)
|
|
ret := c.ItemAdd(uint32(v.ItemID), uint32(count))
|
|
if ret {
|
|
result.OutList = append(result.OutList, item.CateInfo{ID: v.ItemID, Count: uint32(count)})
|
|
|
|
}
|
|
}
|
|
|
|
c.Service.Talk.Update(int(data.ID))
|
|
|
|
return result, 0
|
|
}
|