Post to chat pour les acteurs
This commit is contained in:
parent
26808d7b49
commit
c79298b60a
@ -142,7 +142,8 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
this.render(true);
|
this.render(true);
|
||||||
});
|
});
|
||||||
this.html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true))
|
this.html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true))
|
||||||
this.html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
|
this.html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItemToChat());
|
||||||
|
this.html.find('.actor-montrer').click(async event => this.actor.postActorToChat());
|
||||||
|
|
||||||
// Everything below here is only needed if the sheet is editable
|
// Everything below here is only needed if the sheet is editable
|
||||||
if (!this.options.editable) return;
|
if (!this.options.editable) return;
|
||||||
@ -169,6 +170,18 @@ export class RdDBaseActorSheet extends ActorSheet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
_getHeaderButtons() {
|
||||||
|
let buttons = super._getHeaderButtons();
|
||||||
|
buttons.unshift({
|
||||||
|
class: "montrer",
|
||||||
|
icon: "fas fa-comment",
|
||||||
|
onclick: ev => this.actor.postActorToChat()
|
||||||
|
});
|
||||||
|
return buttons
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async _onDropItem(event, dragData) {
|
async _onDropItem(event, dragData) {
|
||||||
const destItemId = this.html.find(event.target)?.closest('.item').attr('data-item-id')
|
const destItemId = this.html.find(event.target)?.closest('.item').attr('data-item-id')
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { SYSTEM_SOCKET_ID } from "../constants.js";
|
import { SYSTEM_SOCKET_ID } from "../constants.js";
|
||||||
import { Monnaie } from "../item-monnaie.js";
|
import { Monnaie } from "../item-monnaie.js";
|
||||||
import { Misc } from "../misc.js";
|
import { Misc } from "../misc.js";
|
||||||
|
import { RdDUtility } from "../rdd-utility.js";
|
||||||
import { SystemCompendiums } from "../settings/system-compendiums.js";
|
import { SystemCompendiums } from "../settings/system-compendiums.js";
|
||||||
|
|
||||||
export class RdDBaseActor extends Actor {
|
export class RdDBaseActor extends Actor {
|
||||||
@ -146,4 +147,21 @@ export class RdDBaseActor extends Actor {
|
|||||||
canReceive(item) {
|
canReceive(item) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
async postActorToChat(modeOverride) {
|
||||||
|
let chatData = {
|
||||||
|
doctype: 'Actor',
|
||||||
|
id: this.id,
|
||||||
|
type: this.type,
|
||||||
|
img: this.img,
|
||||||
|
pack: this.pack,
|
||||||
|
name: this.name,
|
||||||
|
system: { description: this.system.description }
|
||||||
|
}
|
||||||
|
renderTemplate('systems/foundryvtt-reve-de-dragon/templates/post-actor.html', chatData)
|
||||||
|
.then(html => ChatMessage.create(RdDUtility.chatDataSetup(html, modeOverride)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -66,7 +66,7 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
buttons.unshift({
|
buttons.unshift({
|
||||||
class: "montrer",
|
class: "montrer",
|
||||||
icon: "fas fa-comment",
|
icon: "fas fa-comment",
|
||||||
onclick: ev => this.item.postItem()
|
onclick: ev => this.item.postItemToChat()
|
||||||
});
|
});
|
||||||
return buttons
|
return buttons
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
this.html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true));
|
this.html.find('.item-edit').click(async event => RdDSheetUtility.getItem(event, this.actor)?.sheet.render(true));
|
||||||
this.html.find('.item-delete').click(async event => RdDUtility.confirmActorItemDelete(this, RdDSheetUtility.getItem(event, this.actor)));
|
this.html.find('.item-delete').click(async event => RdDUtility.confirmActorItemDelete(this, RdDSheetUtility.getItem(event, this.actor)));
|
||||||
this.html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
|
this.html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
|
||||||
this.html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItem());
|
this.html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItemToChat());
|
||||||
this.html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor, async () => this.render(true)));
|
this.html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor, async () => this.render(true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,20 +455,19 @@ export class RdDItem extends Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async postItem(modeOverride) {
|
async postItemToChat(modeOverride) {
|
||||||
console.log(this);
|
console.log(this);
|
||||||
let chatData = duplicate(this);
|
let chatData = {
|
||||||
chatData["properties"] = this.getProprietes();
|
doctype: 'Item',
|
||||||
if (this.actor) {
|
id: this.id,
|
||||||
chatData.actor = { id: this.actor.id };
|
type: this.type,
|
||||||
|
img: this.img,
|
||||||
|
pack: this.pack,
|
||||||
|
name: this.name,
|
||||||
|
actor : this.actor ? { id: this.actor.id } : undefined,
|
||||||
|
system: { description: this.system.description },
|
||||||
|
properties: this.getProprietes(),
|
||||||
}
|
}
|
||||||
// JSON object for easy creation
|
|
||||||
chatData.jsondata = JSON.stringify(
|
|
||||||
{
|
|
||||||
compendium: "postedItem",
|
|
||||||
payload: chatData,
|
|
||||||
});
|
|
||||||
|
|
||||||
renderTemplate(this.getChatItemTemplate(), chatData).then(html => {
|
renderTemplate(this.getChatItemTemplate(), chatData).then(html => {
|
||||||
let chatOptions = RdDUtility.chatDataSetup(html, modeOverride);
|
let chatOptions = RdDUtility.chatDataSetup(html, modeOverride);
|
||||||
ChatMessage.create(chatOptions)
|
ChatMessage.create(chatOptions)
|
||||||
|
@ -351,7 +351,7 @@ export class RdDCalendrier extends Application {
|
|||||||
ChatMessage.create({ content: `${actor.name} souffre d'un mal inconnu (${maladie.type}): vérifiez que les effets ne se sont pas aggravés !` });
|
ChatMessage.create({ content: `${actor.name} souffre d'un mal inconnu (${maladie.type}): vérifiez que les effets ne se sont pas aggravés !` });
|
||||||
}
|
}
|
||||||
let itemMaladie = actor.getItem(maladie.id)
|
let itemMaladie = actor.getItem(maladie.id)
|
||||||
itemMaladie.postItem( 'gmroll');
|
itemMaladie.postItemToChat('gmroll');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -783,8 +783,16 @@ export class RdDUtility {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
html.on("click", '.rdd-world-content-link', async event => {
|
html.on("click", '.rdd-world-content-link', async event => {
|
||||||
const itemId = html.find(event.currentTarget)?.data("id");
|
const htmlElement = html.find(event.currentTarget);
|
||||||
game.items.get(itemId)?.sheet.render(true)
|
const id = htmlElement?.data("id");
|
||||||
|
const doctype= htmlElement?.data("doctype");
|
||||||
|
switch (doctype ?? 'Item') {
|
||||||
|
case 'Actor':
|
||||||
|
return game.actors.get(id)?.sheet.render(true);
|
||||||
|
case 'Item':
|
||||||
|
default:
|
||||||
|
return game.items.get(id)?.sheet.render(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
{{#if pack}}
|
{{#if pack}}
|
||||||
{{!-- draggable="true" --}}
|
{{!-- draggable="true" --}}
|
||||||
<a class="content-link" data-pack="{{pack}}" data-uuid="Compendium.{{pack}}.{{id}}" data-id="{{id}}"><i class="fas fa-suitcase"></i>{{name}}</a>
|
<a class="content-link"
|
||||||
|
data-uuid="Compendium.{{pack}}.{{id}}"
|
||||||
|
data-pack="{{pack}}"
|
||||||
|
{{#if doctype}}data-doctype="{{doctype}}"{{/if}}
|
||||||
|
data-id="{{id}}"
|
||||||
|
><i class="fas fa-suitcase"></i>{{name}}</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<a class="rdd-world-content-link" data-id="{{id}}"><i class="fas fa-suitcase"></i>{{name}}</a>
|
<a class="rdd-world-content-link"
|
||||||
|
{{#if doctype}}data-doctype="{{doctype}}"{{/if}}
|
||||||
|
data-id="{{id}}"
|
||||||
|
><i class="fas fa-suitcase"></i>{{name}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
7
templates/post-actor.html
Normal file
7
templates/post-actor.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<div class="post-item">
|
||||||
|
{{#if img}}
|
||||||
|
<img class="chat-icon" src="{{img}}" title="{{name}}" />
|
||||||
|
{{/if}}
|
||||||
|
<p>{{> 'systems/foundryvtt-reve-de-dragon/templates/common/compendium-link.hbs' pack=pack id=id name=name doctype=doctype}}</p>
|
||||||
|
<p class="card-content">{{{system.description}}}</p>
|
||||||
|
</div>
|
@ -1,8 +1,8 @@
|
|||||||
<div class="post-item" data-transfer="{{transfer}}">
|
<div class="post-item">
|
||||||
{{#if img}}
|
{{#if img}}
|
||||||
<img class="chat-icon" src="{{img}}" title="{{name}}" />
|
<img class="chat-icon" src="{{img}}" title="{{name}}" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<p>{{> 'systems/foundryvtt-reve-de-dragon/templates/common/compendium-link.hbs' pack=pack id=_id name=name}}</p>
|
<p>{{> 'systems/foundryvtt-reve-de-dragon/templates/common/compendium-link.hbs' pack=pack id=id name=name docType=docType}}</p>
|
||||||
<p class="card-content">{{{system.description}}}</p>
|
<p class="card-content">{{{system.description}}}</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div class="post-item" data-transfer="{{transfer}}">
|
<div class="post-item">
|
||||||
<h3><b>{{name}}</b></h3>
|
<h3><b>{{name}}</b></h3>
|
||||||
{{#if img}}
|
{{#if img}}
|
||||||
<img class="chat-icon" src="{{img}}" title="{{name}}" />
|
<img class="chat-icon" src="{{img}}" title="{{name}}" />
|
||||||
@ -10,5 +10,4 @@
|
|||||||
<span>{{{property}}}</span><br>
|
<span>{{{property}}}</span><br>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user