add gold calculator and swpf actions #32
@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## 1.1.0
|
||||
|
||||
### Added
|
||||
|
||||
- gold calculator macro for SWPF gold items
|
||||
- Actions for common rolls with links to SWPF rules
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Fixed
|
||||
|
||||
33
macros/gold-calculator.js
Normal file
33
macros/gold-calculator.js
Normal file
@ -0,0 +1,33 @@
|
||||
let tokens = []
|
||||
if (canvas.tokens.controlled.length > 0) {
|
||||
tokens = canvas.tokens.controlled
|
||||
}
|
||||
if (tokens.length > 0) {
|
||||
main(tokens)
|
||||
} else {
|
||||
ui.notifications.error('Please select or target a token')
|
||||
}
|
||||
|
||||
async function main (tokens) {
|
||||
const currencies = ['Copper', 'Silver', 'Gold', 'Platinum']
|
||||
let template = '<div><table><thead><tr><th>Actor</th><th>Currency</th></tr></thead><tbody>'
|
||||
const fmtOptions = {
|
||||
minimumIntegerDigits: 1,
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
}
|
||||
const fmt = Intl.NumberFormat('en-US', fmtOptions)
|
||||
for (const token of tokens) {
|
||||
const actor = token.actor
|
||||
let total = 0
|
||||
for (const item of actor.items.filter(i => currencies.indexOf(i.name) > -1)) {
|
||||
total += item.system.price * item.system.quantity
|
||||
}
|
||||
template += `<tr><td>${actor.name}</td><td>${fmt.format::(total)}</td></tr>`
|
||||
}
|
||||
template += '</thead></tbody>'
|
||||
Dialog.prompt({
|
||||
title: 'Currency Totals',
|
||||
content: template
|
||||
})
|
||||
}
|
||||
14
module.json
14
module.json
@ -3,7 +3,7 @@
|
||||
"name": "SWADE Helpers (MB)",
|
||||
"title": "SWADE Helpers (MB)",
|
||||
"description": "Mike's collection of swade helpers",
|
||||
"version": "1.0.1",
|
||||
"version": "1.1.0",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mike"
|
||||
@ -30,6 +30,18 @@
|
||||
"label": "SWADE MB Effect Macros",
|
||||
"path": "./packs/effect-macros.db",
|
||||
"type": "Macro"
|
||||
},
|
||||
{
|
||||
"name": "helper-macros",
|
||||
"label": "SWADE MB Helper Macros",
|
||||
"path": "./packs/helper-macros.db",
|
||||
"type": "Macro"
|
||||
},
|
||||
{
|
||||
"name": "Common Actions",
|
||||
"label": "SWADE MB Common Actions",
|
||||
"path": "./packs/common-actions.db",
|
||||
"type": "Item"
|
||||
}
|
||||
],
|
||||
"relationships": {
|
||||
|
||||
8
packs/common-actions.db
Normal file
8
packs/common-actions.db
Normal file
File diff suppressed because one or more lines are too long
1
packs/helper-macros.db
Normal file
1
packs/helper-macros.db
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user