palette: MOVE 1 is FIGHT's backstop only while nothing else is a move, and ITEM asks the cartridge about its Potion
This commit is contained in:
parent
86149dca9b
commit
4178a20529
2 changed files with 46 additions and 2 deletions
|
|
@ -658,7 +658,13 @@ pub fn precondition(kind: MacroKind, state: &mut dyn MacroState) -> bool {
|
|||
// the fly's.
|
||||
MacroKind::ThrowBall => throw_slot(state).is_some(),
|
||||
MacroKind::Switch => healthiest_other(state).is_some(),
|
||||
MacroKind::Item => hurt(state) && potion_slot(state).is_some(),
|
||||
// ...and a Potion the cartridge would take (row 63): `ItemUseMedicine` answers "It won't
|
||||
// have any effect." to a Pokémon that is fainted or full, and the fly is back in the bag
|
||||
// with nothing changed. `hurt` already says the one that is out is neither, so this is
|
||||
// the cartridge agreeing rather than a second opinion.
|
||||
MacroKind::Item => {
|
||||
hurt(state) && potion_slot(state).is_some() && !state.item_refused(item::POTION)
|
||||
}
|
||||
// A wild battle the fly is *losing* (`docs/design/macros.md` section 13.1, the operator: "we run
|
||||
// away a lot"). Knowledge inside the macro, as a precondition: nothing ranks `RUN` below
|
||||
// `ATTACK` -- the button simply is not there while the fight is still worth having.
|
||||
|
|
@ -1985,8 +1991,14 @@ pub fn move_slot_bound(state: &mut dyn MacroState, kind: MacroKind) -> bool {
|
|||
}
|
||||
let any_useful = useful.iter().any(|flag| *flag);
|
||||
let entry = holds(usize::from(index)).copied();
|
||||
// `MOVE 1` over the menu is FIGHT's backstop **only while nothing else is a move**: Struggle,
|
||||
// or nothing that would do anything (row 34, row 60). Beside a usable move a spent slot one is
|
||||
// what it is over the list -- not a move -- and its script, "confirm FIGHT and stop", only
|
||||
// opens the list whose `BACK` closes it again: row 63 measured `MOVE 1`, `BACK` ten times in
|
||||
// ten minutes on Mt. Moon B2F with `MOVE 4` usable, 12.11's pair once more. The usable move is
|
||||
// on this pad itself, and it is the button that ends the turn.
|
||||
if index == 0 && main {
|
||||
return !any_useful || useful[0] || entry.is_none_or(|entry| entry.pp == 0);
|
||||
return !any_useful || useful[0];
|
||||
}
|
||||
let Some(entry) = entry else { return false };
|
||||
if entry.pp > 0 {
|
||||
|
|
|
|||
|
|
@ -2377,6 +2377,38 @@ fn a_confirm_is_not_held_back_when_nothing_is_latched() {
|
|||
assert!(world.frames < 120, "no wait: {} frames", world.frames);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn item_is_off_the_pad_while_the_cartridge_would_refuse_the_potion() {
|
||||
let mut world = World::battle();
|
||||
world.bag = vec![(item::POTION, 1)];
|
||||
assert!(precondition(MacroKind::Item, &mut world));
|
||||
world.refused_items.insert(item::POTION);
|
||||
assert!(!precondition(MacroKind::Item, &mut world), "\"It won't have any effect.\"");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn move_one_is_not_fights_backstop_beside_a_usable_move() {
|
||||
// Row 63's second pair, the same ten minutes: slot one spent, slot four with 25 PP. `MOVE 1`
|
||||
// over the menu confirmed FIGHT and stopped, which opens the list and chooses nothing, and the
|
||||
// list's `BACK` closed it again -- `MOVE 1`, `BACK`, ten times. `MOVE 4` is on this menu too,
|
||||
// and it is the button that ends the turn.
|
||||
let mut world = World::battle();
|
||||
world.mons = vec![mon(0, 8, 86, &[(44, 0), (39, 0), (145, 0), (55, 25)])];
|
||||
let moves: Vec<&str> =
|
||||
pad_of(&mut world).into_iter().filter(|name| name.starts_with("MOVE")).collect();
|
||||
assert_eq!(moves, ["MOVE 4"]);
|
||||
// With nothing usable it is the backstop again: Struggle is behind FIGHT (row 34).
|
||||
world.mons = vec![mon(0, 8, 86, &[(44, 0), (39, 0), (145, 0), (55, 0)])];
|
||||
let moves: Vec<&str> =
|
||||
pad_of(&mut world).into_iter().filter(|name| name.starts_with("MOVE")).collect();
|
||||
assert_eq!(moves, ["MOVE 1"]);
|
||||
// And with slot one usable it is slot one's own button.
|
||||
world.mons = vec![mon(0, 8, 86, &[(44, 3), (55, 25)])];
|
||||
let moves: Vec<&str> =
|
||||
pad_of(&mut world).into_iter().filter(|name| name.starts_with("MOVE")).collect();
|
||||
assert_eq!(moves, ["MOVE 1", "MOVE 2"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn buy_potion_takes_buy_then_the_item_then_confirms_twice() {
|
||||
let mut world = World::room();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue