package models

import "github.com/mhaya/game/game_cluster/internal/data"

type SignInBase struct {
	ID       int               `json:"id"  bson:"id""`       // #周签到
	Reward   []data.ItemReward `json:"reward" bson:"reward"` // 奖励
	IsSign   int               `json:"isSign"  bson:"isSign"`
	SignTime int64             `json:"signTime"  bson:"signTime"`
}

type SignIn struct {
	SignDailyTime int64               `json:"signDailyTime"  bson:"signDailyTime"`
	Num           int                 `json:"num"  bson:"num"`
	Sign          map[int]*SignInBase `json:"sign" bson:"sign"`
}

func NewSignIn() SignIn {
	return SignIn{
		SignDailyTime: 0,
		Num:           0,
		Sign:          make(map[int]*SignInBase),
	}
}

func (si SignIn) RefreshSignIn() {
	ret := data.WeeklySignInConfig.GetAll()
	for _, d := range ret {
		si.Sign[d.ID] = &SignInBase{
			ID:       d.ID,
			Reward:   d.Reward,
			IsSign:   0,
			SignTime: 0,
		}

	}
}
