Widget:PriceCalculator: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
(Visual changes.)
(Use math.round)
 
(3 intermediate revisions by the same user not shown)
Line 57: Line 57:
         let get_value = (selector) => document.querySelector(selector).value;
         let get_value = (selector) => document.querySelector(selector).value;
         let item_value = sanitize(get_value('#item-value'));
         let item_value = sanitize(get_value('#item-value'));
         let persuasion_mod = sanitize(get_value('#persuasion-mod')) * 0.05;
         let persuasion_mod = sanitize(get_value('#persuasion-mod')) * 0.1;
         let attitude = sanitize(get_value('#attitude')) * 0.0025;
         let attitude = sanitize(get_value('#attitude')) * 0.005;
         let difficulty = document.querySelector('input[name="difficulty"]:checked').value;
         let difficulty = document.querySelector('input[name="difficulty"]:checked').value;
         difficulty = get_difficulty_mod(difficulty)
         difficulty = get_difficulty_mod(difficulty)
          
          
         let price_mod = Math.max(1.0, 2.5 - persuasion_mod - attitude - difficulty);
         let price_mod = Math.max(1.0, 2.5 - persuasion_mod - attitude - difficulty);
         let price_buy = Math.floor(item_value * price_mod);
         let price_buy = Math.round(item_value * price_mod);
         let price_sell = Math.floor(item_value / price_mod);
         let price_sell = Math.round(item_value / price_mod);
         output.textContent = '';
         output.textContent = '';
         let table = document.createElement('table');
         let table = document.createElement('table');
Line 75: Line 75:
</script>
</script>
</includeonly>
</includeonly>
<noinclude>{{#widget:PriceCalculator}}</noinclude>
<noinclude>{{PageSeo
| title = Widget:PriceCalculator
| description = Price calculator for determining the buy & sell price of items.
}}{{#widget:PriceCalculator}}</noinclude>

Latest revision as of 22:37, 22 November 2023