jsinme / fvtt-bcdice

A FoundryVTT module to query BCDice servers for dice rolls
MIT License
5 stars 3 forks source link

Dice so nice support #8

Closed BrotherSharper closed 3 years ago

BrotherSharper commented 3 years ago

Follow up of #3 Dice so nice uses the size and result of a dice to simulate a 3D roll (it does not to the rolling on its own IIRC) If you are able to get the size and result of BCdice command output, you could plug it in this module to simulate the roll. Based on teal dice, below is the repo. https://gitlab.com/riccisi/foundryvtt-dice-so-nice

This module is the most used module across FVTT due to the visual impact it gives to rolls.

Things to consider:

BrotherSharper commented 3 years ago

From: https://gitlab.com/riccisi/foundryvtt-dice-so-nice/-/wikis/API/Roll#using-a-custom-roll-system

Dice so nice requires three things from BCDice API.

BCDice supplements these from https://github.com/jsinme/fvtt-bcdice/blob/master/scripts/bcdice.js#L111 As seen below: image

data.rands contains the die sides and results of each die, data.rands.length contains the number of dies rolled.

The Dice so nice API should be placed before the chat message is created, roughly in the above line 111 (I think)

const data = {
    throws:[{
        dice:[
            { //result 1
                result:7,
                resultLabel:7,
                type: "d20",
                vectors:[],
                options:{}
            },
            { //result 2
                result:4,
                resultLabel:4,
                type: "d20",
                vectors:[],
                options:{}
            },
            {//result 3 etc.
            }
        ]
    }]
};
game.dice3d.show(data).then(displayed => { /* chat message generation */  }); 

Thusly, the chat message is only generated AFTER the dice so nice rolls are done parsing on the screen. So, you would need to create an iteration with the length of data.rands.length, and transpose the data.rands side to dice so nice type, and data.rands value to dice so nice result and resultLabel. You'd need empty data to hold the json data to be sent to game.dice3d.show.

I was able to write up until here but I don't know how to make such an iteration and append json data, I can ask for assistance in the league if you don't know either.

jsinme commented 3 years ago

You're initial PR was very helpful. I've updated it and DSN support should now be working smoothly. b236c26d163dc90695cf6b26d099ed9381e5aec0