début des messages d'items

This commit is contained in:
rwanoux
2024-11-26 12:48:27 +01:00
parent 1327f92f41
commit dc621f2223
36 changed files with 449 additions and 124 deletions
+29 -39
View File
@@ -13,21 +13,15 @@ export class VermineItem extends Item {
}
prepareBaseData() {
const actorType = (this.actor !== null) ? this.actor.type : 'character';
const itemType = this.type;
switch (this.type) {
case 'ability':
if (this.system.type == "") {
// console.log('je suis une capacité, avec pour sous-type', this.system.type, actorType);
this.system.type = actorType;
}
if (this.system.totem == "" && this.actor !== null && this.actor.system.identity.totem != "") {
// console.log('je suis une capacité, avec pour sous-type', this.system.type, actorType);
this.system.totem = this.actor.system.identity.totem;
}
break;
default:
break;
// Vérifie si une méthode spécifique au type existe// preparedData specifique au type
if (typeof this[`prepare${itemType.charAt(0).toUpperCase() + itemType.slice(1)}Data`] === 'function') {
this[`prepare${itemType.charAt(0).toUpperCase() + itemType.slice(1)}Data`]();
}
// si dégats sur l'item, application du damage label et damage icon
if (this.system.damages?.value) {
this.damagedLabel = this.system.damages.state[parseInt(this.system.damages?.value) - 1];
switch (this.damagedLabel) {
@@ -45,6 +39,19 @@ export class VermineItem extends Item {
}
}
prepareAbilityData() {
console.log('ability data', this)
const actorType = (this.actor !== null) ? this.actor.type : 'character';
if (this.system.type == "") {
// console.log('je suis une capacité, avec pour sous-type', this.system.type, actorType);
this.system.type = actorType;
}
if (this.system.totem == "" && this.actor !== null && this.actor.system.identity.totem != "") {
// console.log('je suis une capacité, avec pour sous-type', this.system.type, actorType);
this.system.totem = this.actor.system.identity.totem;
}
}
/**
* Prepare a data object which is passed to any Roll formulas which are created related to this Item
* @private
@@ -65,9 +72,6 @@ export class VermineItem extends Item {
* @private
*/
async roll() {
if (this.type == "weapon") {
this.rollWeapon()
}
const item = this;
// Initialize chat data.
@@ -76,29 +80,15 @@ export class VermineItem extends Item {
const label = `[${item.type}] ${item.name}`;
// If there's no roll data, send a chat message.
if (!this.system.formula) {
ChatMessage.create({
speaker: speaker,
rollMode: rollMode,
flavor: label,
content: item.system.description ?? ''
});
}
// Otherwise, create a roll and send a chat message from it.
else {
// Retrieve roll data.
const rollData = this.getRollData();
// Invoke the roll and submit it to chat.
const roll = new Roll(rollData.item.formula, rollData);
// If you need to store the value first, uncomment the next line.
// let result = await roll.roll({async: true});
roll.toMessage({
speaker: speaker,
rollMode: rollMode,
flavor: label,
});
return roll;
}
let mess = new ChatMessage({
speaker: speaker,
rollMode: rollMode,
flavor: label,
});
mess.content = await renderTemplate(`systems/vermine2047/templates/item/chatCards/${this.type}.html`, { item: this, message: mess }) ?? null;
console.log(mess)
}
}
-1
View File
@@ -134,7 +134,6 @@ export class VermineCharacterSheet extends VermineActorSheet {
if (input.name != "flags.world.editMode") {
input.setAttribute('disabled', true)
}
}
for (let select of html.find('select')) {
select.setAttribute('disabled', true)
+4 -4
View File
@@ -20,8 +20,8 @@ export async function initUserDice(dice3d, user) {
name: 'human_' + user.name,
description: "human totem dice for " + user.name,
category: "vermine 2047",
foreground: oppositeColor(lightenColor(baseColor, 60)),
background: lightenColor(baseColor, 60),
foreground: oppositeColor(lightenColor(baseColor, 70)),
background: lightenColor(baseColor, 70),
outline: 'black',
visibility: 'visible',
@@ -30,8 +30,8 @@ export async function initUserDice(dice3d, user) {
name: 'adapted_' + user.name,
description: "adapted totem dice for " + user.name,
category: "vermine 2047",
foreground: oppositeColor(darkenColor(baseColor, 60)),
background: darkenColor(baseColor, 60),
foreground: oppositeColor(darkenColor(baseColor, 70)),
background: darkenColor(baseColor, 70),
outline: 'black',
visibility: 'visible',
+1 -60
View File
@@ -327,66 +327,7 @@ export class VermineCombat extends Combat {
async rollInitiative(ids, formula = undefined, messageOptions = {}) {
console.log(`${game.system.title} | Combat.rollInitiative()`, ids, formula, messageOptions);
// Structure input data
ids = typeof ids === "string" ? [ids] : ids;
// étape 1 : on vérifie que le combattant est un pj
/*if (ids.length == 1){
console.log("il n'y a qu'un actor en lice");
} else {
console.log("il faut prendre le premier pj pour lancer la confrontation");
}*/
const combatant = this.combatants.get(ids[0]);
let token = canvas.scene.tokens.get(combatant.tokenId);
combatant.type = game.actors.get(combatant.actorId)?.type;
combatant.disposition = token.disposition;
let enemies = [];
let adversaries = this.combatants.filter((cbt) => {
let token = canvas.scene.tokens.get(cbt.tokenId);
let enemy = token.actor;
const isEnemy = (token.disposition == -1) ? true : false;
if (isEnemy) {
enemies.push({
id: enemy.id,
name: enemy.name,
img: enemy.img,
achievement: parseInt(enemy.system.reroll.achievement.value) + 7,
conservation: 7 - parseInt(enemy.system.reroll.conservation.value)
})
}
return isEnemy;
});
let allies = this.combatants.filter((cbt) => {
let token = canvas.scene.tokens.get(cbt.tokenId);
return (token.disposition == 1 && cbt.id != combatant.id) ? true : false;
});
if (combatant.type != 'character') {
let warningDialogHTML = await renderTemplate('systems/vermine2047/templates/dialogs/warning.html', {
warningText: "Seuls les PJs peuvent initier des confrontations. Relancer l'opération au tour du PJ actif."
});
Dialog.prompt({
title: "Avertissement",
content: warningDialogHTML,
label: 'Okay !',
callback: () => {
// console.log('Il a compris');
},
});
} else {
// étape 2 : on envoie les infos
let fightingActor = game.actors.get(combatant.actorId);
VermineFight.ui({
speakerId: combatant.actorId,
speakerWeapons: fightingActor.items.filter(item => item.type == 'weapon'),
speakerExperience: fightingActor.system.attributes.experience.value,
speakerEffects: token.actor.effects,
adversaries: enemies,
allies: allies
});
}
return super.rollInitiative(ids, formula, messageOptions)
}
+4 -2
View File
@@ -1,5 +1,6 @@
import RollDialog from "./dialogs/rollDialog.mjs";
import { initUserDice } from "./dice3d.mjs";
import { DiceSystem } from '../../../../modules/dice-so-nice/api.js';
import { VermineUtils } from "./roll.mjs";
import { registerTours } from "./tour.mjs";
@@ -9,7 +10,8 @@ export const registerHooks = function () {
*/
CONFIG.debug.hooks = true;
Hooks.once('diceSoNiceReady', async (dice3d) => {
dice3d.addSystem({ id: "Vermine2047", name: "Vermine 2047" }, "preferred");
const vermineSystem = new DiceSystem('Vermine2047', 'Vermine 2047', "preferred", 'totem')
dice3d.addSystem(vermineSystem);
game.users.forEach(user => {
initUserDice(dice3d, user)
@@ -32,7 +34,7 @@ export const registerHooks = function () {
system: "Vermine2047",
},);
});
});
-1
View File
@@ -41,7 +41,6 @@ export class VermineUtils {
let roll = new Roll(formula, actor.getRollData());
//effectuer le lancé
await roll.evaluate();
roll.dice.forEach(die => die.options.appearance = { system: "vermine2047" })
//afficher le lancer 3d
await VermineUtils.showDiceSoNice(roll);
// afficher le résultat dans le chat
+2
View File
@@ -53,6 +53,8 @@ Hooks.once('init', async function () {
CONFIG.ui.combat = VermineCombatTracker;
CONFIG.Combatant.documentClass = VermineCombatant;
CONFIG.Combat.documentClass = VermineCombat;
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);