🏛️ DELPHI ORACLE DIFFICULTY: Apprentice Behavioral

Strategy of the Seeking Missiles

Swappable targeting algorithms for arcane projectiles.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Strategy
ARCANUM SCHOOL: Evocation // Tactical Casting
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// DELPHI PATTERN //
unit StrategyMissiles;

interface

type
  ITargetingStrategy = interface
    function FindTarget: string;
  end;

  TNearestTarget = class(TInterfacedObject, ITargetingStrategy)
  public
    function FindTarget: string;
  end;

  THighestManaTarget = class(TInterfacedObject, ITargetingStrategy)
  public
    function FindTarget: string;
  end;

  TSpellMissile = class
  private
    FStrategy: ITargetingStrategy;
  public
    constructor Create(Strategy: ITargetingStrategy);
    procedure SetStrategy(Strategy: ITargetingStrategy);
    procedure Fire;
  end;

implementation

uses System.SysUtils;

function TNearestTarget.FindTarget: string;
begin
  Result := 'Goblin Skirmisher (Distance: 5m)';
end;

function THighestManaTarget.FindTarget: string;
begin
  Result := 'Lich King (Mana: 9000)';
end;

constructor TSpellMissile.Create(Strategy: ITargetingStrategy);
begin
  FStrategy := Strategy;
end;

procedure TSpellMissile.SetStrategy(Strategy: ITargetingStrategy);
begin
  FStrategy := Strategy;
end;

procedure TSpellMissile.Fire;
begin
  Writeln('Missile fired! Locked onto: ', FStrategy.FindTarget);
end;

end.

A magic missile is useless if it cannot find its mark. The Strategy incantation isolates the targeting algorithm from the explosive payload, allowing the Evoker to swap tactics mid-combat without rewriting the spell.

Runic Tags: #delphi #gof #behavioral #evocation #strategy