Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for exploding dice with manual rolls - likely fix issue #464 #465

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion df-manual-rolls/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"Flagged_Name": "Flag manual rolls",
"Flagged_Hint": "Add a flag to chat rolls that use manual dice.",
"FocusInput_Name": "Auto-Focus First Input Field",
"FocusInput_Hint": "If enabled, will set the focus to the first input field in the roll request window."
"FocusInput_Hint": "If enabled, will set the focus to the first input field in the roll request window.",
"ExplodingDice_Name": "Support Exploding Dice",
"ExplodingDice_Hint": "If enabled, allows entry of a roll that is higher the number of dice sides."
},
"Setting_Options": {
"Disabled": "Manual Rolls Disabled",
Expand Down
4 changes: 3 additions & 1 deletion df-manual-rolls/lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"Flagged_Name": "Oznaczaj rzuty ręczne",
"Flagged_Hint": "Dodaje znacznik na czacie do rzutów wykonanych ręcznie.",
"FocusInput_Name": "Automatycznie wybieraj pierwsze pole tekstowe",
"FocusInput_Hint": "Po wyświetleniu dialogu z prośbą o rzuty kursor automatycznie przeniesiony zostanie na pierwsze pole tekstowe."
"FocusInput_Hint": "Po wyświetleniu dialogu z prośbą o rzuty kursor automatycznie przeniesiony zostanie na pierwsze pole tekstowe.",
"ExplodingDice_Name": "Wspieraj eksplodujące kości",
"ExplodingDice_Hint": "Jeśli ta opcja jest włączona, umożliwia wprowadzenie rzutu, który jest większy niż liczba ścianek kości."
},
"Setting_Options": {
"Disabled": "Wyłączone",
Expand Down
1 change: 1 addition & 0 deletions df-manual-rolls/src/ManualRolls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class ManualRolls {
static PREF_PC_STATE = 'pc';
static PREF_FLAGGED = 'flagged';
static PREF_TOGGLED = 'toggled';
static PREF_EXPLODING_DICE = 'exploding';
static FLAG_ROLL_TYPE = 'roll-type';

static get flagged(): boolean { return SETTINGS.get(ManualRolls.PREF_FLAGGED); }
Expand Down
7 changes: 5 additions & 2 deletions df-manual-rolls/src/RollPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ interface RenderData {
idx: number;
faces: string;
hasTotal: boolean;
term: DiceTerm
term: DiceTerm;
supportExplodingDice: boolean;
}

export default class RollPrompt extends FormApplication<FormApplicationOptions, { terms: RenderData[] }> {
Expand All @@ -23,6 +24,7 @@ export default class RollPrompt extends FormApplication<FormApplicationOptions,
private _rolled = false;

static get focusInput(): boolean { return SETTINGS.get(RollPrompt.PREF_FOCUS_INPUT); }
static get supportExplodingDice(): boolean { return SETTINGS.get(ManualRolls.PREF_EXPLODING_DICE); }

static get defaultOptions(): FormApplicationOptions {
return <FormApplicationOptions>mergeObject(
Expand All @@ -45,7 +47,8 @@ export default class RollPrompt extends FormApplication<FormApplicationOptions,
idx: c,
faces: c == 0 ? `${die.number}d${die.faces}${die.modifiers.length > 0 ? ' [' + die.modifiers.join(',') + ']' : ''}` : '',
hasTotal: c == 0 && die.modifiers.length == 0 && die.number > 1,
term: die
term: die,
supportExplodingDice: RollPrompt.supportExplodingDice
});
}
}
Expand Down
9 changes: 9 additions & 0 deletions df-manual-rolls/src/df-manual-rolls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ Hooks.on('init', function () {
}
});

SETTINGS.register(ManualRolls.PREF_EXPLODING_DICE, {
name: "DF_MANUAL_ROLLS.Settings.ExplodingDice_Name",
hint: "DF_MANUAL_ROLLS.Settings.ExplodingDice_Hint",
scope: 'world',
config: true,
type: Boolean,
default: false
});

RollSettings.init();
});
Hooks.on('ready', function () {
Expand Down
4 changes: 2 additions & 2 deletions df-manual-rolls/templates/roll-prompt.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
{{#each terms}}
<tr>
<td>{{faces}}</td>
<td><input name="{{id}}-{{idx}}" type="number" min="1" max="{{term.faces}}" tabindex="1{{id}}{{idx}}"
<td><input name="{{id}}-{{idx}}" type="number" min="1" {{#unless supportExplodingDice}}max="{{term.faces}}"{{/unless}} tabindex="1{{id}}{{idx}}"
step="1" placeholder="1-{{term.faces}}{{localize "DF_MANUAL_ROLLS.Placeholder.Roll"}}"></input></td>
<td>
{{#if hasTotal}}
<input name="{{id}}-total" type="number" min="{{term.number}}" max="{{dfmr_mul term.number term.faces}}" tabindex="2{{id}}0"
<input name="{{id}}-total" type="number" min="{{term.number}}" {{#unless supportExplodingDice}}max="{{dfmr_mul term.number term.faces}}"{{/unless}} tabindex="2{{id}}0"
step="1" placeholder="{{localize "DF_MANUAL_ROLLS.Placeholder.Total_Pt1"}}{{term.number}}{{localize "DF_MANUAL_ROLLS.Placeholder.Total_Pt2"}}{{dfmr_mul term.number term.faces}}"></input>
{{/if}}
</td>
Expand Down