🎲 R HARUSPEX DIFFICULTY: Adept Behavioral

The Chain of Responsibility: Passing the Omen

A chain of handlers processing statistical anomalies.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Divination // Sequential Filtering
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// R PATTERN //
library(R6)

# Handler Interface
OmenHandler <- R6Class("OmenHandler",
  private = list(
    next_handler = NULL
  ),
  public = list(
    set_next = function(handler) {
      private$next_handler <- handler
      return(handler)
    },
    handle = function(omen_severity) {
      if (!is.null(private$next_handler)) {
        return(private$next_handler$handle(omen_severity))
      }
      return(NULL)
    }
  )
)

# Concrete Handlers
NoviceHaruspex <- R6Class("NoviceHaruspex", inherit = OmenHandler,
  public = list(
    handle = function(omen_severity) {
      if (omen_severity < 10) {
        return("Novice handled the minor omen.")
      } else {
        return(super$handle(omen_severity))
      }
    }
  )
)

MasterHaruspex <- R6Class("MasterHaruspex", inherit = OmenHandler,
  public = list(
    handle = function(omen_severity) {
      if (omen_severity >= 10) {
        return("Master handled the catastrophic omen.")
      } else {
        return(super$handle(omen_severity))
      }
    }
  )
)

The Chain of Responsibility passes statistical anomalies up the hierarchy. Novices handle minor deviations, while Masters handle world-ending prophecies.

Runic Tags: #R6 #Divination #Behavioral #Chain of Responsibility