Compare commits

...

1 Commits

Author SHA1 Message Date
dd296822bc Bouton "don de haut-rêve"
Pour permettre au MJ de rendre un personnage haut rêvant
sans avoir à chercher dans les compendiums
2024-12-03 23:32:43 +01:00
11 changed files with 96 additions and 50 deletions

View File

@ -214,6 +214,8 @@ export class RdDActorSheet extends RdDBaseActorSangSheet {
}); });
// Boutons spéciaux MJs // Boutons spéciaux MJs
this.html.find('.forcer-tmr-aleatoire').click(async event => this.actor.reinsertionAleatoire("Action MJ")) this.html.find('.forcer-tmr-aleatoire').click(async event => this.actor.reinsertionAleatoire("Action MJ"))
this.html.find('.don-de-haut-reve').click(async event => this.actor.addDonDeHautReve())
this.html.find('.afficher-tmr').click(async event => this.actor.changeTMRVisible()) this.html.find('.afficher-tmr').click(async event => this.actor.changeTMRVisible())
} }

View File

@ -38,6 +38,8 @@ import { RdDCoeur } from "./coeur/rdd-coeur.js";
import { DialogChoixXpCarac } from "./dialog-choix-xp-carac.js"; import { DialogChoixXpCarac } from "./dialog-choix-xp-carac.js";
import { RdDItemArme } from "./item-arme.js"; import { RdDItemArme } from "./item-arme.js";
import { RdDCombatManager } from "./rdd-combat.js"; import { RdDCombatManager } from "./rdd-combat.js";
import { RdDItemTete } from "./item/tete.js";
import { SystemCompendiums } from "./settings/system-compendiums.js";
export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre'] export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre']
@ -87,7 +89,7 @@ export class RdDActor extends RdDBaseActorSang {
} }
$computeIsHautRevant() { $computeIsHautRevant() {
this.system.attributs.hautrevant.value = this.itemTypes['tete'].find(it => Grammar.equalsInsensitive(it.name, 'don de haut-reve')) this.system.attributs.hautrevant.value = this.itemTypes[ITEM_TYPES.tete].find(it => RdDItemTete.isDonDeHautReve(it))
? "Haut rêvant" ? "Haut rêvant"
: ""; : "";
} }
@ -989,6 +991,16 @@ export class RdDActor extends RdDBaseActorSang {
}); });
} }
/* -------------------------------------------- */
async addDonDeHautReve() {
if (!game.user.isGM || this.isHautRevant()) {
return
}
const donHR = await RdDItemTete.teteDonDeHautReve()
if (donHR) {
this.createEmbeddedDocuments('Item', [donHR.toObject()])
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async reinsertionAleatoire(raison, accessible = tmr => true) { async reinsertionAleatoire(raison, accessible = tmr => true) {

View File

@ -234,8 +234,7 @@ export class RdDStatBlockParser {
}); });
if (hautRevant) { if (hautRevant) {
let tetes = await SystemCompendiums.getWorldOrCompendiumItems("tete", "tetes-de-dragon-pour-tous-personnages") const donHR = await RdDItemTete.teteDonDeHautReve()
let donHR = tetes.find(t => Grammar.equalsInsensitive(t.name, "Don de Haut-Rêve"))
if (donHR) { if (donHR) {
items.push(donHR.toObject()); items.push(donHR.toObject());
} }

25
module/item/tete.js Normal file
View File

@ -0,0 +1,25 @@
import { Grammar } from "../grammar.js"
import { ITEM_TYPES, RdDItem } from "../item.js"
import { SystemCompendiums } from "../settings/system-compendiums.js"
const DON_HAUT_REVE = "Don de Haut-Rêve"
export class RdDItemTete extends RdDItem {
static get defaultIcon() {
return "systems/foundryvtt-reve-de-dragon/icons/tete_dragon.webp"
}
static isDonDeHautReve(tete) {
return tete.type == ITEM_TYPES.tete && Grammar.equalsInsensitive(tete.name, DON_HAUT_REVE)
}
static async teteDonDeHautReve() {
const tetes = await SystemCompendiums.getItems("tetes-de-dragon-pour-tous-personnages", ITEM_TYPES.tete)
const tete = tetes.find(it => RdDItemTete.isDonDeHautReve(it))
if (!tete) {
ui.notifications.warn(`Impossible de trouver la tête "${DON_HAUT_REVE}", vérifiez le compendium de têtes pour tous personnages`)
}
return tete
}
}

View File

@ -70,6 +70,7 @@ import { AppPersonnageAleatoire } from "./actor/random/app-personnage-aleatoire.
import { RdDActorExportSheet } from "./actor/export-scriptarium/actor-encart-sheet.js" import { RdDActorExportSheet } from "./actor/export-scriptarium/actor-encart-sheet.js"
import { RdDStatBlockParser } from "./apps/rdd-import-stats.js" import { RdDStatBlockParser } from "./apps/rdd-import-stats.js"
import { RdDItemSort } from "./item-sort.js" import { RdDItemSort } from "./item-sort.js"
import { RdDItemTete } from "./item/tete.js"
/** /**
* RdD system * RdD system
@ -97,6 +98,7 @@ export class SystemReveDeDragon {
ombre: RdDItemOmbre, ombre: RdDItemOmbre,
poison: RdDItemPoison, poison: RdDItemPoison,
queue: RdDItemQueue, queue: RdDItemQueue,
tete: RdDItemTete,
rencontre: RdDRencontre, rencontre: RdDRencontre,
service: RdDItemService, service: RdDItemService,
signedraconique: RdDItemSigneDraconique, signedraconique: RdDItemSigneDraconique,

View File

@ -145,8 +145,8 @@ export class RdDUtility {
'systems/foundryvtt-reve-de-dragon/templates/actor/alchimie.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/alchimie.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/astrologie.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/astrologie.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/chirurgie.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/chirurgie.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/non-haut-revant.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/non-haut-revant.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/haut-revant.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/haut-revant.hbs',
'systems/foundryvtt-reve-de-dragon/templates/actor/dragon-queues.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/dragon-queues.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/dragon-queue.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/dragon-queue.html',
'systems/foundryvtt-reve-de-dragon/templates/actor/dragon-souffles.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/dragon-souffles.html',

View File

@ -1,5 +1,6 @@
import { ChatUtility } from "../chat-utility.js"; import { ChatUtility } from "../chat-utility.js";
import { HIDE_DICE, SYSTEM_RDD } from "../constants.js"; import { HIDE_DICE, SYSTEM_RDD } from "../constants.js";
import { Grammar } from "../grammar.js";
import { RdDItem } from "../item.js"; import { RdDItem } from "../item.js";
import { Misc } from "../misc.js"; import { Misc } from "../misc.js";
import { RdDDice } from "../rdd-dice.js"; import { RdDDice } from "../rdd-dice.js";
@ -84,15 +85,14 @@ export class SystemCompendiums extends FormApplication {
static async getWorldOrCompendiumItems(itemType, compendium) { static async getWorldOrCompendiumItems(itemType, compendium) {
let items = game.items.filter(it => it.type == itemType) let items = game.items.filter(it => it.type == itemType)
if (compendium) { if (compendium) {
const ids = items.map(it => it.id); const ids = items.map(it => it.id)
const names = items.map(it => it.name.toLowerCase()); const names = items.map(it => Grammar.toLowerCaseNoAccent(it.name))
const compendiumItems = await SystemCompendiums.getItems(compendium); const compendiumItems = await SystemCompendiums.getItems(compendium, itemType)
items = items.concat(compendiumItems return items.concat(compendiumItems
.filter(it => it.type == itemType)
.filter(it => !ids.includes(it.id)) .filter(it => !ids.includes(it.id))
.filter(it => !names.includes(it.name.toLowerCase()))); .filter(it => !names.includes(Grammar.equalsInsensitive(it.name))))
} }
return items; return items
} }
static async loadDocument(document) { static async loadDocument(document) {

View File

@ -129,11 +129,10 @@
<div> <div>
{{#if system.attributs.hautrevant.value}} {{#if system.attributs.hautrevant.value}}
<h3>Haut rêvant</h3> <h3>Haut rêvant</h3>
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/haut-revant.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/haut-revant.hbs"}}
{{else}} {{else}}
<h3>Vous n'avez pas le don de haut-rêve</h3> <h3>Vous n'avez pas le don de haut-rêve</h3>
<p>Attribuer la Tête de Dragon 'Don de Haut Rêve' pour rendre le personnage Haut-Rêvant.</p> {{> "systems/foundryvtt-reve-de-dragon/templates/actor/non-haut-revant.hbs"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/non-haut-revant.html"}}
{{/if}} {{/if}}
<br><br> <br><br>
</div> </div>

View File

@ -26,7 +26,7 @@
{{/if}} {{/if}}
</span> </span>
</li> </li>
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/non-haut-revant.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/non-haut-revant.hbs"}}
<hr> <hr>
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-signes-draconiques.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-signes-draconiques.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-rencontres.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/hr-rencontres.html"}}

View File

@ -0,0 +1,41 @@
{{#if (not system.attributs.hautrevant.value)}}
<p>Attribuer la Tête de Dragon
{{#if options.isGM}}
<a class="chat-card-button don-de-haut-reve" data-tooltip="Donner le don de haut-rêve">Don de Haut Rêve</a>
{{else}}
'Don de Haut Rêve'
{{/if}}
pour rendre le personnage Haut-Rêvant.</p>
{{/if}}
<li class="item flexrow">
<span class="competence-label">Seuil de Rêve :</span>
<span>
{{#if options.isGM}}
<input class="competence-value seuil-reve-value" type="text" name="system.reve.seuil.value" value="{{system.reve.seuil.value}}" data-dtype="Number"/>
{{else}}
{{system.reve.seuil.value}}
{{/if}}
</span>
</li>
<li class="item flexrow" >
<span class="competence-label">Refoulement : </span>
<span>
{{#if options.isGM}}
<input class="competence-value" type="text" name="system.reve.refoulement.value" value="{{system.reve.refoulement.value}}" data-dtype="Number"/>
{{else}}
{{system.reve.refoulement.value}}
{{/if}}
</span>
</li>
{{#if system.reve.reve.thanatosused}}
<li class="item flexrow" >
<span class="competence-label">La prochaine queue est une Ombre</span>
<span>
<img class="sheet-competence-img" src="systems/foundryvtt-reve-de-dragon/icons/competence_thanatos.webp"/>
</span>
</li>
{{/if}}
<hr>
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/dragon-queues.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/dragon-souffles.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/dragon-tetes.html"}}

View File

@ -1,34 +0,0 @@
<ul class="item-list">
<li class="item flexrow">
<span class="competence-label">Seuil de Rêve :</span>
<span>
{{#if options.isGM}}
<input class="competence-value seuil-reve-value" type="text" name="system.reve.seuil.value" value="{{system.reve.seuil.value}}" data-dtype="Number"/>
{{else}}
{{system.reve.seuil.value}}
{{/if}}
</span>
</li>
<li class="item flexrow" >
<span class="competence-label">Refoulement : </span>
<span>
{{#if options.isGM}}
<input class="competence-value" type="text" name="system.reve.refoulement.value" value="{{system.reve.refoulement.value}}" data-dtype="Number"/>
{{else}}
{{system.reve.refoulement.value}}
{{/if}}
</span>
</li>
{{#if system.reve.reve.thanatosused}}
<li class="item flexrow" >
<span class="competence-label">La prochaine queue est une Ombre</span>
<span>
<img class="sheet-competence-img" src="systems/foundryvtt-reve-de-dragon/icons/competence_thanatos.webp"/>
</span>
</li>
{{/if}}
</ul>
<hr>
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/dragon-queues.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/dragon-souffles.html"}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/dragon-tetes.html"}}