73 lines
1.6 KiB
Go
73 lines
1.6 KiB
Go
|
|
package controller
|
||
|
|
|
||
|
|
import (
|
||
|
|
"blazing/common/data/xmlres"
|
||
|
|
"blazing/common/socket/errorcode"
|
||
|
|
"blazing/logic/service/item"
|
||
|
|
"blazing/logic/service/player"
|
||
|
|
"blazing/modules/blazing/model"
|
||
|
|
|
||
|
|
"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{}
|
||
|
|
c.Service.Talk.Exec(func(t map[uint32]uint32) bool {
|
||
|
|
|
||
|
|
tt, ok := t[data.ID]
|
||
|
|
if ok {
|
||
|
|
result.GiftCount = tt
|
||
|
|
}
|
||
|
|
return false
|
||
|
|
})
|
||
|
|
|
||
|
|
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)
|
||
|
|
for _, te := range xmlres.TalkConfig.Energies {
|
||
|
|
if te.MapID == uint64(c.Info.MapID) && te.Type == uint64(data.ID) { //
|
||
|
|
|
||
|
|
_, ok := talkcacche[te.Name]
|
||
|
|
if !ok {
|
||
|
|
for _, v := range xmlres.ItemsMAP {
|
||
|
|
if v.Name == te.Name {
|
||
|
|
talkcacche[te.Name] = uint32(v.ID)
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
randomNum := grand.Intn(10) + 1
|
||
|
|
c.Service.Talk.Exec(func(t map[uint32]uint32) bool {
|
||
|
|
if t == nil {
|
||
|
|
t = make(map[uint32]uint32)
|
||
|
|
|
||
|
|
}
|
||
|
|
_, ok := t[data.ID]
|
||
|
|
if !ok {
|
||
|
|
t[data.ID] = 0
|
||
|
|
}
|
||
|
|
|
||
|
|
t[data.ID] += 1
|
||
|
|
if t[data.ID] < uint32(te.CollectCnt) {
|
||
|
|
result.OutList = append(result.OutList, item.CateInfo{ID: uint32(talkcacche[te.Name]), Count: uint32(randomNum)})
|
||
|
|
c.ItemAdd(model.ItemInfo{ItemId: uint32(talkcacche[te.Name]), ItemCnt: uint32(randomNum)})
|
||
|
|
}
|
||
|
|
|
||
|
|
return true
|
||
|
|
})
|
||
|
|
|
||
|
|
break
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
return result, 0
|
||
|
|
}
|