package mhayaSlice

import (
	"fmt"
	mhayaString "github.com/mhaya/extend/string"
	mhayaTime "github.com/mhaya/extend/time"
	"slices"
	"testing"
	"time"
)

func TestUnique(t *testing.T) {
	list := Unique[string]("1", "2", "3", "1")
	fmt.Println(list)
}

var currentTime = int64(1727366400)

func TestUniques(t *testing.T) {
	//s1 := []string{"1", "2", "3"}
	//s2 := []string{"1", "2", "3"}
	//
	//list := Uniques[string](s1, s2)
	//fmt.Println(list)

	//var roolDay = time.Now().Unix()
	var roolDay = int64(1727337600)

	for i := 0; i < 10; i++ {
		RefreshRoll(&roolDay)
	}
}

func RefreshRoll(roolDay *int64) bool {
	arr := []string{"8", "16", "24"}
	slice := make([]int, 0)
	for _, s := range arr {
		hour, _ := mhayaString.ToInt(s)
		slice = append(slice, hour)
	}

	// 小时数，24小时制
	//curHour := time.Now().Hour()
	curHour := 24
	rollHour := time.Unix(*roolDay, 0).Hour()

	isToday := mhayaTime.CreateFromTimestamp(*roolDay).IsToday()
	if isToday {
		slice = slices.DeleteFunc(slice, func(x int) bool {
			return x <= rollHour
		})
	}

	fmt.Println("slice:", slice)
	if slices.Contains(slice, curHour) && isToday {
		*roolDay = currentTime
		fmt.Println(" execute ==> num := p.Item[ItemRoll].AddSameTwo()")
		return true
	}
	return false
}
