PYTHON ?= python3
PYTEST ?= pytest
VENV ?= .venv

.PHONY: all help venv play play-gui play-cli play-ai-battle play-humans test test-cov run clean

all: help

help:
	@echo "Trouble Game - Available Make Targets:"
	@echo "  make venv              Create virtual environment and install requirements"
	@echo "  make play              Run default GUI game (1 Human vs 3 AIs)"
	@echo "  make play-gui          Run default GUI game"
	@echo "  make play-ai-battle    Run GUI game with 4 AI players (Max Pain vs Max Goal Seeking)"
	@echo "  make play-humans       Run GUI game configured for 4 human players"
	@echo "  make play-cli          Run interactive terminal CLI game"
	@echo "  make play-cli-ai       Run terminal CLI game with 4 AI players"
	@echo "  make test              Run unit tests with pytest"
	@echo "  make test-cov          Run unit tests with coverage report"
	@echo "  make clean             Clean Python cache and bytecode files"

venv:
	$(PYTHON) -m venv $(VENV)
	$(VENV)/bin/pip install --upgrade pip
	$(VENV)/bin/pip install -r requirements.txt

play: play-gui

play-gui:
	$(PYTHON) -m trouble.gui

play-ai-battle:
	$(PYTHON) -m trouble.gui --players ai_pain,ai_goal,ai_pain,ai_goal

play-humans:
	$(PYTHON) -m trouble.gui --players human,human,human,human

play-cli:
	$(PYTHON) -m trouble.cli

play-cli-ai:
	$(PYTHON) -m trouble.cli --players ai_pain,ai_goal,ai_pain,ai_goal --speed 0.1

run: play

test:
	$(PYTEST) -v

test-cov:
	$(PYTEST) -v --cov=trouble --cov-report=term-missing

clean:
	find . -type d -name "__pycache__" -exec rm -rf {} +
	find . -type f -name "*.pyc" -delete
	find . -type f -name "*.pyo" -delete
	rm -rf .pytest_cache .coverage htmlcov
