Open DawidIzydor opened 1 year ago
Created PR #72
Example usage - using PartyResources to manage cooking ingredients from the Pathfinder Kingmaker AP
new Dialog({
title:'Add resource',
content:`
<form>
<div class="form-group">
<label>Basic ingredient</label>
<input type='number' name='basicIngredient'></input>
</div>
<div class="form-group">
<label>Special ingredient</label>
<input type='number' name='specialIngredient'></input>
</div>
</form>`,
buttons:{
yes: {
icon: "<i class='fas fa-check'></i>",
label: `Apply Changes`
}},
default:'yes',
close: html => {
let basicIngredient = html.find('input[name=\'basicIngredient\']');
if (basicIngredient.val()!== '') {
PartyResources.incrementByName('Basic Ingredient', Number(basicIngredient.val()));
}
let specialIngredient = html.find('input[name=\'specialIngredient\']');
if (specialIngredient.val()!== '') {
PartyResources.incrementByName('Special Ingredient', Number(specialIngredient.val()));
}
}
}).render(true);```
@DawidIzydor There already is a public-facing API, it's outlined in the FAQ.
That's true but this wrapper makes it more intuitive to use
@DawidIzydor Sorry for taking this long to respond, got a lot on my plate at the moment.
I reviewed this in more detail and will redact my previous comment. incrementByName
and decrementByName
can be useful in itself and they're probably a good idea to incorporate in the module. Though what I don't agree with is having two API endpoints where one contains several methods the other one doesn't have. I'm fine with having window.PartyResources
as an alias to window.pr.api
, but I'd aggregate incrementByName
, decrementByName
, _getResourceId
, and getByName
into window.pr.api
so all API methods reside in the same class. Does that make sense to you?
Feature: add api wrapper for easier interactions with this module through macros
I have this feature already implemented, will create a PR shortly