package player

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

func (p *actorPlayer) signIn() (*param.ChangeData, int32) {
	if !p.isOnline {
		return nil, code.PlayerNotLogin
	}
	if !mhayaTime.CreateFromTimestamp(p.Player.SinIn.SignDailyTime).IsToday() {
		resp := p.Player.SignIn()
		p.dirty = true

		p.itemStat(resp.AddItem)

		return resp, code.OK
	} else {
		return nil, code.PlayerSignInError
	}
}
