Merge pull request 'Limit capped qualities to max. 70 CP' (#1) from dot_sent/fallen_london_scripts:master into master

Reviewed-on: audrey/fallen_london_scripts#1
This commit is contained in:
audrey 2021-09-17 12:05:11 +02:00
commit b3d49a9805

View File

@ -8,7 +8,7 @@
// @name FallenLondon Enhancer
// @namespace https://forge.chapril.org/audrey/
// @require https://forge.chapril.org/audrey/fallen_london_scripts/raw/branch/master/jquery/jquery-3.6.0.min.js
// @version 0.1-rc1
// @version 0.1-rc2
// ==/UserScript==
"use strict";
@ -203,12 +203,18 @@ function cleanup() {
}
function display_stats_progress() {
const capped_qualities = ["Dangerous", "Persuasive", "Shadowy", "Watchful"];
$('ul.items--list li.sidebar-quality').each( function( index, element ){
bar = $( this ).find('div.progress-bar');
percent = bar.find('span').prop('style').width.slice(0, -1);
lvl = Number($( this ).find('span.item__value').text());
quality = $( this ).find('span.item__name').text();
target = lvl + 1;
lvl_pts = Math.round(lvl * target / 2);
if (capped_qualities.includes(quality) && target > 70) {
target = 70;
lvl_pts = 2485 + (lvl-70) * 70;
}
CP = Math.round(target * percent / 100);
points = Math.round(lvl_pts + CP);
bar.html( bar.html() + '<span style="color:grey; font-size:75%;">' + points + ' (' + lvl_pts + '+' + CP + '/' + target + ')</span>' );