commit
bb130368ea
|
@ -1,5 +1,5 @@
|
|||
v0.7.0
|
||||
v0.7.1
|
||||
|
||||
- Fix Dice rolls
|
||||
- Fix Cohorts
|
||||
- Get ready for FoundryVTT 0.7.0
|
||||
- Adds Dice-so-nice support for FoundryVTT <0.7.0
|
||||
- Adds a proper Dice backward compatibility support (FVTT <0.7.0)
|
||||
- Refactors Dice functionality a bit
|
|
@ -4,6 +4,10 @@
|
|||
|
||||
Contact Discord: `megastruktur#5704` in case you find any bugs or if you have any suggestions.
|
||||
|
||||
Contributors:
|
||||
- `megastruktur#5704`
|
||||
- `Tyronne I’Saurus#5415`
|
||||
|
||||
## Usage
|
||||
`"Item" - all classes, crew types, upgrades, items, abilities, upgrades, etc.`
|
||||
|
||||
|
@ -43,10 +47,8 @@ Crew Types:
|
|||
![alt screen][screenshot_compendium]
|
||||
|
||||
## To be done in the nearest future
|
||||
- Clocks
|
||||
- Friends/rivals section
|
||||
- Stress/Harm dynamic values (can be modified by abilities but for now are hardcoded)
|
||||
- Enhance Dice Rolling (ability modifiers)
|
||||
|
||||
## Troubleshooting
|
||||
- If you can't find the drag-n-dropped item, refer to "All Items" tab on each sheet.
|
||||
|
|
|
@ -5,6 +5,23 @@
|
|||
*/
|
||||
export async function bladesRoll(dice_amount, attribute_name = "") {
|
||||
|
||||
// Is Dice So Nice enabled ?
|
||||
let niceDice = false;
|
||||
|
||||
try {
|
||||
niceDice = game.settings.get('dice-so-nice', 'settings').enabled;
|
||||
} catch {
|
||||
console.log("Dice-is-nice! not enabled");
|
||||
}
|
||||
|
||||
// Is FoundryVTT core version >= 0.7.0 ?
|
||||
// if using >= 0.7.0 New api calls enabled and DiceSoNice disabled until module update
|
||||
// if using < 0.7.0 Old Roll API calls used and DiceSoNice enabled
|
||||
|
||||
let isBelow070 = isNewerVersion('0.7.0', game.data.version);
|
||||
|
||||
if (isBelow070 == false) { niceDice=false; }
|
||||
|
||||
let speaker = ChatMessage.getSpeaker();
|
||||
// ChatMessage.getSpeaker(controlledToken)
|
||||
let zeromode = false;
|
||||
|
@ -14,18 +31,64 @@ export async function bladesRoll(dice_amount, attribute_name = "") {
|
|||
|
||||
let r = new Roll( `${dice_amount}d6`, {} );
|
||||
|
||||
r.roll();
|
||||
// show 3d Dice so Nice if enabled
|
||||
if (niceDice) {
|
||||
game.dice3d.showForRoll(r).then(displayed => {});
|
||||
} else {
|
||||
r.roll();
|
||||
}
|
||||
|
||||
// r.toMessage();
|
||||
|
||||
// Might be better as a DicePool with keep high/keep low intelligence,
|
||||
// but I want to get my hands into this directly, and I think players
|
||||
// will want to see all the dice happening.
|
||||
|
||||
let rolls = (r.parts)[0].rolls;
|
||||
|
||||
// Sort roll values from lowest to highest.
|
||||
let sorted_rolls = rolls.map(i => i.roll).sort();
|
||||
let rolls = [];
|
||||
if (isBelow070) {
|
||||
rolls = (r.parts)[0].rolls;
|
||||
} else {
|
||||
rolls = (r.terms)[0].results;
|
||||
}
|
||||
|
||||
// Retrieve Roll status.
|
||||
let roll_status = getBladesRollStatus(rolls, zeromode);
|
||||
|
||||
let result = await renderTemplate("systems/blades-in-the-dark/templates/blades-roll.html", {rolls: rolls, roll_status: roll_status, attribute_name: attribute_name});
|
||||
|
||||
let messageData = {
|
||||
speaker: speaker,
|
||||
content: result,
|
||||
type: CONST.CHAT_MESSAGE_TYPES.OOC,
|
||||
roll: r
|
||||
}
|
||||
|
||||
CONFIG.ChatMessage.entityClass.create(messageData, {})
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get status of the Roll.
|
||||
* - failure
|
||||
* - partial-success
|
||||
* - success
|
||||
* - critical-success
|
||||
* @param {Array} rolls
|
||||
* @param {Boolean} zeromode
|
||||
*/
|
||||
export function getBladesRollStatus(rolls, zeromode = false) {
|
||||
|
||||
// Dice API has changed in 0.7.0 so need to keep that in mind.
|
||||
let isBelow070 = isNewerVersion('0.7.0', game.data.version);
|
||||
|
||||
let sorted_rolls = [];
|
||||
// Sort roll values from lowest to highest.
|
||||
if (isBelow070) {
|
||||
sorted_rolls = rolls.map(i => i.roll).sort();
|
||||
} else {
|
||||
sorted_rolls = rolls.map(i => i.result).sort();
|
||||
}
|
||||
|
||||
let roll_status = "failure"
|
||||
|
||||
|
@ -69,20 +132,11 @@ export async function bladesRoll(dice_amount, attribute_name = "") {
|
|||
|
||||
}
|
||||
|
||||
let result = await renderTemplate("systems/blades-in-the-dark/templates/blades-roll.html", {rolls: rolls, roll_status: roll_status, attribute_name: attribute_name});
|
||||
return roll_status;
|
||||
|
||||
let messageData = {
|
||||
speaker: speaker,
|
||||
content: result,
|
||||
type: CONST.CHAT_MESSAGE_TYPES.OOC,
|
||||
roll: r
|
||||
}
|
||||
|
||||
CONFIG.ChatMessage.entityClass.create(messageData, {})
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call a Roll popup.
|
||||
*/
|
||||
|
@ -120,4 +174,4 @@ export async function simpleRollPopup() {
|
|||
},
|
||||
default: "yes"
|
||||
}).render(true);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue