Roll recette de cuisine
This commit is contained in:
1
assets/actions/cuisine.svg
Normal file
1
assets/actions/cuisine.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="height: 256px; width: 256px;"><g class="" transform="translate(0,-28)" style=""><path d="M259.063 25.094c-56.045 0-106.836 9.775-144.438 26.125-18.8 8.174-34.34 17.96-45.594 29.53-11.254 11.57-18.28 25.338-18.28 40.188 0 9.936 3.17 19.388 8.625 28.03-10.218 21.883-15.844 45.794-15.844 70.782 0 103.158 95.757 187.844 215.532 187.844 119.776 0 215.563-84.686 215.563-187.844 0-24.99-5.653-48.897-15.875-70.78 5.454-8.644 8.625-18.096 8.625-28.032 0-14.85-7.026-28.617-18.28-40.188-11.256-11.57-26.825-21.356-45.626-29.53-37.603-16.35-88.363-26.126-144.408-26.126zm0 18.687c53.848 0 102.554 9.6 136.968 24.564 17.208 7.482 30.775 16.306 39.658 25.437 8.882 9.133 13 18.115 13 27.157 0 9.043-4.118 18.057-13 27.188-8.883 9.13-22.45 17.956-39.657 25.438-34.413 14.963-83.12 24.562-136.967 24.562-53.85 0-102.555-9.6-136.97-24.563-17.206-7.48-30.804-16.306-39.687-25.437-8.882-9.13-12.97-18.145-12.97-27.188 0-9.042 4.088-18.024 12.97-27.156 8.883-9.13 22.48-17.954 39.688-25.436 34.414-14.964 83.12-24.563 136.97-24.563zm-7.782 17.282c-80.57 0-146 26.008-146 57.844 0 31.836 65.43 57.81 146 57.813 40.04 0 76.404-6.613 102.782-16.94-21.316 3.34-45.064 5.845-70.656 5.845-86.066 0-155.937-21.656-155.937-47.906s69.868-47.282 155.936-47.282c20.43 0 39.926.725 57.813 2.906-24.816-7.704-55.957-12.28-89.94-12.28zM87.657 360.5c-9.916 19.897-14.758 36.638-15.78 49.03-1.23 14.906 2.752 22.238 6.655 24.626 3.905 2.388 11.497 2.48 23.376-5.75 9.25-6.41 20.16-17.73 31.375-34.406-16.778-9.432-32.1-20.71-45.624-33.5zm342.75.063c-13.532 12.782-28.872 24.043-45.656 33.468 11.21 16.666 22.13 27.97 31.375 34.376 11.88 8.23 19.472 8.138 23.375 5.75 3.903-2.388 7.886-9.72 6.656-24.625-1.022-12.38-5.855-29.098-15.75-48.967zm-199.25 64.25c1.36 21.275 5.296 37.554 10.344 48.468 6.272 13.56 13.26 17.82 17.72 17.908 4.457.088 11.14-3.683 17.374-16.907 5.133-10.89 9.165-27.52 10.437-49.467a267.366 267.366 0 0 1-27.967 1.468c-9.437 0-18.75-.506-27.907-1.467z" fill="#fff" fill-opacity="1" transform="translate(25.6, 25.6) scale(0.9, 0.9) rotate(0, 256, 256) skewX(0) skewY(0)"></path></g></svg>
|
After Width: | Height: | Size: 2.1 KiB |
@@ -4,6 +4,7 @@ export const ROLL_TYPE_COMP = 'comp'
|
||||
export const ROLL_TYPE_DEFENSE = 'defense'
|
||||
export const ROLL_TYPE_JEU = 'jeu'
|
||||
export const ROLL_TYPE_MEDITATION = 'meditation'
|
||||
export const ROLL_TYPE_CUISINE = 'cuisine'
|
||||
export const ROLL_TYPE_OEUVRE = 'oeuvre'
|
||||
export const ROLL_TYPE_SORT = 'sort'
|
||||
export const ROLL_TYPE_TACHE = 'tache'
|
||||
|
@@ -37,9 +37,11 @@ import { RollPartAttaque } from "./roll-part-attaque.mjs";
|
||||
import { RollPartDefense } from "./roll-part-defense.mjs";
|
||||
import { RollDialogAdapter } from "./roll-dialog-adapter.mjs";
|
||||
import { ROLLDIALOG_SECTION } from "./roll-part.mjs";
|
||||
import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_COMP } from "./roll-constants.mjs";
|
||||
import { ROLL_TYPE_COMP } from "./roll-constants.mjs";
|
||||
import ChatRollResult from "./chat-roll-result.mjs";
|
||||
import { renderTemplate } from "../constants.js";
|
||||
import { RollTypeCuisine } from "./roll-type-cuisine.mjs";
|
||||
import { RollPartCuisine } from "./roll-part-cuisine.mjs";
|
||||
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api
|
||||
@@ -52,6 +54,7 @@ const ALL_ROLL_TYPES = [
|
||||
new RollTypeDefense(),
|
||||
new RollTypeSort(),
|
||||
new RollTypeMeditation(),
|
||||
new RollTypeCuisine(),
|
||||
new RollTypeOeuvre(),
|
||||
new RollTypeJeu(),
|
||||
// new RollTypeResistance ??
|
||||
@@ -71,6 +74,7 @@ const ROLL_PARTS = [
|
||||
new RollPartMeditation(),
|
||||
new RollPartSort(),
|
||||
new RollPartTache(),
|
||||
new RollPartCuisine(),
|
||||
new RollPartOeuvre(),
|
||||
new RollPartJeu(),
|
||||
|
||||
|
76
module/roll/roll-part-cuisine.mjs
Normal file
76
module/roll/roll-part-cuisine.mjs
Normal file
@@ -0,0 +1,76 @@
|
||||
import { ITEM_TYPES } from "../constants.js"
|
||||
import { CARACS } from "../rdd-carac.js"
|
||||
import { ROLL_TYPE_CUISINE } from "./roll-constants.mjs"
|
||||
import { PART_CARAC } from "./roll-part-carac.mjs"
|
||||
import { PART_COMP } from "./roll-part-comp.mjs"
|
||||
import { RollPartSelect } from "./roll-part-select.mjs"
|
||||
import { ROLLDIALOG_SECTION } from "./roll-part.mjs"
|
||||
|
||||
export const PART_CUISINE = "cuisine"
|
||||
|
||||
export class RollPartCuisine extends RollPartSelect {
|
||||
onReady() {
|
||||
foundry.applications.handlebars.loadTemplates({ 'roll-oeuvre-recettecuisine': `systems/foundryvtt-reve-de-dragon/templates/roll/roll-oeuvre-recettecuisine.hbs` })
|
||||
}
|
||||
|
||||
get code() { return PART_CUISINE }
|
||||
get section() { return ROLLDIALOG_SECTION.CHOIX }
|
||||
|
||||
isValid(rollData) { return rollData.active.actor.isPersonnage() }
|
||||
visible(rollData) { return this.isRollType(rollData, ROLL_TYPE_CUISINE) }
|
||||
|
||||
loadRefs(rollData) {
|
||||
const refs = this.getRefs(rollData)
|
||||
refs.recettes = rollData.active.actor.items
|
||||
.filter(it => it.type == ITEM_TYPES.recettecuisine)
|
||||
.map(it => RollPartCuisine.$extractRecette(it, rollData.active.actor))
|
||||
if (refs.recettes.length > 0) {
|
||||
this.$selectRecette(rollData)
|
||||
}
|
||||
}
|
||||
|
||||
choices(refs) { return refs.recettes }
|
||||
|
||||
static $extractRecette(recette, actor) {
|
||||
return {
|
||||
key: recette.id,
|
||||
label: recette.name,
|
||||
caracs: RollPartCuisine.getCaracs(recette),
|
||||
qualite: recette.system.niveau,
|
||||
value: -recette.system.niveau,
|
||||
recette: recette,
|
||||
comp: actor.getCompetence('Cuisine')
|
||||
}
|
||||
}
|
||||
static getCaracs(recette){
|
||||
// TODO: permettre différentes caractéristiques pour la cuisine?
|
||||
return [CARACS.ODORATGOUT, CARACS.EMPATHIE, CARACS.DEXTERITE]
|
||||
}
|
||||
|
||||
$selectRecette(rollData, key) {
|
||||
this.selectByKey(rollData, key, 0)
|
||||
}
|
||||
|
||||
async _onRender(rollDialog, context, options) {
|
||||
const selectRecette = rollDialog.element.querySelector(`roll-section[name="${this.code}"] select[name="select-recette"]`)
|
||||
|
||||
selectRecette.addEventListener("change", e => {
|
||||
const selectOptions = e.currentTarget.options
|
||||
const index = selectOptions.selectedIndex
|
||||
this.$selectRecette(rollDialog.rollData, selectOptions[index]?.value)
|
||||
rollDialog.render()
|
||||
})
|
||||
}
|
||||
|
||||
impactOtherPart(part, rollData) {
|
||||
if (this.visible(rollData)) {
|
||||
const current = this.getCurrent(rollData)
|
||||
switch (part.code) {
|
||||
case PART_CARAC: return part.filterCaracs(rollData, current.caracs)
|
||||
case PART_COMP: return part.filterComps(rollData, [current.comp?.name])
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
}
|
@@ -11,6 +11,7 @@ export const PART_OEUVRE = "oeuvre"
|
||||
|
||||
const ARTS = [
|
||||
{ type: ITEM_TYPES.oeuvre, action: "interpréte l'oeuvre", competence: it => it.system.competence, caracs: it => [it.system.default_carac] },
|
||||
{ type: ITEM_TYPES.musique, action: "joue le morceau:", competence: it => 'Musique', caracs: it => [CARACS.OUIE] },
|
||||
{ type: ITEM_TYPES.chant, action: "chante", competence: it => 'Chant', caracs: it => [CARACS.OUIE] },
|
||||
{
|
||||
type: ITEM_TYPES.danse, action: "danse:", competence: it => 'Danse', caracs: it => {
|
||||
@@ -20,8 +21,6 @@ const ARTS = [
|
||||
return caracs
|
||||
}
|
||||
},
|
||||
{ type: ITEM_TYPES.musique, action: "joue le morceau:", competence: it => 'Musique', caracs: it => [CARACS.OUIE] },
|
||||
{ type: ITEM_TYPES.recettecuisine, action: "cuisine le plat:", competence: it => 'Cuisine', caracs: it => [CARACS.ODORATGOUT] },
|
||||
]
|
||||
|
||||
export class RollPartOeuvre extends RollPartSelect {
|
||||
|
28
module/roll/roll-type-cuisine.mjs
Normal file
28
module/roll/roll-type-cuisine.mjs
Normal file
@@ -0,0 +1,28 @@
|
||||
import { DIFF, ROLL_TYPE_CUISINE } from "./roll-constants.mjs"
|
||||
import { PART_CUISINE } from "./roll-part-cuisine.mjs"
|
||||
import { RollType } from "./roll-type.mjs"
|
||||
|
||||
export class RollTypeCuisine extends RollType {
|
||||
get code() { return ROLL_TYPE_CUISINE }
|
||||
get name() { return `Interpréter une oeuvre` }
|
||||
|
||||
visible(rollData) { return rollData.active.actor.isPersonnage() }
|
||||
title(rollData) {
|
||||
const current = rollData.current[PART_CUISINE]
|
||||
return `prépare une recette: ${current.label}`
|
||||
}
|
||||
|
||||
onSelect(rollData) {
|
||||
this.setDiffType(rollData, DIFF.AUCUN)
|
||||
}
|
||||
|
||||
getResult(rollData){
|
||||
const current = rollData.current[PART_CUISINE]
|
||||
const qualite = rollData.rolled.isSuccess ? current.qualite : Math.min(current.qualite, current.comp.system.niveau)
|
||||
return {
|
||||
qualite: qualite + rollData.rolled.ptQualite
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
29
templates/roll/result/chat-cuisine.hbs
Normal file
29
templates/roll/result/chat-cuisine.hbs
Normal file
@@ -0,0 +1,29 @@
|
||||
<div class="roll-chat">
|
||||
<div class="chat-img">
|
||||
<img src="{{active.img}}" data-tooltip="{{active.name}}" />
|
||||
<img src="{{current.comp.img}}" data-tooltip="{{current.comp.name}}" />
|
||||
</div>
|
||||
<div class="chat-header">
|
||||
{{active.name}} prépare une recette de niveau {{current.cuisine.recette.system.niveau}}: : {{current.cuisine.label}} (
|
||||
</div>
|
||||
|
||||
<div class="chat-resume">
|
||||
{{current.carac.label}} / {{current.comp.label}} à {{current.diff.value}}
|
||||
<br>{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
|
||||
</div>
|
||||
|
||||
<div class="chat-details">
|
||||
<p>
|
||||
{{active.name}}
|
||||
{{#if rolled.isSuccess}}réussit la recette avec
|
||||
{{else}}manque d'inspiration, le plat a
|
||||
{{/if}}
|
||||
une qualité de {{result.qualite}}.
|
||||
</p>
|
||||
{{> 'partial-info-appel-moral'}}
|
||||
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-description.hbs" current.cuisine.recette.system}}
|
||||
</div>
|
||||
<div class="chat-buttons">
|
||||
{{> 'partial-appel-chance'}}
|
||||
</div>
|
||||
</div>
|
@@ -1,3 +1,4 @@
|
||||
|
||||
<subline>
|
||||
{{> "systems/foundryvtt-reve-de-dragon/templates/partial-description.hbs" current.oeuvre.system}}
|
||||
{{> "systems/foundryvtt-reve-de-dragon/templates/partial-description.hbs" current.recette.system}}
|
||||
</subline>
|
||||
|
16
templates/roll/roll-part-cuisine.hbs
Normal file
16
templates/roll/roll-part-cuisine.hbs
Normal file
@@ -0,0 +1,16 @@
|
||||
<roll-part-img>
|
||||
<img src="{{current.recette.img}}" data-tooltip="{{current.recette.name}}" />
|
||||
</roll-part-img>
|
||||
<roll-part-detail>
|
||||
<subline>
|
||||
<select name="select-recette" {{#if rollData.type.retry}}disabled{{/if}}>
|
||||
{{selectOptions refs.recettes selected=current.key valueAttr="key" labelAttr="label"}}
|
||||
</select>
|
||||
{{#if current.recette}}
|
||||
<selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value>
|
||||
{{/if}}
|
||||
</subline>
|
||||
{{#if current.recette}}
|
||||
{{> 'roll-oeuvre-recettecuisine'}}
|
||||
{{/if}}
|
||||
</roll-part-detail>
|
Reference in New Issue
Block a user