The Decorator Glyph
Dynamically attach new enchantments to an artifact without altering its base composition.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Enchantment // Imbuement
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SCALA PATTERN //
trait Weapon {
def damage: Int
def description: String
}
class BaseSword extends Weapon {
def damage: Int = 10
def description: String = "Iron Sword"
}
trait WeaponEnchantment extends Weapon {
def base: Weapon
def damage: Int = base.damage
def description: String = base.description
}
class Flaming(val base: Weapon) extends WeaponEnchantment {
override def damage: Int = super.damage + 5
override def description: String = s"Flaming ${super.description}"
}
class Vorpal(val base: Weapon) extends WeaponEnchantment {
override def damage: Int = super.damage + 15
override def description: String = s"Vorpal ${super.description}"
}
Stacking buffs. The Decorator allows a pure base object to be enveloped in multiple, stackable layers of arcane modifiers.
Runic Tags:
#scala
#structural
#enchantment