Module: Lich::DragonRealms

Includes:
Lich
Defined in:
documented/games.rb,
documented/dragonrealms/drinfomon.rb,
documented/dragonrealms/commons/common.rb,
documented/dragonrealms/commons/slackbot.rb,
documented/dragonrealms/drinfomon/drdefs.rb,
documented/dragonrealms/drinfomon/drroom.rb,
documented/dragonrealms/drinfomon/events.rb,
documented/dragonrealms/drinfomon/drskill.rb,
documented/dragonrealms/drinfomon/drstats.rb,
documented/dragonrealms/drinfomon/drparser.rb,
documented/dragonrealms/drinfomon/drspells.rb,
documented/dragonrealms/commons/common-items.rb,
documented/dragonrealms/commons/common-money.rb,
documented/dragonrealms/commons/equipmanager.rb,
documented/dragonrealms/commons/common-arcana.rb,
documented/dragonrealms/commons/common-travel.rb,
documented/dragonrealms/drinfomon/drvariables.rb,
documented/dragonrealms/commons/common-healing.rb,
documented/dragonrealms/commons/common-theurgy.rb,
documented/dragonrealms/commons/common-crafting.rb,
documented/dragonrealms/commons/common-moonmage.rb,
documented/dragonrealms/commons/common-summoning.rb,
documented/dragonrealms/commons/common-validation.rb,
documented/dragonrealms/commons/common-healing-data.rb

Overview

Maps bleed rates from ‘health` command to severity number. A partially tended wound is considered more severe than its non-tended counterpart because once the bandages come off then the wound is much worse so they should be triaged first. elanthipedia.play.net/Damage#Bleeding_Levels

Skill to tend based on elanthipedia.play.net/First_Aid_skill#Skill_to_Tend A ‘nil’ value means that can’t be tended because already is tended or isn’t bleeding.

Examples:

Usage of the module

severity = Lich::DragonRealms::DRCH_BLEED_RATE_TO_SEVERITY_MAP["slight"]

Defined Under Namespace

Modules: DRC, DRCA, DRCC, DRCH, DRCI, DRCM, DRCMM, DRCS, DRCT, DRCTH, DRInfomon, DRParser, DRSpells, DRStats Classes: CharacterValidator, DRRoom, DRSkill, EquipmentManager, Flags, Game, GameInstance, SlackBot

Constant Summary collapse

DR_LEARNING_RATES =

Array of learning rates used in the game.

Returns:

  • (Array<String>)

    An array of strings representing different learning rates.

[
  'clear',
  'dabbling',
  'perusing',
  'learning',
  'thoughtful',
  'thinking',
  'considering',
  'pondering',
  'ruminating',
  'concentrating',
  'attentive',
  'deliberative',
  'interested',
  'examining',
  'understanding',
  'absorbing',
  'intrigued',
  'scrutinizing',
  'analyzing',
  'studious',
  'focused',
  'very focused',
  'engaged',
  'very engaged',
  'cogitating',
  'fascinated',
  'captivated',
  'engrossed',
  'riveted',
  'very riveted',
  'rapt',
  'very rapt',
  'enthralled',
  'nearly locked',
  'mind lock'
]
DR_BALANCE_VALUES =

Array of balance values used in the game.

Returns:

  • (Array<String>)

    An array of strings representing different balance values.

[
  'completely',
  'hopelessly',
  'extremely',
  'very badly',
  'badly',
  'somewhat off',
  'off',
  'slightly off',
  'solidly',
  'nimbly',
  'adeptly',
  'incredibly'
]
DR_SKILLS_DATA =

Hash containing skill data for various skillsets in the game.

Returns:

  • (Hash)

    A hash with skillsets and their corresponding skills.

{
  "skillsets": {
    "Armor": [
      "Shield Usage",
      "Light Armor",
      "Chain Armor",
      "Brigandine",
      "Plate Armor",
      "Defending",
      "Conviction"
    ],
    "Lore": [
      "Alchemy",
      "Appraisal",
      "Enchanting",
      "Engineering",
      "Forging",
      "Outfitting",
      "Performance",
      "Scholarship",
      "Tactics",
      "Empathy",
      "Bardic Lore",
      "Trading",
      "Mechanical Lore"
    ],
    "Weapon": [
      "Parry Ability",
      "Small Edged",
      "Large Edged",
      "Twohanded Edged",
      "Small Blunt",
      "Large Blunt",
      "Twohanded Blunt",
      "Slings",
      "Bow",
      "Crossbow",
      "Staves",
      "Polearms",
      "Light Thrown",
      "Heavy Thrown",
      "Brawling",
      "Offhand Weapon",
      "Melee Mastery",
      "Missile Mastery",
      "Expertise"
    ],
    "Magic": [
      "Primary Magic",
      "Arcana",
      "Attunement",
      "Augmentation",
      "Debilitation",
      "Targeted Magic",
      "Utility",
      "Warding",
      "Sorcery",
      "Astrology",
      "Summoning",
      "Theurgy",
      "Inner Magic",
      "Inner Fire",
      "Lunar Magic",
      "Elemental Magic",
      "Holy Magic",
      "Life Magic",
      "Arcane Magic"
    ],
    "Survival": [
      "Evasion",
      "Athletics",
      "Perception",
      "Stealth",
      "Locksmithing",
      "Thievery",
      "First Aid",
      "Outdoorsmanship",
      "Skinning",
      "Instinct",
      "Backstab",
      "Thanatology"
    ]
  },
  "guild_skill_aliases": {
    "Cleric"       => { "Primary Magic" => "Holy Magic" },
    "Necromancer"  => { "Primary Magic" => "Arcane Magic" },
    "Warrior Mage" => { "Primary Magic" => "Elemental Magic" },
    "Thief"        => { "Primary Magic" => "Inner Magic" },
    "Barbarian"    => { "Primary Magic" => "Inner Fire" },
    "Ranger"       => { "Primary Magic" => "Life Magic" },
    "Bard"         => { "Primary Magic" => "Elemental Magic" },
    "Paladin"      => { "Primary Magic" => "Holy Magic" },
    "Empath"       => { "Primary Magic" => "Life Magic" },
    "Trader"       => { "Primary Magic" => "Lunar Magic" },
    "Moon Mage"    => { "Primary Magic" => "Lunar Magic" }
  }
}
KRONAR_BANKS =

Array of bank names in the Kronar region.

Returns:

  • (Array<String>)

    An array of strings representing bank names.

['Crossings', 'Dirge', 'Ilaya Taipa', 'Leth Deriel']
LIRUM_BANKS =

Array of bank names in the Lirum region.

Returns:

  • (Array<String>)

    An array of strings representing bank names.

["Aesry Surlaenis'a", "Hara'jaal", "Mer'Kresh", "Muspar'i", "Ratha", "Riverhaven", "Rossman's Landing", "Therenborough", "Throne City"]
DOKORA_BANKS =

Array of bank names in the Dokora region.

Returns:

  • (Array<String>)

    An array of strings representing bank names.

["Ain Ghazal", "Boar Clan", "Chyolvea Tayeu'a", "Hibarnhvidar", "Fang Cove", "Raven's Point", "Shard"]
BANK_TITLES =

Hash mapping bank names to their titles.

Returns:

  • (Hash)

    A hash where keys are bank names and values are arrays of titles.

{
  "Aesry Surlaenis'a" => ["[[Tona Kertigen, Deposit Window]]"],
  "Ain Ghazal"        => ["[[Ain Ghazal, Private Depository]]"],
  "Boar Clan"         => ["[[Ranger Guild, Bank]]"],
  "Chyolvea Tayeu'a"  => ["[[Chyolvea Tayeu'a, Teller]]"],
  "Crossings"         => ["[[Provincial Bank, Teller]]"],
  "Dirge"             => ["[[Dirge, Traveller's Bank]]"],
  "Fang Cove"         => ["[[First Council Banking, Vault]]"],
  "Hara'jaal"         => ["[[Baron's Forset, Teller]]"],
  "Hibarnhvidar"      => ["[[Second Provincial Bank of Hibarnhvidar, Teller]]", "[[Hibarnhvidar, Teller Windows]]", "[[First Arachnid Bank, Lobby]]"],
  "Ilaya Taipa"       => ["[[Ilaya Taipa, Trader Outpost Bank]]"],
  "Leth Deriel"       => ["[[Imperial Depository, Domestic Branch]]"],
  "Mer'Kresh"         => ["[[Harti Clemois Bank, Teller's Window]]"],
  "Muspar'i"          => ["[[Old Lata'arna Keep, Teller Windows]]"],
  "Ratha"             => ["[[Lower Bank of Ratha, Cashier]]", "[[Sshoi-sson Palace, Grand Provincial Bank, Bursarium]]"],
  "Raven's Point"     => ["[[Bank of Raven's Point, Depository]]"],
  "Riverhaven"        => ["[[Bank of Riverhaven, Teller]]"],
  "Rossman's Landing" => ["[[Traders' Guild Outpost, Depository]]"],
  "Shard"             => ["[[First Bank of Ilithi, Teller's Windows]]"],
  "Therenborough"     => ["[[Bank of Therenborough, Teller]]"],
  "Throne City"       => ["[[Faldesu Exchequer, Teller]]"]
}
VAULT_TITLES =

Hash mapping vault names to their titles.

Returns:

  • (Hash)

    A hash where keys are vault names and values are arrays of titles.

{
  "Crossings"     => ["[[Crossing, Carousel Chamber]]"],
  "Fang Cove"     => ["[[Fang Cove, Carousel Chamber]]"],
  "Leth Deriel"   => ["[[Leth Deriel, Carousel Chamber]]"],
  "Mer'Kresh"     => ["[[Mer'Kresh, Carousel Square]]"],
  "Muspar'i"      => ["[[Muspar'i, Carousel Square]]"],
  "Ratha"         => ["[[Ratha, Carousel Square]]"],
  "Riverhaven"    => ["[[Riverhaven, Carousel Chamber]]"],
  "Shard"         => ["[[Shard, Carousel Chamber]]"],
  "Therenborough" => ["[[Therenborough, Carousel Chamber]]"]
}
UNKNOWN_DURATION =

Some spells may last for an unknown duration, such as cyclic spells that last as long as the caster can harness mana for it. Or, barbarian abilities when the character doesn’t have Power Monger mastery to see true durations but only vague guestimates. In those situations, we set use this value. Constant representing an unknown duration for spells.

Returns:

  • (Integer)

    A default value indicating unknown duration.

1000

Instance Method Summary collapse

Methods included from Lich

break_game_host_port, class_eval, class_variable_get, core_updated_with_lich_version, core_updated_with_lich_version=, db, db_mutex, debug_messaging, debug_messaging=, deprecated, display_exits, display_exits=, display_lichid, display_lichid=, display_stringprocs, display_stringprocs=, display_uid, display_uid=, find_hosts_file, fix_game_host_port, get_simu_launcher, hide_uid_flag, hide_uid_flag=, hosts_file, init_db, inventory_boxes, link_to_sal, link_to_sge, log, method_missing, modify_hosts, module_eval, msgbox, mutex_lock, mutex_unlock, restore_hosts, seek, set_inventory_boxes, show_deprecated_log, track_autosort_state, track_autosort_state=, track_dark_mode, track_dark_mode=, track_layout_state, track_layout_state=, unlink_from_sal, unlink_from_sge, win32_launch_method, win32_launch_method=

Instance Method Details

#add_ordinals_to_duplicates(npc_list) ⇒ Array<String>

Adds ordinal numbers to duplicate NPC names in the list.

Examples:

add_ordinals_to_duplicates(['goblin', 'goblin', 'troll']) #=> ['1 goblin', '2 goblin', 'troll']

Parameters:

  • npc_list (Array<String>)

    The list of NPC names.

Returns:

  • (Array<String>)

    The list with ordinals added to duplicates.



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 174

def add_ordinals_to_duplicates(npc_list)
  flat_npcs = []

  npc_list.uniq.each do |npc|
    # Count how many times this NPC appears
    count = npc_list.count(npc)

    # Create entries with ordinals for duplicates
    count.times do |index|
      name = index.zero? ? npc : "#{$ORDINALS[index]} #{npc}"
      flat_npcs << name
    end
  end

  flat_npcs
end

#check_exp_modsString

Checks the experience modifiers currently in effect.

Examples:

check_exp_mods

Returns:

  • (String)

    The output of the command issued.



30
31
32
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 30

def check_exp_mods
  Lich::Util.issue_command("exp mods", /The following skills are currently under the influence of a modifier/, /^<output class=""/, quiet: true, include_end: false, usexml: false)
end

#clean_and_split(room_objs) ⇒ Array<String>

Cleans and splits room objects into an array.

Examples:

clean_and_split("You also see a dragon, a knight.") #=> ['a dragon', 'a knight']

Parameters:

  • room_objs (String)

    The string containing room objects.

Returns:

  • (Array<String>)

    An array of cleaned room object names.



56
57
58
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 56

def clean_and_split(room_objs)
  room_objs.sub(/You also see/, '').sub(/ with a [\w\s]+ sitting astride its back/, '').strip.split(/,|\sand\s/)
end

#clean_npc_string(npc_string) ⇒ Array<String>

Cleans and normalizes a list of NPC names.

Examples:

clean_npc_string(['goblin', 'goblin', 'troll']) #=> ['1 goblin', '2 goblin', 'troll']

Parameters:

  • npc_string (Array<String>)

    An array of NPC names.

Returns:

  • (Array<String>)

    A sorted array of cleaned NPC names with ordinals for duplicates.



113
114
115
116
117
118
119
120
121
122
123
124
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 113

def clean_npc_string(npc_string)
  # Normalize NPC names
  normalized_npcs = npc_string
                    .map { |obj| normalize_creature_names(obj) }
                    .map { |obj| remove_html_tags(obj) }
                    .map { |obj| extract_last_creature(obj) }
                    .map { |obj| extract_final_name(obj) }
                    .sort

  # Count occurrences and add ordinals
  add_ordinals_to_duplicates(normalized_npcs)
end

#convert2copper(amt, denomination) ⇒ Numeric

Converts a given amount to copper based on the denomination.

Examples:

convert2copper(10, 'gold') #=> 10000

Parameters:

  • amt (Numeric)

    The amount to convert.

  • denomination (String)

    The type of denomination (e.g., ‘platinum’, ‘gold’, ‘silver’, ‘bronze’).

Returns:

  • (Numeric)

    The equivalent amount in copper.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 12

def convert2copper(amt, denomination)
  if denomination =~ /platinum/
    (amt.to_i * 10_000)
  elsif denomination =~ /gold/
    (amt.to_i * 1000)
  elsif denomination =~ /silver/
    (amt.to_i * 100)
  elsif denomination =~ /bronze/
    (amt.to_i * 10)
  else
    amt
  end
end

#convert2plats(copper) ⇒ String

Converts a given amount of copper to various denominations.

Examples:

convert2plats(25000) #=> '2 platinum, 5 gold'

Parameters:

  • copper (Numeric)

    The amount of copper to convert.

Returns:

  • (String)

    A string representation of the amount in different denominations.



39
40
41
42
43
44
45
46
47
48
49
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 39

def convert2plats(copper)
  denominations = [[10_000, 'platinum'], [1000, 'gold'], [100, 'silver'], [10, 'bronze'], [1, 'copper']]
  denominations.inject([copper, []]) do |result, denomination|
    remaining = result.first
    display = result.last
    if remaining / denomination.first > 0
      display << "#{remaining / denomination.first} #{denomination.last}"
    end
    [remaining % denomination.first, display]
  end.last.join(', ')
end

#extract_final_name(text) ⇒ String

Extracts just the creature name from the text.

Examples:

extract_final_name("a goblin") #=> 'goblin'

Parameters:

  • text (String)

    The text containing the creature name.

Returns:

  • (String)

    The extracted creature name.



164
165
166
167
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 164

def extract_final_name(text)
  # Extract just the creature name (letters, hyphens, apostrophes)
  text.strip.scan(/[A-z'-]+$/).first
end

#extract_last_creature(text) ⇒ String

Extracts the last creature name from a string after ‘and’.

Examples:

extract_last_creature("a goblin and a troll") #=> 'a troll'

Parameters:

  • text (String)

    The text containing creature names.

Returns:

  • (String)

    The last creature name extracted.



154
155
156
157
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 154

def extract_last_creature(text)
  # Get the last creature name after "and", removing modifiers like "glowing with"
  text.split(/\sand\s/).last.sub(/(?:\sglowing)?\swith\s.*/, '')
end

#find_all_npcs(room_objs) ⇒ Array<String>

Finds all non-player characters (NPCs) in the room description.

Examples:

find_all_npcs("You also see a goblin, a troll.") #=> ['a goblin', 'a troll']

Parameters:

  • room_objs (String)

    The string containing room objects.

Returns:

  • (Array<String>)

    An array of NPC names.



103
104
105
106
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 103

def find_all_npcs(room_objs)
  room_objs.sub(/You also see/, '').sub(/ with a [\w\s]+ sitting astride its back/, '').strip
           .scan(%r{<pushBold/>[^<>]*<popBold/> which appears dead|<pushBold/>[^<>]*<popBold/> \(dead\)|<pushBold/>[^<>]*<popBold/>})
end

#find_dead_npcs(room_objs) ⇒ Array<String>

Finds all NPCs in the room that are dead.

Examples:

find_dead_npcs("You also see a goblin which appears dead, a troll.") #=> ['a goblin']

Parameters:

  • room_objs (String)

    The string containing room objects.

Returns:

  • (Array<String>)

    An array of dead NPC names.



206
207
208
209
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 206

def find_dead_npcs(room_objs)
  dead_npcs = find_all_npcs(room_objs).select { |obj| obj =~ /which appears dead|\(dead\)/ }
  clean_npc_string(dead_npcs)
end

#find_npcs(room_objs) ⇒ Array<String>

Finds all NPCs in the room that are not dead.

Examples:

find_npcs("You also see a goblin which appears dead, a troll.") #=> ['a troll']

Parameters:

  • room_objs (String)

    The string containing room objects.

Returns:

  • (Array<String>)

    An array of living NPC names.



196
197
198
199
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 196

def find_npcs(room_objs)
  npcs = find_all_npcs(room_objs).reject { |obj| obj =~ /which appears dead|\(dead\)/ }
  clean_npc_string(npcs)
end

#find_objects(room_objs) ⇒ Array<String>

Finds and cleans object names in the room description.

Examples:

find_objects("<pushBold/>a goblin<popBold/>, a troll.") #=> ['goblin', 'a troll']

Parameters:

  • room_objs (String)

    The string containing room objects.

Returns:

  • (Array<String>)

    An array of cleaned object names.



216
217
218
219
220
221
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 216

def find_objects(room_objs)
  room_objs.sub!("<pushBold/>a domesticated gelapod<popBold/>", 'domesticated gelapod')
  clean_and_split(room_objs)
    .reject { |obj| obj =~ /pushBold/ }
    .map { |obj| obj.sub(/\.$/, '').strip.sub(/^a /, '').strip.sub(/^some /, '') }
end

#find_pcs(room_players) ⇒ Array<String>

Finds player characters in the room description.

Examples:

find_pcs("John who is glowing, Mary who is sitting") #=> ['John', 'Mary']

Parameters:

  • room_players (String)

    The string containing room players.

Returns:

  • (Array<String>)

    An array of player character names.



65
66
67
68
69
70
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 65

def find_pcs(room_players)
  room_players.sub(/ and (.*)$/) { ", #{Regexp.last_match(1)}" }
              .split(', ')
              .map { |obj| obj.sub(/ (who|whose body)? ?(has|is|appears|glows) .+/, '').sub(/ \(.+\)/, '') }
              .map { |obj| obj.strip.scan(/\w+$/).first }
end

#find_pcs_prone(room_players) ⇒ Array<String>

Finds player characters that are lying down in the room description.

Examples:

find_pcs_prone("John who is lying down, Mary who is sitting") #=> ['John']

Parameters:

  • room_players (String)

    The string containing room players.

Returns:

  • (Array<String>)

    An array of prone player character names.



77
78
79
80
81
82
83
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 77

def find_pcs_prone(room_players)
  room_players.sub(/ and (.*)$/) { ", #{Regexp.last_match(1)}" }
              .split(', ')
              .select { |obj| obj =~ /who is lying down/i }
              .map { |obj| obj.sub(/ who (has|is) .+/, '').sub(/ \(.+\)/, '') }
              .map { |obj| obj.strip.scan(/\w+$/).first }
end

#find_pcs_sitting(room_players) ⇒ Array<String>

Finds player characters that are sitting in the room description.

Examples:

find_pcs_sitting("John who is sitting, Mary who is standing") #=> ['John']

Parameters:

  • room_players (String)

    The string containing room players.

Returns:

  • (Array<String>)

    An array of sitting player character names.



90
91
92
93
94
95
96
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 90

def find_pcs_sitting(room_players)
  room_players.sub(/ and (.*)$/) { ", #{Regexp.last_match(1)}" }
              .split(', ')
              .select { |obj| obj =~ /who is sitting/i }
              .map { |obj| obj.sub(/ who (has|is) .+/, '').sub(/ \(.+\)/, '') }
              .map { |obj| obj.strip.scan(/\w+$/).first }
end

#normalize_creature_names(text) ⇒ String

Normalizes specific creature names in the text.

Examples:

normalize_creature_names("an alfar warrior") #=> 'alfar warrior'

Parameters:

  • text (String)

    The text containing creature names.

Returns:

  • (String)

    The normalized text.



131
132
133
134
135
136
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 131

def normalize_creature_names(text)
  text
    .sub(/.*alfar warrior.*/, 'alfar warrior')
    .sub(/.*sinewy leopard.*/, 'sinewy leopard')
    .sub(/.*lesser naga.*/, 'lesser naga')
end

#remove_html_tags(text) ⇒ String

Removes HTML tags from the given text.

Examples:

remove_html_tags("<pushBold/>a goblin<popBold/>") #=> 'a goblin'

Parameters:

  • text (String)

    The text containing HTML tags.

Returns:

  • (String)

    The text without HTML tags.



143
144
145
146
147
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 143

def remove_html_tags(text)
  text
    .sub('<pushBold/>', '')
    .sub(%r{<popBold/>.*}, '')
end