优化时间线奖励
This commit is contained in:
parent
659e9dc135
commit
47d4112999
@ -772,6 +772,7 @@ func (ad *GameLogic) RegisterNetWorkFunc() {
|
||||
RegisterMsgProcessFunc("ReqFriendTimeLine", ReqFriendTimeLine) // 请求好友时间线
|
||||
RegisterMsgProcessFunc("ReqFriendRecommend", ReqFriendRecommend) // 获取推荐好友
|
||||
RegisterMsgProcessFunc("ReqFriendTLUpvote", ReqFriendTLUpvote) // 请求时间线点赞
|
||||
RegisterMsgProcessFunc("ReqFriendTReward", ReqFriendTReward) // 请求时间线点赞
|
||||
RegisterMsgProcessFunc("ReqAddNpc", ReqAddNpc) // 增加npc
|
||||
RegisterMsgProcessFunc("ReqWishApply", ReqWishApply) // 同意好友心愿单请求
|
||||
RegisterMsgProcessFunc("ReqFriendByCode", ReqFriendByCode) // 根据邀请码查询好友
|
||||
|
||||
@ -2678,6 +2678,34 @@ func ReqFriendTLUpvote(player *Player, buf []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReqFriendTReward(player *Player, buf []byte) error {
|
||||
req := &msg.ReqFriendTReward{}
|
||||
proto.Unmarshal(buf, req)
|
||||
FriendMod := player.PlayMod.getFriendMod()
|
||||
Items, err := FriendMod.GetReward(int(req.Id))
|
||||
if err != nil {
|
||||
player.SendErrClienRes(&msg.ResFriendTReward{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
Msg: err.Error(),
|
||||
})
|
||||
return err
|
||||
}
|
||||
err = player.HandleItem(Items, msg.ITEM_POP_LABEL_FriendTReward.String())
|
||||
if err != nil {
|
||||
player.SendErrClienRes(&msg.ResFriendTReward{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
Msg: err.Error(),
|
||||
})
|
||||
return err
|
||||
}
|
||||
player.PlayMod.save()
|
||||
player.PushClientRes(&msg.ResFriendTReward{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
Id: req.Id,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReqChampshipRankReward(player *Player, buf []byte) error {
|
||||
MyLastRank := G_GameLogicPtr.ChampshipMgr.getLastMyRank(int(player.M_DwUin))
|
||||
ChampshipMod := player.PlayMod.getChampshipMod()
|
||||
|
||||
@ -94,6 +94,7 @@ type LogInfo struct {
|
||||
Time int64
|
||||
Param string
|
||||
Upvote bool // 点赞
|
||||
Reward bool // 是否已领取奖励
|
||||
}
|
||||
|
||||
func (f *FriendMod) InitData() {
|
||||
@ -287,7 +288,37 @@ func (f *FriendMod) Upvote(Id int) ([]*item.Item, int, error) {
|
||||
return nil, 0, fmt.Errorf("already upvote")
|
||||
}
|
||||
info.Upvote = true
|
||||
return []*item.Item{item.NewItem(item.ITEM_ENERGY_ID, 1)}, info.Uid, nil
|
||||
return []*item.Item{item.NewItem(item.ITEM_ENERGY_ID, 5)}, info.Uid, nil
|
||||
}
|
||||
|
||||
func (f *FriendMod) GetReward(Id int) ([]*item.Item, error) {
|
||||
if len(f.Log) == 0 {
|
||||
return nil, fmt.Errorf("no log")
|
||||
}
|
||||
info := &LogInfo{}
|
||||
reward := make([]*item.Item, 0)
|
||||
for _, v := range f.Log {
|
||||
if v.Id == Id {
|
||||
info = v
|
||||
break
|
||||
}
|
||||
}
|
||||
if info.Id == 0 {
|
||||
return nil, fmt.Errorf("log not exist")
|
||||
}
|
||||
if info.Reward {
|
||||
return nil, fmt.Errorf("already get reward")
|
||||
}
|
||||
info.Reward = true
|
||||
switch info.Type {
|
||||
case LOG_TYPE_HANDBOOK_UPVOTE:
|
||||
reward = append(reward, item.NewItem(item.ITEM_ENERGY_ID, 5))
|
||||
case LOG_TYPE_PLAYROOM_UPVOTE:
|
||||
reward = append(reward, item.NewItem(item.ITEM_ENERGY_ID, 5))
|
||||
default:
|
||||
return nil, fmt.Errorf("log type not support")
|
||||
}
|
||||
return reward, nil
|
||||
}
|
||||
|
||||
func (f *FriendMod) AddWishApply(Uid int64) error {
|
||||
|
||||
@ -839,7 +839,7 @@ func (p *PlayroomMod) GiveUpvote(Uid int) ([]*item.Item, error) {
|
||||
return nil, fmt.Errorf("upvote already")
|
||||
}
|
||||
p.UpvoteList = append(p.UpvoteList, Uid)
|
||||
return []*item.Item{item.NewItem(item.ITEM_ENERGY_ID, 10)}, nil
|
||||
return []*item.Item{item.NewItem(item.ITEM_ENERGY_ID, 5)}, nil
|
||||
}
|
||||
|
||||
func (p *PlayroomMod) AddUpvote() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user