class Mythal::Npc

Attributes

challenge_rating[R]
user_overrides[R]

Public Class Methods

new(challenge_rating: "1/4", user_overrides: {}) click to toggle source
# File lib/mythal/npc.rb, line 5
def initialize(challenge_rating: "1/4", user_overrides: {})
  @challenge_rating = challenge_rating
  @user_overrides = user_overrides
end

Public Instance Methods

call() click to toggle source
# File lib/mythal/npc.rb, line 10
def call
  self
end
character_description() click to toggle source
# File lib/mythal/npc.rb, line 21
def character_description
  trait + " " + race + " " + dnd_class
end
dnd_class() click to toggle source
# File lib/mythal/npc.rb, line 25
def dnd_class
  config.dnd_classes.sample
end
message() click to toggle source
# File lib/mythal/npc.rb, line 37
    def message
      <<~OUTPUT
        ---
        #{character_description}
        ---
        Armor Class: #{stats.armor_class}
        Hit Points: #{stats.hit_points}
        Attack: +#{stats.attack_bonus}
        Damage: #{stats.damage_per_round} slashing
        Speed: #{stats.speed}ft
        Challenge Rating: #{stats.challenge_rating}
        ---
      OUTPUT
    end
race() click to toggle source
# File lib/mythal/npc.rb, line 29
def race
  config.races.sample
end
stats() click to toggle source
# File lib/mythal/npc.rb, line 14
def stats
  @stats ||= Mythal::Stats.new(
    challenge_rating: challenge_rating,
    options: (user_overrides || {}),
  )
end
trait() click to toggle source
# File lib/mythal/npc.rb, line 33
def trait
  config.traits.sample
end

Private Instance Methods

config() click to toggle source
# File lib/mythal/npc.rb, line 56
def config
  Mythal::Config
end