Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions crates/engine/src/parser/oracle_effect/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,11 @@ pub(crate) fn assemble_effect_chain(ir: &EffectChainIr) -> AbilityDefinition {
if let Some(continuation) = clause_ir.disposition.followup() {
apply_clause_continuation(&mut defs, continuation.clone(), kind, &env);
env.observe(&defs, None, NodeRole::ContinuationProduct);
apply_where_x_to_latest_def(&mut defs, clause_ir.where_x_expression.as_deref());
apply_where_x_to_latest_def(
&mut defs,
clause_ir.where_x_expression.as_deref(),
clause_ir.where_x_scope.as_ref(),
);
}
true
} else if let ClauseDisposition::Absorb { rider, kind } = &clause_ir.disposition {
Expand Down Expand Up @@ -1567,6 +1571,7 @@ pub(crate) fn assemble_effect_chain(ir: &EffectChainIr) -> AbilityDefinition {
apply_where_x_ability_expression(
&mut new_def,
clause_ir.where_x_expression.as_deref(),
clause_ir.where_x_scope.as_ref(),
);
new_def.else_ability = Some(Box::new(last_def));
defs.push(new_def);
Expand Down Expand Up @@ -1835,7 +1840,11 @@ pub(crate) fn assemble_effect_chain(ir: &EffectChainIr) -> AbilityDefinition {
if let Some(continuation) = clause_ir.disposition.followup() {
apply_clause_continuation(&mut defs, continuation.clone(), kind, &env);
env.observe(&defs, None, NodeRole::ContinuationProduct);
apply_where_x_to_latest_def(&mut defs, clause_ir.where_x_expression.as_deref());
apply_where_x_to_latest_def(
&mut defs,
clause_ir.where_x_expression.as_deref(),
clause_ir.where_x_scope.as_ref(),
);
}

// ── Build AbilityDefinition from ClauseIr ──
Expand Down Expand Up @@ -2187,7 +2196,11 @@ pub(crate) fn assemble_effect_chain(ir: &EffectChainIr) -> AbilityDefinition {
current_defs.push(*sub.clone());
}
for current in &mut current_defs {
apply_where_x_ability_expression(current, clause_ir.where_x_expression.as_deref());
apply_where_x_ability_expression(
current,
clause_ir.where_x_expression.as_deref(),
clause_ir.where_x_scope.as_ref(),
);
}

// CR 615.5 + CR 609.7: In a "damage is prevented this way" rider, the
Expand Down Expand Up @@ -2413,7 +2426,11 @@ pub(crate) fn assemble_effect_chain(ir: &EffectChainIr) -> AbilityDefinition {
if let Some(continuation) = clause_ir.disposition.intrinsic() {
apply_clause_continuation(&mut defs, continuation.clone(), kind, &env);
env.observe(&defs, None, NodeRole::ContinuationProduct);
apply_where_x_to_latest_def(&mut defs, clause_ir.where_x_expression.as_deref());
apply_where_x_to_latest_def(
&mut defs,
clause_ir.where_x_expression.as_deref(),
clause_ir.where_x_scope.as_ref(),
);
}

// CR 608.2c: Advance the separating boundary for the next normal-path
Expand Down
11 changes: 8 additions & 3 deletions crates/engine/src/parser/oracle_effect/imperative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use super::counter::{
};
use super::lower::{
parse_for_each_multiplier_prefix, parse_multi_target_count_expr,
parse_where_x_quantity_expression, strip_leading_quantifier, strip_trailing_where_x,
parse_where_x_quantity_expression, parse_where_x_quantity_expression_with_context,
strip_leading_quantifier, strip_trailing_where_x,
};
use super::mana::{try_parse_activate_only_condition, try_parse_add_mana_effect_with_context};
use super::token::try_parse_token;
Expand Down Expand Up @@ -8999,7 +9000,11 @@ pub(super) fn parse_counter_ast(text: &str, lower: &str) -> Option<ZoneCounterIm
// the spell phrase to the stack through the shared target parser. Keep this
// path on that building block and only apply the trailing X definition.
// CR 107.3c: fail honestly instead of fabricating a raw-text placeholder.
let target = super::apply_where_x_to_filter(target, where_x_expression.as_deref())?;
let target = super::apply_where_x_to_filter(
target,
where_x_expression.as_deref(),
&ParseContext::default(),
)?;
// CR 118.12: Parse "unless its controller pays {X}" for conditional counters
let unless_pay = parse_counter_unless_pay(rest)?;
Some(ZoneCounterImperativeAst::Counter {
Expand Down Expand Up @@ -10319,7 +10324,7 @@ pub(super) fn parse_imperative_family_ast(
.map(|(r, _)| r)
.unwrap_or("");
let amount = if let Some(expr) = where_x {
parse_where_x_quantity_expression(&expr)
parse_where_x_quantity_expression_with_context(&expr, ctx)
.unwrap_or(QuantityExpr::Fixed { value: 0 })
} else {
let count = nom_primitives::parse_number_or_x
Expand Down
Loading
Loading