Compare commits

...

2 Commits

5 changed files with 65 additions and 37 deletions

View File

@ -190,39 +190,44 @@ Hooks.on('dropActorSheetData', (actor, sheet, data) => {
Hooks.once("ready", async function () { Hooks.once("ready", async function () {
// Wait to register hotbar drop hook on ready so that modules could register earlier if they want to // 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) console.log(data, slot)
if (data.type !== "Item") return; 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 // Create the macro command
const command = `game.DSA41.rollItemMacro("${item.name}");`; const command = `game.DSA41.rollItemMacro("${data.uuid}");`;
let macro = game.macros.entities.find(m => (m.name === item.name) && (m.command === command));
if (!macro) { const macro = await Macro.create({
macro = await Macro.create({
name: item.name, name: item.name,
type: "script", type: "script",
img: item.img, img: item.img,
command: command, command: command,
flags: {"dsa41.itemMacro": true} flags: {"dsa41.skillMacro": true}
}); });
}
game.user.assignHotbarMacro(macro, slot); game.user.assignHotbarMacro(macro, slot);
return false; return false;
} }
function rollItemMacro(itemName) { function rollItemMacro(_uuid) {
const speaker = ChatMessage.getSpeaker(); const speaker = ChatMessage.getSpeaker();
let actor; const uuid = foundry.utils.parseUuid(_uuid)
if (speaker.token) actor = game.actors.tokens[speaker.token]; const itemId = uuid.id;
if (!actor) actor = game.actors.get(speaker.actor); const actorId = uuid.primaryId;
const item = actor ? actor.items.find(i => i.name === itemName) : null; let actor = game.actors.get(actorId);
if (!item) return ui.notifications.warn(`Your controlled Actor does not have an item named ${itemName}`); 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.system.roll();
return item.roll();
} }

View File

@ -41,25 +41,25 @@ export class SkillDataModel extends BaseItem {
* @private * @private
*/ */
async roll() { async roll() {
console.log(this.parent) const owner = this.parent.parent
let roll1 = new Roll("3d20", this.actor.getRollData()); let roll1 = new Roll("3d20", owner.getRollData());
let evaluated1 = (await roll1.evaluate()) let evaluated1 = (await roll1.evaluate())
const dsaDieRollEvaluated = this._evaluateRoll(evaluated1.terms[0].results, { const dsaDieRollEvaluated = this._evaluateRoll(evaluated1.terms[0].results, {
taw: dataset.taw, taw: this.taw,
werte: [this.system.probe[0], this.system.probe[1], this.system.probe[2]], werte: [this.probe[0], this.probe[1], this.probe[2]],
}) })
if (dsaDieRollEvaluated.tap >= 0) { // erfolg if (dsaDieRollEvaluated.tap >= 0) { // erfolg
evaluated1.toMessage({ evaluated1.toMessage({
speaker: ChatMessage.getSpeaker({actor: this.actor}), speaker: ChatMessage.getSpeaker({actor: owner}),
flavor: ` ${dsaDieRollEvaluated.meisterlich ? 'Meisterlich geschafft' : 'Geschafft'} mit ${dsaDieRollEvaluated.tap} Punkten übrig`, flavor: ` ${dsaDieRollEvaluated.meisterlich ? 'Meisterlich geschafft' : 'Geschafft'} mit ${dsaDieRollEvaluated.tap} Punkten übrig`,
rollMode: game.settings.get('core', 'rollMode'), rollMode: game.settings.get('core', 'rollMode'),
}) })
} else { // misserfolg } else { // misserfolg
evaluated1.toMessage({ evaluated1.toMessage({
speaker: ChatMessage.getSpeaker({actor: this.actor}), speaker: ChatMessage.getSpeaker({actor: owner}),
flavor: ` ${dsaDieRollEvaluated.meisterlich ? 'Gepatzt' : ''} mit ${Math.abs(dsaDieRollEvaluated.tap)} Punkten daneben`, flavor: ` ${dsaDieRollEvaluated.meisterlich ? 'Gepatzt' : ''} mit ${Math.abs(dsaDieRollEvaluated.tap)} Punkten daneben`,
rollMode: game.settings.get('core', 'rollMode'), rollMode: game.settings.get('core', 'rollMode'),
}) })

View File

@ -383,8 +383,10 @@ export class CharacterSheet extends ActorSheet {
context.attacks.push({ context.attacks.push({
name: obj.name, name: obj.name,
using: fernkampf.name, using: fernkampf.name,
atroll: `1d20 + ${this.object.system.fk.aktuell + obj.system.at}`, atroll: `1d20cs<${this.object.system.fk.aktuell + obj.system.at}`,
at: `1w20 + ${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}`, iniroll: `(${context.inidice})d6 + ${context.inivalue + fernkampf.system.iniModifier ?? 0}`,
ini: `${context.inidice}w6 + ${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({ context.attacks.push({
name: obj.name, name: obj.name,
using: links.name, using: links.name,
atroll: `1d20 + ${this.object.system.at.links.aktuell + obj.system.at + links.system.attackModifier}`, atroll: `1d20cs<${this.object.system.at.links.aktuell + obj.system.at + links.system.attackModifier}`, // TODO consider adding W/M
at: `1w20 + ${this.object.system.at.links.aktuell + obj.system.at + links.system.attackModifier}`, at: `${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}`, paroll: `1d20cs<${this.object.system.pa.links.aktuell + obj.system.pa + links.system.parryModifier}`, // TODO consider adding W/M
pa: `1w20 + ${this.object.system.pa.links.aktuell + obj.system.pa + links.system.parryModifier}`, 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}`, iniroll: `(${context.inidice})d6 + ${context.inivalue + links.system.iniModifier ?? 0}`,
ini: `${context.inidice}w6 + ${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({ context.attacks.push({
name: obj.name, name: obj.name,
using: rechts.name, using: rechts.name,
atroll: `1d20 + ${this.object.system.at.rechts.aktuell + obj.system.at + rechts.system.attackModifier}`, atroll: `1d20cs<${this.object.system.at.rechts.aktuell + obj.system.at + rechts.system.attackModifier}`, // TODO consider adding W/M
at: `1w20 + ${this.object.system.at.rechts.aktuell + obj.system.at + rechts.system.attackModifier}`, at: `${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}`, paroll: `1d20cs<${this.object.system.pa.rechts.aktuell + obj.system.pa + rechts.system.parryModifier}`, // TODO consider adding W/M
pa: `1w20 + ${this.object.system.pa.rechts.aktuell + obj.system.pa + rechts.system.parryModifier}`, 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}`, iniroll: `(${context.inidice})d6 + ${context.inivalue + rechts.system.iniModifier ?? 0}`,
ini: `${context.inidice}w6 + ${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. // Find all items on the character sheet.
html.find('.talent.rollable').each((i, li) => { html.find('.talent.rollable').each((i, li) => {
// Add draggable attribute and dragstart listener. // Add draggable attribute and dragstart listener.

View File

@ -43,6 +43,7 @@
{{#each attacks}} {{#each attacks}}
<div> <div>
<h3>{{this.using}} ({{this.name}})</h3> <h3>{{this.using}} ({{this.name}})</h3>
<div class="combined">
{{#if this.at}} {{#if this.at}}
<div class="sidebar-element rollable" data-roll="{{this.atroll}}" data-label="Attacke"> <div class="sidebar-element rollable" data-roll="{{this.atroll}}" data-label="Attacke">
<label>AT</label> <label>AT</label>
@ -55,6 +56,13 @@
<div class="formula">{{this.pa}}</div> <div class="formula">{{this.pa}}</div>
</div> </div>
{{/if}} {{/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}} {{#if this.ini}}
<div class="sidebar-element rollable" data-label="Initiative" data-roll="{{this.iniroll}}"><label>Initiative</label> <div class="sidebar-element rollable" data-label="Initiative" data-roll="{{this.iniroll}}"><label>Initiative</label>
<div class="formula">{{this.ini}}</div> <div class="formula">{{this.ini}}</div>

View File

@ -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-name="{{this.name}}" data-eigenschaft1="{{this.eigenschaft1}}" data-eigenschaft2="{{this.eigenschaft2}}"
data-eigenschaft3="{{this.eigenschaft3}}" data-rollEigenschaft1="{{this.rollEigenschaft1}}" data-eigenschaft3="{{this.eigenschaft3}}" data-rollEigenschaft1="{{this.rollEigenschaft1}}"
data-rollEigenschaft2="{{this.rollEigenschaft2}}" data-rollEigenschaft3="{{this.rollEigenschaft3}}"> data-rollEigenschaft2="{{this.rollEigenschaft2}}" data-rollEigenschaft3="{{this.rollEigenschaft3}}">