javierriveracastro / betteroll-swade

A Better Rolls port for SWADE
GNU General Public License v3.0
15 stars 31 forks source link

create_item_card_from_id doesn't support consumables #598

Closed mrcomac closed 1 year ago

mrcomac commented 1 year ago

I'm calling the function create_attribute_card_from_id using as arguments:

  • token.id
  • actor.id
  • "vigor"

better rolls version is 3.30

The card in the chat is correct however the console shows an error.

the error from console is

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'name')
    at create_skill_card (skill_card.js:44:30)
    at Object.create_skill_card_from_id (skill_card.js:74:12)
    at br2_rollhandler (roll-handlers.js:73:29)

function definition

/**
 * Creates an attribute card from a token or actor id
 *
 * @param {string} token_id A token id, if it can be solved it will be used
 *  before actor
 * @param {string} actor_id An actor id, it could be set as fallback or
 *  if you keep token empty as the only way to find the actor
 * @param {string} name: Name of the attribute to roll, like 'vigor'
 * @return {Promise} a promise fot the ChatMessage object
 */
function create_attribute_card_from_id(token_id, actor_id, name){
    console.log("NAME", name);
        const actor = get_actor_from_ids(token_id, actor_id);
    return create_attribute_card(actor, name,
        game.settings.get('betterrolls-swade2', 'collapse-modifiers'));
}

mrcomac commented 1 year ago

also create_item_card_from_id is not working for consumable items

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'additional') at create_item_card (item_card.js:71:48) at Object.create_item_card_from_id (item_card.js:130:12)

javierriveracastro commented 1 year ago

Please, post each issue as it's own issue.

Now, first issue, are you sure that you are calling create_attribute_card_from_id, the error is happening in create_skill_card_from_id that expects an skill not a string.

The second one is probably a bug, I need to take a look at how consumables work.

mrcomac commented 1 year ago

Sorry @javierriveracastro ,

I'm editing this to reflect only the issue with the consumable items.

javierriveracastro commented 1 year ago

I'm not sure about what to do with consumables. I have asked on Discord for feedback. Right now I think that showing the system card is probably the best option, but I'm not sure. Maybe someone wants to run macros or add actions to consumables as system support seems quite barebone.

valdier1 commented 1 year ago

I think it would be nice for consumables in the sense of a fantasy setting, like "Potion of Giant Strength" that allows you to gain a bonus to a die type for x rounds. Something akin to that?

grendel111111 commented 1 year ago

I think it would be nice for consumables in the sense of a fantasy setting, like "Potion of Giant Strength" that allows you to gain a bonus to a die type for x rounds. Something akin to that?

If there are no dice rolls in taking the potion then I'm not sure if it needs to [or even can] go through BR2.

mrcomac commented 1 year ago

I'll suggest a card with a button to consume the item. The issue that I have is when I click on the consumable the card shows a roll button. I would like to have the card with the description of the item and the consume button.

javierriveracastro commented 1 year ago

At the end consumables show the system card. It has the description (collapsed) and a use and reload button.

It is an inconsistency (like running and some other cards), but it is also very resilient to changes in core.