From af1221c3e3ba55f99d3a5dc0983c67f3bdda525f Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 26 Jun 2024 13:25:28 +0200 Subject: reverse instant recipe output when input is reversed --- server/src/interaction.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'server/src/interaction.rs') diff --git a/server/src/interaction.rs b/server/src/interaction.rs index 615d2aab..e3dccfba 100644 --- a/server/src/interaction.rs +++ b/server/src/interaction.rs @@ -192,12 +192,13 @@ pub fn interact( } => { let on_tile = this.as_ref().map(|i| i.kind); let in_hand = other.as_ref().map(|i| i.kind); - let ok = (inputs[0] == on_tile && inputs[1] == in_hand) - || (inputs[1] == on_tile && inputs[0] == in_hand); - if ok { - info!("instant recipe {ri:?}"); - *other = outputs[0].map(|kind| Item { kind, active: None }); - *this = outputs[1].map(|kind| Item { kind, active: None }); + let ok = inputs[0] == on_tile && inputs[1] == in_hand; + let ok_rev = inputs[1] == on_tile && inputs[0] == in_hand; + if ok || ok_rev { + info!("instant recipe {ri:?} reversed={ok_rev}"); + let ok_rev = ok_rev as usize; + *other = outputs[1 - ok_rev].map(|kind| Item { kind, active: None }); + *this = outputs[ok_rev].map(|kind| Item { kind, active: None }); return Some(InteractEffect::Produce); } } -- cgit v1.2.3-70-g09d2