mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 07:59:03 +01:00
Deleting old templates
This commit is contained in:
parent
9b3632be2f
commit
aff5998a45
21 changed files with 447 additions and 1015 deletions
|
|
@ -33,6 +33,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
html.querySelectorAll('.duality-action-effect').forEach(element =>
|
||||
element.addEventListener('click', event => this.onApplyEffect(event, data.message))
|
||||
);
|
||||
html.querySelectorAll('.simple-roll-button').forEach(element =>
|
||||
element.addEventListener('click', event => this.onRollSimple(event, data.message))
|
||||
);
|
||||
html.querySelectorAll('.target-container').forEach(element => {
|
||||
element.addEventListener('mouseenter', this.hoverTarget);
|
||||
element.addEventListener('mouseleave', this.unhoverTarget);
|
||||
|
|
@ -211,7 +214,6 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
async onDamage(event, message) {
|
||||
event.stopPropagation();
|
||||
const { isHit, targets } = this.getTargetList(event, message);
|
||||
console.log(message, isHit, targets)
|
||||
|
||||
if (message.system.onSave && isHit) {
|
||||
const pendingingSaves = message.system.targets.filter(
|
||||
|
|
@ -251,6 +253,33 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
}
|
||||
}
|
||||
|
||||
async onRollSimple(event, message) {
|
||||
const buttonType = event.target.dataset.type ?? 'damage',
|
||||
total = message.rolls.reduce((a,c) => a + Roll.fromJSON(c).total, 0),
|
||||
damages = {
|
||||
'hitPoints': {
|
||||
parts: [
|
||||
{
|
||||
applyTo: 'hitPoints',
|
||||
damageTypes: [],
|
||||
total
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
targets = Array.from(game.user.targets);
|
||||
|
||||
if (targets.length === 0)
|
||||
return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected'));
|
||||
|
||||
targets.forEach(target => {
|
||||
if(buttonType === 'healing')
|
||||
target.actor.takeHealing(damages);
|
||||
else
|
||||
target.actor.takeDamage(damages);
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle visibility of target containers.
|
||||
* @param {MouseEvent} event
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ export default class DHDamageAction extends DHBaseAction {
|
|||
}
|
||||
|
||||
async rollDamage(event, data) {
|
||||
// console.log(data)
|
||||
const systemData = data.system ?? data;
|
||||
|
||||
let formulas = this.damage.parts.map(p => ({
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ export default class DamageRoll extends DHRoll {
|
|||
static DefaultDialog = DamageDialog;
|
||||
|
||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||
console.log(roll,config)
|
||||
if (config.evaluate !== false)
|
||||
for (const roll of config.roll) await roll.roll.evaluate();
|
||||
|
||||
|
|
@ -33,6 +32,21 @@ export default class DamageRoll extends DHRoll {
|
|||
};
|
||||
}
|
||||
|
||||
static async buildPost(roll, config, message) {
|
||||
if (game.modules.get('dice-so-nice')?.active) {
|
||||
const pool = foundry.dice.terms.PoolTerm.fromRolls(
|
||||
Object.values(config.damage).flatMap(r => r.parts.map(p => p.roll))
|
||||
),
|
||||
diceRoll = Roll.fromTerms([pool]);
|
||||
await game.dice3d.showForRoll(diceRoll, game.user, true);
|
||||
}
|
||||
await super.buildPost(roll, config, message);
|
||||
if (config.source?.message) {
|
||||
const chatMessage = ui.chat.collection.get(config.source.message);
|
||||
chatMessage.update({ 'system.damage': config.damage });
|
||||
}
|
||||
}
|
||||
|
||||
static unifyDamageRoll(rolls) {
|
||||
const unified = {};
|
||||
rolls.forEach(r => {
|
||||
|
|
|
|||
|
|
@ -64,24 +64,8 @@ export default class DHRoll extends Roll {
|
|||
}
|
||||
|
||||
// Create Chat Message
|
||||
// if (roll instanceof CONFIG.Dice.daggerheart.DamageRoll && Object.values(config.roll)?.length) {
|
||||
// const pool = foundry.dice.terms.PoolTerm.fromRolls(
|
||||
// Object.values(config.roll).flatMap(r => r.parts.map(p => p.roll))
|
||||
// );
|
||||
// roll = Roll.fromTerms([pool]);
|
||||
// }
|
||||
if (config.source?.message) {
|
||||
if (game.modules.get('dice-so-nice')?.active) await game.dice3d.showForRoll(roll, game.user, true);
|
||||
const chatMessage = ui.chat.collection.get(config.source.message);
|
||||
chatMessage.update({ 'system.damage': config.damage });
|
||||
} else {
|
||||
console.log(roll, config)
|
||||
if (!config.source?.message)
|
||||
config.message = await this.toMessage(roll, config);
|
||||
// if(roll._evaluated) {
|
||||
// const cls = getDocumentClass('ChatMessage');
|
||||
// await cls.create(config.message, { rollMode: config.selectedRollMode });
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
static postEvaluate(roll, config = {}) {
|
||||
|
|
|
|||
|
|
@ -541,12 +541,12 @@ export default class DhpActor extends Actor {
|
|||
}
|
||||
|
||||
canResist(type, resistance) {
|
||||
if (!type) return 0;
|
||||
if (!type?.length) return false;
|
||||
return type.every(t => this.system.resistance[t]?.[resistance] === true);
|
||||
}
|
||||
|
||||
getDamageTypeReduction(type) {
|
||||
if (!type) return 0;
|
||||
if (!type?.length) return 0;
|
||||
const reduction = Object.entries(this.system.resistance).reduce(
|
||||
(a, [index, value]) => (type.includes(index) ? Math.min(value.reduction, a) : a),
|
||||
Infinity
|
||||
|
|
|
|||
|
|
@ -93,9 +93,8 @@ export const enrichedDualityRoll = async (
|
|||
advantage,
|
||||
type: reaction ? 'reaction' : null
|
||||
},
|
||||
chatMessage: {
|
||||
template: 'systems/daggerheart/templates/ui/chat/duality-roll.hbs'
|
||||
}
|
||||
type: 'trait',
|
||||
hasRoll: true
|
||||
};
|
||||
|
||||
if (target) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue