Skip to content

Commit

Permalink
Merge pull request #72 from BlitzKraig/master
Browse files Browse the repository at this point in the history
Option for larger price modifiers
  • Loading branch information
jopeek authored Dec 13, 2020
2 parents 0414a67 + 59be6ab commit 4da6874
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions lootsheetnpc5e.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,16 @@ class LootSheet5eNPC extends ActorSheet5eNPC {

priceModifier = Math.round(priceModifier * 100);

var maxPriceModifier = await game.settings.get("lootsheetnpc5e", "maxPriceModifier");

if (!maxPriceModifier){
maxPriceModifier = 200;
}

var html = "<p>Use this slider to increase or decrease the price of all items in this inventory. <i class='fa fa-question-circle' title='This uses a percentage factor where 100% is the current price, 0% is 0, and 200% is double the price.'></i></p>";
html += '<p><input name="price-modifier-percent" id="price-modifier-percent" type="range" min="0" max="200" value="'+priceModifier+'" class="slider"></p>';
html += '<p><label>Percentage:</label> <input type=number min="0" max="200" value="'+priceModifier+'" id="price-modifier-percent-display"></p>';
html += '<script>var pmSlider = document.getElementById("price-modifier-percent"); var pmDisplay = document.getElementById("price-modifier-percent-display"); pmDisplay.value = pmSlider.value; pmSlider.oninput = function() { pmDisplay.value = this.value; }; pmDisplay.oninput = function() { pmSlider.value = this.value; };</script>';
html += '<p><input name="price-modifier-percent" id="price-modifier-percent" type="range" min="0" max="' + maxPriceModifier + '" value="' + priceModifier + '" class="slider"></p>';
html += '<p><label>Percentage:</label> <input type=number min="0" max="' + maxPriceModifier + '" value="' + priceModifier + '" id="price-modifier-percent-display"></p>';
html += '<script>var pmSlider = document.getElementById("price-modifier-percent"); var pmDisplay = document.getElementById("price-modifier-percent-display"); pmDisplay.value = pmSlider.value; pmSlider.onchange = function() { pmDisplay.value = this.value; }; pmDisplay.oninput = function() { pmSlider.value = this.value; };</script>';

let d = new Dialog({
title: "Price Modifier",
Expand Down Expand Up @@ -1129,6 +1135,20 @@ Hooks.once("init", () => {
type: Boolean
});

game.settings.register("lootsheetnpc5e", "maxPriceModifier", {
name: "Max price modifier percentage",
hint: "Increasing this will allow a higher price modifier to be used for merchant sheets",
scope: "world",
config: true,
type: Number,
range: {
min: 200,
max: 10000,
step: 100
},
default: 200
});

function chatMessage (speaker, owner, message, item) {
if (game.settings.get("lootsheetnpc5e", "buyChat")) {
message = `
Expand Down

0 comments on commit 4da6874

Please sign in to comment.