diff --git a/app/encounter-builder/monster-table.html b/app/encounter-builder/monster-table.html index c3f72532..e5825bca 100644 --- a/app/encounter-builder/monster-table.html +++ b/app/encounter-builder/monster-table.html @@ -33,6 +33,13 @@ + + + + {{ vm.monsters | countHiddenMonstersFilter:vm.filters }} monsters hidden by filters or in unselected sources + + + + diff --git a/scripts/monsterfactory.js b/scripts/monsterfactory.js index 93b1e37b..34e6ed00 100644 --- a/scripts/monsterfactory.js +++ b/scripts/monsterfactory.js @@ -8,6 +8,7 @@ function MonsterFactory(alignments, crInfo) { var factory = { checkMonster: checkMonster, + checkIsMonsterFoundAndFiltered: checkIsMonsterFoundAndFiltered, Monster: Monster, }; @@ -159,6 +160,14 @@ }; var lastRegex = regexCache[""]; function checkMonster(monster, filters, args) { + return !isFiltered(monster, filters, args) && isNameMatched(monster, filters); + } + + function checkIsMonsterFoundAndFiltered(monster, filters, args) { + return isNameMatched(monster, filters) && isFiltered(monster, filters, args); + } + + function isFiltered(monster, filters, args) { args = args || {}; var legendaryMap = { @@ -171,52 +180,56 @@ var legendaryFilter = legendaryMap[filters.legendary]; if (legendaryFilter) { - if (!monster[legendaryFilter]) return false; + if (!monster[legendaryFilter]) return true; } else { - if (monster.legendary || monster.lair) return false; + if (monster.legendary || monster.lair) return true; } } if ( filters.type && monster.type !== filters.type ) { - return false; + return true; } if ( filters.size && monster.size !== filters.size ) { - return false; + return true; } if ( args.nonUnique && monster.unique ) { - return false; + return true; } if ( filters.alignment ) { if ( !monster.alignment ) { - return false; + return true; } if ( ! (filters.alignment.flags & monster.alignment.flags) ) { - return false; + return true; } } if ( !args.skipCrCheck ) { if ( filters.minCr && monster.cr.numeric < filters.minCr ) { - return false; + return true; } if ( filters.maxCr && monster.cr.numeric > filters.maxCr ) { - return false; + return true; } } if ( filters.environment && monster.environments.indexOf(filters.environment) === -1 ) { - return false; + return true; } if ( !isInSource(monster, filters.source) ) { - return false; + return true; } + return false; + } + + function isNameMatched(monster, filters) { if ( filters.search ) { let checkRegex = filters.search.match(/^\/(.*?)\/?$/); if ( checkRegex ) { @@ -254,7 +267,6 @@ } else if ( monster.searchable.indexOf(filters.search.toLowerCase()) === -1 ) { return false; } - } return true; diff --git a/styles/style.css b/styles/style.css index 5136106f..287e4f07 100755 --- a/styles/style.css +++ b/styles/style.css @@ -7557,6 +7557,10 @@ button.close { display: none; } .monster-table--source-name__long { display: inline; } } + .monster-table--filter-warning-cell { + background-color: #faf2cc; + text-align: center; + font-style: italic; } @media (max-width: 768px) { .monster-table--table { @@ -7572,6 +7576,12 @@ button.close { min-height: 100px; } .monster-table--row:not(:last-child) { border-bottom: 1px solid #ddd; } + .monster-table--warning-row { + display: block; + position: relative; } + .monster-table--warning-row:not(:last-child) { + border-bottom: 1px solid #ddd; } + .monster-table--filter-warning-cell.monster-table--filter-warning-cell, .monster-table--button-cell.monster-table--button-cell, .monster-table--name-cell.monster-table--name-cell, .monster-table--cr-cell.monster-table--cr-cell, @@ -7583,6 +7593,8 @@ button.close { border: 0; padding: 0; margin: 0 3px; } + .monster-table--filter-warning-cell.monster-table--filter-warning-cell { + width: 100%; } .monster-table--name-cell.monster-table--name-cell { display: block; font-size: 1.25em; }