package port

import (
	"context"

	"github.com/costap/quarkshologridledger/tongo-core/internal/domain/entity"
)

// SchedulerService defines the match lifecycle management interface.
type SchedulerService interface {
	// Tick advances the scheduler by one cycle, creating or retiring matches as needed.
	Tick(ctx context.Context) error

	// ActiveMatches returns all currently active matches.
	ActiveMatches() []*entity.Match

	// SeedMatches creates initial matches up to the target count.
	SeedMatches(ctx context.Context, count int) error
}

// MatchmakerService defines the faction pairing and venue selection interface.
type MatchmakerService interface {
	// CreateMatch generates a new match by selecting factions and a venue.
	CreateMatch(ctx context.Context) (*entity.Match, error)
}

// SimulatorService defines the combat tick resolution interface.
type SimulatorService interface {
	// ResolveTick processes one combat tick for a match.
	ResolveTick(match *entity.Match) entity.TickResult
}

// EventGeneratorService defines the random event system interface.
type EventGeneratorService interface {
	// Roll checks for and generates any random events this tick.
	Roll(match *entity.Match, tickResult entity.TickResult) []entity.MatchEvent
}

// ProbabilityService defines the odds calculation interface.
type ProbabilityService interface {
	// RecalculateAll recomputes probabilities for all markets in a match.
	RecalculateAll(match *entity.Match)
}

// MarketService defines the market management interface.
type MarketService interface {
	// HydrateMarkets generates markets for a new match from templates.
	HydrateMarkets(match *entity.Match, templates []entity.MarketTemplate)

	// UpdatePrices converts probabilities to prices with margin.
	UpdatePrices(match *entity.Match)

	// SuspendAll suspends all markets in a match.
	SuspendAll(match *entity.Match, durationTicks int)
}
