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.
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.
[ '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.
[ '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.
{ "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.
['Crossings', 'Dirge', 'Ilaya Taipa', 'Leth Deriel']
- LIRUM_BANKS =
Array of bank names in the Lirum region.
["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.
["Ain Ghazal", "Boar Clan", "Chyolvea Tayeu'a", "Hibarnhvidar", "Fang Cove", "Raven's Point", "Shard"]
- BANK_TITLES =
Hash mapping bank names to their 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.
{ "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.
1000
Instance Method Summary collapse
-
#add_ordinals_to_duplicates(npc_list) ⇒ Array<String>
Adds ordinal numbers to duplicate NPC names in the list.
-
#check_exp_mods ⇒ String
Checks the experience modifiers currently in effect.
-
#clean_and_split(room_objs) ⇒ Array<String>
Cleans and splits room objects into an array.
-
#clean_npc_string(npc_string) ⇒ Array<String>
Cleans and normalizes a list of NPC names.
-
#convert2copper(amt, denomination) ⇒ Numeric
Converts a given amount to copper based on the denomination.
-
#convert2plats(copper) ⇒ String
Converts a given amount of copper to various denominations.
-
#extract_final_name(text) ⇒ String
Extracts just the creature name from the text.
-
#extract_last_creature(text) ⇒ String
Extracts the last creature name from a string after ‘and’.
-
#find_all_npcs(room_objs) ⇒ Array<String>
Finds all non-player characters (NPCs) in the room description.
-
#find_dead_npcs(room_objs) ⇒ Array<String>
Finds all NPCs in the room that are dead.
-
#find_npcs(room_objs) ⇒ Array<String>
Finds all NPCs in the room that are not dead.
-
#find_objects(room_objs) ⇒ Array<String>
Finds and cleans object names in the room description.
-
#find_pcs(room_players) ⇒ Array<String>
Finds player characters in the room description.
-
#find_pcs_prone(room_players) ⇒ Array<String>
Finds player characters that are lying down in the room description.
-
#find_pcs_sitting(room_players) ⇒ Array<String>
Finds player characters that are sitting in the room description.
-
#normalize_creature_names(text) ⇒ String
Normalizes specific creature names in the text.
-
#remove_html_tags(text) ⇒ String
Removes HTML tags from the given text.
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.
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_mods ⇒ String
Checks the experience modifiers currently in effect.
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.
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.
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| (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.
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.
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.
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’.
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.
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.
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.
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.
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.
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.
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.
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.
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.
143 144 145 146 147 |
# File 'documented/dragonrealms/drinfomon/drdefs.rb', line 143 def (text) text .sub('<pushBold/>', '') .sub(%r{<popBold/>.*}, '') end |