Skip to content

Commit

Permalink
Updating to fix issues where prices were not respected
Browse files Browse the repository at this point in the history
  • Loading branch information
nicleary committed Jan 12, 2023
1 parent 3723cde commit babc5e5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion shop-generator/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"esmodules": [
"modules/main.js"
],
"version": "1.0.3",
"version": "1.0.4",
"compatibility": {
"minimum": "9",
"verified": "10"
Expand Down
1 change: 0 additions & 1 deletion shop-generator/modules/compendium.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export async function mapCompendiumContentsToRarity(compendiumName, shopType) {
hasWarnings = true;
continue
}
console.error(item);
const rarity = item.system[rarityOrLevel].toString().toLowerCase();
if (rarity === "artifact") {
consoleLogging(`${item.name} is an artifact, skipping`, "warn");
Expand Down
4 changes: 2 additions & 2 deletions shop-generator/modules/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {Constants} from "./values.js";
import {mapCompendiumContentsToRarity} from "./compendium.js";
import {getRandomInt, getRandomItemsWithDuplicates, getRandomItemsWithoutDuplication, getRandomItemWithChance} from "./utils/generator_utils.js";
import { getRarities } from "./utils/compendium_utils.js";
import { getObjectPrice } from "./utils/pricing.js";

export async function generateItemShop(shopSettings, type) {
console.error(shopSettings);
// Initialize the chat message
let chatMessage = "<h1>Shop Contents</h1>";
// Get the compendium's contents as a map of rarities to arrays of items
Expand All @@ -29,7 +29,7 @@ export async function generateItemShop(shopSettings, type) {
chatMessage = chatMessage.concat(`<h2>${rarities[rarity]}:</h2><br/><table><tr><td>Item</td><td>Quantity</td><td>Price</td></tr>`);
// Iterate through each item, then add them to the table
for (const item of Object.keys(items)) {
chatMessage = chatMessage.concat(`<tr><td>${items[item].value.name}</td><td>${items[item].quantity}</td><td>${items[item].price}</td></tr>`);
chatMessage = chatMessage.concat(`<tr><td>${items[item].value.name}</td><td>${items[item].quantity}</td><td>${getObjectPrice(items[item].value, type)}</td></tr>`);
}
chatMessage = chatMessage.concat(`</table>`);
}
Expand Down
2 changes: 1 addition & 1 deletion shop-generator/modules/presets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.3",
"version": "1.0.4",
"presets": {
"potion": {
"metropolis": {
Expand Down
4 changes: 2 additions & 2 deletions shop-generator/modules/utils/pricing.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ export function getObjectPrice(item, type) {
}
}
// If the price override isn't valid or the price doesn't exist, then we try to return item price
if (item.system.price !== null) {
return item.system.price;
if (item.system.price.value !== null && item.system.price.value !== 0) {
return item.system.price.value;
}
// If the price is null, then return -1 to signify we don't have a price
return -1
Expand Down

0 comments on commit babc5e5

Please sign in to comment.