Compare commits
2 Commits
39a408fb3d
...
719e571b21
| Author | SHA1 | Date |
|---|---|---|
|
|
719e571b21 | |
|
|
5275a59b70 |
43
src/main.mjs
43
src/main.mjs
|
|
@ -190,39 +190,44 @@ Hooks.on('dropActorSheetData', (actor, sheet, data) => {
|
|||
|
||||
Hooks.once("ready", async function () {
|
||||
// Wait to register hotbar drop hook on ready so that modules could register earlier if they want to
|
||||
Hooks.on("hotbarDrop", (bar, data, slot) => createBoilerplateMacro(data, slot));
|
||||
Hooks.on("hotbarDrop", (bar, data, slot) => {
|
||||
return createTalentMacro(data, slot)
|
||||
});
|
||||
});
|
||||
|
||||
async function createBoilerplateMacro(data, slot) {
|
||||
async function createTalentMacro(data, slot) {
|
||||
console.log(data, slot)
|
||||
if (data.type !== "Item") return;
|
||||
if (!("data" in data)) return ui.notifications.warn("You can only create macro buttons for owned Items");
|
||||
const item = data.data;
|
||||
|
||||
const uuid = foundry.utils.parseUuid(data.uuid)
|
||||
|
||||
const itemId = uuid.id;
|
||||
const actorId = uuid.primaryId;
|
||||
const item = await game.actors.get(actorId).items.get(itemId);
|
||||
|
||||
// Create the macro command
|
||||
const command = `game.DSA41.rollItemMacro("${item.name}");`;
|
||||
let macro = game.macros.entities.find(m => (m.name === item.name) && (m.command === command));
|
||||
if (!macro) {
|
||||
macro = await Macro.create({
|
||||
const command = `game.DSA41.rollItemMacro("${data.uuid}");`;
|
||||
|
||||
const macro = await Macro.create({
|
||||
name: item.name,
|
||||
type: "script",
|
||||
img: item.img,
|
||||
command: command,
|
||||
flags: {"dsa41.itemMacro": true}
|
||||
});
|
||||
}
|
||||
flags: {"dsa41.skillMacro": true}
|
||||
});
|
||||
|
||||
game.user.assignHotbarMacro(macro, slot);
|
||||
return false;
|
||||
}
|
||||
|
||||
function rollItemMacro(itemName) {
|
||||
function rollItemMacro(_uuid) {
|
||||
const speaker = ChatMessage.getSpeaker();
|
||||
let actor;
|
||||
if (speaker.token) actor = game.actors.tokens[speaker.token];
|
||||
if (!actor) actor = game.actors.get(speaker.actor);
|
||||
const item = actor ? actor.items.find(i => i.name === itemName) : null;
|
||||
if (!item) return ui.notifications.warn(`Your controlled Actor does not have an item named ${itemName}`);
|
||||
const uuid = foundry.utils.parseUuid(_uuid)
|
||||
const itemId = uuid.id;
|
||||
const actorId = uuid.primaryId;
|
||||
let actor = game.actors.get(actorId);
|
||||
const item = actor ? actor.items.get(itemId) : null;
|
||||
if (!item) return ui.notifications.warn(`Your controlled Actor does not have an item with id ${itemId}`);
|
||||
|
||||
// Trigger the item roll
|
||||
return item.roll();
|
||||
return item.system.roll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,25 +41,25 @@ export class SkillDataModel extends BaseItem {
|
|||
* @private
|
||||
*/
|
||||
async roll() {
|
||||
console.log(this.parent)
|
||||
let roll1 = new Roll("3d20", this.actor.getRollData());
|
||||
const owner = this.parent.parent
|
||||
let roll1 = new Roll("3d20", owner.getRollData());
|
||||
|
||||
let evaluated1 = (await roll1.evaluate())
|
||||
|
||||
const dsaDieRollEvaluated = this._evaluateRoll(evaluated1.terms[0].results, {
|
||||
taw: dataset.taw,
|
||||
werte: [this.system.probe[0], this.system.probe[1], this.system.probe[2]],
|
||||
taw: this.taw,
|
||||
werte: [this.probe[0], this.probe[1], this.probe[2]],
|
||||
})
|
||||
|
||||
if (dsaDieRollEvaluated.tap >= 0) { // erfolg
|
||||
evaluated1.toMessage({
|
||||
speaker: ChatMessage.getSpeaker({actor: this.actor}),
|
||||
speaker: ChatMessage.getSpeaker({actor: owner}),
|
||||
flavor: ` ${dsaDieRollEvaluated.meisterlich ? 'Meisterlich geschafft' : 'Geschafft'} mit ${dsaDieRollEvaluated.tap} Punkten übrig`,
|
||||
rollMode: game.settings.get('core', 'rollMode'),
|
||||
})
|
||||
} else { // misserfolg
|
||||
evaluated1.toMessage({
|
||||
speaker: ChatMessage.getSpeaker({actor: this.actor}),
|
||||
speaker: ChatMessage.getSpeaker({actor: owner}),
|
||||
flavor: ` ${dsaDieRollEvaluated.meisterlich ? 'Gepatzt' : ''} mit ${Math.abs(dsaDieRollEvaluated.tap)} Punkten daneben`,
|
||||
rollMode: game.settings.get('core', 'rollMode'),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -383,8 +383,10 @@ export class CharacterSheet extends ActorSheet {
|
|||
context.attacks.push({
|
||||
name: obj.name,
|
||||
using: fernkampf.name,
|
||||
atroll: `1d20 + ${this.object.system.fk.aktuell + obj.system.at}`,
|
||||
at: `1w20 + ${this.object.system.fk.aktuell + obj.system.at}`,
|
||||
atroll: `1d20cs<${this.object.system.fk.aktuell + obj.system.at}`,
|
||||
at: `${this.object.system.fk.aktuell + obj.system.at}`,
|
||||
tproll: `${fernkampf.system.rangedAttackDamage}`, // TODO consider adding TP/KK mod and Range mod
|
||||
tp: `${fernkampf.system.rangedAttackDamage}`,
|
||||
iniroll: `(${context.inidice})d6 + ${context.inivalue + fernkampf.system.iniModifier ?? 0}`,
|
||||
ini: `${context.inidice}w6 + ${context.inivalue + fernkampf.system.iniModifier ?? 0}`,
|
||||
})
|
||||
|
|
@ -397,10 +399,12 @@ export class CharacterSheet extends ActorSheet {
|
|||
context.attacks.push({
|
||||
name: obj.name,
|
||||
using: links.name,
|
||||
atroll: `1d20 + ${this.object.system.at.links.aktuell + obj.system.at + links.system.attackModifier}`,
|
||||
at: `1w20 + ${this.object.system.at.links.aktuell + obj.system.at + links.system.attackModifier}`,
|
||||
paroll: `1d20 + ${this.object.system.pa.links.aktuell + obj.system.pa + links.system.parryModifier}`,
|
||||
pa: `1w20 + ${this.object.system.pa.links.aktuell + obj.system.pa + links.system.parryModifier}`,
|
||||
atroll: `1d20cs<${this.object.system.at.links.aktuell + obj.system.at + links.system.attackModifier}`, // TODO consider adding W/M
|
||||
at: `${this.object.system.at.links.aktuell + obj.system.at + links.system.attackModifier}`,
|
||||
paroll: `1d20cs<${this.object.system.pa.links.aktuell + obj.system.pa + links.system.parryModifier}`, // TODO consider adding W/M
|
||||
pa: `${this.object.system.pa.links.aktuell + obj.system.pa + links.system.parryModifier}`,
|
||||
tproll: `${links.system.meleeAttackDamage}`, // TODO consider adding TP/KK mod
|
||||
tp: `${links.system.meleeAttackDamage}`,
|
||||
iniroll: `(${context.inidice})d6 + ${context.inivalue + links.system.iniModifier ?? 0}`,
|
||||
ini: `${context.inidice}w6 + ${context.inivalue + links.system.iniModifier ?? 0}`,
|
||||
})
|
||||
|
|
@ -414,10 +418,12 @@ export class CharacterSheet extends ActorSheet {
|
|||
context.attacks.push({
|
||||
name: obj.name,
|
||||
using: rechts.name,
|
||||
atroll: `1d20 + ${this.object.system.at.rechts.aktuell + obj.system.at + rechts.system.attackModifier}`,
|
||||
at: `1w20 + ${this.object.system.at.rechts.aktuell + obj.system.at + rechts.system.attackModifier}`,
|
||||
paroll: `1d20 + ${this.object.system.pa.rechts.aktuell + obj.system.pa + rechts.system.parryModifier}`,
|
||||
pa: `1w20 + ${this.object.system.pa.rechts.aktuell + obj.system.pa + rechts.system.parryModifier}`,
|
||||
atroll: `1d20cs<${this.object.system.at.rechts.aktuell + obj.system.at + rechts.system.attackModifier}`, // TODO consider adding W/M
|
||||
at: `${this.object.system.at.rechts.aktuell + obj.system.at + rechts.system.attackModifier}`,
|
||||
paroll: `1d20cs<${this.object.system.pa.rechts.aktuell + obj.system.pa + rechts.system.parryModifier}`, // TODO consider adding W/M
|
||||
pa: `${this.object.system.pa.rechts.aktuell + obj.system.pa + rechts.system.parryModifier}`,
|
||||
tproll: `${rechts.system.meleeAttackDamage}`, // TODO consider adding TP/KK mod
|
||||
tp: `${rechts.system.meleeAttackDamage}`,
|
||||
iniroll: `(${context.inidice})d6 + ${context.inivalue + rechts.system.iniModifier ?? 0}`,
|
||||
ini: `${context.inidice}w6 + ${context.inivalue + rechts.system.iniModifier ?? 0}`,
|
||||
})
|
||||
|
|
@ -932,7 +938,15 @@ export class CharacterSheet extends ActorSheet {
|
|||
}
|
||||
]);
|
||||
|
||||
let handler = ev => this._onDragStart(ev);
|
||||
let handler = evt => {
|
||||
const talentId = evt.target.dataset.id
|
||||
evt.dataTransfer.setData("application/json", JSON.stringify({
|
||||
talentId
|
||||
}));
|
||||
this._onDragStart(evt)
|
||||
|
||||
}
|
||||
|
||||
// Find all items on the character sheet.
|
||||
html.find('.talent.rollable').each((i, li) => {
|
||||
// Add draggable attribute and dragstart listener.
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
{{#each attacks}}
|
||||
<div>
|
||||
<h3>{{this.using}} ({{this.name}})</h3>
|
||||
<div class="combined">
|
||||
{{#if this.at}}
|
||||
<div class="sidebar-element rollable" data-roll="{{this.atroll}}" data-label="Attacke">
|
||||
<label>AT</label>
|
||||
|
|
@ -55,6 +56,13 @@
|
|||
<div class="formula">{{this.pa}}</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{#if this.at}}
|
||||
<div class="sidebar-element rollable" data-roll="{{this.tproll}}" data-label="Schaden">
|
||||
<label>Schaden</label>
|
||||
<div class="formula">{{this.tp}}</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if this.ini}}
|
||||
<div class="sidebar-element rollable" data-label="Initiative" data-roll="{{this.iniroll}}"><label>Initiative</label>
|
||||
<div class="formula">{{this.ini}}</div>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<div class="block rollable {{this.type}} {{this.gruppe}}" data-id="{{this.id}}" data-taw="{{this.taw}}"
|
||||
<div class="block rollable {{this.type}} {{this.gruppe}}" data-item-id="{{this.id}}" data-id="{{this.id}}"
|
||||
data-taw="{{this.taw}}"
|
||||
data-name="{{this.name}}" data-eigenschaft1="{{this.eigenschaft1}}" data-eigenschaft2="{{this.eigenschaft2}}"
|
||||
data-eigenschaft3="{{this.eigenschaft3}}" data-rollEigenschaft1="{{this.rollEigenschaft1}}"
|
||||
data-rollEigenschaft2="{{this.rollEigenschaft2}}" data-rollEigenschaft3="{{this.rollEigenschaft3}}">
|
||||
|
|
|
|||
Loading…
Reference in New Issue