package render

import (
	"image/color"

	"github.com/hajimehoshi/ebiten/v2"
	"github.com/hajimehoshi/ebiten/v2/vector"
	"github.com/soer/football/internal/entities"
	"github.com/soer/football/internal/game"
)

type Renderer struct{}

func NewRenderer() *Renderer {
	return &Renderer{}
}

func (r *Renderer) DrawWorld(screen *ebiten.Image, world *game.World) {
	// Draw Puck
	vector.DrawFilledCircle(
		screen,
		float32(world.Puck.Position.X),
		float32(world.Puck.Position.Y),
		float32(world.Puck.Radius),
		color.White,
		true,
	)

	// Draw Players
	for _, p := range world.Players {
		var c color.Color
		if p.Team == entities.TeamRed {
			c = color.RGBA{R: 255, G: 0, B: 0, A: 255}
		} else {
			c = color.RGBA{R: 0, G: 0, B: 255, A: 255}
		}

		vector.DrawFilledCircle(
			screen,
			float32(p.Position.X),
			float32(p.Position.Y),
			float32(p.Radius),
			c,
			true,
		)
	}
}
