Skip to content

Commit 805053d

Browse files
authored
RE data entry fixes 1 (#650)
* Fix inline damage application * Fix faction relation evaluation * Update entries for crossfire, soul steal * Fix bone crusher, counterattack, consume, potion rain * Fix check predicate parity rendering * Fix modify consumable evaluation
1 parent d325f2d commit 805053d

13 files changed

+189
-47
lines changed

module/documents/effects/actions/modify-consumable-rule-action.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class ModifyConsumableRuleAction extends RuleActionDataModel {
5252
amount += evalBonus;
5353
}
5454
if (this.multiplier) {
55-
const evalMultiplier = await Expressions.evaluateAsync(this.multiplier, expressionContext);
55+
const evalMultiplier = await Expressions.evaluateAsync(this.multiplier, expressionContext, false);
5656
amount *= evalMultiplier;
5757
}
5858
context.event.builder.amount = amount;

module/documents/effects/predicates/faction-relation-rule-predicate.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,18 @@ export class FactionRelationRulePredicate extends RulePredicateDataModel {
3737
validateContext(context) {
3838
switch (this.relation) {
3939
case 'ally':
40-
if (context.targets.find((t) => this.inclusive === (t.actor === context.character.actor) && t.disposition === context.character.disposition) === undefined) {
40+
if (!context.targets.some((t) => t.disposition === context.character.disposition && (this.inclusive || t.actor !== context.character.actor))) {
4141
return false;
4242
}
4343
break;
44+
4445
case 'enemy':
45-
if (context.targets.find((t) => this.inclusive === (t.actor === context.character.actor) && t.disposition !== context.character.disposition) === undefined) {
46+
if (!context.targets.some((t) => t.disposition !== context.character.disposition && (this.inclusive || t.actor !== context.character.actor))) {
4647
return false;
4748
}
4849
break;
4950
}
51+
5052
return true;
5153
}
5254
}

module/documents/items/common/traits-predicate-data-model.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ export class TraitsPredicateDataModel extends TraitsDataModel {
4242
return false;
4343
}
4444
}
45-
return false;
45+
break;
4646

4747
case 'none':
4848
for (const t of traits) {
4949
if (this.has(t)) {
5050
return false;
5151
}
5252
}
53-
return true;
53+
break;
5454
}
55-
return false;
55+
return true;
5656
}
5757
}

module/expressions/expressions.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,10 @@ const asyncFunctions = [evaluateMacrosAsync];
266266
* @description Evaluates the given expression using a superset of the DSL
267267
* @param {String} expression
268268
* @param {ExpressionContext} context
269+
* @param {Boolean} applyRounding Whether to round the result, which is the default for FU.
269270
* @return {Promise<Number>} The evaluated amount
270271
*/
271-
async function evaluateAsync(expression, context) {
272+
async function evaluateAsync(expression, context, applyRounding = true) {
272273
if (!requiresContext(expression)) {
273274
return Number(expression);
274275
}
@@ -291,7 +292,9 @@ async function evaluateAsync(expression, context) {
291292
}
292293

293294
// FU always rounds down numbers
294-
result = round(result);
295+
if (applyRounding) {
296+
result = round(result);
297+
}
295298

296299
console.debug(`Evaluated expression ${expression} = ${substitutedExpression} = ${result}`);
297300
return result;

module/helpers/inline-damage.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async function onRender(element) {
7171
let targets = await targetHandler();
7272
if (targets.length > 0) {
7373
let context = ExpressionContext.fromSourceInfo(renderContext.sourceInfo, targets);
74-
let check = document.getFlag(SYSTEM, Flags.ChatMessage.CheckV2);
74+
let check = renderContext.document.getFlag(SYSTEM, Flags.ChatMessage.CheckV2);
7575
if (check) {
7676
context = context.withCheck(check);
7777
}

module/helpers/inline-resources.mjs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,38 +107,36 @@ function lossEnricher(text, options) {
107107
* @returns {Promise<void>}
108108
*/
109109
async function onRender(element) {
110-
const document = InlineHelper.resolveDocument(element);
110+
const renderContext = await InlineHelper.getRenderContext(element);
111111
const target = element.firstElementChild;
112-
const sourceInfo = InlineHelper.determineSource(document, target);
113-
const dataset = target.dataset;
114-
const type = dataset.type;
115-
const uncapped = dataset.uncapped === 'true';
112+
const type = renderContext.dataset.type;
113+
const uncapped = renderContext.dataset.uncapped === 'true';
116114

117115
element.addEventListener('click', async function () {
118116
const targets = await targetHandler();
119117
if (targets.length > 0) {
120-
let context = ExpressionContext.fromSourceInfo(sourceInfo, targets);
121-
let check = document.getFlag(SYSTEM, Flags.ChatMessage.CheckV2);
118+
let context = ExpressionContext.fromSourceInfo(renderContext.sourceInfo, targets);
119+
let check = renderContext.document.getFlag(SYSTEM, Flags.ChatMessage.CheckV2);
122120
if (check) {
123121
context = context.withCheck(check);
124122
}
125-
const amount = await Expressions.evaluateAsync(dataset.amount, context);
123+
const amount = await Expressions.evaluateAsync(renderContext.dataset.amount, context);
126124

127125
if (target.classList.contains(classInlineRecovery)) {
128-
await applyRecovery(sourceInfo, targets, type, amount, uncapped);
126+
await applyRecovery(renderContext.sourceInfo, targets, type, amount, uncapped);
129127
} else if (target.classList.contains(classInlineLoss)) {
130-
await applyLoss(sourceInfo, targets, type, amount);
128+
await applyLoss(renderContext.sourceInfo, targets, type, amount);
131129
}
132130
}
133131
});
134132

135133
element.addEventListener('dragstart', function (event) {
136134
const data = {
137135
type: target.classList.contains(classInlineRecovery) ? INLINE_RECOVERY : INLINE_LOSS,
138-
sourceInfo,
139-
recoveryType: dataset.type,
140-
amount: dataset.amount,
141-
uncapped: dataset.uncapped === 'true',
136+
sourceInfo: renderContext.sourceInfo,
137+
recoveryType: renderContext.dataset.type,
138+
amount: renderContext.dataset.amount,
139+
uncapped: renderContext.dataset.uncapped === 'true',
142140
};
143141

144142
event.dataTransfer.setData('text/plain', JSON.stringify(data));

src/packs/skills/skill_Bone_Crusher_7jWycVYFgZ1BMxch.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@
151151
"attack"
152152
],
153153
"outcome": "success",
154-
"identifier": ""
154+
"identifier": "",
155+
"local": false
155156
},
156157
"actions": {
157158
"9e9YoPMUF2VqMiU1": {
@@ -203,7 +204,7 @@
203204
"systemId": "projectfu",
204205
"systemVersion": "#{VERSION}#",
205206
"createdTime": 1766788902986,
206-
"modifiedTime": 1766828627966,
207+
"modifiedTime": 1767559675817,
207208
"lastModifiedBy": "J5B4HfVqUaCPvzGg"
208209
},
209210
"_key": "!items.effects!7jWycVYFgZ1BMxch.YkOEtHV4uwAnjQnW"

src/packs/skills/skill_Consume_c46SCybV1gtiHbL4.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@
171171
"resource": "mp",
172172
"amount": "$sl*2"
173173
}
174-
}
174+
},
175+
"selector": "self"
175176
}
176177
},
177178
"progress": {
@@ -207,7 +208,7 @@
207208
"systemId": "projectfu",
208209
"systemVersion": "#{VERSION}#",
209210
"createdTime": 1766925259175,
210-
"modifiedTime": 1766925336258,
211+
"modifiedTime": 1767559939944,
211212
"lastModifiedBy": "J5B4HfVqUaCPvzGg"
212213
},
213214
"_key": "!items.effects!c46SCybV1gtiHbL4.QvJKfoqYcZGOxmLS"

src/packs/skills/skill_Counterattack_XhcTVGtGEk7L2Ddq.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,14 @@
154154
"attack"
155155
],
156156
"outcome": "",
157-
"identifier": ""
157+
"identifier": "",
158+
"local": false
158159
},
159160
"predicates": {
160161
"AccwRopUxS7jiAR4": {
161162
"type": "checkRulePredicate",
162163
"_id": "AccwRopUxS7jiAR4",
163-
"parity": "",
164+
"parity": "even",
164165
"result": null
165166
}
166167
},
@@ -206,7 +207,7 @@
206207
"systemId": "projectfu",
207208
"systemVersion": "#{VERSION}#",
208209
"createdTime": 1766789080881,
209-
"modifiedTime": 1766829391957,
210+
"modifiedTime": 1767559780888,
210211
"lastModifiedBy": "J5B4HfVqUaCPvzGg"
211212
},
212213
"_key": "!items.effects!XhcTVGtGEk7L2Ddq.3I4QKAPzn55nGTVF"

src/packs/skills/skill_Crossfire_sIkQa2NzkqsvczBr.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
"Jg8qePO1hy7kyP6V": {
177177
"type": "messageRuleAction",
178178
"_id": "Jg8qePO1hy7kyP6V",
179-
"message": "<p>This attack maybe interrupted by spending @LOSS[$chk mp].</p>"
179+
"message": "<p>This attack may be interrupted by spending @LOSS[$chk mp].</p>"
180180
}
181181
}
182182
}
@@ -214,7 +214,7 @@
214214
"systemId": "projectfu",
215215
"systemVersion": "#{VERSION}#",
216216
"createdTime": 1766863644203,
217-
"modifiedTime": 1766868712597,
217+
"modifiedTime": 1767558638386,
218218
"lastModifiedBy": "J5B4HfVqUaCPvzGg"
219219
},
220220
"_key": "!items.effects!sIkQa2NzkqsvczBr.ZUwqffH7kP8rWg0g"

0 commit comments

Comments
 (0)