Inlined a bunch of discord webhook text to help format messages better

This commit is contained in:
Stefan Zermatten
2022-02-28 16:55:15 +02:00
parent 94cdca4f31
commit 473a9f0253
7 changed files with 28 additions and 11 deletions

View File

@@ -17,6 +17,11 @@ let LogContentSchema = new SimpleSchema({
optional: true,
max: STORAGE_LIMITS.summary,
},
// Inline with other content fields
inline: {
type: Boolean,
optional: true,
},
context: {
type: Object,
optional: true,

View File

@@ -67,7 +67,8 @@ function applyAttackWithoutTarget({attack, scope, log}){
}
log.content.push({
name,
value: `${resultPrefix} **${result}**`,
value: `${resultPrefix}\n**${result}**`,
inline: true,
});
}
@@ -102,7 +103,8 @@ function applyAttackToTarget({attack, target, scope, log}){
log.content.push({
name,
value: `${resultPrefix} **${result}**`,
value: `${resultPrefix}\n**${result}**`,
inline: true,
});
if ((result > armor) || (criticalHit)){
scope['$attackHit'] = true;
@@ -116,7 +118,8 @@ function applyAttackToTarget({attack, target, scope, log}){
});
log.content.push({
name: criticalHit ? 'Critical Hit!' : criticalMiss ? 'Critical Miss!' : 'To Hit',
value: `${resultPrefix} **${result}**`,
value: `${resultPrefix}\n**${result}**`,
inline: true,
});
}
}
@@ -128,23 +131,23 @@ function rollAttack(attack, scope){
const [a, b] = rollDice(2, 20);
if (a >= b) {
value = a;
resultPrefix = `1d20 [ ${a}, ~~${b}~~ ] ${rollModifierText} = `;
resultPrefix = `1d20 [ ${a}, ~~${b}~~ ] ${rollModifierText}`;
} else {
value = b;
resultPrefix = `1d20 [ ~~${a}~~, ${b} ] ${rollModifierText} = `;
resultPrefix = `1d20 [ ~~${a}~~, ${b} ] ${rollModifierText}`;
}
} else if (attack.advantage === -1 || scope['$attackDisadvantage']){
const [a, b] = rollDice(2, 20);
if (a <= b) {
value = a;
resultPrefix = `1d20 [ ${a}, ~~${b}~~ ] ${rollModifierText} = `;
resultPrefix = `1d20 [ ${a}, ~~${b}~~ ] ${rollModifierText}`;
} else {
value = b;
resultPrefix = `1d20 [ ~~${a}~~, ${b} ] ${rollModifierText} = `;
resultPrefix = `1d20 [ ~~${a}~~, ${b} ] ${rollModifierText}`;
}
} else {
value = rollDice(1, 20)[0];
resultPrefix = `1d20 [${value}] ${rollModifierText} = `
resultPrefix = `1d20 [${value}] ${rollModifierText}`
}
scope['$attackRoll'] = {value};
const result = value + attack.value;
@@ -251,6 +254,7 @@ function spendResources({prop, log, scope}){
log.content.push({
name: 'Uses left',
value: prop.usesLeft - 1,
inline: true,
});
}
@@ -280,9 +284,11 @@ function spendResources({prop, log, scope}){
if (gainLog.length) log.content.push({
name: 'Gained',
value: gainLog.join('\n'),
inline: true,
});
if (spendLog.length) log.content.push({
name: 'Spent',
value: spendLog.join('\n'),
inline: true,
});
}

View File

@@ -14,7 +14,7 @@ export default function applyAdjustment(node, {
// Evaluate the amount
recalculateCalculation(prop.amount, scope, log);
const value = +prop.amount.value;
if (!isFinite(value)) {
return applyChildren(node, {creature, targets, scope, log});
@@ -39,6 +39,7 @@ export default function applyAdjustment(node, {
name: 'Attribute damage',
value: `${prop.stat}${prop.operation === 'set' ? ' set to' : ''}` +
` ${value}`,
inline: true,
});
});
} else {
@@ -46,6 +47,7 @@ export default function applyAdjustment(node, {
name: 'Attribute damage',
value: `${prop.stat}${prop.operation === 'set' ? ' set to' : ''}` +
` ${value}`,
inline: true,
});
}

View File

@@ -77,7 +77,7 @@ function crystalizeVariables({propList, scope, log}){
// Can't strip symbols
log.content.push({
name: 'Error',
value: 'Variable `$target` should not be used without a property: $target.property'
value: 'Variable `$target` should not be used without a property: $target.property',
});
}
return node;

View File

@@ -110,6 +110,7 @@ export default function applyDamage(node, {
log.content.push({
name: logName,
value: logValue.join('\n'),
inline: true,
});
return applyChildren();
}

View File

@@ -13,6 +13,7 @@ export default function applyRoll(node, {creature, targets, scope, log}){
log.content.push({
name: prop.name,
value: prop.variableName + ' = ' + prop.roll.calculation + ' = ' + prop.roll.value,
inline: true,
});
}
return node.children.forEach(child => applyProperty(child, {

View File

@@ -23,6 +23,7 @@ export default function applySavingThrow(node, {creature, targets, scope, log}){
log.content.push({
name: prop.name,
value: ' DC ' + dc,
inline: true,
});
saveTargets.forEach(target => {
@@ -84,7 +85,8 @@ export default function applySavingThrow(node, {creature, targets, scope, log}){
}
log.content.push({
name: 'Save',
value: resultPrefix + result + (saveSuccess ? 'Passed' : 'Failed')
value: resultPrefix + result + (saveSuccess ? 'Passed' : 'Failed'),
inline: true,
});
return applyChildren();
});