Skip to content
Merged
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
1 change: 1 addition & 0 deletions crates/engine/src/database/hideaway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ fn hideaway_trigger(n: u32) -> TriggerDefinition {
filter: TargetFilter::Any,
// CR 702.75a: "put the rest on the bottom of your library."
rest_destination: Some(Zone::Library),
rest_order: crate::types::ability::DigRestOrder::Random,
// CR 701.20e: the cards are looked at privately, not revealed.
reveal: false,
enter_tapped: false,
Expand Down
1 change: 1 addition & 0 deletions crates/engine/src/game/ability_rw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4675,6 +4675,7 @@ fn rw_effect(
keep_count: _,
up_to: _,
rest_destination: _,
rest_order: _,
reveal: _,
enter_tapped: _,
source: _,
Expand Down
1 change: 1 addition & 0 deletions crates/engine/src/game/ability_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ fn scan_effect(x: &Effect, mode: ScanMode) -> Axes {
keep_count: _,
up_to: _,
rest_destination: _,
rest_order: _,
reveal: _,
enter_tapped: _,
source: _,
Expand Down
1 change: 1 addition & 0 deletions crates/engine/src/game/effects/choose_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub fn resolve(
up_to: false,
kept_destination: None,
rest_destination: None,
rest_order: crate::types::ability::DigRestOrder::Preserve,
source_id: Some(ability.source_id),
enter_tapped: false,
};
Expand Down
54 changes: 52 additions & 2 deletions crates/engine/src/game/effects/dig.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::game::filter::{matches_target_filter, FilterContext};
use crate::game::quantity::resolve_quantity_with_targets;
use crate::types::ability::{
DigSource, Effect, EffectError, EffectKind, ParentTargetMissingReason, ResolvedAbility,
TargetFilter,
DigRestOrder, DigSource, Effect, EffectError, EffectKind, ParentTargetMissingReason,
ResolvedAbility, TargetFilter,
};
use crate::types::events::GameEvent;
use crate::types::game_state::{BatchCompletion, GameState, WaitingFor};
Expand All @@ -23,6 +23,7 @@ pub fn resolve(
filter,
kept_dest,
rest_dest,
rest_order,
is_reveal,
enter_tapped,
dig_source,
Expand All @@ -36,6 +37,7 @@ pub fn resolve(
filter,
destination,
rest_destination,
rest_order,
reveal,
enter_tapped,
source,
Expand Down Expand Up @@ -63,6 +65,7 @@ pub fn resolve(
filter.clone(),
*destination,
*rest_destination,
*rest_order,
*reveal,
*enter_tapped,
*source,
Expand All @@ -76,6 +79,7 @@ pub fn resolve(
TargetFilter::Any,
None,
None,
DigRestOrder::Preserve,
false,
false,
DigSource::Library,
Expand Down Expand Up @@ -107,6 +111,7 @@ pub fn resolve(
filter,
kept_dest,
rest_dest,
rest_order,
enter_tapped,
);
}
Expand Down Expand Up @@ -241,6 +246,7 @@ pub fn resolve(
&selectable_cards,
dest,
rest_dest,
rest_order,
enter_tapped,
events,
);
Expand All @@ -263,6 +269,7 @@ pub fn resolve(
up_to: is_up_to,
kept_destination: kept_dest,
rest_destination: rest_dest,
rest_order,
source_id: Some(ability.source_id),
enter_tapped,
};
Expand Down Expand Up @@ -300,6 +307,7 @@ fn resolve_from_prior_look(
filter: TargetFilter,
kept_dest: Option<Zone>,
rest_dest: Option<Zone>,
rest_order: DigRestOrder,
enter_tapped: bool,
) -> Result<(), EffectError> {
let cards = state.private_look_ids.clone();
Expand Down Expand Up @@ -327,6 +335,7 @@ fn resolve_from_prior_look(
state,
&cards,
dest,
rest_order,
Some(ability.source_id),
events,
) {
Expand Down Expand Up @@ -374,6 +383,7 @@ fn resolve_from_prior_look(
state,
&cards,
dest,
rest_order,
Some(ability.source_id),
events,
) {
Expand Down Expand Up @@ -417,6 +427,7 @@ fn resolve_from_prior_look(
up_to: is_up_to,
kept_destination: kept_dest,
rest_destination: rest_dest,
rest_order,
source_id: Some(ability.source_id),
enter_tapped,
};
Expand Down Expand Up @@ -450,6 +461,7 @@ fn resolve_mass_put_all(
selectable: &[crate::types::identifiers::ObjectId],
dest: Zone,
rest_destination: Option<Zone>,
rest_order: DigRestOrder,
enter_tapped: bool,
events: &mut Vec<GameEvent>,
) {
Expand All @@ -465,6 +477,7 @@ fn resolve_mass_put_all(
state,
&rest,
rest_destination.unwrap_or(Zone::Library),
rest_order,
Some(ability.source_id),
events,
) {
Expand Down Expand Up @@ -550,6 +563,7 @@ mod tests {
use crate::types::mana::{ManaCost, ManaCostShard};
use crate::types::player::PlayerId;
use crate::types::zones::Zone;
use rand::seq::SliceRandom;

fn make_dig_ability(dig_num: u32) -> ResolvedAbility {
ResolvedAbility::new(
Expand All @@ -564,6 +578,7 @@ mod tests {
up_to: false,
filter: TargetFilter::Any,
rest_destination: None,
rest_order: DigRestOrder::Preserve,
reveal: false,
enter_tapped: false,
source: DigSource::Library,
Expand Down Expand Up @@ -658,6 +673,7 @@ mod tests {
up_to: false,
filter: TargetFilter::Any,
rest_destination: None,
rest_order: DigRestOrder::Preserve,
reveal: false,
enter_tapped: false,
source: DigSource::Library,
Expand Down Expand Up @@ -711,6 +727,7 @@ mod tests {
up_to: false,
filter: TargetFilter::Any,
rest_destination: None,
rest_order: DigRestOrder::Preserve,
reveal: false,
enter_tapped: false,
source: DigSource::Library,
Expand Down Expand Up @@ -764,6 +781,7 @@ mod tests {
up_to: false,
filter: TargetFilter::Any,
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
reveal: false,
enter_tapped: false,
source: DigSource::Library,
Expand Down Expand Up @@ -834,6 +852,7 @@ mod tests {
up_to: true,
kept_destination: None,
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
source_id: Some(ObjectId(100)),
enter_tapped: false,
};
Expand Down Expand Up @@ -915,6 +934,7 @@ mod tests {
up_to: true,
kept_destination: None,
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
source_id: Some(ObjectId(100)),
enter_tapped: false,
};
Expand Down Expand Up @@ -975,6 +995,7 @@ mod tests {
up_to: false,
kept_destination: Some(Zone::Library),
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
source_id: Some(ObjectId(100)),
enter_tapped: false,
};
Expand Down Expand Up @@ -1046,6 +1067,7 @@ mod tests {
up_to: false,
kept_destination: Some(Zone::Library),
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
source_id: Some(ObjectId(100)),
enter_tapped: false,
};
Expand Down Expand Up @@ -1109,6 +1131,7 @@ mod tests {
up_to: true,
kept_destination: Some(Zone::Hand),
rest_destination: Some(Zone::Graveyard),
rest_order: DigRestOrder::Preserve,
source_id: Some(ObjectId(100)),
enter_tapped: false,
};
Expand Down Expand Up @@ -1169,6 +1192,7 @@ mod tests {
up_to: true,
kept_destination: Some(Zone::Hand),
rest_destination: Some(Zone::Graveyard),
rest_order: DigRestOrder::Preserve,
source_id: Some(ObjectId(100)),
enter_tapped: false,
};
Expand Down Expand Up @@ -1238,6 +1262,7 @@ mod tests {
up_to: true,
kept_destination: Some(Zone::Hand),
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
source_id: Some(ObjectId(100)),
enter_tapped: false,
};
Expand Down Expand Up @@ -1310,6 +1335,7 @@ mod tests {
up_to: true,
kept_destination: Some(Zone::Hand),
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
source_id: Some(ObjectId(100)),
enter_tapped: false,
};
Expand Down Expand Up @@ -1376,6 +1402,7 @@ mod tests {
up_to: true,
kept_destination: Some(Zone::Hand),
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
source_id: Some(ObjectId(100)),
enter_tapped: false,
};
Expand Down Expand Up @@ -1453,6 +1480,7 @@ mod tests {
up_to: false,
filter,
rest_destination: None,
rest_order: DigRestOrder::Preserve,
reveal: false,
enter_tapped: false,
source: DigSource::Library,
Expand Down Expand Up @@ -1529,6 +1557,7 @@ mod tests {
up_to: false,
filter: TargetFilter::Typed(TypedFilter::creature()),
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
reveal: false,
enter_tapped: false,
source: DigSource::Library,
Expand Down Expand Up @@ -1834,6 +1863,7 @@ mod tests {
up_to: true,
filter: filter.clone(),
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
reveal: false,
enter_tapped: false,
source: DigSource::Library,
Expand Down Expand Up @@ -1890,6 +1920,7 @@ mod tests {
up_to: true,
filter: filter_you,
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
reveal: false,
enter_tapped: false,
source: DigSource::Library,
Expand Down Expand Up @@ -1957,6 +1988,7 @@ mod tests {
up_to: true,
kept_destination: Some(Zone::Battlefield),
rest_destination: Some(Zone::Library),
rest_order: DigRestOrder::Preserve,
source_id: Some(ObjectId(100)),
enter_tapped: false,
};
Expand Down Expand Up @@ -2026,6 +2058,7 @@ mod tests {
up_to,
destination,
rest_destination,
rest_order,
..
} => {
assert_eq!(
Expand All @@ -2041,6 +2074,11 @@ mod tests {
"the in-clause 'and the rest on the bottom' rider must set rest=Library, \
not fall through to the graveyard default"
);
assert_eq!(
*rest_order,
DigRestOrder::Random,
"Muxus's exact random-order rider must reach the mass Dig resolver"
);
}
other => panic!("expected a Dig effect, got {other:?}"),
}
Expand Down Expand Up @@ -2083,6 +2121,9 @@ mod tests {

let ability =
ResolvedAbility::new((*def.effect).clone(), vec![], ObjectId(100), PlayerId(0));
let mut expected_rest = rest.clone();
let mut expected_rng = state.rng.clone();
expected_rest.shuffle(&mut expected_rng);
let mut events = Vec::new();
resolve(&mut state, &ability, &mut events).unwrap();

Expand Down Expand Up @@ -2115,6 +2156,15 @@ mod tests {
"non-matching card {id:?} must remain in the library"
);
}
assert_eq!(
library, expected_rest,
"Muxus's random-order rest pile must use the seeded shuffle before bottom placement"
);
assert_eq!(
state.rng.get_word_pos(),
expected_rng.get_word_pos(),
"the deterministic mass path must consume exactly its rest-pile shuffle"
);
let bottom: Vec<_> = library
.iter()
.rev()
Expand Down
1 change: 1 addition & 0 deletions crates/engine/src/game/effects/explore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ pub(crate) fn resolve_explore_effect(
up_to: true,
kept_destination: Some(crate::types::zones::Zone::Library),
rest_destination: Some(crate::types::zones::Zone::Graveyard),
rest_order: crate::types::ability::DigRestOrder::Preserve,
source_id: Some(ability.source_id),
enter_tapped: false,
};
Expand Down
2 changes: 2 additions & 0 deletions crates/engine/src/game/effects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27352,6 +27352,7 @@ mod tests {
up_to: false,
filter: TargetFilter::Any,
rest_destination: None,
rest_order: crate::types::ability::DigRestOrder::Preserve,
reveal: false,
enter_tapped: false,
source: DigSource::Library,
Expand Down Expand Up @@ -27986,6 +27987,7 @@ mod tests {
up_to: false,
filter: TargetFilter::Any,
rest_destination: None,
rest_order: crate::types::ability::DigRestOrder::Preserve,
reveal: false,
enter_tapped: false,
source: DigSource::Library,
Expand Down
Loading
Loading