The Chain of Arcane Wards
Pass a magical intrusion through a chain of defensive wards until one handles it.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Abjuration // Wardmancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// PROLOG PATTERN //
% Handlers in the chain
handle_intrusion(ThreatLevel) :-
ThreatLevel =< 2,
write('Minor ward repels the intrusion.').
handle_intrusion(ThreatLevel) :-
ThreatLevel > 2, ThreatLevel =< 5,
write('Greater shield absorbs the magical force.').
handle_intrusion(ThreatLevel) :-
ThreatLevel > 5,
write('Archmage summoned! The threat is too great!').
% The chain processes sequentially thanks to Prolog's rule ordering and backtracking.
% We use a simple cut to stop the chain once handled.
process_threat(ThreatLevel) :-
handle_intrusion(ThreatLevel), !.
% ?- process_threat(4).
% "Greater shield absorbs the magical force."
Runic Tags:
#chain-of-responsibility
#behavioral
#prolog
#wards
#defense