diff --git a/CHANGELOG.md b/CHANGELOG.md index a10a0ac..b9b472f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Power Effect for Havoc +- Power Effect Macro for Havoc +- Power Effect Action for Havoc +- New Macro: Request Roll + - NEW DEPENDENCY: socketlib +- Documentation: + - API Documentation + - Request Roll macro documentation + ## 2.1.0 ### Changed diff --git a/macros/requestDialog.js b/macros/requestDialog.js new file mode 100644 index 0000000..4372f1a --- /dev/null +++ b/macros/requestDialog.js @@ -0,0 +1,70 @@ +const requestRollFromTokens = game.modules.get('swade-mb-helpers').api.requestRollFromTokens + +async function main () { + let tokens = Array.from(game.user.targets) + if (tokens.length < 1) { + tokens = canvas.tokens.controlled + } + if (tokens.length < 1) { + ui.notifications.error('Please target or select some tokens') + return + } + + const menuData = { + inputs: [ + { type: 'info', label: `Requesting roll from ${tokens.map(t => t.name).join(', ')}` }, + { + type: 'select', + label: 'Trait to roll', + options: [] + }, + { type: 'number', label: 'Roll Modifier', options: 0 }, + { type: 'text', label: 'Roll Modifier Description', options: 'Roll Modifier' } + ], + buttons: [ + { label: 'Request roll', value: 'ok', default: true }, + { label: 'Cancel', value: 'cancel' } + ] + } + const menuConfig = { + title: 'Request roll...' + } + for (const attribute of ['Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor']) { + menuData.inputs[1].options.push( + { html: `Attribute | ${attribute}`, value: `a|${attribute}` } + ) + } + const skillSet = new Set() + for (const token of tokens) { + const skills = token.actor.items.filter(i => i.type === 'skill' && + !['Untrained', 'Unskilled Attempt'].includes(i.name)) + for (const skill of skills) { + skillSet.add(skill.name) + } + } + for (const skill of Array.from(skillSet).sort()) { + menuData.inputs[1].options.push( + { html: `Skill | ${skill}`, value: `s|${skill}` }) + } + menuData.inputs[1].options.push( + { html: 'Skill | Untrained', value: 's|NOSKILL' }) + const result = await warpgate.menu(menuData, menuConfig) + + if (result.buttons !== 'ok') { + return + } + console.log(result) + const rollMod = result.inputs[2] + const rollModDesc = result.inputs[3] + const rollParts = result.inputs[1].split('|') + const rollType = (rollParts[0] === 'a' ? 'attribute' : 'skill') + const rollDesc = rollParts[1] + const options = {} + if (rollMod !== 0) { + options.mods = [{ label: rollModDesc, value: rollMod }] + } + + requestRollFromTokens(tokens, rollType, rollDesc, options) +} + +main() diff --git a/module.json b/module.json index 636b2b5..2733081 100644 --- a/module.json +++ b/module.json @@ -15,6 +15,7 @@ "esmodules": [ "scripts/module.js" ], + "socket": true, "packs": [ { "name": "module-docs", @@ -54,11 +55,22 @@ "label": "SWADE MB Helper Actors", "path": "packs/helper-actors", "type": "Actor", + "system": "swade", "ownership": { "PLAYER": "OBSERVER", "ASSISTANT": "OWNER" - }, - "system": "swade" + } + }, + { + "name": "swade-mb-gear", + "label": "SWADE MB Gear", + "path": "packs/gear", + "type": "Item", + "system": "swade", + "ownership": { + "PLAYER": "OBSERVER", + "ASSISTANT": "OWNER" + } } ], "packFolders": [ @@ -71,7 +83,8 @@ "module-docs", "helper-macros", "helper-actors", - "Common Actions" + "Common Actions", + "swade-mb-gear" ] } ], @@ -94,6 +107,10 @@ "compatibility": { "verified": "1.16.2" } + }, + { + "id": "socketlib", + "type": "module" } ], "recommends": [ diff --git a/packs/common-actions/000169.ldb b/packs/common-actions/000169.ldb deleted file mode 100644 index 7d7fc35..0000000 Binary files a/packs/common-actions/000169.ldb and /dev/null differ diff --git a/packs/common-actions/000215.ldb b/packs/common-actions/000215.ldb new file mode 100644 index 0000000..7400b24 Binary files /dev/null and b/packs/common-actions/000215.ldb differ diff --git a/packs/common-actions/CURRENT b/packs/common-actions/CURRENT index 301747a..12fd282 100644 --- a/packs/common-actions/CURRENT +++ b/packs/common-actions/CURRENT @@ -1 +1 @@ -MANIFEST-000170 +MANIFEST-000211 diff --git a/packs/common-actions/LOG b/packs/common-actions/LOG index a5697e4..c1deeb5 100644 --- a/packs/common-actions/LOG +++ b/packs/common-actions/LOG @@ -1,8 +1,15 @@ -2023/11/07-23:29:20.343335 7f46667fc640 Recovering log #167 -2023/11/07-23:29:20.345329 7f46667fc640 Delete type=0 #167 -2023/11/07-23:29:20.345336 7f46667fc640 Delete type=3 #165 -2023/11/07-23:29:29.393563 7f46649f4640 Level-0 table #173: started -2023/11/07-23:29:29.393574 7f46649f4640 Level-0 table #173: 0 bytes OK -2023/11/07-23:29:29.394638 7f46649f4640 Delete type=0 #171 -2023/11/07-23:29:29.396575 7f46649f4640 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items!xA7qKMmugJv7z6j1' @ 0 : 0; will stop at (end) -2023/11/07-23:29:29.396609 7f46649f4640 Manual compaction at level-1 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items!xA7qKMmugJv7z6j1' @ 0 : 0; will stop at (end) +2023/11/20-21:06:40.386610 7f1f87fff640 Recovering log #209 +2023/11/20-21:06:40.392165 7f1f87fff640 Delete type=0 #209 +2023/11/20-21:06:40.392245 7f1f87fff640 Delete type=3 #207 +2023/11/20-21:52:53.117342 7f1f7fab1640 Level-0 table #214: started +2023/11/20-21:52:53.119155 7f1f7fab1640 Level-0 table #214: 1361 bytes OK +2023/11/20-21:52:53.120662 7f1f7fab1640 Delete type=0 #212 +2023/11/20-21:52:53.122863 7f1f7fab1640 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items!xA7qKMmugJv7z6j1' @ 0 : 0; will stop at (end) +2023/11/20-21:52:53.123064 7f1f7fab1640 Manual compaction at level-1 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items!xA7qKMmugJv7z6j1' @ 0 : 0; will stop at '!items!6fkUnnyILsETRfjI' @ 267 : 1 +2023/11/20-21:52:53.123073 7f1f7fab1640 Compacting 1@1 + 1@2 files +2023/11/20-21:52:53.125481 7f1f7fab1640 Generated table #215@1: 23 keys, 11463 bytes +2023/11/20-21:52:53.125500 7f1f7fab1640 Compacted 1@1 + 1@2 files => 11463 bytes +2023/11/20-21:52:53.126584 7f1f7fab1640 compacted to: files[ 0 0 1 0 0 0 0 ] +2023/11/20-21:52:53.126649 7f1f7fab1640 Delete type=2 #214 +2023/11/20-21:52:53.126731 7f1f7fab1640 Delete type=2 #194 +2023/11/20-21:52:53.130970 7f1f7fab1640 Manual compaction at level-1 from '!items!6fkUnnyILsETRfjI' @ 267 : 1 .. '!items!xA7qKMmugJv7z6j1' @ 0 : 0; will stop at (end) diff --git a/packs/common-actions/LOG.old b/packs/common-actions/LOG.old index de1ee9f..8cfcbe5 100644 --- a/packs/common-actions/LOG.old +++ b/packs/common-actions/LOG.old @@ -1,15 +1,8 @@ -2023/11/07-17:50:41.783626 7f4666ffd640 Recovering log #163 -2023/11/07-17:50:41.785537 7f4666ffd640 Delete type=0 #163 -2023/11/07-17:50:41.785550 7f4666ffd640 Delete type=3 #161 -2023/11/07-23:29:14.520879 7f46649f4640 Level-0 table #168: started -2023/11/07-23:29:14.522237 7f46649f4640 Level-0 table #168: 19378 bytes OK -2023/11/07-23:29:14.523105 7f46649f4640 Delete type=0 #166 -2023/11/07-23:29:14.524999 7f46649f4640 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items!xA7qKMmugJv7z6j1' @ 0 : 0; will stop at (end) -2023/11/07-23:29:14.526907 7f46649f4640 Manual compaction at level-1 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items!xA7qKMmugJv7z6j1' @ 0 : 0; will stop at '!items!xA7qKMmugJv7z6j1' @ 219 : 1 -2023/11/07-23:29:14.526908 7f46649f4640 Compacting 1@1 + 1@2 files -2023/11/07-23:29:14.527704 7f46649f4640 Generated table #169@1: 21 keys, 9211 bytes -2023/11/07-23:29:14.527711 7f46649f4640 Compacted 1@1 + 1@2 files => 9211 bytes -2023/11/07-23:29:14.528471 7f46649f4640 compacted to: files[ 0 0 1 0 0 0 0 ] -2023/11/07-23:29:14.528489 7f46649f4640 Delete type=2 #168 -2023/11/07-23:29:14.528516 7f46649f4640 Delete type=2 #160 -2023/11/07-23:29:14.541956 7f46649f4640 Manual compaction at level-1 from '!items!xA7qKMmugJv7z6j1' @ 219 : 1 .. '!items!xA7qKMmugJv7z6j1' @ 0 : 0; will stop at (end) +2023/11/19-23:28:00.231858 7f1f877fe640 Recovering log #205 +2023/11/19-23:28:00.235312 7f1f877fe640 Delete type=0 #205 +2023/11/19-23:28:00.235339 7f1f877fe640 Delete type=3 #203 +2023/11/19-23:53:02.984028 7f1f7fab1640 Level-0 table #210: started +2023/11/19-23:53:02.984051 7f1f7fab1640 Level-0 table #210: 0 bytes OK +2023/11/19-23:53:02.985426 7f1f7fab1640 Delete type=0 #208 +2023/11/19-23:53:02.987037 7f1f7fab1640 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items!xA7qKMmugJv7z6j1' @ 0 : 0; will stop at (end) +2023/11/19-23:53:02.987301 7f1f7fab1640 Manual compaction at level-1 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items!xA7qKMmugJv7z6j1' @ 0 : 0; will stop at (end) diff --git a/packs/common-actions/MANIFEST-000170 b/packs/common-actions/MANIFEST-000170 deleted file mode 100644 index 02e3785..0000000 Binary files a/packs/common-actions/MANIFEST-000170 and /dev/null differ diff --git a/packs/common-actions/MANIFEST-000211 b/packs/common-actions/MANIFEST-000211 new file mode 100644 index 0000000..23b580b Binary files /dev/null and b/packs/common-actions/MANIFEST-000211 differ diff --git a/packs/gear/000069.ldb b/packs/gear/000069.ldb new file mode 100644 index 0000000..0f0c6ce Binary files /dev/null and b/packs/gear/000069.ldb differ diff --git a/packs/gear/CURRENT b/packs/gear/CURRENT new file mode 100644 index 0000000..e333c89 --- /dev/null +++ b/packs/gear/CURRENT @@ -0,0 +1 @@ +MANIFEST-000102 diff --git a/packs/gear/LOCK b/packs/gear/LOCK new file mode 100644 index 0000000..e69de29 diff --git a/packs/gear/LOG b/packs/gear/LOG new file mode 100644 index 0000000..9e094c1 --- /dev/null +++ b/packs/gear/LOG @@ -0,0 +1,8 @@ +2023/11/20-21:06:40.409700 7f1f87fff640 Recovering log #100 +2023/11/20-21:06:40.414561 7f1f87fff640 Delete type=3 #98 +2023/11/20-21:06:40.414639 7f1f87fff640 Delete type=0 #100 +2023/11/20-21:52:53.126794 7f1f7fab1640 Level-0 table #105: started +2023/11/20-21:52:53.126822 7f1f7fab1640 Level-0 table #105: 0 bytes OK +2023/11/20-21:52:53.127902 7f1f7fab1640 Delete type=0 #103 +2023/11/20-21:52:53.130985 7f1f7fab1640 Manual compaction at level-0 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end) +2023/11/20-21:52:53.131222 7f1f7fab1640 Manual compaction at level-1 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end) diff --git a/packs/gear/LOG.old b/packs/gear/LOG.old new file mode 100644 index 0000000..2218deb --- /dev/null +++ b/packs/gear/LOG.old @@ -0,0 +1,8 @@ +2023/11/19-23:28:00.254245 7f1f877fe640 Recovering log #96 +2023/11/19-23:28:00.258969 7f1f877fe640 Delete type=3 #94 +2023/11/19-23:28:00.259068 7f1f877fe640 Delete type=0 #96 +2023/11/19-23:53:02.987311 7f1f7fab1640 Level-0 table #101: started +2023/11/19-23:53:02.987354 7f1f7fab1640 Level-0 table #101: 0 bytes OK +2023/11/19-23:53:02.989583 7f1f7fab1640 Delete type=0 #99 +2023/11/19-23:53:02.994695 7f1f7fab1640 Manual compaction at level-0 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end) +2023/11/19-23:53:02.997387 7f1f7fab1640 Manual compaction at level-1 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end) diff --git a/packs/gear/MANIFEST-000102 b/packs/gear/MANIFEST-000102 new file mode 100644 index 0000000..abbfc24 Binary files /dev/null and b/packs/gear/MANIFEST-000102 differ diff --git a/packs/helper-actors/CURRENT b/packs/helper-actors/CURRENT index 5893b8f..8d5e72e 100644 --- a/packs/helper-actors/CURRENT +++ b/packs/helper-actors/CURRENT @@ -1 +1 @@ -MANIFEST-000069 +MANIFEST-000109 diff --git a/packs/helper-actors/LOG b/packs/helper-actors/LOG index 6e054fa..378bdd2 100644 --- a/packs/helper-actors/LOG +++ b/packs/helper-actors/LOG @@ -1,8 +1,8 @@ -2023/11/07-23:29:20.346979 7f4665ffb640 Recovering log #66 -2023/11/07-23:29:20.349569 7f4665ffb640 Delete type=3 #64 -2023/11/07-23:29:20.349612 7f4665ffb640 Delete type=0 #66 -2023/11/07-23:29:29.395544 7f46649f4640 Level-0 table #72: started -2023/11/07-23:29:29.395555 7f46649f4640 Level-0 table #72: 0 bytes OK -2023/11/07-23:29:29.396547 7f46649f4640 Delete type=0 #70 -2023/11/07-23:29:29.396590 7f46649f4640 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end) -2023/11/07-23:29:29.396624 7f46649f4640 Manual compaction at level-1 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end) +2023/11/20-21:06:40.400000 7f1f8cafa640 Recovering log #107 +2023/11/20-21:06:40.405266 7f1f8cafa640 Delete type=3 #105 +2023/11/20-21:06:40.405349 7f1f8cafa640 Delete type=0 #107 +2023/11/20-21:52:53.120803 7f1f7fab1640 Level-0 table #112: started +2023/11/20-21:52:53.120825 7f1f7fab1640 Level-0 table #112: 0 bytes OK +2023/11/20-21:52:53.122805 7f1f7fab1640 Delete type=0 #110 +2023/11/20-21:52:53.122942 7f1f7fab1640 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end) +2023/11/20-21:52:53.122987 7f1f7fab1640 Manual compaction at level-1 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end) diff --git a/packs/helper-actors/LOG.old b/packs/helper-actors/LOG.old index 3c2f3b8..068b571 100644 --- a/packs/helper-actors/LOG.old +++ b/packs/helper-actors/LOG.old @@ -1,15 +1,8 @@ -2023/11/07-17:50:41.786664 7f4665ffb640 Recovering log #62 -2023/11/07-17:50:41.788546 7f4665ffb640 Delete type=0 #62 -2023/11/07-17:50:41.788559 7f4665ffb640 Delete type=3 #60 -2023/11/07-23:29:14.523160 7f46649f4640 Level-0 table #67: started -2023/11/07-23:29:14.524102 7f46649f4640 Level-0 table #67: 1737 bytes OK -2023/11/07-23:29:14.524964 7f46649f4640 Delete type=0 #65 -2023/11/07-23:29:14.525003 7f46649f4640 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end) -2023/11/07-23:29:14.525014 7f46649f4640 Manual compaction at level-1 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at '!actors!U5v4gFHquo0Y1SAq' @ 2 : 1 -2023/11/07-23:29:14.525016 7f46649f4640 Compacting 1@1 + 1@2 files -2023/11/07-23:29:14.526092 7f46649f4640 Generated table #68@1: 1 keys, 1737 bytes -2023/11/07-23:29:14.526097 7f46649f4640 Compacted 1@1 + 1@2 files => 1737 bytes -2023/11/07-23:29:14.526856 7f46649f4640 compacted to: files[ 0 0 1 0 0 0 0 ] -2023/11/07-23:29:14.526872 7f46649f4640 Delete type=2 #5 -2023/11/07-23:29:14.526891 7f46649f4640 Delete type=2 #67 -2023/11/07-23:29:14.541950 7f46649f4640 Manual compaction at level-1 from '!actors!U5v4gFHquo0Y1SAq' @ 2 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end) +2023/11/19-23:28:00.240421 7f1f86ffd640 Recovering log #103 +2023/11/19-23:28:00.246181 7f1f86ffd640 Delete type=0 #103 +2023/11/19-23:28:00.246268 7f1f86ffd640 Delete type=3 #101 +2023/11/19-23:53:02.985473 7f1f7fab1640 Level-0 table #108: started +2023/11/19-23:53:02.985488 7f1f7fab1640 Level-0 table #108: 0 bytes OK +2023/11/19-23:53:02.987004 7f1f7fab1640 Delete type=0 #106 +2023/11/19-23:53:02.987267 7f1f7fab1640 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end) +2023/11/19-23:53:02.992459 7f1f7fab1640 Manual compaction at level-1 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end) diff --git a/packs/helper-actors/MANIFEST-000069 b/packs/helper-actors/MANIFEST-000109 similarity index 74% rename from packs/helper-actors/MANIFEST-000069 rename to packs/helper-actors/MANIFEST-000109 index c33b28b..6bd5ecd 100644 Binary files a/packs/helper-actors/MANIFEST-000069 and b/packs/helper-actors/MANIFEST-000109 differ diff --git a/packs/helper-macros/000190.ldb b/packs/helper-macros/000190.ldb deleted file mode 100644 index 403a4e6..0000000 Binary files a/packs/helper-macros/000190.ldb and /dev/null differ diff --git a/packs/helper-macros/000223.ldb b/packs/helper-macros/000223.ldb new file mode 100644 index 0000000..451ea8e Binary files /dev/null and b/packs/helper-macros/000223.ldb differ diff --git a/packs/helper-macros/CURRENT b/packs/helper-macros/CURRENT index d0dd497..803ffe2 100644 --- a/packs/helper-macros/CURRENT +++ b/packs/helper-macros/CURRENT @@ -1 +1 @@ -MANIFEST-000199 +MANIFEST-000240 diff --git a/packs/helper-macros/LOG b/packs/helper-macros/LOG index 8a775cc..4ece3e4 100644 --- a/packs/helper-macros/LOG +++ b/packs/helper-macros/LOG @@ -1,8 +1,8 @@ -2023/11/07-23:29:20.340266 7f4665ffb640 Recovering log #197 -2023/11/07-23:29:20.342378 7f4665ffb640 Delete type=0 #197 -2023/11/07-23:29:20.342408 7f4665ffb640 Delete type=3 #195 -2023/11/07-23:29:29.392493 7f46649f4640 Level-0 table #202: started -2023/11/07-23:29:29.392505 7f46649f4640 Level-0 table #202: 0 bytes OK -2023/11/07-23:29:29.393529 7f46649f4640 Delete type=0 #200 -2023/11/07-23:29:29.394661 7f46649f4640 Manual compaction at level-0 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end) -2023/11/07-23:29:29.396569 7f46649f4640 Manual compaction at level-1 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end) +2023/11/20-21:06:40.379066 7f1f8cafa640 Recovering log #238 +2023/11/20-21:06:40.383341 7f1f8cafa640 Delete type=0 #238 +2023/11/20-21:06:40.383379 7f1f8cafa640 Delete type=3 #236 +2023/11/20-21:52:53.115026 7f1f7fab1640 Level-0 table #243: started +2023/11/20-21:52:53.115074 7f1f7fab1640 Level-0 table #243: 0 bytes OK +2023/11/20-21:52:53.117191 7f1f7fab1640 Delete type=0 #241 +2023/11/20-21:52:53.120794 7f1f7fab1640 Manual compaction at level-0 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end) +2023/11/20-21:52:53.122890 7f1f7fab1640 Manual compaction at level-1 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end) diff --git a/packs/helper-macros/LOG.old b/packs/helper-macros/LOG.old index 0d7870b..a868491 100644 --- a/packs/helper-macros/LOG.old +++ b/packs/helper-macros/LOG.old @@ -1,8 +1,8 @@ -2023/11/07-17:50:41.780718 7f4665ffb640 Recovering log #193 -2023/11/07-17:50:41.782723 7f4665ffb640 Delete type=3 #191 -2023/11/07-17:50:41.782737 7f4665ffb640 Delete type=0 #193 -2023/11/07-23:29:14.517951 7f46649f4640 Level-0 table #198: started -2023/11/07-23:29:14.517966 7f46649f4640 Level-0 table #198: 0 bytes OK -2023/11/07-23:29:14.518928 7f46649f4640 Delete type=0 #196 -2023/11/07-23:29:14.520867 7f46649f4640 Manual compaction at level-0 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end) -2023/11/07-23:29:14.524993 7f46649f4640 Manual compaction at level-1 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end) +2023/11/19-23:28:00.222566 7f1f86ffd640 Recovering log #234 +2023/11/19-23:28:00.228468 7f1f86ffd640 Delete type=0 #234 +2023/11/19-23:28:00.228572 7f1f86ffd640 Delete type=3 #232 +2023/11/19-23:53:02.980676 7f1f7fab1640 Level-0 table #239: started +2023/11/19-23:53:02.980736 7f1f7fab1640 Level-0 table #239: 0 bytes OK +2023/11/19-23:53:02.982353 7f1f7fab1640 Delete type=0 #237 +2023/11/19-23:53:02.985462 7f1f7fab1640 Manual compaction at level-0 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end) +2023/11/19-23:53:02.987044 7f1f7fab1640 Manual compaction at level-1 from '!folders!hIbrWxg1nDutCSwt' @ 72057594037927935 : 1 .. '!macros!wU2mAUnw3RW9qMT8' @ 0 : 0; will stop at (end) diff --git a/packs/helper-macros/MANIFEST-000199 b/packs/helper-macros/MANIFEST-000199 deleted file mode 100644 index e1dd246..0000000 Binary files a/packs/helper-macros/MANIFEST-000199 and /dev/null differ diff --git a/packs/helper-macros/MANIFEST-000240 b/packs/helper-macros/MANIFEST-000240 new file mode 100644 index 0000000..de84bde Binary files /dev/null and b/packs/helper-macros/MANIFEST-000240 differ diff --git a/packs/module-docs/000196.ldb b/packs/module-docs/000196.ldb deleted file mode 100644 index 8fa59a9..0000000 Binary files a/packs/module-docs/000196.ldb and /dev/null differ diff --git a/packs/module-docs/000221.ldb b/packs/module-docs/000221.ldb new file mode 100644 index 0000000..11a7d7b Binary files /dev/null and b/packs/module-docs/000221.ldb differ diff --git a/packs/module-docs/CURRENT b/packs/module-docs/CURRENT index edcd2de..4846f49 100644 --- a/packs/module-docs/CURRENT +++ b/packs/module-docs/CURRENT @@ -1 +1 @@ -MANIFEST-000197 +MANIFEST-000238 diff --git a/packs/module-docs/LOG b/packs/module-docs/LOG index 240cfe4..17e646e 100644 --- a/packs/module-docs/LOG +++ b/packs/module-docs/LOG @@ -1,8 +1,8 @@ -2023/11/07-23:29:20.336710 7f46667fc640 Recovering log #194 -2023/11/07-23:29:20.338673 7f46667fc640 Delete type=0 #194 -2023/11/07-23:29:20.338682 7f46667fc640 Delete type=3 #192 -2023/11/07-23:29:29.390257 7f46649f4640 Level-0 table #200: started -2023/11/07-23:29:29.390274 7f46649f4640 Level-0 table #200: 0 bytes OK -2023/11/07-23:29:29.391163 7f46649f4640 Delete type=0 #198 -2023/11/07-23:29:29.392479 7f46649f4640 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!Mw1g2Fx5dp4SoqVP.lhULHNp4gz9IjOR3' @ 0 : 0; will stop at (end) -2023/11/07-23:29:29.393557 7f46649f4640 Manual compaction at level-1 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!Mw1g2Fx5dp4SoqVP.lhULHNp4gz9IjOR3' @ 0 : 0; will stop at (end) +2023/11/20-21:06:40.367710 7f1f87fff640 Recovering log #236 +2023/11/20-21:06:40.373515 7f1f87fff640 Delete type=3 #234 +2023/11/20-21:06:40.373593 7f1f87fff640 Delete type=0 #236 +2023/11/20-21:52:53.112300 7f1f7fab1640 Level-0 table #241: started +2023/11/20-21:52:53.112780 7f1f7fab1640 Level-0 table #241: 0 bytes OK +2023/11/20-21:52:53.114883 7f1f7fab1640 Delete type=0 #239 +2023/11/20-21:52:53.120771 7f1f7fab1640 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!Q4iS1LIiyy7acuaF.zvPWCYx402kk2hsE' @ 0 : 0; will stop at (end) +2023/11/20-21:52:53.122876 7f1f7fab1640 Manual compaction at level-1 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!Q4iS1LIiyy7acuaF.zvPWCYx402kk2hsE' @ 0 : 0; will stop at (end) diff --git a/packs/module-docs/LOG.old b/packs/module-docs/LOG.old index 0224ebe..6dde5ab 100644 --- a/packs/module-docs/LOG.old +++ b/packs/module-docs/LOG.old @@ -1,15 +1,8 @@ -2023/11/07-17:50:41.777838 7f4666ffd640 Recovering log #190 -2023/11/07-17:50:41.779631 7f4666ffd640 Delete type=0 #190 -2023/11/07-17:50:41.779649 7f4666ffd640 Delete type=3 #188 -2023/11/07-23:29:14.515315 7f46649f4640 Level-0 table #195: started -2023/11/07-23:29:14.516677 7f46649f4640 Level-0 table #195: 9634 bytes OK -2023/11/07-23:29:14.517872 7f46649f4640 Delete type=0 #193 -2023/11/07-23:29:14.518953 7f46649f4640 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!Mw1g2Fx5dp4SoqVP.lhULHNp4gz9IjOR3' @ 0 : 0; will stop at (end) -2023/11/07-23:29:14.518974 7f46649f4640 Manual compaction at level-1 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!Mw1g2Fx5dp4SoqVP.lhULHNp4gz9IjOR3' @ 0 : 0; will stop at '!journal.pages!Mw1g2Fx5dp4SoqVP.lhULHNp4gz9IjOR3' @ 98 : 1 -2023/11/07-23:29:14.518976 7f46649f4640 Compacting 1@1 + 1@2 files -2023/11/07-23:29:14.519779 7f46649f4640 Generated table #196@1: 6 keys, 4503 bytes -2023/11/07-23:29:14.519792 7f46649f4640 Compacted 1@1 + 1@2 files => 4503 bytes -2023/11/07-23:29:14.520666 7f46649f4640 compacted to: files[ 0 0 1 0 0 0 0 ] -2023/11/07-23:29:14.520737 7f46649f4640 Delete type=2 #167 -2023/11/07-23:29:14.520824 7f46649f4640 Delete type=2 #195 -2023/11/07-23:29:14.524986 7f46649f4640 Manual compaction at level-1 from '!journal.pages!Mw1g2Fx5dp4SoqVP.lhULHNp4gz9IjOR3' @ 98 : 1 .. '!journal.pages!Mw1g2Fx5dp4SoqVP.lhULHNp4gz9IjOR3' @ 0 : 0; will stop at (end) +2023/11/19-23:28:00.213421 7f1f877fe640 Recovering log #232 +2023/11/19-23:28:00.217882 7f1f877fe640 Delete type=0 #232 +2023/11/19-23:28:00.218006 7f1f877fe640 Delete type=3 #230 +2023/11/19-23:53:02.978275 7f1f7fab1640 Level-0 table #237: started +2023/11/19-23:53:02.978315 7f1f7fab1640 Level-0 table #237: 0 bytes OK +2023/11/19-23:53:02.980281 7f1f7fab1640 Delete type=0 #235 +2023/11/19-23:53:02.980581 7f1f7fab1640 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!Q4iS1LIiyy7acuaF.zvPWCYx402kk2hsE' @ 0 : 0; will stop at (end) +2023/11/19-23:53:02.982433 7f1f7fab1640 Manual compaction at level-1 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!Q4iS1LIiyy7acuaF.zvPWCYx402kk2hsE' @ 0 : 0; will stop at (end) diff --git a/packs/module-docs/MANIFEST-000197 b/packs/module-docs/MANIFEST-000197 deleted file mode 100644 index 4460a83..0000000 Binary files a/packs/module-docs/MANIFEST-000197 and /dev/null differ diff --git a/packs/module-docs/MANIFEST-000238 b/packs/module-docs/MANIFEST-000238 new file mode 100644 index 0000000..05a5b89 Binary files /dev/null and b/packs/module-docs/MANIFEST-000238 differ diff --git a/scripts/api.js b/scripts/api.js index 1a5fd51..c638e78 100644 --- a/scripts/api.js +++ b/scripts/api.js @@ -1,5 +1,5 @@ -import { helpers } from './helpers.js' -import { shim, log } from './shim.js' +import { log } from './shim.js' +import { requestRollFromTokens } from './helpers.js' import { powerEffects } from './powerEffects.js' export class api { @@ -11,8 +11,8 @@ export class api { static globals () { const moduleName = 'swade-mb-helpers' game.modules.get(moduleName).api = { - DEBUG: true, - powerEffects + powerEffects, + requestRollFromTokens } } } diff --git a/scripts/helpers.js b/scripts/helpers.js index 553e929..5e31f83 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -1,92 +1,61 @@ -import { CONST, shim } from './shim.js' +import { shim } from './shim.js' -export class helpers { - static runOnTargetOrSelectedTokens (runFunc) { - let tokens = [] - const targets = Array.from(shim.targets) - if (targets.length > 0) { - tokens = targets - } else if (shim.controlled.length > 0) { - tokens = shim.controlled +export async function requestRollFromTokens (tokens, rollType, rollDesc, options = {}) { + // tokens: list of tokens to request a roll from + // rollType: 'attribute' or 'skill + // rollDesc: name of attribute or skill + // options: + // title: title for the roll dialog. Will have "- {{ token name }}" + // appended + // flavour: flavor text for the roll card. Defaults to title + // mods: list of modifiers {label: "", value: 0, ignore: false} + // modCallback: callback function that takes a token and returns a list of + // modifiers in the same format as modifiers, above + const requestingUser = shim.user + const title = options?.title || `${requestingUser.name} requests a ${rollDesc} roll` + const flavour = options?.flavour || options?.flavor || title + const promises = [] + for (const token of tokens) { + const owner = shim.warpgateUtil.firstOwner(token.document) + const rollOpts = { + title: `${title} - ${token.name}`, + flavour } - if (tokens.length > 0) { - runFunc(tokens) - } else { - shim.notifications.error('Please select or target a token') - } - } - - static createEffectDocument (icon, name, durationRounds, changes) { - const effectData = { - icon, - name, - duration: { rounds: durationRounds }, - flags: { - swade: { - expiration: CONST.SWADE.STATUS_EFFECT_EXPIRATION.EndOfTurnPrompt, - loseTurnOnHold: true - } - }, - changes - } - return effectData - } - - static createMutationWithEffect (icon, name, durationRounds, changes) { - const effect = helpers.createEffectDocument(icon, name, durationRounds, changes) - const mutate = { - embedded: { ActiveEffect: {} } - } - mutate.embedded.ActiveEffect[name] = effect - return mutate - } - - static defaultMutationOptions (name) { - const mutateOptions = { - name, - permanent: true, - description: name - } - return mutateOptions - } - - static getActorFolderByPath (path) { - const names = path.split('/') - if (names[0] === '') { - names.shift() - } - let name = names.shift() - let folder = shim.folders.find(f => f.name === name && !f.folder) - while (names.length > 0) { - name = names.shift() - folder = folder.children.find(c => c.folder.name === name) - folder = folder.folder - } - return folder - } - - static getActorsInFolder (inFolder) { - const prefixStack = [''] - const actors = {} - const folderStack = [inFolder] - - while (folderStack.length > 0) { - const prefix = prefixStack.shift() - const folder = folderStack.shift() - for (const actor of folder.contents) { - if ( - shim.user.isGM || actor.testUserPermission( - shim.user, CONST.FOUNDRY.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER) - ) { - actors[`${prefix}${actor.name}`] = actor - } - } - for (const child of folder.children) { - const newPrefix = `${prefix}${child.folder.name} | ` - prefixStack.push(newPrefix) - folderStack.push(child.folder) + const additionalMods = [] + if ('mods' in options) { + for (const mod of options.mods) { + additionalMods.push(mod) } } - return actors + if ('modCallback' in options) { + const tokenMods = await options.modCallback(token) + for (const tm of tokenMods) { + additionalMods.push(tm) + } + } + if (additionalMods.length > 0) { + rollOpts.additionalMods = additionalMods + } + promises.push(shim.socket.executeAsUser(requestTokenRoll, owner.id, + token.scene.id, token.id, rollType, rollDesc, rollOpts)) } + const results = await Promise.allSettled(promises) + return results +} + +export async function requestTokenRoll ( + sceneId, tokenId, rollType, rollDesc, options +) { + const scene = shim.scenes.get(sceneId) + const token = scene.tokens.get(tokenId) + let rollFunc = 'rollAttribute' + let rollId = rollDesc.toLowerCase() + if (rollType === 'skill') { + rollFunc = 'rollSkill' + rollId = token.actor.items.filter(i => i.type === 'skill').find(i => ( + i.system.swid === rollDesc.toLowerCase() || + i.name.toLowerCase() === rollDesc.toLowerCase()))?.id + } + const result = await token.actor[rollFunc](rollId, options) + return { sceneId, tokenId, result } } diff --git a/scripts/module.js b/scripts/module.js index 9171ae8..852a4cc 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -1,6 +1,7 @@ import { api } from './api.js' +import { requestTokenRoll } from './helpers.js' import { shapeChangeOnDismiss } from './powerEffects.js' -import { log } from './shim.js' +import { log, shim } from './shim.js' const moduleName = 'swade-mb-helpers' @@ -17,6 +18,13 @@ Hooks.on('setup', api.registerFunctions) Hooks.on('ready', () => { _checkModule('warpgate') + _checkModule('socketlib') log('Initialized SWADE MB Helpers') warpgate.event.watch(warpgate.EVENT.DISMISS, shapeChangeOnDismiss) }) + +Hooks.on('socketlib.ready', () => { + const socket = socketlib.registerModule('swade-mb-helpers') + socket.register('requestTokenRoll', requestTokenRoll) + shim._socket = socket +}) diff --git a/scripts/powerEffects.js b/scripts/powerEffects.js index 96e4ca9..9765507 100644 --- a/scripts/powerEffects.js +++ b/scripts/powerEffects.js @@ -1,4 +1,5 @@ import { CONST, log, shim } from './shim.js' +import { requestRollFromTokens } from './helpers.js' class PowerEffect { constructor (token, targets) { @@ -545,6 +546,46 @@ class EntangleEffect extends TargetedPowerEffect { } } +class HavocEffect extends TargetedPowerEffect { + get name () { + return 'Havoc' + } + + get baseDurationRounds () { + return 1 + } + + async prepResult () { + this.raise = (this.buttons === 'raise') + this.effectDocs.unshift(shim.getStatus('SWADE.Distr', 'Distracted')) + } + + async applyResult () { + await super.applyResult() + await shim.wait(1000) + + const resistMods = function (token) { + const mods = [] + if (token.actor.effects.find(e => e.name === 'Flying')) { + mods.push({ label: 'Flying', value: -2 }) + } + return mods + } + + const options = { + title: 'Resisting Havoc!', + flavour: 'Havoc!', + mods: [], + modCallback: resistMods + } + if (this.raise) { + options.mods.push({ label: 'vs. Raise', value: -2 }) + } + + await requestRollFromTokens(this.targets, 'attribute', 'strength', options) + } +} + class IntangibilityEffect extends TargetedPowerEffect { get name () { return 'Intangility' @@ -1349,6 +1390,7 @@ const PowerClasses = { 'detectconceal-aracana': DetectConcealArcanaEffect, disguise: DisguiseEffect, entangle: EntangleEffect, + havoc: HavocEffect, intangibility: IntangibilityEffect, invisibility: InvisibilityEffect, 'lower trait': BoostLowerTraitEffect, diff --git a/scripts/shim.js b/scripts/shim.js index fef99b3..f8beeb1 100644 --- a/scripts/shim.js +++ b/scripts/shim.js @@ -21,6 +21,10 @@ export class shim { return Actor } + static get canvas () { + return game.canvas + } + static get folders () { return game.folders } @@ -37,6 +41,10 @@ export class shim { return game.user } + static get users () { + return game.users + } + static get notifications () { return ui.notifications } @@ -49,6 +57,12 @@ export class shim { return game.scenes } + static _socket = null + + static get socket () { + return shim._socket + } + static mergeObject (...args) { return mergeObject(...args) } @@ -102,6 +116,10 @@ export class shim { await warpgate.mutate(token.document, mutation, {}, mutateOptions) } + static wait (ms) { + return warpgate.wait(ms) + } + static warpgateMenu (menuData, menuOptions) { return warpgate.menu(menuData, menuOptions) } @@ -114,6 +132,10 @@ export class shim { return warpgate.spawnAt(...args) } + static get warpgateUtil () { + return warpgate.util + } + static getActorFolderByPath (path) { const names = path.split('/') if (names[0] === '') {