PYTHON ?= python3
CACHE  ?= .cache/gamedata

.PHONY: help gamedata gamedata-check gamedata-force test lint clean-gamedata

help:
	@echo 'Targets:'
	@echo '  gamedata         regenerate src/static tables from the game dumps'
	@echo '  gamedata-check   verify the committed tables are up to date'
	@echo '  test             run the unit tests'

# Regenerate the shipped lookup tables. Fetches the game dumps first if the
# cache is missing. Tables land in src/static and should be committed.
gamedata:
	$(PYTHON) scripts/fetch_gamedata.py --cache $(CACHE)
	$(PYTHON) scripts/gen_gamedata.py --cache $(CACHE)

# Regenerate from a fresh checkout of the dumps.
gamedata-force:
	$(PYTHON) scripts/fetch_gamedata.py --cache $(CACHE) --force
	$(PYTHON) scripts/gen_gamedata.py --cache $(CACHE)

# CI guard: fail if the committed tables have drifted from the dumps.
gamedata-check:
	$(PYTHON) scripts/fetch_gamedata.py --cache $(CACHE)
	$(PYTHON) scripts/gen_gamedata.py --cache $(CACHE) --check

test:
	$(PYTHON) -m pytest tests

clean-gamedata:
	rm -rf .cache
