.PHONY: test test gui coverage crap clean

# Show available make targets
help:
	@echo "Available targets:"
	@echo "  help       - Show this help"
	@echo "  test       - Run the test suite"
	@echo "  coverage   - Run tests with coverage report"
	@echo "  crap       - Run CRAP index report"
	@echo "  gui        - Launch the Monopoly Qt GUI"
	@echo "  clean      - Remove the virtual environment"

VENV = .venv

$(VENV)/bin/activate:
	python3 -m venv $(VENV)
	$(VENV)/bin/pip install pytest PySide6 pytest-xdist pytest-cov radon

.venv: $(VENV)/bin/activate

# Run the test suite
test: $(VENV)/bin/activate
	. $(VENV)/bin/activate && python -m pytest tests/ -v

# Run tests with coverage report (produces coverage.json for crap target)
coverage: $(VENV)/bin/activate
	. $(VENV)/bin/activate && python -m pytest tests/ --cov=monopoly --cov-report=term-missing --cov-report=html:coverage_html --cov-report=json -v

# CRAP scores per function (complexity * untested), sorted worst first.
# Requires coverage.json — run 'make coverage' first.
crap: $(VENV)/bin/activate
	@if [ ! -f coverage.json ]; then \
	  echo "No coverage.json — run 'make coverage' first" >&2; exit 1; \
	fi
	. $(VENV)/bin/activate && python scripts/crap.py .

# Launch the Monopoly Qt GUI
gui: $(VENV)/bin/activate
	. $(VENV)/bin/activate && python -m monopoly.gui

# Remove the virtual environment
clean:
	rm -rf $(VENV)

", "path": "/home/fox/git/monopoly/Makefile