Skip to content

Commit

Permalink
Fix - grab spell tooltip data from monster page since it's incorrect …
Browse files Browse the repository at this point in the history
…in encounter tool/MAPS
  • Loading branch information
Azmoria committed Feb 16, 2025
1 parent 39b931b commit 7b9332b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions EncounterHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ async function fetch_monsters(monsterIds, callback, open5e=false) {
monsterData[i].treasure = treasure;
monsterData[i].gear = gear;
}
let spellTooltips = $(moreInfo)?.find('[class*="mon-stat-block-2024"] .spell-tooltip')
monsterData[i].spellTooltips = spellTooltips;
resolve();
}))

Expand Down
26 changes: 19 additions & 7 deletions MonsterStatBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ function build_monster_stat_block(statBlock, token) {
if (!statBlock.userHasAccess) {
return `<div id='noAccessToContent' style='height: 100%;text-align: center;width: 100%;padding: 10px;font-weight: bold;color: #944;'>You do not have access to this content on DndBeyond.</div>`;
}

let statblockData = '';
if(get_avtt_setting_value('statBlockStyle') == 0 && statBlock.data.initiativeMod != undefined || get_avtt_setting_value('statBlockStyle') == 2){
return `
statblockData = `
<div class="container avtt-stat-block-container ${(statBlock.data.slug) ? 'open5eMonster' : ''}">
<div id="content" class="main content-container" style="padding:0!important">
<section class="primary-content" role="main">
Expand Down Expand Up @@ -478,7 +478,7 @@ function build_monster_stat_block(statBlock, token) {
`
}
else{
return `
statblockData = `
<div class="container avtt-stat-block-container ${(statBlock.data.slug) ? 'open5eMonster' : ''}">
<div id="content" class="main content-container" style="padding:0!important">
<section class="primary-content" role="main">
Expand Down Expand Up @@ -768,15 +768,20 @@ function build_monster_stat_block(statBlock, token) {
</div>
`;
}


let $stat = $(statblockData); //spell tooltip data is incorrect in 2024 monsters - grab from monster page until fixed in monster api for encounter tool/MAPS
$stat.find('.spell-tooltip').each((index, tooltip) =>{
$(tooltip).attr('data-tooltip-href', $(statBlock.data.spellTooltips[index]).attr('data-tooltip-href'))
$(tooltip).attr('href', $(statBlock.data.spellTooltips[index]).attr('href'))
})
return $stat[0].outerHTML;
}
function build_monster_copy_stat_block(statBlock) {
if (!statBlock.userHasAccess) {
return `<div id='noAccessToContent' style='height: 100%;text-align: center;width: 100%;padding: 10px;font-weight: bold;color: #944;'>You do not have access to this content on DndBeyond.</div>`;
}
let statblockData = '';
if(get_avtt_setting_value('statBlockStyle') == 0 && statBlock.data.initiativeMod != undefined || get_avtt_setting_value('statBlockStyle') == 2){
return `
statblockData = `
<div id="content" class="main content-container" style="padding:0!important">
<section class="primary-content" role="main">
Expand Down Expand Up @@ -1032,7 +1037,7 @@ function build_monster_copy_stat_block(statBlock) {
`
}
else{
return `
statblockData = `
<div id="content" class="main content-container" style="padding:0!important">
<section class="primary-content" role="main">
Expand Down Expand Up @@ -1286,6 +1291,13 @@ function build_monster_copy_stat_block(statBlock) {
</div>
`;
}

let $stat = $(statblockData); //spell tooltip data is incorrect in 2024 monsters - grab from monster page until fixed in monster api for encounter tool/MAPS
$stat.find('.spell-tooltip').each((index, tooltip) =>{
$(tooltip).attr('data-tooltip-href', $(statBlock.data.spellTooltips[index]).attr('data-tooltip-href'))
$(tooltip).attr('href', $(statBlock.data.spellTooltips[index]).attr('href'))
})
return $stat[0].outerHTML;
}
class MonsterStatBlock {
constructor(data) {
Expand Down

0 comments on commit 7b9332b

Please sign in to comment.