remove warpgate dependency

This commit is contained in:
Mike Bloy 2024-05-18 00:03:02 -05:00
parent a1246bf758
commit b6c16ed0f5
13 changed files with 123 additions and 112 deletions

View File

@ -18,7 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
- Began work to remove Warpgate dependency
- Removed warpgate dependency
## [2.4.3] 2024-04-21

View File

@ -1,72 +1,93 @@
const requestRollFromTokens = game.modules.get('swade-mb-helpers').api.requestRollFromTokens
const requestRollFromTokens = game.modules.get('swade-mb-helpers').api.requestRollFromTokens;
async function main () {
let tokens = Array.from(game.user.targets)
async function main() {
let tokens = Array.from(game.user.targets);
if (tokens.length < 1) {
tokens = canvas.tokens.controlled
tokens = canvas.tokens.controlled;
}
if (tokens.length < 1) {
ui.notifications.error('Please target or select some tokens')
return
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' },
{ type: 'number', label: 'Target Number', options: 4 }
],
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()
const attributes = ['Agility', 'Smarts', 'Spirit', 'Strength', 'Vigor'];
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)
const tokenSkills = token.actor.items.filter(
(i) => i.type === 'skill' && !['Untrained', 'Untrained Attempt'].includes(i.name),
);
for (const skill of tokenSkills) {
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 targetNumber = result.inputs[4] || 4
const options = { targetNumber }
if (rollMod !== 0) {
options.mods = [{ label: rollModDesc, value: rollMod }]
}
requestRollFromTokens(tokens, rollType, rollDesc, options)
const attributeOptions = attributes
.map(
(a) => `
<option ${a === 'Agility' ? 'selected ' : ''} value="a|${a}">${a}</option>`,
)
.join('');
const skillOptions = Array.from(skillSet)
.sort()
.map(
(s) => `
<option value="s|${s}">${s}</option>`,
)
.join('');
const content = `
<form>
<p>Requesting roll from ${tokens.map((t) => t.name).join(', ')}.</p>
<div class="form-group">
<label for="trait">Trait to roll</label>
<select name="trait">
<optgroup label="Attributes">${attributeOptions}</optgroup>
<optgroup label="Skills">
${skillOptions}
<option value="s|NOSKILL">Untrained</option>
</optgroup>
</select>
</div>
<div class="form-group">
<label for="mod">Roll Modifier:</label>
<input type="number" value="0" name="mod">
</div>
<div class="form-group">
<label for="modDesc">Roll Modifier Description:</label>
<input type="text" value="Roll Modifier" name="modDesc">
</div>
<div class="form-group">
<label for="tn">Target Number</label>
<input type="number" value="4" name="tn">
</div>
</form>
`;
const buttons = {
ok: {
label: 'Request Roll',
callback: (html) => {
const form = html[0].querySelector('form');
const formDataObject = new FormDataExtended(form).object;
const rollMod = parseInt(formDataObject.mod);
const rollModDesc = formDataObject.modDesc;
const rollParts = formDataObject.trait.split('|');
const rollType = rollParts[0] === 'a' ? 'attribute' : 'skill';
const rollDesc = rollParts[1];
const targetNumber = parseInt(formDataObject.tn);
const options = { targetNumber };
if (rollMod !== 0) {
options.mods = [{ label: rollModDesc, value: rollMod }];
}
requestRollFromTokens(tokens, rollType, rollDesc, options);
},
},
cancel: {
label: 'Cancel',
},
};
new Dialog({
title: 'Request roll',
content,
buttons,
}).render(true);
}
main()
main();

View File

@ -13,7 +13,6 @@
"minimum": "11",
"verified": "11"
},
"scripts": [],
"esmodules": [
"module/swade-mb-helpers.js"
],
@ -104,18 +103,9 @@
}
],
"requires": [
{
"id": "warpgate",
"type": "module",
"manifest": "https://github.com/trioderegion/warpgate/releases/latest/download/module.json",
"compatibility": {
"verified": "1.16.2"
}
},
{
"id": "socketlib",
"type": "module",
"compatibility": {}
"type": "module"
}
],
"recommends": [
@ -131,7 +121,8 @@
},
{
"id": "JB2A_DnD5e",
"type": "module"
"type": "module",
"compatibility": {}
}
]
},
@ -139,11 +130,11 @@
{
"lang": "en",
"name": "English",
"path": "lang/en.json"
"path": "lang/en.json",
"flags": {}
}
],
"socket": true,
"manifest": "https://git.bloy.org/foundryvtt/swade-mb-helpers/raw/branch/main/module.json",
"download": "https://host/path/to/0.0.0.zip",
"library": false
}
"download": "https://host/path/to/0.0.0.zip"
}

View File

@ -28,7 +28,6 @@ Hooks.once('setup', async () => {
});
Hooks.once('ready', async () => {
_checkModule('warpgate');
_checkModule('socketlib');
log('Initialized SWADE MB Helpers');
});

View File

@ -1,5 +1,5 @@
2024/05/16-23:14:05.503945 7fb7397bc700 Delete type=3 #1
2024/05/16-23:14:05.506913 7fb738fbb700 Level-0 table #5: started
2024/05/16-23:14:05.514549 7fb738fbb700 Level-0 table #5: 17097 bytes OK
2024/05/16-23:14:05.529036 7fb738fbb700 Delete type=0 #3
2024/05/16-23:14:05.529186 7fb738fbb700 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items.effects!RC1Nz6iph8wPPK1B.g9W5hJisq3MsCpZW' @ 0 : 0; will stop at (end)
2024/05/17-23:56:12.076223 7fcb1c8ec700 Delete type=3 #1
2024/05/17-23:56:12.078659 7fcaf6d82700 Level-0 table #5: started
2024/05/17-23:56:12.081722 7fcaf6d82700 Level-0 table #5: 17097 bytes OK
2024/05/17-23:56:12.084330 7fcaf6d82700 Delete type=0 #3
2024/05/17-23:56:12.084425 7fcaf6d82700 Manual compaction at level-0 from '!folders!0nDRFmMBs5DBJU9M' @ 72057594037927935 : 1 .. '!items.effects!RC1Nz6iph8wPPK1B.g9W5hJisq3MsCpZW' @ 0 : 0; will stop at (end)

View File

@ -1,5 +1,5 @@
2024/05/16-23:14:05.659843 7f43fa7bf700 Delete type=3 #1
2024/05/16-23:14:05.662531 7f415bfff700 Level-0 table #5: started
2024/05/16-23:14:05.669856 7f415bfff700 Level-0 table #5: 6787 bytes OK
2024/05/16-23:14:05.678710 7f415bfff700 Delete type=0 #3
2024/05/16-23:14:05.678846 7f415bfff700 Manual compaction at level-0 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end)
2024/05/17-23:56:12.190384 7f9c8b7bf700 Delete type=3 #1
2024/05/17-23:56:12.192563 7f9c894ff700 Level-0 table #5: started
2024/05/17-23:56:12.195476 7f9c894ff700 Level-0 table #5: 6787 bytes OK
2024/05/17-23:56:12.198437 7f9c894ff700 Delete type=0 #3
2024/05/17-23:56:12.198534 7f9c894ff700 Manual compaction at level-0 from '!items!JWyBQe4tnOYljFAF' @ 72057594037927935 : 1 .. '!items!tWWSfEMmLmws6Yb1' @ 0 : 0; will stop at (end)

View File

@ -1,5 +1,5 @@
2024/05/16-23:14:05.828069 7fce92ffd700 Delete type=3 #1
2024/05/16-23:14:05.830670 7fce92581700 Level-0 table #5: started
2024/05/16-23:14:05.841187 7fce92581700 Level-0 table #5: 1751 bytes OK
2024/05/16-23:14:05.856746 7fce92581700 Delete type=0 #3
2024/05/16-23:14:05.856904 7fce92581700 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end)
2024/05/17-23:56:12.306331 7f05477fe700 Delete type=3 #1
2024/05/17-23:56:12.308360 7f0545d3f700 Level-0 table #5: started
2024/05/17-23:56:12.311076 7f0545d3f700 Level-0 table #5: 1751 bytes OK
2024/05/17-23:56:12.313731 7f0545d3f700 Delete type=0 #3
2024/05/17-23:56:12.313822 7f0545d3f700 Manual compaction at level-0 from '!actors!U5v4gFHquo0Y1SAq' @ 72057594037927935 : 1 .. '!actors!U5v4gFHquo0Y1SAq' @ 0 : 0; will stop at (end)

Binary file not shown.

View File

@ -1,5 +1,5 @@
2024/05/16-23:14:06.012926 7f4a3bfff700 Delete type=3 #1
2024/05/16-23:14:06.015815 7f4a3a7fc700 Level-0 table #5: started
2024/05/16-23:14:06.024676 7f4a3a7fc700 Level-0 table #5: 24947 bytes OK
2024/05/16-23:14:06.043395 7f4a3a7fc700 Delete type=0 #3
2024/05/16-23:14:06.043576 7f4a3a7fc700 Manual compaction at level-0 from '!folders!8FWN37c0gcpAisAv' @ 72057594037927935 : 1 .. '!macros!ypFtlnrgQkzqLpxI' @ 0 : 0; will stop at (end)
2024/05/17-23:56:12.425855 7f34337fe700 Delete type=3 #1
2024/05/17-23:56:12.428238 7f3431d3f700 Level-0 table #5: started
2024/05/17-23:56:12.431468 7f3431d3f700 Level-0 table #5: 25095 bytes OK
2024/05/17-23:56:12.434416 7f3431d3f700 Delete type=0 #3
2024/05/17-23:56:12.434513 7f3431d3f700 Manual compaction at level-0 from '!folders!8FWN37c0gcpAisAv' @ 72057594037927935 : 1 .. '!macros!ypFtlnrgQkzqLpxI' @ 0 : 0; will stop at (end)

View File

@ -1,5 +1,5 @@
2024/05/16-23:14:06.188000 7f7cda7bf700 Delete type=3 #1
2024/05/16-23:14:06.191101 7f7a3bfff700 Level-0 table #5: started
2024/05/16-23:14:06.210876 7f7a3bfff700 Level-0 table #5: 18987 bytes OK
2024/05/16-23:14:06.219803 7f7a3bfff700 Delete type=0 #3
2024/05/16-23:14:06.219923 7f7a3bfff700 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!w4TImRTAiNiqDWeL.vQhO6BVdKZOubTUQ' @ 0 : 0; will stop at (end)
2024/05/17-23:56:12.540188 7ffb0f7bf700 Delete type=3 #1
2024/05/17-23:56:12.542303 7ffb0d540700 Level-0 table #5: started
2024/05/17-23:56:12.545279 7ffb0d540700 Level-0 table #5: 18987 bytes OK
2024/05/17-23:56:12.547877 7ffb0d540700 Delete type=0 #3
2024/05/17-23:56:12.547974 7ffb0d540700 Manual compaction at level-0 from '!journal!HbtPlHNFO1L6RVj0' @ 72057594037927935 : 1 .. '!journal.pages!w4TImRTAiNiqDWeL.vQhO6BVdKZOubTUQ' @ 0 : 0; will stop at (end)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long