tellement de trucs

This commit is contained in:
rwanoux
2024-05-13 18:27:54 +02:00
parent 9cee590267
commit 83c3f1df0b
83 changed files with 1457 additions and 702 deletions
+31 -1
View File
@@ -1,4 +1,5 @@
import { onManageActiveEffect, prepareActiveEffectCategories } from "../system/effects.mjs";
import { preloadHandlebarsTemplates } from "../system/handlebars-manager.mjs";
/**
* Extend the basic ActorSheet with some very simple modifications
@@ -53,7 +54,7 @@ export class VermineActorSheet extends ActorSheet {
/** @override */
activateListeners(html) {
super.activateListeners(html);
html.find('.min-max-edit').click(this._onMinMaxEdit.bind(this))
// Render the item sheet for viewing/editing prior to the editable check.
html.find('.item-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item");
@@ -105,6 +106,35 @@ export class VermineActorSheet extends ActorSheet {
this.actor.update(update)
}
async _onMinMaxEdit(event) {
event.preventDefault();
let propPath = event.currentTarget.dataset.prop;
let propName = propPath.split('.').slice(-1).pop()
let data = {
actorName: this.actor.name,
propName: propName
}
let html = await renderTemplate('systems/vermine2047/templates/dialogs/min-max-edit.hbs', data);
let ui = new Dialog({
title: "edit : " + propName,
content: html,
buttons: {
roll: {
label: "ok",
callback: (html) => { }
},
cancel: {
label: game.i18n.localize('Close'),
callback: () => { }
}
}
}
);
ui.render(true)
}
async _onItemCreate(event) {
event.preventDefault();
const header = event.currentTarget;
+35 -10
View File
@@ -1,6 +1,6 @@
import { onManageActiveEffect, prepareActiveEffectCategories } from "../system/effects.mjs";
import { VermineActorSheet } from "./actor-sheet.mjs";
import { RollDialog } from "../system/dialogs.mjs";
import RollDialog from "../system/dialogs/rollDialog.mjs";
import { TotemPicker } from "../system/applications.mjs";
/**
@@ -14,7 +14,8 @@ export class VermineCharacterSheet extends VermineActorSheet {
return mergeObject(super.defaultOptions, {
classes: ["vermine2047", "sheet", "character", "actor"],
template: "systems/vermine2047/templates/actor/actor-sheet.hbs",
width: "fit-content",
height: "fit-content",
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "features" }]
});
}
@@ -73,6 +74,14 @@ export class VermineCharacterSheet extends VermineActorSheet {
for (let [k, v] of Object.entries(context.system.abilities)) {
v.label = game.i18n.localize(context.system.abilities[k].label) ?? k;
}
for (let [k, v] of Object.entries(context.system.skills)) {
if (v.value >= 2) {
let spe = this.actor.items.filter(it => it.type == "specialty").filter(spec => spec.system.skill == k);
v.specialties = spe
}
}
}
/**
@@ -103,10 +112,23 @@ export class VermineCharacterSheet extends VermineActorSheet {
// Choose Totem
html.find('.chooseTotem').click(this._onTotemButton.bind(this));
html.find('.ability .rollable').click(this._onRoll.bind(this));
html.find('[data-totem-name]').click(this._onClickTotemDice.bind(this))
html.find('[data-totem-name]').click(this._onClickTotemDice.bind(this));
if (!this.actor.flags.world?.editMode) {
this.disableInputs(html)
}
}
disableInputs(html) {
for (let input of html.find('input')) {
if (input.name != "flags.world.editMode") {
input.setAttribute('disabled', true)
}
}
for (let select of html.find('select')) {
select.setAttribute('disabled', true)
}
}
async _onClickTotemDice(ev) {
let el = ev.currentTarget;
let totem = el.dataset.totemName;
@@ -116,14 +138,17 @@ export class VermineCharacterSheet extends VermineActorSheet {
if (value === oldValue) { value-- };
let updates = {};
updates[`system.adaptation.totems.${totem}.value`] = value;
let totems = this.actor.system.adaptation.totems;
let sumTotems = Object.keys(totems).reduce(function (previous, key) {
return previous + totems[key].value;
}, 0);
if (sumTotems >5) {
ui.notifications.warn('vous ne pouvez pas avoir plus de 5 dés totems')
//verifier le max des dés totems
let sum = value;
switch (totem) {
case "human":
sum += this.actor.system.adaptation.totems.adapted.value;
break;
case "adapted":
sum += this.actor.system.adaptation.totems.human.value;
break;
}
console.log(sumTotems, updates)
if (sum > 5) { return ui.notifications.warn("pas plus de 5 dés totems") }
await this.actor.update(updates);
}
/**
+14 -2
View File
@@ -9,7 +9,7 @@ export class VermineItemSheet extends ItemSheet {
return mergeObject(super.defaultOptions, {
classes: ["vermine2047", "sheet", "item"],
width: 520,
height: 480,
height: "auto",
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }]
});
}
@@ -34,7 +34,7 @@ export class VermineItemSheet extends ItemSheet {
// Use a safe clone of the item data for further operations.
const itemData = context.item;
// Retrieve the roll data for TinyMCE editors.
context.rollData = {};
let actor = this.object?.parent ?? null;
@@ -58,7 +58,19 @@ export class VermineItemSheet extends ItemSheet {
// Everything below here is only needed if the sheet is editable
if (!this.isEditable) return;
//click on wound radio
html.find('.damages-row [type="radio"]').click(ev => {
this._onClickDamage(ev)
})
// Roll handlers, click handlers, etc. would go here.
}
async _onClickDamage(ev) {
if (!ev.currentTarget.checked) { return }
let prop = ev.currentTarget.name;
let update = {};
update[prop] = ev.currentTarget.value - 1
this.item.update(update)
}
}