Compare commits

..

No commits in common. "719e571b21f44c8bbb918e8dea9a968fcff4b3c8" and "39a408fb3da99f9ab55f8fdb217d4b01cc488735" have entirely different histories.

5 changed files with 37 additions and 65 deletions

View File

@ -190,44 +190,39 @@ 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) => { Hooks.on("hotbarDrop", (bar, data, slot) => createBoilerplateMacro(data, slot));
return createTalentMacro(data, slot)
});
}); });
async function createTalentMacro(data, slot) { async function createBoilerplateMacro(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 uuid = foundry.utils.parseUuid(data.uuid) const item = data.data;
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("${data.uuid}");`; const command = `game.DSA41.rollItemMacro("${item.name}");`;
let macro = game.macros.entities.find(m => (m.name === item.name) && (m.command === command));
const macro = await Macro.create({ if (!macro) {
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.skillMacro": true} flags: {"dsa41.itemMacro": true}
}); });
}
game.user.assignHotbarMacro(macro, slot); game.user.assignHotbarMacro(macro, slot);
return false; return false;
} }
function rollItemMacro(_uuid) { function rollItemMacro(itemName) {
const speaker = ChatMessage.getSpeaker(); const speaker = ChatMessage.getSpeaker();
const uuid = foundry.utils.parseUuid(_uuid) let actor;
const itemId = uuid.id; if (speaker.token) actor = game.actors.tokens[speaker.token];
const actorId = uuid.primaryId; if (!actor) actor = game.actors.get(speaker.actor);
let actor = game.actors.get(actorId); const item = actor ? actor.items.find(i => i.name === itemName) : null;
const item = actor ? actor.items.get(itemId) : null; if (!item) return ui.notifications.warn(`Your controlled Actor does not have an item named ${itemName}`);
if (!item) return ui.notifications.warn(`Your controlled Actor does not have an item with id ${itemId}`);
return item.system.roll(); // Trigger the item roll
return item.roll();
} }

View File

@ -41,25 +41,25 @@ export class SkillDataModel extends BaseItem {
* @private * @private
*/ */
async roll() { async roll() {
const owner = this.parent.parent console.log(this.parent)
let roll1 = new Roll("3d20", owner.getRollData()); let roll1 = new Roll("3d20", this.actor.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: this.taw, taw: dataset.taw,
werte: [this.probe[0], this.probe[1], this.probe[2]], werte: [this.system.probe[0], this.system.probe[1], this.system.probe[2]],
}) })
if (dsaDieRollEvaluated.tap >= 0) { // erfolg if (dsaDieRollEvaluated.tap >= 0) { // erfolg
evaluated1.toMessage({ evaluated1.toMessage({
speaker: ChatMessage.getSpeaker({actor: owner}), speaker: ChatMessage.getSpeaker({actor: this.actor}),
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: owner}), speaker: ChatMessage.getSpeaker({actor: this.actor}),
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,10 +383,8 @@ export class CharacterSheet extends ActorSheet {
context.attacks.push({ context.attacks.push({
name: obj.name, name: obj.name,
using: fernkampf.name, using: fernkampf.name,
atroll: `1d20cs<${this.object.system.fk.aktuell + obj.system.at}`, atroll: `1d20 + ${this.object.system.fk.aktuell + obj.system.at}`,
at: `${this.object.system.fk.aktuell + obj.system.at}`, at: `1w20 + ${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}`,
}) })
@ -399,12 +397,10 @@ export class CharacterSheet extends ActorSheet {
context.attacks.push({ context.attacks.push({
name: obj.name, name: obj.name,
using: links.name, using: links.name,
atroll: `1d20cs<${this.object.system.at.links.aktuell + obj.system.at + links.system.attackModifier}`, // TODO consider adding W/M atroll: `1d20 + ${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}`, at: `1w20 + ${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 paroll: `1d20 + ${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}`, pa: `1w20 + ${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}`,
}) })
@ -418,12 +414,10 @@ export class CharacterSheet extends ActorSheet {
context.attacks.push({ context.attacks.push({
name: obj.name, name: obj.name,
using: rechts.name, using: rechts.name,
atroll: `1d20cs<${this.object.system.at.rechts.aktuell + obj.system.at + rechts.system.attackModifier}`, // TODO consider adding W/M atroll: `1d20 + ${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}`, at: `1w20 + ${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 paroll: `1d20 + ${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}`, pa: `1w20 + ${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}`,
}) })
@ -938,15 +932,7 @@ export class CharacterSheet extends ActorSheet {
} }
]); ]);
let handler = evt => { let handler = ev => this._onDragStart(ev);
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,7 +43,6 @@
{{#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>
@ -56,13 +55,6 @@
<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,5 +1,4 @@
<div class="block rollable {{this.type}} {{this.gruppe}}" data-item-id="{{this.id}}" data-id="{{this.id}}" <div class="block rollable {{this.type}} {{this.gruppe}}" data-id="{{this.id}}" data-taw="{{this.taw}}"
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}}">