Cleanup
This commit is contained in:
parent
7efa7be1c0
commit
7b58407634
@ -133,7 +133,7 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
async _onDropItem(event, dragData) {
|
async _onDropItem(event, dragData) {
|
||||||
const destItemId = $(event.target)?.closest('.item').attr('data-item-id')
|
const destItemId = $(event.target)?.closest('.item').attr('data-item-id')
|
||||||
const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor, dragData, this.objetVersConteneur)
|
const dropParams = RdDSheetUtility.prepareItemDropParameters(destItemId, this.actor, dragData, this.objetVersConteneur)
|
||||||
if (dropParams){
|
if (dropParams) {
|
||||||
const callSuper = await this.actor.processDropItem(dropParams)
|
const callSuper = await this.actor.processDropItem(dropParams)
|
||||||
if (callSuper) {
|
if (callSuper) {
|
||||||
await super._onDropItem(event, dragData)
|
await super._onDropItem(event, dragData)
|
||||||
@ -164,31 +164,14 @@ export class RdDActorSheet extends ActorSheet {
|
|||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
RdDSheetUtility.splitItem(item, this.actor);
|
RdDSheetUtility.splitItem(item, this.actor);
|
||||||
});
|
});
|
||||||
html.find('.item-edit').click(async event => {
|
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor)
|
|
||||||
item.sheet.render(true)
|
|
||||||
})
|
|
||||||
html.find('.display-label a').click(async event => {
|
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
|
||||||
item.sheet.render(true);
|
|
||||||
});
|
|
||||||
html.find('.item-delete').click(async event => {
|
|
||||||
const li = RdDSheetUtility.getEventElement(event);
|
|
||||||
const item = this.actor.getObjet(li.data("item-id"));
|
|
||||||
RdDUtility.confirmerSuppressionItem(this, item, li);
|
|
||||||
});
|
|
||||||
html.find('.item-vendre').click(async event => {
|
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
|
||||||
item?.proposerVente();
|
|
||||||
});
|
|
||||||
html.find('.item-montrer').click(async event => {
|
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
|
||||||
item?.postItem();
|
|
||||||
});
|
|
||||||
html.find('.item-action').click(async event => {
|
html.find('.item-action').click(async event => {
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor)
|
const item = RdDSheetUtility.getItem(event, this.actor)
|
||||||
this.actor.actionItem(item);
|
this.actor.actionItem(item);
|
||||||
});
|
});
|
||||||
|
html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true))
|
||||||
|
html.find('.item-delete').click(async event => RdDUtility.confirmerSuppressionItem(this, RdDSheetUtility.getItem(event, this.actor)));
|
||||||
|
html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
|
||||||
|
html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
|
||||||
html.find('.subacteur-delete').click(async event => {
|
html.find('.subacteur-delete').click(async event => {
|
||||||
const li = RdDSheetUtility.getEventElement(event);
|
const li = RdDSheetUtility.getEventElement(event);
|
||||||
const actorId = li.data("actor-id");
|
const actorId = li.data("actor-id");
|
||||||
|
@ -250,7 +250,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getReveActuel() {
|
getReveActuel() {
|
||||||
switch(this.type) {
|
switch (this.type) {
|
||||||
case 'personnage':
|
case 'personnage':
|
||||||
return Misc.toInt(this.system.reve?.reve?.value ?? this.carac.reve.value);
|
return Misc.toInt(this.system.reve?.reve?.value ?? this.carac.reve.value);
|
||||||
case 'creature':
|
case 'creature':
|
||||||
@ -620,7 +620,7 @@ export class RdDActor extends Actor {
|
|||||||
content: 'Remise à neuf de ' + this.name
|
content: 'Remise à neuf de ' + this.name
|
||||||
});
|
});
|
||||||
const updates = {
|
const updates = {
|
||||||
'system.sante.endurance.value' : this.system.sante.endurance.max
|
'system.sante.endurance.value': this.system.sante.endurance.max
|
||||||
};
|
};
|
||||||
if (!this.isEntite([ENTITE_INCARNE, ENTITE_BLURETTE])) {
|
if (!this.isEntite([ENTITE_INCARNE, ENTITE_BLURETTE])) {
|
||||||
if (this.system.blessures) {
|
if (this.system.blessures) {
|
||||||
@ -631,7 +631,7 @@ export class RdDActor extends Actor {
|
|||||||
updates['system.sante.vie.value'] = this.system.sante.vie.max;
|
updates['system.sante.vie.value'] = this.system.sante.vie.max;
|
||||||
updates['system.sante.fatigue.value'] = 0;
|
updates['system.sante.fatigue.value'] = 0;
|
||||||
if (this.isPersonnage()) {
|
if (this.isPersonnage()) {
|
||||||
updates['system.compteurs.ethylisme'] = { value:1, nb_doses: 0, jet_moral: false};
|
updates['system.compteurs.ethylisme'] = { value: 1, nb_doses: 0, jet_moral: false };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.update(updates);
|
await this.update(updates);
|
||||||
@ -809,8 +809,7 @@ export class RdDActor extends Actor {
|
|||||||
name: 'maitrise',
|
name: 'maitrise',
|
||||||
label: 'Maîtriser le Rêve de Dragon',
|
label: 'Maîtriser le Rêve de Dragon',
|
||||||
callbacks: [
|
callbacks: [
|
||||||
{ action: async r =>
|
{ action: async r => this.resultCombatReveDeDragon(r) }
|
||||||
this.resultCombatReveDeDragon(r) }
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -832,8 +831,9 @@ export class RdDActor extends Actor {
|
|||||||
type: 'sortreserve',
|
type: 'sortreserve',
|
||||||
name: sort.name,
|
name: sort.name,
|
||||||
img: sort.img,
|
img: sort.img,
|
||||||
system: { sortid: sort._id, draconic: (draconic?.name ?? sort.system.draconic), ptreve: ptreve, coord: coord, heurecible: 'Vaisseau' } }],
|
system: { sortid: sort._id, draconic: (draconic?.name ?? sort.system.draconic), ptreve: ptreve, coord: coord, heurecible: 'Vaisseau' }
|
||||||
{ renderSheet: false});
|
}],
|
||||||
|
{ renderSheet: false });
|
||||||
this.currentTMR.updateTokens();
|
this.currentTMR.updateTokens();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -923,7 +923,7 @@ export class RdDActor extends Actor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const xpUtilise = Math.max(0, Math.min(stress, xpRequis));
|
const xpUtilise = Math.max(0, Math.min(stress, xpRequis));
|
||||||
const gainNiveau = (xpUtilise >= xpRequis || xpRequis <=0) ? 1 : 0;
|
const gainNiveau = (xpUtilise >= xpRequis || xpRequis <= 0) ? 1 : 0;
|
||||||
const nouveauNiveau = niveau + gainNiveau;
|
const nouveauNiveau = niveau + gainNiveau;
|
||||||
const nouveauXp = gainNiveau > 0 ? Math.max(competence.system.xp - xpSuivant, 0) : (competence.system.xp + xpUtilise);
|
const nouveauXp = gainNiveau > 0 ? Math.max(competence.system.xp - xpSuivant, 0) : (competence.system.xp + xpUtilise);
|
||||||
await competence.update({
|
await competence.update({
|
||||||
@ -1568,7 +1568,7 @@ export class RdDActor extends Actor {
|
|||||||
async deleteTMRRencontreAtPosition() {
|
async deleteTMRRencontreAtPosition() {
|
||||||
const demiReve = this.getDemiReve()
|
const demiReve = this.getDemiReve()
|
||||||
let rencontreIds = this.items.filter(it => it.type == 'rencontre' && it.system.coord == demiReve).map(it => it.id);
|
let rencontreIds = this.items.filter(it => it.type == 'rencontre' && it.system.coord == demiReve).map(it => it.id);
|
||||||
if (rencontreIds.length>0) {
|
if (rencontreIds.length > 0) {
|
||||||
await this.deleteEmbeddedDocuments('Item', rencontreIds);
|
await this.deleteEmbeddedDocuments('Item', rencontreIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1576,7 +1576,7 @@ export class RdDActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async addTMRRencontre(currentRencontre) {
|
async addTMRRencontre(currentRencontre) {
|
||||||
const toCreate = currentRencontre.toObject();
|
const toCreate = currentRencontre.toObject();
|
||||||
console.log('actor.addTMRRencontre(', toCreate,')');
|
console.log('actor.addTMRRencontre(', toCreate, ')');
|
||||||
this.createEmbeddedDocuments('Item', [toCreate]);
|
this.createEmbeddedDocuments('Item', [toCreate]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1813,7 +1813,7 @@ export class RdDActor extends Actor {
|
|||||||
const value = this.system.etat[name].value;
|
const value = this.system.etat[name].value;
|
||||||
const max = this.system.etat[name].max;
|
const max = this.system.etat[name].max;
|
||||||
const newValue = value + inc;
|
const newValue = value + inc;
|
||||||
if (0 <= newValue && newValue <=max) {
|
if (0 <= newValue && newValue <= max) {
|
||||||
await this.update({ [`system.etat.${name}.value`]: newValue })
|
await this.update({ [`system.etat.${name}.value`]: newValue })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1965,9 +1965,9 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async actionNourritureboisson(item, onActionItem) {
|
|
||||||
const dialog = await DialogConsommer.create(this, item, onActionItem);
|
async mangerNourriture(item, onActionItem) {
|
||||||
dialog.render(true);
|
return (await DialogConsommer.create(this, item, onActionItem)).render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async actionLire(item) {
|
async actionLire(item) {
|
||||||
@ -1988,7 +1988,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async consommerNourritureboisson(itemId, choix = { doses: 1, seForcer: false, supprimerSiZero: false}, userId = undefined) {
|
async consommerNourritureboisson(itemId, choix = { doses: 1, seForcer: false, supprimerSiZero: false }, userId = undefined) {
|
||||||
if (userId != undefined && userId != game.user.id) {
|
if (userId != undefined && userId != game.user.id) {
|
||||||
RdDActor.remoteActorCall({
|
RdDActor.remoteActorCall({
|
||||||
actorId: this.id,
|
actorId: this.id,
|
||||||
@ -2297,9 +2297,9 @@ export class RdDActor extends Actor {
|
|||||||
if (xpData) {
|
if (xpData) {
|
||||||
const content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-gain-xp.html`, xpData);
|
const content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-gain-xp.html`, xpData);
|
||||||
if (hideChatMessage) {
|
if (hideChatMessage) {
|
||||||
ChatUtility.blindMessageToGM({ content: content});
|
ChatUtility.blindMessageToGM({ content: content });
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
|
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.name),
|
||||||
content: content
|
content: content
|
||||||
@ -2583,7 +2583,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async rollCompetence(idOrName, options = {tryTarget: true}) {
|
async rollCompetence(idOrName, options = { tryTarget: true }) {
|
||||||
let rollData = {
|
let rollData = {
|
||||||
carac: this.system.carac,
|
carac: this.system.carac,
|
||||||
competence: this.getCompetence(idOrName)
|
competence: this.getCompetence(idOrName)
|
||||||
@ -2705,12 +2705,13 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _rollArt(artData, selected, oeuvre, callBackResult = r => this._resultArt(r)) {
|
async _rollArt(artData, selected, oeuvre, callBackResult = r => this._resultArt(r)) {
|
||||||
|
oeuvre.system.niveau = oeuvre.system.niveau ?? 0;
|
||||||
mergeObject(artData,
|
mergeObject(artData,
|
||||||
{
|
{
|
||||||
oeuvre: oeuvre,
|
oeuvre: oeuvre,
|
||||||
art: oeuvre.type,
|
art: oeuvre.type,
|
||||||
competence: duplicate(this.getCompetence(artData.compName ?? oeuvre.system.competence ?? artData.art)),
|
competence: duplicate(this.getCompetence(artData.compName ?? oeuvre.system.competence ?? artData.art)),
|
||||||
diffLibre: - (oeuvre.system.niveau ?? 0),
|
diffLibre: - oeuvre.system.niveau,
|
||||||
diffConditions: 0,
|
diffConditions: 0,
|
||||||
use: { libre: false, conditions: true, surenc: false },
|
use: { libre: false, conditions: true, surenc: false },
|
||||||
selectedCarac: duplicate(this.system.carac[selected])
|
selectedCarac: duplicate(this.system.carac[selected])
|
||||||
@ -2803,13 +2804,13 @@ export class RdDActor extends Actor {
|
|||||||
type: 'nourritureboisson',
|
type: 'nourritureboisson',
|
||||||
img: 'systems/foundryvtt-reve-de-dragon/icons/objets/provision_cuite.webp',
|
img: 'systems/foundryvtt-reve-de-dragon/icons/objets/provision_cuite.webp',
|
||||||
system: {
|
system: {
|
||||||
"description": artData.oeuvre.system.description,
|
description: cuisine.oeuvre.system.description,
|
||||||
"sust": Math.min(sust, 1),
|
sust: 1,
|
||||||
"qualite": artData.qualiteFinale,
|
qualite: cuisine.qualiteFinale,
|
||||||
"exotisme": artData.exotismeFinal,
|
exotisme: cuisine.exotismeFinal,
|
||||||
"encombrement": 0.1,
|
encombrement: 0.1,
|
||||||
"quantite": Math.max(1, Math.floor(sust)),
|
quantite: Math.max(1, Math.floor(cuisine.sust)),
|
||||||
"cout": Math.max(artData.qualiteFinale) * 0.01
|
cout: Math.max(cuisine.qualiteFinale, 0) * 0.01
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (artData.ajouterEquipement) {
|
if (artData.ajouterEquipement) {
|
||||||
@ -3169,7 +3170,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
const caracList = Object.entries(carac);
|
const caracList = Object.entries(carac);
|
||||||
let entry = Misc.findFirstLike(name, caracList, { mapper: it => it[0], description: 'caractéristique' });
|
let entry = Misc.findFirstLike(name, caracList, { mapper: it => it[0], description: 'caractéristique' });
|
||||||
if (!entry || entry.length ==0) {
|
if (!entry || entry.length == 0) {
|
||||||
entry = Misc.findFirstLike(name, caracList, { mapper: it => it[1].label, description: 'caractéristique' });
|
entry = Misc.findFirstLike(name, caracList, { mapper: it => it[1].label, description: 'caractéristique' });
|
||||||
}
|
}
|
||||||
return entry && entry.length > 0 ? carac[entry[0]] : undefined;
|
return entry && entry.length > 0 ? carac[entry[0]] : undefined;
|
||||||
@ -3263,13 +3264,13 @@ export class RdDActor extends Actor {
|
|||||||
title: 'Ne pas utiliser les automatisation de combat',
|
title: 'Ne pas utiliser les automatisation de combat',
|
||||||
buttonLabel: "Pas d'automatisation",
|
buttonLabel: "Pas d'automatisation",
|
||||||
onAction: async () => {
|
onAction: async () => {
|
||||||
this.rollCompetence(arme.system.competence, {tryTarget: false})
|
this.rollCompetence(arme.system.competence, { tryTarget: false })
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Targets.selectOneToken(target => {
|
Targets.selectOneToken(target => {
|
||||||
if (Targets.isTargetEntite(target)){
|
if (Targets.isTargetEntite(target)) {
|
||||||
ui.notifications.warn(`Vous ne pouvez pas attaquer une entité non incarnée avec votre ${arme.name}!!!!`);
|
ui.notifications.warn(`Vous ne pouvez pas attaquer une entité non incarnée avec votre ${arme.name}!!!!`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3878,7 +3879,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
addSubActeur(subActor) {
|
addSubActeur(subActor) {
|
||||||
if(subActor?.id == this.id){
|
if (subActor?.id == this.id) {
|
||||||
ui.notifications.warn("Vous ne pouvez pas attacher un acteur à lui même")
|
ui.notifications.warn("Vous ne pouvez pas attacher un acteur à lui même")
|
||||||
}
|
}
|
||||||
else if (!subActor?.isOwner) {
|
else if (!subActor?.isOwner) {
|
||||||
@ -4105,10 +4106,10 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
console.log("setEffect", statusId, status)
|
console.log("setEffect", statusId, status)
|
||||||
const effect = this.getEffect(statusId);
|
const effect = this.getEffect(statusId);
|
||||||
if (!status && effect){
|
if (!status && effect) {
|
||||||
await this.deleteEmbeddedDocuments('ActiveEffect', [effect.id]);
|
await this.deleteEmbeddedDocuments('ActiveEffect', [effect.id]);
|
||||||
}
|
}
|
||||||
if (status && !effect ) {
|
if (status && !effect) {
|
||||||
await this.createEmbeddedDocuments("ActiveEffect", [StatusEffects.status(statusId)]);
|
await this.createEmbeddedDocuments("ActiveEffect", [StatusEffects.status(statusId)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4134,7 +4135,6 @@ export class RdDActor extends Actor {
|
|||||||
await this.checkCompetenceXP(item.name, item.system.xp);
|
await this.checkCompetenceXP(item.name, item.system.xp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async onCreateItem(item, options, id) {
|
async onCreateItem(item, options, id) {
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
|
@ -2,13 +2,13 @@ import { Misc } from "./misc.js";
|
|||||||
|
|
||||||
export class DialogConsommer extends Dialog {
|
export class DialogConsommer extends Dialog {
|
||||||
|
|
||||||
static async create(actor, item, onActionItem = async ()=>{}) {
|
static async create(actor, item, onActionItem = async () => { }) {
|
||||||
const consommerData = DialogConsommer.prepareData(actor, item);
|
const consommerData = DialogConsommer.prepareData(actor, item);
|
||||||
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-item-consommer.html', consommerData);
|
const html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-item-consommer.html', consommerData);
|
||||||
return new DialogConsommer(actor, item, consommerData, html, onActionItem)
|
return new DialogConsommer(actor, item, consommerData, html, onActionItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(actor, item, consommerData, html, onActionItem = async ()=>{}) {
|
constructor(actor, item, consommerData, html, onActionItem = async () => { }) {
|
||||||
const options = { classes: ["dialogconsommer"], width: 350, height: 'fit-content', 'z-index': 99999 };
|
const options = { classes: ["dialogconsommer"], width: 350, height: 'fit-content', 'z-index': 99999 };
|
||||||
let conf = {
|
let conf = {
|
||||||
title: consommerData.title,
|
title: consommerData.title,
|
||||||
@ -18,7 +18,8 @@ export class DialogConsommer extends Dialog {
|
|||||||
[consommerData.buttonName]: {
|
[consommerData.buttonName]: {
|
||||||
label: consommerData.buttonName, callback: async it => {
|
label: consommerData.buttonName, callback: async it => {
|
||||||
await this.onConsommer(it);
|
await this.onConsommer(it);
|
||||||
await onActionItem();}
|
await onActionItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -38,9 +39,8 @@ export class DialogConsommer extends Dialog {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static prepareData(actor, item) {
|
static prepareData(actor, item) {
|
||||||
item = duplicate(item);
|
|
||||||
let consommerData = {
|
let consommerData = {
|
||||||
item: item,
|
item: duplicate(item),
|
||||||
cuisine: actor.getCompetence('cuisine'),
|
cuisine: actor.getCompetence('cuisine'),
|
||||||
choix: {
|
choix: {
|
||||||
doses: 1,
|
doses: 1,
|
||||||
|
@ -281,4 +281,36 @@ export class RdDItemCompetence extends Item {
|
|||||||
return duplicate(limitesArchetypes);
|
return duplicate(limitesArchetypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static triVisible(competences) {
|
||||||
|
return competences.filter(it => it.system.isVisible)
|
||||||
|
.sort((a, b) => RdDItemCompetence.compare(a,b))
|
||||||
|
}
|
||||||
|
|
||||||
|
static $positionTri(comp) {
|
||||||
|
if (comp.name.startsWith("Survie")) {
|
||||||
|
if (comp.name.includes("Cité")) return 0;
|
||||||
|
if (comp.name.includes("Extérieur")) return 1;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
if (comp.system.categorie.startsWith("melee")) {
|
||||||
|
if (comp.name.includes("Corps")) return 0;
|
||||||
|
if (comp.name.includes("Dague")) return 1;
|
||||||
|
if (comp.name.includes("Esquive")) return 2;
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
if (comp.system.categorie.startsWith("draconic")) {
|
||||||
|
if (comp.name.includes("Oniros")) return 0;
|
||||||
|
if (comp.name.includes("Hypnos")) return 1;
|
||||||
|
if (comp.name.includes("Narcos")) return 2;
|
||||||
|
if (comp.name.includes("Thanatos")) return 3;
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static compare(a,b) {
|
||||||
|
const diff = RdDItemCompetence.$positionTri(a) - RdDItemCompetence.$positionTri(b);
|
||||||
|
return diff ? diff : a.name.localeCompare(b.name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -166,7 +166,6 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
this.form.ondragstart = (event) => this._onDragStart(event);
|
this.form.ondragstart = (event) => this._onDragStart(event);
|
||||||
this.form.ondrop = (event) => this._onDrop(event);
|
this.form.ondrop = (event) => this._onDrop(event);
|
||||||
|
|
||||||
|
|
||||||
// Select competence categorie
|
// Select competence categorie
|
||||||
html.find(".categorie").change(event => this._onSelectCategorie(event));
|
html.find(".categorie").change(event => this._onSelectCategorie(event));
|
||||||
|
|
||||||
@ -182,60 +181,37 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
this.dateUpdated = game.system.rdd.calendrier.getIndexFromDate(jour, mois);
|
this.dateUpdated = game.system.rdd.calendrier.getIndexFromDate(jour, mois);
|
||||||
});
|
});
|
||||||
|
|
||||||
html.find('.creer-tache-livre').click((event) => {
|
html.find('.creer-tache-livre').click((event) => this._getEventActor(event).creerTacheDepuisLivre(this.item));
|
||||||
let actorId = event.currentTarget.attributes['data-actor-id'].value;
|
html.find('.consommer-potion').click((event) => this._getEventActor(event).consommerPotion(this.item));
|
||||||
let actor = game.actors.get(actorId);
|
html.find('.creer-potion-base').click((event) => this._getEventActor(event).dialogFabriquerPotion(this.item));
|
||||||
actor.creerTacheDepuisLivre(this.item);
|
|
||||||
});
|
|
||||||
html.find('.consommer-potion').click((event) => {
|
|
||||||
let actorId = event.currentTarget.attributes['data-actor-id'].value;
|
|
||||||
let actor = game.actors.get(actorId);
|
|
||||||
actor.consommerPotion(this.item);
|
|
||||||
});
|
|
||||||
html.find('.creer-potion-base').click((event) => {
|
|
||||||
let actorId = event.currentTarget.attributes['data-actor-id'].value;
|
|
||||||
let actor = game.actors.get(actorId);
|
|
||||||
actor.dialogFabriquerPotion(this.item);
|
|
||||||
});
|
|
||||||
|
|
||||||
html.find('.alchimie-tache a').click((event) => {
|
html.find('.alchimie-tache a').click((event) => {
|
||||||
let actorId = event.currentTarget.attributes['data-actor-id'].value;
|
let actor = this._getEventActor(event);
|
||||||
|
if (actor) {
|
||||||
let recetteId = event.currentTarget.attributes['data-recette-id'].value;
|
let recetteId = event.currentTarget.attributes['data-recette-id'].value;
|
||||||
let tacheName = event.currentTarget.attributes['data-alchimie-tache'].value;
|
let tacheName = event.currentTarget.attributes['data-alchimie-tache'].value;
|
||||||
let tacheData = event.currentTarget.attributes['data-alchimie-data'].value;
|
let tacheData = event.currentTarget.attributes['data-alchimie-data'].value;
|
||||||
let actor = game.actors.get(actorId);
|
|
||||||
if (actor) {
|
|
||||||
actor.effectuerTacheAlchimie(recetteId, tacheName, tacheData);
|
actor.effectuerTacheAlchimie(recetteId, tacheName, tacheData);
|
||||||
} else {
|
} else {
|
||||||
ui.notifications.info("Impossible trouver un acteur pour réaliser cette tache Alchimique.");
|
ui.notifications.info("Impossible trouver un acteur pour réaliser cette tache Alchimique.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
html.find('.item-split').click(async event => {
|
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
|
||||||
await RdDSheetUtility.splitItem(item, this.actor, async () => itemSheetDialog.render(true));
|
|
||||||
});
|
|
||||||
html.find('.item-edit').click(async event => {
|
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
|
||||||
item.sheet.render(true);
|
|
||||||
});
|
|
||||||
html.find('.item-delete').click(async event => {
|
|
||||||
const li = RdDSheetUtility.getEventElement(event);
|
|
||||||
const item = this.actor.getObjet(li.data("item-id"));
|
|
||||||
RdDUtility.confirmerSuppressionItem(this, item, li);
|
|
||||||
});
|
|
||||||
html.find('.item-vendre').click(async event => {
|
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
|
||||||
item?.proposerVente();
|
|
||||||
});
|
|
||||||
html.find('.item-montrer').click(async event => {
|
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
|
||||||
item?.postItem();
|
|
||||||
});
|
|
||||||
html.find('.item-action').click(async event => {
|
html.find('.item-action').click(async event => {
|
||||||
const item = RdDSheetUtility.getItem(event, this.actor);
|
const item = RdDSheetUtility.getItem(event, this.actor);
|
||||||
this.actor.actionItem(item, async () => itemSheetDialog.render(true));
|
this.actor.actionItem(item, async () => itemSheetDialog.render(true));
|
||||||
});
|
});
|
||||||
|
html.find('.item-split').click(async event => RdDSheetUtility.splitItem(RdDSheetUtility.getItem(event, this.actor), this.actor, async () => itemSheetDialog.render(true)));
|
||||||
|
html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true));
|
||||||
|
html.find('.item-delete').click(async event => RdDUtility.confirmerSuppressionItem(this, RdDSheetUtility.getItem(event, this.actor)));
|
||||||
|
html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
|
||||||
|
html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
_getEventActor(event) {
|
||||||
|
let actorId = event.currentTarget.attributes['data-actor-id'].value;
|
||||||
|
let actor = game.actors.get(actorId);
|
||||||
|
return actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -287,7 +287,6 @@ export class RdDItem extends Item {
|
|||||||
if (!other || !this.isInventaire()) {
|
if (!other || !this.isInventaire()) {
|
||||||
return [false, undefined];
|
return [false, undefined];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.system.quantite == undefined) {
|
if (this.system.quantite == undefined) {
|
||||||
return [false, `Impossible de regrouper des ${this.type}, ils ne sont pas empilables`];
|
return [false, `Impossible de regrouper des ${this.type}, ils ne sont pas empilables`];
|
||||||
}
|
}
|
||||||
|
@ -279,6 +279,7 @@ export class RdDUtility {
|
|||||||
'systems/foundryvtt-reve-de-dragon/templates/chat-signe-draconique-actor.html'
|
'systems/foundryvtt-reve-de-dragon/templates/chat-signe-draconique-actor.html'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Handlebars.registerHelper('either', (a, b) => a ?? b);
|
||||||
Handlebars.registerHelper('upperFirst', str => Misc.upperFirst(str ?? 'Null'));
|
Handlebars.registerHelper('upperFirst', str => Misc.upperFirst(str ?? 'Null'));
|
||||||
Handlebars.registerHelper('lowerFirst', str => Misc.lowerFirst(str ?? 'Null'));
|
Handlebars.registerHelper('lowerFirst', str => Misc.lowerFirst(str ?? 'Null'));
|
||||||
Handlebars.registerHelper('upper', str => str?.toUpperCase() ?? 'NULL');
|
Handlebars.registerHelper('upper', str => str?.toUpperCase() ?? 'NULL');
|
||||||
@ -296,46 +297,18 @@ export class RdDUtility {
|
|||||||
Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1)));
|
Handlebars.registerHelper('min', (...args) => Math.min(...args.slice(0, -1)));
|
||||||
Handlebars.registerHelper('regle-optionnelle', (option) => ReglesOptionelles.isUsing(option));
|
Handlebars.registerHelper('regle-optionnelle', (option) => ReglesOptionelles.isUsing(option));
|
||||||
Handlebars.registerHelper('trier', list => list.sort((a, b) => a.name.localeCompare(b.name)));
|
Handlebars.registerHelper('trier', list => list.sort((a, b) => a.name.localeCompare(b.name)));
|
||||||
Handlebars.registerHelper('filtreTriCompetences', competences => competences.filter(it => it.system.isVisible)
|
Handlebars.registerHelper('filtreTriCompetences', competences => RdDItemCompetence.triVisible(competences));
|
||||||
.sort((a, b) => {
|
Handlebars.registerHelper('linkCompendium', (pack, id, name) => RdDUtility.linkCompendium(pack, id, name));
|
||||||
if (a.name.startsWith("Survie") && b.name.startsWith("Survie")) {
|
Handlebars.registerHelper('uniteQuantite', (itemId, actorId) => RdDUtility.getItem(itemId, actorId)?.getUniteQuantite());
|
||||||
if (a.name.includes("Cité")) return -1;
|
|
||||||
if (b.name.includes("Cité")) return 1;
|
|
||||||
if (a.name.includes("Extérieur")) return -1;
|
|
||||||
if (b.name.includes("Extérieur")) return 1;
|
|
||||||
return a.name.localeCompare(b.name);
|
|
||||||
}
|
|
||||||
if (a.system.categorie.startsWith("melee") && b.system.categorie.startsWith("melee")) {
|
|
||||||
if (a.name.includes("Corps")) return -1;
|
|
||||||
if (b.name.includes("Corps")) return 1;
|
|
||||||
if (a.name.includes("Dague")) return -1;
|
|
||||||
if (b.name.includes("Dague")) return 1;
|
|
||||||
if (a.name.includes("Esquive")) return -1;
|
|
||||||
if (b.name.includes("Esquive")) return 1;
|
|
||||||
return a.name.localeCompare(b.name);
|
|
||||||
}
|
|
||||||
if (a.name.startsWith("Voie") && b.name.startsWith("Voie")) {
|
|
||||||
if (a.name.includes("Oniros")) return -1;
|
|
||||||
if (b.name.includes("Oniros")) return 1;
|
|
||||||
if (a.name.includes("Hypnos")) return -1;
|
|
||||||
if (b.name.includes("Hypnos")) return 1;
|
|
||||||
if (a.name.includes("Narcos")) return -1;
|
|
||||||
if (b.name.includes("Narcos")) return 1;
|
|
||||||
if (a.name.includes("Thanatos")) return -1;
|
|
||||||
if (b.name.includes("Thanatos")) return 1;
|
|
||||||
return a.name.localeCompare(b.name);
|
|
||||||
}
|
|
||||||
return a.name.localeCompare(b.name);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
Handlebars.registerHelper('linkCompendium', (pack, id, name)=> RdDUtility.linkCompendium(pack, id, name));
|
|
||||||
Handlebars.registerHelper('uniteQuantite', (type) => RdDItem.getUniteQuantite(type));
|
|
||||||
Handlebars.registerHelper('isFieldInventaireModifiable', (type, field) => RdDItem.isFieldInventaireModifiable(type, field));
|
Handlebars.registerHelper('isFieldInventaireModifiable', (type, field) => RdDItem.isFieldInventaireModifiable(type, field));
|
||||||
Handlebars.registerHelper('getFrequenceRarete', (rarete, field) => Environnement.getFrequenceRarete(rarete, field));
|
Handlebars.registerHelper('getFrequenceRarete', (rarete, field) => Environnement.getFrequenceRarete(rarete, field));
|
||||||
Handlebars.registerHelper('either', (a, b) => a ?? b);
|
|
||||||
return loadTemplates(templatePaths);
|
return loadTemplates(templatePaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getItem(itemId, actorId = undefined) {
|
||||||
|
return actorId ? game.actors.get(actorId)?.getObjet(itemId) : game.items.get(itemId);
|
||||||
|
}
|
||||||
|
|
||||||
static linkCompendium(pack, id, name) {
|
static linkCompendium(pack, id, name) {
|
||||||
return `@Compendium[${pack}.${id}]{${name}}`;
|
return `@Compendium[${pack}.${id}]{${name}}`;
|
||||||
}
|
}
|
||||||
@ -1001,7 +974,7 @@ export class RdDUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static slideOnDelete(sheet, htmlToDelete) {
|
static slideOnDelete(sheet, htmlToDelete) {
|
||||||
return htmlToDelete.slideUp(200, () => sheet.render(false));
|
return htmlToDelete?.slideUp(200, () => sheet.render(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<li class="item flexrow" data-attribute={{key}} data-item-id="{{queue._id}}">
|
<li class="item flexrow" data-attribute={{key}} data-item-id="{{queue._id}}">
|
||||||
<img class="sheet-competence-img" src="{{queue.img}}" />
|
<img class="sheet-competence-img" src="{{queue.img}}" />
|
||||||
<span class="display-label flex-grow">
|
<span class="item-edit flex-grow">
|
||||||
{{#if (eq queue.type 'ombre')}}
|
{{#if (eq queue.type 'ombre')}}
|
||||||
<img class="sheet-competence-img" src="systems/foundryvtt-reve-de-dragon/icons/competence_thanatos.webp" />
|
<img class="sheet-competence-img" src="systems/foundryvtt-reve-de-dragon/icons/competence_thanatos.webp" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{#each souffles as |souffle key|}}
|
{{#each souffles as |souffle key|}}
|
||||||
<li class="item flexrow" data-attribute={{key}} data-item-id="{{souffle._id}}">
|
<li class="item flexrow" data-attribute={{key}} data-item-id="{{souffle._id}}">
|
||||||
<img class="sheet-competence-img" src="{{souffle.img}}" />
|
<img class="sheet-competence-img" src="{{souffle.img}}" />
|
||||||
<span class="display-label flex-grow"><a>{{souffle.name}}</a></span>
|
<span class="item-edit flex-grow"><a>{{souffle.name}}</a></span>
|
||||||
<div class="item-controls flex-shrink">
|
<div class="item-controls flex-shrink">
|
||||||
<a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
<a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{#each tetes as |tete key|}}
|
{{#each tetes as |tete key|}}
|
||||||
<li class="item flexrow" data-attribute={{key}} data-item-id="{{tete._id}}">
|
<li class="item flexrow" data-attribute={{key}} data-item-id="{{tete._id}}">
|
||||||
<img class="sheet-competence-img" src="{{tete.img}}" />
|
<img class="sheet-competence-img" src="{{tete.img}}" />
|
||||||
<span class="display-label flex-grow"><a>{{tete.name}}</a></span>
|
<span class="item-edit flex-grow"><a>{{tete.name}}</a></span>
|
||||||
<div class="item-controls flex-shrink">
|
<div class="item-controls flex-shrink">
|
||||||
<a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
<a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{#each casestmr as |casetmr key|}}
|
{{#each casestmr as |casetmr key|}}
|
||||||
<li class="item list-item flexrow" data-item-id="{{casetmr.id}}" data-attribute="{{key}}">
|
<li class="item list-item flexrow" data-item-id="{{casetmr.id}}" data-attribute="{{key}}">
|
||||||
<img class="sheet-competence-img" src="{{casetmr.img}}" />
|
<img class="sheet-competence-img" src="{{casetmr.img}}" />
|
||||||
<span class="display-label"><a>{{casetmr.name}}</a></span>
|
<span class="item-edit"><a>{{casetmr.name}}</a></span>
|
||||||
<span>{{casetmr.system.coord}} - {{caseTmr-label casetmr.system.coord}}</span>
|
<span>{{casetmr.system.coord}} - {{caseTmr-label casetmr.system.coord}}</span>
|
||||||
<div class="item-controls flex-shrink">
|
<div class="item-controls flex-shrink">
|
||||||
<a class="item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
<a class="item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{#each rencontres as |rencontre key|}}
|
{{#each rencontres as |rencontre key|}}
|
||||||
<li class="item flexrow" data-item-id="{{rencontre._id}}" data-attribute="{{key}}">
|
<li class="item flexrow" data-item-id="{{rencontre._id}}" data-attribute="{{key}}">
|
||||||
<img class="sheet-competence-img" src="{{rencontre.img}}" />
|
<img class="sheet-competence-img" src="{{rencontre.img}}" />
|
||||||
<span class="display-label flex-grow"><a>
|
<span class="item-edit flex-grow"><a>
|
||||||
{{rencontre.name}} r{{rencontre.system.force}} ({{rencontre.system.coord}} - {{caseTmr-label rencontre.system.coord}})
|
{{rencontre.name}} r{{rencontre.system.force}} ({{rencontre.system.coord}} - {{caseTmr-label rencontre.system.coord}})
|
||||||
</a></span>
|
</a></span>
|
||||||
{{#if rencontre.system.date}}
|
{{#if rencontre.system.date}}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{#each signesdraconiques as |signe key|}}
|
{{#each signesdraconiques as |signe key|}}
|
||||||
<li class="item list-item flexrow" data-item-id="{{signe._id}}" data-attribute="{{key}}">
|
<li class="item list-item flexrow" data-item-id="{{signe._id}}" data-attribute="{{key}}">
|
||||||
<img class="sheet-competence-img" src="{{signe.img}}" />
|
<img class="sheet-competence-img" src="{{signe.img}}" />
|
||||||
<span class="display-label flex-grow"><a>{{signe.name}}</a></span>
|
<span class="item-edit flex-grow"><a>{{signe.name}}</a></span>
|
||||||
<span class="flex-shrink">{{signe.system.difficulte}}</span>
|
<span class="flex-shrink">{{signe.system.difficulte}}</span>
|
||||||
<div class="item-controls flex-shrink">
|
<div class="item-controls flex-shrink">
|
||||||
<a class="item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
<a class="item-delete" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{#each sortsReserve as |sort key|}}
|
{{#each sortsReserve as |sort key|}}
|
||||||
<li class="item list-item flexrow" data-item-id="{{sort._id}}" data-attribute="{{key}}">
|
<li class="item list-item flexrow" data-item-id="{{sort._id}}" data-attribute="{{key}}">
|
||||||
<img class="sheet-competence-img" src="{{sort.img}}" />
|
<img class="sheet-competence-img" src="{{sort.img}}" />
|
||||||
<span class="display-label"><a>{{#if sort.system.echectotal}}Echec total: {{/if}}{{sort.name}} r{{sort.system.ptreve}}</a></span>
|
<span class="item-edit"><a>{{#if sort.system.echectotal}}Echec total: {{/if}}{{sort.name}} r{{sort.system.ptreve}}</a></span>
|
||||||
<span>{{sort.system.coord}} - {{caseTmr-label sort.system.coord}}</span>
|
<span>{{sort.system.coord}} - {{caseTmr-label sort.system.coord}}</span>
|
||||||
<div class="item-controls flex-shrink">
|
<div class="item-controls flex-shrink">
|
||||||
<a class="item-delete flex-shrink" title="Supprimer"><i class="fas fa-trash"></i></a>
|
<a class="item-delete flex-shrink" title="Supprimer"><i class="fas fa-trash"></i></a>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{{#each sorts as |sort key|}}
|
{{#each sorts as |sort key|}}
|
||||||
<li class="item list-item flexrow" data-item-id="{{sort._id}}" data-attribute="{{key}}">
|
<li class="item list-item flexrow" data-item-id="{{sort._id}}" data-attribute="{{key}}">
|
||||||
<img class="sheet-competence-img" src="{{sort.img}}" />
|
<img class="sheet-competence-img" src="{{sort.img}}" />
|
||||||
<span class="display-label flex-grow-2">
|
<span class="item-edit flex-grow-2">
|
||||||
<a data-item-id="{{sort._id}}">{{sort.name}}
|
<a data-item-id="{{sort._id}}">{{sort.name}}
|
||||||
- {{#if sort.system.caseTMRspeciale}}{{sort.system.caseTMRspeciale}}{{else}}{{upperFirst sort.system.caseTMR}}{{/if}}
|
- {{#if sort.system.caseTMRspeciale}}{{sort.system.caseTMRspeciale}}{{else}}{{upperFirst sort.system.caseTMR}}{{/if}}
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user