The Combat Strategy
Define a family of algorithms, encapsulate each one, and make them interchangeable at runtime.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Divination // Tactical Precognition
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
# The Strategy interface
STRATEGY ?= stealth
# Concrete Strategies
.PHONY: strat_stealth strat_assault strat_diplomacy
strat_stealth:
@echo "Executing Stealth Strategy: Casting invisibility and silencing footsteps."
strat_assault:
@echo "Executing Assault Strategy: Pre-casting fireballs and summoning battle mounts."
strat_diplomacy:
@echo "Executing Diplomacy Strategy: Casting charm person and brewing tea."
# The Context
.PHONY: execute_mission
execute_mission: strat_$(STRATEGY)
@echo "Mission concluded using the $(STRATEGY) paradigm."
Runic Tags:
#makefile
#behavioral
#strategy
#tactics