Ame/Ame max

This commit is contained in:
2025-10-26 11:41:18 +01:00
parent 2dc7665a25
commit 40e11aca1b
146 changed files with 417 additions and 912 deletions

View File

@@ -0,0 +1,116 @@
/**
* Macro pour remplacer les chemins d'images dans les compendiums
* Remplace "fvtt-hawkmoon-cyd" par "fvtt-mournblade-cyd2" dans tous les champs 'img'
*/
(async () => {
// Confirmation avant de procéder
let confirm = await Dialog.confirm({
title: "Remplacement des chemins d'images",
content: `<p>Cette macro va :</p>
<ul>
<li>Déverrouiller tous les compendiums</li>
<li>Remplacer "fvtt-hawkmoon-cyd" par "fvtt-mournblade-cyd2" dans tous les champs 'img'</li>
<li>Reverrouiller les compendiums</li>
</ul>
<p><strong>Voulez-vous continuer ?</strong></p>`,
defaultYes: false
});
if (!confirm) {
ui.notifications.info("Opération annulée");
return;
}
ui.notifications.info("Début du traitement des compendiums...");
let totalUpdated = 0;
let compendiumsProcessed = 0;
// Parcourir tous les compendiums
for (let pack of game.packs) {
// Filtrer uniquement les compendiums du système mournblade
if (!pack.metadata.packageName.includes("mournblade")) continue;
console.log(`Traitement du compendium: ${pack.metadata.label}`);
compendiumsProcessed++;
try {
// Unlock le compendium
await pack.configure({ locked: false });
// Récupérer tous les documents du compendium
let documents = await pack.getDocuments();
let updatedInPack = 0;
for (let doc of documents) {
let needsUpdate = false;
let updateData = {};
// Vérifier le champ img principal
if (doc.img && doc.img.includes("fvtt-hawkmoon-cyd")) {
updateData.img = doc.img.replace(/fvtt-hawkmoon-cyd/g, "fvtt-mournblade-cyd2");
needsUpdate = true;
}
// Pour les acteurs, vérifier aussi prototypeToken.texture.src
if (doc.documentName === "Actor" && doc.prototypeToken?.texture?.src) {
if (doc.prototypeToken.texture.src.includes("fvtt-hawkmoon-cyd")) {
updateData["prototypeToken.texture.src"] = doc.prototypeToken.texture.src.replace(/fvtt-hawkmoon-cyd/g, "fvtt-mournblade-cyd2");
needsUpdate = true;
}
}
// Pour les items contenus dans les acteurs
if (doc.documentName === "Actor" && doc.items) {
for (let item of doc.items) {
if (item.img && item.img.includes("fvtt-hawkmoon-cyd")) {
// Note: Les items embarqués nécessitent une approche différente
needsUpdate = true;
}
}
}
// Pour les scènes, vérifier background.src et les tokens
if (doc.documentName === "Scene") {
if (doc.background?.src && doc.background.src.includes("fvtt-hawkmoon-cyd")) {
updateData["background.src"] = doc.background.src.replace(/fvtt-hawkmoon-cyd/g, "fvtt-mournblade-cyd2");
needsUpdate = true;
}
}
// Effectuer la mise à jour si nécessaire
if (needsUpdate) {
await doc.update(updateData);
updatedInPack++;
console.log(` - Mise à jour: ${doc.name}`);
}
}
// Lock le compendium
await pack.configure({ locked: true });
if (updatedInPack > 0) {
ui.notifications.info(`${pack.metadata.label}: ${updatedInPack} document(s) mis à jour`);
totalUpdated += updatedInPack;
}
} catch (error) {
console.error(`Erreur lors du traitement de ${pack.metadata.label}:`, error);
ui.notifications.error(`Erreur sur ${pack.metadata.label}: ${error.message}`);
// Tenter de reverrouiller en cas d'erreur
try {
await pack.configure({ locked: true });
} catch (lockError) {
console.error(`Impossible de reverrouiller ${pack.metadata.label}:`, lockError);
}
}
}
ui.notifications.info(`Traitement terminé ! ${totalUpdated} document(s) mis à jour dans ${compendiumsProcessed} compendium(s).`);
console.log(`=== Résumé ===`);
console.log(`Compendiums traités: ${compendiumsProcessed}`);
console.log(`Total de documents mis à jour: ${totalUpdated}`);
})();

View File

@@ -53,7 +53,6 @@ export class MournbladeCYD2ActorSheet extends foundry.appv1.sheets.ActorSheet {
traitsEspeces: foundry.utils.duplicate(this.actor.getTraitsEspeces() || []),
aspect: this.actor.getAspect(),
marge: this.actor.getMarge(),
talentsCell: this.getCelluleTalents(),
profils: foundry.utils.duplicate(this.actor.getProfils() || []),
combat: this.actor.getCombatValues(),
equipements: foundry.utils.duplicate(this.actor.getEquipments()),
@@ -82,20 +81,6 @@ export class MournbladeCYD2ActorSheet extends foundry.appv1.sheets.ActorSheet {
return formData;
}
/* -------------------------------------------- */
getCelluleTalents() {
let talents = []
for (let cellule of game.actors) {
if (cellule.type == "cellule") {
let found = cellule.system.members.find(it => it.id == this.actor.id)
if (found) {
talents = talents.concat(cellule.getTalents())
}
}
}
return talents
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {

View File

@@ -38,6 +38,7 @@ export class MournbladeCYD2Actor extends Actor {
}
if (data.type == 'personnage') {
console.log("Loading skills for personnage")
const skills = await MournbladeCYD2Utility.loadCompendium("fvtt-mournblade-cyd2.skills")
data.items = skills.map(i => i.toObject())
}
@@ -67,10 +68,6 @@ export class MournbladeCYD2Actor extends Actor {
/* -------------------------------------------- */
prepareArme(arme) {
if (this.type == "cellule") {
return arme
}
arme = foundry.utils.duplicate(arme)
let combat = this.getCombatValues()
if (arme.system.typearme == "contact" || arme.system.typearme == "contactjet") {
@@ -235,20 +232,6 @@ export class MournbladeCYD2Actor extends Actor {
/* -------------------------------------------- */
getCombatValues() {
if (this.type == "cellule") {
return {
initBase: 0,
initTotal: 0,
bonusDegats: 0,
bonusDegatsTotal: 0,
vitesseBase: 0,
vitesseTotal: 0,
defenseBase: 0,
protection: 0,
defenseTotal: 0
}
}
let combat = {
initBase: this.system.attributs.adr.value,
initTotal: this.system.attributs.adr.value + this.system.combat.initbonus,
@@ -550,11 +533,16 @@ export class MournbladeCYD2Actor extends Actor {
// Gestion des états Traumatisé, Très Traumatisé et Brisé
if (ame.etat == traumatiseValue) {
ChatMessage.create({ content: `<strong>${this.name} est Traumatisé !</strong>` })
ChatMessage.create({ content: `<strong>${this.name} est Traumatisé et subit 1 adversité bleue et 1 adversité noire !</strong>` })
this.incDecAdversite("bleue", 1)
this.incDecAdversite("noire", 1)
} else if (ame.etat == tresTraumatiseValue) {
ChatMessage.create({ content: `<strong>${this.name} est Très Traumatisé !</strong>` })
ChatMessage.create({ content: `<strong>${this.name} est Très Traumatisé et subit 1 adversité bleue et 1 adversité noire !</strong>` })
this.incDecAdversite("bleue", 1)
this.incDecAdversite("noire", 1)
} else if (ame.etat >= briseValue) {
ChatMessage.create({ content: `<strong>${this.name} est Brisé !</strong>` })
ChatMessage.create({ content: `<strong>${this.name} est Brisé et subit 1 adversité noire !</strong>` })
this.incDecAdversite("noire", 1)
}
}

View File

@@ -1,173 +0,0 @@
/**
* Extend the basic ActorSheet with some very simple modifications
* @extends {ActorSheet}
*/
import { MournbladeCYD2Utility } from "./mournblade-cyd2-utility.js";
import { MournbladeCYD2Automation } from "./mournblade-cyd2-automation.js";
/* -------------------------------------------- */
const __ALLOWED_ITEM_CELLULE = { "talent": 1, "ressource": 1, "contact": 1, "equipement": 1, "protection": 1, "artefact": 1, "arme": 1, "monnaie": 1 }
/* -------------------------------------------- */
export class MournbladeCYD2CelluleSheet extends foundry.appv1.sheets.ActorSheet {
/** @override */
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["fvtt-mournblade-cyd2", "sheet", "actor"],
template: "systems/fvtt-mournblade-cyd2/templates/cellule-sheet.html",
width: 640,
height: 720,
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "talents" }],
dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }],
editScore: false
});
}
/* -------------------------------------------- */
async getData() {
const objectData = foundry.utils.duplicate(this.object)
let formData = {
title: this.title,
id: objectData.id,
type: objectData.type,
img: objectData.img,
name: objectData.name,
editable: this.isEditable,
cssClass: this.isEditable ? "editable" : "locked",
system: objectData.system,
effects: this.object.effects.map(e => foundry.utils.deepClone(e.data)),
limited: this.object.limited,
talents: foundry.utils.duplicate(this.actor.getTalents() || {}),
ressources: foundry.utils.duplicate(this.actor.getRessources()),
contacts: foundry.utils.duplicate(this.actor.getContacts()),
members: this.getMembers(),
equipements: foundry.utils.duplicate(this.actor.getEquipments()),
artefacts: foundry.utils.duplicate(this.actor.getArtefacts()),
armes: foundry.utils.duplicate(this.actor.getWeapons()),
monnaies: foundry.utils.duplicate(this.actor.getMonnaies()),
protections: foundry.utils.duplicate(this.actor.getArmors()),
richesse: this.actor.computeRichesse(),
valeurEquipement: this.actor.computeValeurEquipement(),
description: await TextEditor.enrichHTML(this.object.system.description, { async: true }),
options: this.options,
owner: this.document.isOwner,
editScore: this.options.editScore,
isGM: game.user.isGM,
config: game.system.mournbladecyd2.config
}
this.formData = formData;
console.log("CELLULE : ", formData, this.object);
return formData;
}
/* -------------------------------------------- */
getMembers( ) {
let membersFull = []
for(let def of this.actor.system.members) {
let actor = game.actors.get(def.id)
membersFull.push( { name: actor.name, id: actor.id, img: actor.img } )
}
return membersFull
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
super.activateListeners(html);
// Everything below here is only needed if the sheet is editable
if (!this.options.editable) return;
// Update Inventory Item
html.find('.actor-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item")
let actorId = li.data("actor-id")
const actor = game.actors.get(actorId)
actor.sheet.render(true)
})
html.find('.actor-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item")
let actorId = li.data("actor-id")
this.actor.removeMember(actorId)
})
// Update Inventory Item
html.find('.item-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item")
let itemId = li.data("item-id")
const item = this.actor.items.get(itemId)
item.sheet.render(true)
})
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
MournbladeCYD2Utility.confirmDelete(this, li);
})
html.find('.edit-item-data').change(ev => {
const li = $(ev.currentTarget).parents(".item")
let itemId = li.data("item-id")
let itemType = li.data("item-type")
let itemField = $(ev.currentTarget).data("item-field")
let dataType = $(ev.currentTarget).data("dtype")
let value = ev.currentTarget.value
this.actor.editItemField(itemId, itemType, itemField, dataType, value)
})
html.find('.quantity-modify').click(event => {
const li = $(event.currentTarget).parents(".item")
const value = Number($(event.currentTarget).data("quantite-value"))
this.actor.incDecQuantity( li.data("item-id"), value );
})
html.find('.item-add').click((event) => {
const itemType = $(event.currentTarget).data("type")
this.actor.createEmbeddedDocuments('Item', [{ name: `Nouveau ${itemType}`, type: itemType }], { renderSheet: true })
})
html.find('.lock-unlock-sheet').click((event) => {
this.options.editScore = !this.options.editScore;
this.render(true);
});
}
/* -------------------------------------------- */
async _onDropActor(event, dragData) {
const actor = fromUuidSync(dragData.uuid)
if (actor) {
this.actor.addMember(actor.id)
} else {
ui.notifications.warn("Cet acteur n'a pas été trouvé.")
}
super._onDropActor(event)
}
/* -------------------------------------------- */
async _onDropItem(event, dragData) {
let data = event.dataTransfer.getData('text/plain')
let dataItem = JSON.parse(data)
let item = fromUuidSync(dataItem.uuid)
if (item.pack) {
item = await MournbladeCYD2Utility.searchItem(item)
}
if ( __ALLOWED_ITEM_CELLULE[item.type]) {
super._onDropItem(event, dragData)
return
}
ui.notification.info("Ce type d'item n'est pas autorisé sur une Cellule.")
}
/* -------------------------------------------- */
/** @override */
setPosition(options = {}) {
const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 192;
sheetBody.css("height", bodyHeight);
return position;
}
}

View File

@@ -121,7 +121,6 @@ export const MOURNBLADECYD2_CONFIG = {
],
optionsTypeTalent: [
{ key: "personnage", label: "Personnage" },
{ key: "cellule", label: "Cellule" },
{ key: "traitespece", label: "Trait d'espèce" }
],
optionsUseTalent: [

View File

@@ -12,7 +12,6 @@ import { MournbladeCYD2Actor } from "./mournblade-cyd2-actor.js";
import { MournbladeCYD2ItemSheet } from "./mournblade-cyd2-item-sheet.js";
import { MournbladeCYD2ActorSheet } from "./mournblade-cyd2-actor-sheet.js";
import { MournbladeCYD2CreatureSheet } from "./mournblade-cyd2-creature-sheet.js";
import { MournbladeCYD2CelluleSheet } from "./mournblade-cyd2-cellule-sheet.js";
import { MournbladeCYD2Utility } from "./mournblade-cyd2-utility.js";
import { MournbladeCYD2Combat } from "./mournblade-cyd2-combat.js";
import { MournbladeCYD2Item } from "./mournblade-cyd2-item.js";
@@ -60,7 +59,6 @@ Hooks.once("init", async function () {
foundry.documents.collections.Actors.unregisterSheet("core", foundry.appv1.sheets.ActorSheet);
foundry.documents.collections.Actors.registerSheet("fvtt-mournblade-cyd2", MournbladeCYD2ActorSheet, { types: ["personnage"], makeDefault: true })
foundry.documents.collections.Actors.registerSheet("fvtt-mournblade-cyd2", MournbladeCYD2CreatureSheet, { types: ["creature"], makeDefault: true })
foundry.documents.collections.Actors.registerSheet("fvtt-mournblade-cyd2", MournbladeCYD2CelluleSheet, { types: ["cellule"], makeDefault: true });
foundry.documents.collections.Items.unregisterSheet("core", foundry.appv1.sheets.ItemSheet);
foundry.documents.collections.Items.registerSheet("fvtt-mournblade-cyd2", MournbladeCYD2ItemSheet, { makeDefault: true })

View File

@@ -882,20 +882,4 @@ export class MournbladeCYD2Utility {
d.render(true);
}
/************************************************************************************/
static async __create_talents_table() {
let compName = "fvtt-mournblade-cyd2.talents-cellule"
const compData = await MournbladeCYD2Utility.loadCompendium(compName)
let talents = compData.map(i => i.toObject())
let htmlTab = "<table border='1'><tbody>";
for (let entryData of talents) {
console.log(entryData)
htmlTab += `<tr><td>@UUID[Compendium.${compName}.${entryData._id}]{${entryData.name}}</td>`
htmlTab += `<td>${entryData.system.description}</td>`;
htmlTab += "</tr>\n";
}
htmlTab += "</table>";
await JournalEntry.create({ name: 'Liste des Talents de Cellule', content: htmlTab });
}
}