package player

import (
	mhayaTime "github.com/mhaya/extend/time"
	"github.com/mhaya/game/game_cluster/internal/code"
	"github.com/mhaya/game/game_cluster/internal/mdb/models"
	"github.com/mhaya/game/game_cluster/internal/param"
	clog "github.com/mhaya/logger"
)

func (p *actorPlayer) guide(req *param.GuideReq) (*param.GuideResp, int32) {
	if !p.isOnline {
		clog.Infof("[guide] PlayerNotLogin err node=%v", p.App().NodeId())
		return nil, code.PlayerNotLogin
	}

	if req.Close == 1 {
		p.Player.Guide = 0
	}

	var resp param.GuideResp

	resp.Guide = p.Player.Guide
	resp.FirstReward = p.Player.FirstReward
	resp.Rolled = p.Player.Roll.RollNums
	resp.FollowChannel = req.Status
	resp.AddItem = models.NewAddItem()
	//var addItem = models.NewAddItem()

	if req.CloseReward == 1 && p.Player.FirstReward == 1 {
		//it := addItem.Add(ret.Reward)
		//p.Player.Item.AddItem(ret.Reward)
		//	resp.AddItem = it
		p.Player.FirstReward = 0
	}

	p.dirty = true
	p.Player.UpdateTime = mhayaTime.Now().Unix()
	resp.SubItem = models.SubItem{}

	p.itemStat(resp.AddItem)

	return &resp, code.OK
}
