Skip to content

Commit

Permalink
3 beta release
Browse files Browse the repository at this point in the history
  • Loading branch information
Plushtoast committed Dec 16, 2021
1 parent f10a93f commit ffcc040
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion modules/actor/merchant-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,18 @@ export default class MerchantSheetDSA5 extends ActorSheetdsa5NPC {
if (!itemLibrary.equipmentBuild) {
await itemLibrary.buildEquipmentIndex()
}

let items = []
for (let cat of categories) {
items.push(...await itemLibrary.getRandomItems(cat, numbers[cat]))
}

var seen = {}
items = items.filter(function(x) {
const domain = getProperty(x, "data.data.effect.attributes") || ""
const price = Number(getProperty(x, "data.data.price.value")) || 0
if (domain != "" || price > 10000) return false

let seeName = `${x.type}_${x.name}`
return (seen.hasOwnProperty(seeName) ? false : (seen[seeName] = true)) && actor.data.items.filter(function(y) {
return y.type == x.type && y.name == x.name
Expand All @@ -275,7 +281,7 @@ export default class MerchantSheetDSA5 extends ActorSheetdsa5NPC {
async removeAllGoods(actor, ev) {
let text = $(ev.currentTarget).text()
$(ev.currentTarget).html(' <i class="fa fa-spin fa-spinner"></i>')
let ids = actor.items.filter(x => ["poison", "consumable", "equipment","plant", "ammunition"].includes(x.type)).map(x => x.id)
let ids = actor.items.filter(x => ["poison", "consumable", "equipment", "plant", "ammunition"].includes(x.type)).map(x => x.id)
ids.push(...actor.items.filter(x => ["armor", "meleeweapon", "rangeweapon"].includes(x.type) && !x.data.data.worn.value).map(x => x.id))
await actor.deleteEmbeddedDocuments("Item", ids);
$(ev.currentTarget).text(text)
Expand Down
1 change: 1 addition & 0 deletions modules/system/itemlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ export default class DSA5ItemLibrary extends Application {
async getRandomItems(category, limit) {
let filteredItems = []
let index = this.equipmentIndex

filteredItems.push(...(await index.search(category, { field: ["itemType"] })))
return await Promise.all(this.shuffle(filteredItems.filter(x => x.hasPermission)).slice(0, limit).map(x => x.getItem()))
}
Expand Down
2 changes: 1 addition & 1 deletion modules/system/migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function migrateWorld() {
Hooks.once("ready", async function() {
if (!game.user.isGM) return

await ChatMessage.create(DSA5_Utility.chatDataSetup("<h3>TDE for Foundry 9 is still in beta test. Please report bugs in <a href=\"https://github.com/Plushtoast/dsa5-foundryVTT/issues\">Github</a>.</h3>", "roll"))
//await ChatMessage.create(DSA5_Utility.chatDataSetup("<h3>TDE for Foundry 9 is still in beta test. Please report bugs in <a href=\"https://github.com/Plushtoast/dsa5-foundryVTT/issues\">Github</a>.</h3>", "roll"))

await setupDefaulTokenConfig()
const currentVersion = await game.settings.get("dsa5", "migrationVersion")
Expand Down

0 comments on commit ffcc040

Please sign in to comment.