package player

import (
	"github.com/mhaya/game/game_cluster/internal/code"
	"github.com/mhaya/game/game_cluster/internal/param"
)

func (p *actorPlayer) claim(req *param.ClaimReq) (*param.ChangeData, int32) {
	if !p.isOnline {
		return nil, code.PlayerNotLogin
	}
	var resp param.ChangeData
	switch req.Tp {
	case 1:
		resp = p.Player.ClaimRankReward(req.Id)
	case 2:
		resp = p.Player.ClaimInviteReward(req.Id)
	case 3:
		resp = p.Player.ClaimAchieveTaskReward(req.Id)
	case 4:
		resp = p.Player.ClaimDailyTaskReward(req.Id)
	}

	p.itemStat(resp.AddItem)
	p.dirty = true

	return &resp, code.OK
}
