Added some check on 20Q, and now rolls fill the form
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { HelpersL5r5e } from "../helpers.js";
|
import { HelpersL5r5e } from "../helpers.js";
|
||||||
import { TwentyQuestions } from "./twenty-questions.js";
|
import { TwentyQuestions } from "./twenty-questions.js";
|
||||||
|
import { RollL5r5e } from "../dice/roll.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* L5R Twenty Questions form
|
* L5R Twenty Questions form
|
||||||
@@ -141,8 +142,18 @@ export class TwentyQuestionsDialog extends FormApplication {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Heritage Roll (step 18)
|
||||||
|
html.find(".inline-roll").on("click", (event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
const diceRoll = $(event.currentTarget);
|
||||||
|
const stepKey = diceRoll.data("step");
|
||||||
|
const formula = diceRoll.data("formula");
|
||||||
|
const flavor = diceRoll.data("flavor");
|
||||||
|
this._rollHeritage(stepKey, formula, flavor).then(() => this.render(false));
|
||||||
|
});
|
||||||
|
|
||||||
// Delete a dnd element
|
// Delete a dnd element
|
||||||
html.find(`.property-delete`).on("click", (event) => {
|
html.find(".property-delete").on("click", (event) => {
|
||||||
const stepKey = $(event.currentTarget).parents(".tq-drag-n-drop").data("step");
|
const stepKey = $(event.currentTarget).parents(".tq-drag-n-drop").data("step");
|
||||||
const itemId = $(event.currentTarget).parents(".property").data("propertyId");
|
const itemId = $(event.currentTarget).parents(".property").data("propertyId");
|
||||||
this._deleteOwnedItem(stepKey, itemId);
|
this._deleteOwnedItem(stepKey, itemId);
|
||||||
@@ -181,6 +192,55 @@ export class TwentyQuestionsDialog extends FormApplication {
|
|||||||
console.warn("forbidden item for this drop zone", type, item.data.type);
|
console.warn("forbidden item for this drop zone", type, item.data.type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Check if this item id already exist ?
|
||||||
|
|
||||||
|
// Specific entry
|
||||||
|
switch (type) {
|
||||||
|
case "technique":
|
||||||
|
// Tech not allowed
|
||||||
|
if (!this.actor.data.data.techniques[item.data.data.technique_type]) {
|
||||||
|
console.warn("This technique is not allowed for your character", type, item.data.type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "peculiarity":
|
||||||
|
switch (stepKey) {
|
||||||
|
case "step9.distinction":
|
||||||
|
if (item.data.data.peculiarity_type !== "distinction") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "step10.adversity":
|
||||||
|
if (item.data.data.peculiarity_type !== "adversity") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "step11.passion":
|
||||||
|
if (item.data.data.peculiarity_type !== "passion") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "step12.anxiety":
|
||||||
|
if (item.data.data.peculiarity_type !== "anxiety") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "step13.advantage":
|
||||||
|
if (!["distinction", "passion"].includes(item.data.data.peculiarity_type)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "step13.disadvantage":
|
||||||
|
if (!["adversity", "anxiety"].includes(item.data.data.peculiarity_type)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Add the item (step and cache)
|
// Add the item (step and cache)
|
||||||
this._addOwnedItem(item, stepKey);
|
this._addOwnedItem(item, stepKey);
|
||||||
|
|
||||||
@@ -257,6 +317,19 @@ export class TwentyQuestionsDialog extends FormApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Roll Heritage dice and fill the form with the result
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
async _rollHeritage(stepName, formula, flavor) {
|
||||||
|
const roll = new RollL5r5e(formula);
|
||||||
|
roll.actor = this._actor;
|
||||||
|
|
||||||
|
await roll.roll();
|
||||||
|
setProperty(this.object.data, stepName, roll.result);
|
||||||
|
return roll.toMessage({ flavor: flavor });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a owned item reference in step and cache
|
* Add a owned item reference in step and cache
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
@@ -578,7 +578,7 @@
|
|||||||
<label>
|
<label>
|
||||||
{{localize 'l5r5e.twenty_questions.d10r1'}}
|
{{localize 'l5r5e.twenty_questions.d10r1'}}
|
||||||
<a class="inline-roll roll" title="1d10" data-mode="roll"
|
<a class="inline-roll roll" title="1d10" data-mode="roll"
|
||||||
data-flavor="{{localize 'l5r5e.twenty_questions.d10r1'}}" data-formula="1d10">
|
data-flavor="{{localize 'l5r5e.twenty_questions.d10r1'}}" data-formula="1d10" data-step="step18.heritage_1">
|
||||||
<i class="fas fa-dice-d20"></i> 1d10
|
<i class="fas fa-dice-d20"></i> 1d10
|
||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
@@ -589,7 +589,7 @@
|
|||||||
<label>
|
<label>
|
||||||
{{localize 'l5r5e.twenty_questions.d10r2'}}
|
{{localize 'l5r5e.twenty_questions.d10r2'}}
|
||||||
<a class="inline-roll roll" title="1d10" data-mode="roll"
|
<a class="inline-roll roll" title="1d10" data-mode="roll"
|
||||||
data-flavor="{{localize 'l5r5e.twenty_questions.d10r2'}}" data-formula="1d10">
|
data-flavor="{{localize 'l5r5e.twenty_questions.d10r2'}}" data-formula="1d10" data-step="step18.heritage_2">
|
||||||
<i class="fas fa-dice-d20"></i> 1d10
|
<i class="fas fa-dice-d20"></i> 1d10
|
||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user