Compare commits

..

2 Commits

Author SHA1 Message Date
da1719a336 Start SheetV2 & fields 2025-02-02 00:07:52 +01:00
78e30b5503 Correction message min/max de race 2025-02-02 00:06:38 +01:00
27 changed files with 248 additions and 192 deletions

View File

@ -1,8 +1,4 @@
# 12.0
## 12.0.40 - Les mains d'Astrobazzarh
- correction des attaques particulières en combat
- correction de message sur les min/max liés aux modificateurs de races (s'applique uniquement sur la taille)
## 12.0.39 - Les mains d'Astrobazzarh
- les armes à 1 ou 2 mains fonctionnent dans les liens de jets de dés
- commande `/jet` pour poster une demande de jet de dés

View File

@ -1,2 +1,3 @@
export { default as RdDItemBaseSheet} from "./common-item-sheet.mjs"
export { default as RdDItemSheet} from "./common-item-sheet.mjs"
export { default as RdDMonnaieSheet } from "./monnaie-sheet.mjs"
export { default as RdDMunitionSheet } from "./munition-sheet.mjs"

View File

@ -1,20 +1,8 @@
const { HandlebarsApplicationMixin } = foundry.applications.api
import { SYSTEM_RDD } from "../../constants.js"
import { Misc } from "../../misc.js"
import { RdDSheetUtility } from "../../rdd-sheet-utility.js";
export default class RdDItemBaseSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ItemSheetV2) {
static preloadHandlebars(...templatesList) {
const handlebars = ["systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/header.hbs"]
templatesList.forEach(templates =>
templates.forEach(t =>
t.handlebars().forEach(h => handlebars.push(h))
)
)
loadTemplates(Misc.distinct(handlebars))
}
export default class RdDItemSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ItemSheetV2) {
static register(sheetClass) {
const itemType = sheetClass.ITEM_TYPE
@ -25,29 +13,20 @@ export default class RdDItemBaseSheet extends HandlebarsApplicationMixin(foundry
})
}
static registerAll(...sheetClasses) {
const handlebars = ["systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/header.hbs"]
sheetClasses.forEach(sheetClass => {
sheetClass.TEMPLATES.forEach(t =>
t.handlebars().forEach(h => handlebars.push(h))
)
const itemType = sheetClass.ITEM_TYPE
Items.registerSheet(SYSTEM_RDD, sheetClass, {
label: Misc.typeName('Item', itemType),
types: [itemType],
makeDefault: true
})
})
loadTemplates(Misc.distinct(handlebars))
}
static get ITEM_TYPE() { return undefined }
/**
* Different sheet modes.
* @enum {number}
*/
static SHEET_MODES = { EDIT: 0, PLAY: 1 }
constructor(options = {}) {
super(options)
this.#dragDrop = this.#createDragDropHandlers()
}
static get TEMPLATES() { return [] }
#dragDrop
_sheetMode = this.constructor.SHEET_MODES.PLAY
/** @override */
static DEFAULT_OPTIONS = {
@ -62,30 +41,140 @@ export default class RdDItemBaseSheet extends HandlebarsApplicationMixin(foundry
window: {
resizable: true,
},
dragDrop: [{ dragSelector: "[data-drag]", dropSelector: null }],
actions: {
editImage: RdDItemBaseSheet.#onEditImage,
toggleSheet: RdDItemSheet.#onToggleSheet,
editImage: RdDItemSheet.#onEditImage,
},
}
/**
* Is the sheet currently in 'Play' mode?
* @type {boolean}
*/
get isPlayMode() {
return this._sheetMode === this.constructor.SHEET_MODES.PLAY
}
/**
* Is the sheet currently in 'Edit' mode?
* @type {boolean}
*/
get isEditMode() {
return this._sheetMode === this.constructor.SHEET_MODES.EDIT
}
/** @override */
async _prepareContext() {
return {
item: this.document,
options: RdDSheetUtility.getOptions(this.document, this.isEditable),
const context = {
fields: this.document.schema.fields,
systemFields: this.document.system.schema.fields,
item: this.document,
system: this.document.system,
source: this.document.toObject(),
isEditMode: this.isEditMode,
isPlayMode: this.isPlayMode,
isEditable: this.isEditable,
}
return context
}
/** @override */
_onRender(context, options) {
this.#dragDrop.forEach((d) => d.bind(this.element))
}
// #region Drag-and-Drop Workflow
/**
* Create drag-and-drop workflow handlers for this Application
* @returns {DragDrop[]} An array of DragDrop handlers
* @private
*/
#createDragDropHandlers() {
return this.options.dragDrop.map((d) => {
d.permissions = {
dragstart: this._canDragStart.bind(this),
drop: this._canDragDrop.bind(this),
}
d.callbacks = {
dragstart: this._onDragStart.bind(this),
dragover: this._onDragOver.bind(this),
drop: this._onDrop.bind(this),
}
return new DragDrop(d)
})
}
/**
* Define whether a user is able to begin a dragstart workflow for a given drag selector
* @param {string} selector The candidate HTML selector for dragging
* @returns {boolean} Can the current user drag this selector?
* @protected
*/
_canDragStart(selector) {
return this.isEditable
}
/**
* Define whether a user is able to conclude a drag-and-drop workflow for a given drop selector
* @param {string} selector The candidate HTML selector for the drop target
* @returns {boolean} Can the current user drop on this selector?
* @protected
*/
_canDragDrop(selector) {
return this.isEditable && this.document.isOwner
}
/**
* Callback actions which occur at the beginning of a drag start workflow.
* @param {DragEvent} event The originating DragEvent
* @protected
*/
_onDragStart(event) {
const el = event.currentTarget
if ("link" in event.target.dataset) return
// Extract the data you need
let dragData = null
if (!dragData) return
// Set data transfer
event.dataTransfer.setData("text/plain", JSON.stringify(dragData))
}
/**
* Callback actions which occur when a dragged element is over a drop target.
* @param {DragEvent} event The originating DragEvent
* @protected
*/
_onDragOver(event) { }
/**
* Callback actions which occur when a dragged element is dropped on a target.
* @param {DragEvent} event The originating DragEvent
* @protected
*/
async _onDrop(event) { }
// #endregion
// #region Actions
/**
* Handle toggling between Edit and Play mode.
* @param {Event} event The initiating click event.
* @param {HTMLElement} target The current target of the event listener.
*/
static #onToggleSheet(event, target) {
const modes = this.constructor.SHEET_MODES
this._sheetMode = this.isEditMode ? modes.PLAY : modes.EDIT
this.render()
}
/**
* Handle changing a Document's image.
*
* @this RdDItemBaseSheet
* @this RdDItemSheet
* @param {PointerEvent} event The originating click event
* @param {HTMLElement} target The capturing HTML element which defined a [data-action]
* @returns {Promise}

View File

@ -1,40 +1,35 @@
import { TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE } from "../../common/_module.mjs";
import { ITEM_TYPES } from "../../constants.js";
import RdDItemBaseSheet from "./common-item-sheet.mjs";
export default class RdDMonnaieSheet extends RdDItemBaseSheet {
import RdDItemSheet from "./common-item-sheet.mjs";
export default class RdDMonnaieSheet extends RdDItemSheet {
/** @override */
static get ITEM_TYPE() { return ITEM_TYPES.monnaie }
static get TEMPLATES() { return [TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE] }
/** @override */
static DEFAULT_OPTIONS = Object.assign({},
RdDItemBaseSheet.DEFAULT_OPTIONS,
{
static DEFAULT_OPTIONS = {
classes: ["fvtt-rdd", "item", "monnaie"],
position: {
width: 400,
width: 600,
},
window: {
contentClasses: ["monnaie-content"],
},
}
})
/** @override */
static PARTS = {
main: {
template: "systems/foundryvtt-reve-de-dragon/templates/sheets/item/monnaie.hbs",
template: "systems/foundryvtt-reve-de-dragon/templates/item/monnaie.hbs",
},
}
/** @override */
async _prepareContext() {
return Object.assign(
await super._prepareContext(),
await TEMPLATE_DESCRIPTION.prepareContext(this.document),
await TEMPLATE_INVENTAIRE.prepareContext(this.document)
const context = await super._prepareContext()
return Object.assign(context,
await TEMPLATE_DESCRIPTION.prepareContext(this.item),
await TEMPLATE_INVENTAIRE.prepareContext(this.item)
)
}
}

View File

@ -0,0 +1,35 @@
import { TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE } from "../../common/_module.mjs";
import { ITEM_TYPES } from "../../constants.js";
import RdDItemSheet from "./common-item-sheet.mjs";
export default class RdDMunitionSheet extends RdDItemSheet {
/** @override */
static get ITEM_TYPE() { return ITEM_TYPES.munition }
/** @override */
static DEFAULT_OPTIONS = {
classes: ["fvtt-rdd", "item", "munition"],
position: {
width: 600,
},
window: {
contentClasses: ["munition-content"],
},
}
/** @override */
static PARTS = {
main: {
template: "systems/foundryvtt-reve-de-dragon/templates/item/munition.hbs",
},
}
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
return Object.assign(context,
await TEMPLATE_DESCRIPTION.prepareContext(this.item),
await TEMPLATE_INVENTAIRE.prepareContext(this.item)
)
}
}

View File

@ -4,5 +4,4 @@ import { CommonInventaire } from "./inventaire.mjs";
export const TEMPLATE_DESCRIPTION = new CommonDescription()
export const TEMPLATE_INVENTAIRE = new CommonInventaire()
export const ALL_COMMON_TEMPLATES = [TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE]

View File

@ -4,7 +4,5 @@
*/
export default class CommonTemplate {
fields() { }
handlebars() { return [] }
actions() { return {} }
async prepareContext(item) { }
}

View File

@ -12,21 +12,11 @@ export class CommonDescription extends CommonTemplate {
}
}
handlebars() {
return [
"systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/template-description.hbs",
]
}
actions() {
return {}
}
async prepareContext(item) {
const enriched = {
return {
description: await RdDTextEditor.enrichHTML(item.system.description, item),
descriptionmj: await RdDTextEditor.enrichHTML(item.system.descriptionmj, item),
}
return { enriched }
}
}

View File

@ -3,7 +3,7 @@ export const DECIMAL = { required: true, nullable: false, min: 0, integer: false
export const INTEGER_SIGNED = { required: true, nullable: false, integer: true }
export const DECIMAL_SIGNED = { required: true, nullable: false, integer: false }
export const STRING = { required: true, nullable: false, blank: true, trim: true }
export const HTMLSTRING = { initial: "", required: true, nullable: false, blank: true, textSearch: true }
export const HTMLSTRING = { initial: "", required: true, nullable: false, blank: true, trim: false, textSearch: true }
export const MODEL_ARRAY = { initial: [], required: true, nullable: false }

View File

@ -23,14 +23,6 @@ export class CommonInventaire extends CommonTemplate {
{ label: "Environnement", ...MODEL_ARRAY }),
}
}
handlebars() {
return [
"systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/template-inventaire.hbs"
]
}
async prepareContext(item) {
return {}
}
}

View File

@ -0,0 +1,7 @@
import { RdDItem } from "../item.js";
export default class RdDItemMunition extends RdDItem {
static get defaultIcon() {
return 'systems/foundryvtt-reve-de-dragon/icons/objets/fleche.webp'
}
}

View File

@ -100,7 +100,7 @@ export class RdDItemSheetV1 extends ItemSheet {
description: await RdDTextEditor.enrichHTML(this.item.system.description, this.item),
descriptionmj: await RdDTextEditor.enrichHTML(this.item.system.descriptionmj, this.item),
isComestible: this.item.getUtilisationCuisine(),
options: RdDSheetUtility.mergeDocumentRights({}, this.item, this.isEditable),
options: RdDSheetUtility.mergeDocumentRights(this.options, this.item, this.isEditable),
competences: await SystemCompendiums.getCompetences(ACTOR_TYPES.personnage),
categories: RdDItem.getCategories(this.item.type),
}

View File

@ -1 +1,2 @@
export { default as RdDModelMonnaie } from "./monnaie.mjs"
export { default as RdDModelMunition } from "./munition.mjs"

View File

@ -0,0 +1,10 @@
import { TEMPLATE_DESCRIPTION, TEMPLATE_INVENTAIRE } from "../common/_module.mjs";
export default class RdDModelMunition extends foundry.abstract.TypeDataModel {
static defineSchema() {
return Object.assign({},
TEMPLATE_DESCRIPTION.fields(),
TEMPLATE_INVENTAIRE.fields()
)
}
}

View File

@ -832,10 +832,7 @@ export class RdDCombat {
/* -------------------------------------------- */
async _onAttaqueNormale(attackerRoll) {
if (!RdDCombat.isReussite(attackerRoll)) {
return
}
if (RdDCombat.isParticuliere(attackerRoll) && attackerRoll.particuliere == undefined) {
if (!RdDCombat.isReussite(attackerRoll) || RdDCombat.isParticuliere(attackerRoll)) {
return
}
console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll);
@ -852,7 +849,7 @@ export class RdDCombat {
return;
}
if (this.defender) {
if (this.target) {
await this._sendMessageDefense(attackerRoll, defenderRoll);
}
}
@ -1002,7 +999,7 @@ export class RdDCombat {
this.removeChatMessageActionsPasseArme(rollData.passeArme);
rollData.particuliere = choix;
await this._onAttaqueNormale(rollData)
await this._onAttaqueNormale(rollData);
}
/* -------------------------------------------- */

View File

@ -105,6 +105,7 @@ export class SystemReveDeDragon {
this.RdDStatBlockParser = RdDStatBlockParser
this.itemClasses = {
monnaie: items.RdDModelMonnaie,
munition: items.RdDModelMunition,
armure: RdDItemArmure,
blessure: RdDItemBlessure,
gemme: RdDItemGemme,
@ -185,6 +186,7 @@ export class SystemReveDeDragon {
CONFIG.Item.documentClass = RdDItem
CONFIG.Item.dataModels = {
monnaie: models.RdDModelMonnaie,
munition: models.RdDModelMunition,
}
CONFIG.RDD = {
resolutionTable: RdDResolutionTable.resolutionTable,
@ -206,17 +208,14 @@ export class SystemReveDeDragon {
Items.registerSheet(SYSTEM_RDD, RdDItemInventaireSheet, {
types: [
"objet", "arme", "armure", "livre", "munition", "nourritureboisson",
"objet", "arme", "armure", "livre", "nourritureboisson",
],
makeDefault: true
})
sheets.RdDItemBaseSheet.registerAll(
sheets.RdDMonnaieSheet
)
sheets.RdDItemSheet.register(sheets.RdDMonnaieSheet)
sheets.RdDItemSheet.register(sheets.RdDMunitionSheet)
// ,
// sheets.RdDMunitionSheet
Items.registerSheet(SYSTEM_RDD, RdDItemSheetV1, {
types: [
"competence", "competencecreature",

View File

@ -3,11 +3,11 @@ import { RdDItem } from "./item.js";
export class RdDSheetUtility {
static getOptions(document, editable) {
static mergeDocumentRights(options, document, editable) {
const userRightLevel = game.user.isGM
? CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER
: document.getUserLevel(game.user);
return {
let newOptions = {
isGM: game.user.isGM,
isOwned: document.parent ? true : false,
editable: editable,
@ -16,15 +16,10 @@ export class RdDSheetUtility {
isObserver: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER,
isOwner: userRightLevel >= CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER
}
}
static mergeDocumentRights(options, document, editable) {
const newOptions = RdDSheetUtility.getOptions(document, editable);
foundry.utils.mergeObject(options, newOptions);
return options;
}
static getItem(event, actor) {
return actor.items.get(RdDSheetUtility.getItemId(event))
}

View File

@ -28,9 +28,6 @@
font-weight: normal;
font-style: normal;
}
body {
--input-height: 1.4rem;
}
:root {
/* =================== 1. ACTOR SHEET FONT STYLES =========== */
--window-header-title-font-family: CaslonAntique;
@ -734,36 +731,10 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) {
.flex-grow-3 {
flex-grow: 3;
}
fieldset {
border-style: groove;
border-width: 0.1rem;
padding-inline: 0.2rem;
padding-block: 0.1rem;
margin-inline: 0.1rem;
margin-block: 0.1rem;
}
form.application.sheet.fvtt-rdd fieldset :is(label, input) {
font-family: CaslonAntique;
text-align: justify;
font-size: 1rem;
letter-spacing: 1px;
}
form.application.sheet.fvtt-rdd div.form-group {
clear: both;
display: flex;
flex-direction: row;
flex-wrap: wrap;
margin: 0.1rem 0;
align-items: center;
}
form.application.sheet.fvtt-rdd .editor.prosemirror {
.editor.prosemirror {
height: fit-content;
min-height: 5rem;
}
form.application.sheet.fvtt-rdd prose-mirror.prosemirror .editor-container {
min-height: 5rem;
height: fit-content;
margin: 0;
min-height: 20rem;
}
.large-editor {
border: 2;
@ -771,7 +742,6 @@ form.application.sheet.fvtt-rdd prose-mirror.prosemirror .editor-container {
min-height: 12rem;
padding: 0 3px;
}
.editor {
border: 2;
height: fit-content;
@ -795,7 +765,6 @@ form.application.sheet.fvtt-rdd prose-mirror.prosemirror .editor-container {
.foundryvtt-reve-de-dragon.sheet :is(.large-editor,.editor,.medium-editor,.small-editor){
align-items: start;
}
.foundryvtt-reve-de-dragon.sheet :is(.large-editor,.editor,.medium-editor,.small-editor) .editor.prosemirror{
align-items: normal;
}

View File

@ -750,9 +750,6 @@
"inertie": 0,
"enchantabilite": 0
},
"munition": {
"templates": ["description", "inventaire"]
},
"nourritureboisson": {
"templates": ["description", "inventaire", "comestible"],
"cuisinier": "",

View File

@ -2,22 +2,19 @@
<h4 class="rdd-roll-part">{{alias}} réussit une attaque particulière!</strong></h4>
{{#if isForce}}
<br>
<a class="chat-card-button particuliere-attaque" data-mode="force" data-attackerId="{{attackerId}}"
data-defenderTokenId="{{defenderToken.id}}" data-attackerTokenId="{{attackerToken.id}}">
<a class="chat-card-button particuliere-attaque" data-mode="force" data-attackerId="{{attackerId}}">
Attaquer en Force
</a>
{{/if}}
{{#if isRapide}}
<br>
<a class="chat-card-button particuliere-attaque" data-mode="rapidite" data-attackerId="{{attackerId}}"
data-defenderTokenId="{{defenderToken.id}}" data-attackerTokenId="{{attackerToken.id}}">
<a class="chat-card-button particuliere-attaque" data-mode="rapidite" data-attackerId="{{attackerId}}">
Attaquer en Rapidité
</a>
{{/if}}
{{#if isFinesse}}
<br>
<a class="chat-card-button particuliere-attaque" data-mode="finesse" data-attackerId="{{attackerId}}"
data-defenderTokenId="{{defenderToken.id}}" data-attackerTokenId="{{attackerToken.id}}">
<a class="chat-card-button particuliere-attaque" data-mode="finesse" data-attackerId="{{attackerId}}">
Attaquer en Finesse
</a>
{{/if}}

View File

@ -0,0 +1,14 @@
<form class="{{cssClass}}" autocomplete="off">
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.hbs"}}
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="informations">Informations</a>
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-tab-environnement.hbs"}}
</nav>
<section class="sheet-body">
<div class="tab items flexcol" data-group="primary" data-tab="informations">
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-inventaire.hbs"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.hbs"}}
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-environnement.hbs"}}
</section>
</form>

View File

@ -0,0 +1,14 @@
<form class="{{cssClass}}" autocomplete="off">
{{>"systems/foundryvtt-reve-de-dragon/templates/header-item.hbs"}}
<nav class="sheet-tabs tabs" data-group="primary">
<a class="item" data-tab="informations">Informations</a>
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-tab-environnement.hbs"}}
</nav>
<section class="sheet-body">
<div class="tab items flexcol" data-group="primary" data-tab="informations">
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-inventaire.hbs"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-item-description.hbs"}}
</div>
{{>"systems/foundryvtt-reve-de-dragon/templates/item/partial-environnement.hbs"}}
</section>
</form>

View File

@ -1,6 +0,0 @@
<header class="sheet-header">
<img class="profile-img" src="{{item.img}}" data-edit="img" data-tooltip="{{item.name}}"/>
<div class="header-fields">
<h1 class="charname"><input name="name" type="text" value="{{item.name}}" placeholder="Name"/></h1>
</div>
</header>

View File

@ -1,21 +0,0 @@
<fieldset>
<div>
<label>Description :</label>
{{formInput
systemFields.description
enriched=enriched.description
value=system.description
name="system.description"
toggled=true}}
</div>
{{#if options.isGM}}
<div>
<label>Description (MJ seulement):</label>
{{formInput
systemFields.descriptionmj
enriched=enriched.descriptionmj
value=system.descriptionmj
name="system.descriptionmj" toggled=true}}
</div>
{{/if}}
</fieldset>

View File

@ -1,6 +0,0 @@
<fieldset>
{{formField systemFields.qualite value=system.qualite}}
{{formField systemFields.encombrement value=system.encombrement}}
{{formField systemFields.quantite value=system.quantite}}
{{formField systemFields.cout value=system.cout}}
</fieldset>

View File

@ -1,6 +0,0 @@
<section>
{{> "systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/header.hbs"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/template-inventaire.hbs"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/sheets/item/common/template-description.hbs"}}
</section>