package domaintest

import (
	"net/url"

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

type BaseVillageConfig struct {
	ID       int
	Bonus    int
	PlayerID int
}

func NewBaseVillage(tb TestingTB, opts ...func(cfg *BaseVillageConfig)) domain.BaseVillage {
	tb.Helper()

	cfg := &BaseVillageConfig{
		ID:       RandID(),
		PlayerID: RandID(),
		Bonus:    0,
	}

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

	u, err := url.ParseRequestURI(gofakeit.URL())
	require.NoError(tb, err)

	v, err := domain.NewBaseVillage(
		cfg.ID,
		gofakeit.LetterN(50),
		gofakeit.IntRange(1, 10000),
		gofakeit.IntRange(1, 1000),
		gofakeit.IntRange(1, 1000),
		gofakeit.LetterN(3),
		cfg.Bonus,
		cfg.PlayerID,
		u,
	)
	require.NoError(tb, err)

	return v
}
