package domaintest

import (
	"time"

	"gitea.dwysokinski.me/twhelp/corev3/internal/domain"
	"github.com/brianvoe/gofakeit/v6"
	"github.com/stretchr/testify/require"
)

type EnnoblementConfig struct {
	ID        int
	ServerKey string
	VillageID int
}

func NewEnnoblement(tb TestingTB, opts ...func(cfg *EnnoblementConfig)) domain.Ennoblement {
	tb.Helper()

	cfg := &EnnoblementConfig{
		ID:        RandID(),
		ServerKey: RandServerKey(),
		VillageID: RandID(),
	}

	for _, opt := range opts {
		opt(cfg)
	}

	e, err := domain.UnmarshalEnnoblementFromDatabase(
		cfg.ID,
		cfg.ServerKey,
		cfg.VillageID,
		RandID(),
		RandID(),
		RandID(),
		RandID(),
		gofakeit.IntRange(1, 10000),
		time.Now(),
	)
	require.NoError(tb, err)

	return e
}
