diff options
| author | metamuffin <metamuffin@disroot.org> | 2024-06-26 13:25:28 +0200 | 
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2024-06-26 13:26:09 +0200 | 
| commit | af1221c3e3ba55f99d3a5dc0983c67f3bdda525f (patch) | |
| tree | ca072538361807738397e0a8cb4f1e2cb1b23098 /server/src/interaction.rs | |
| parent | cf24bc076e9d3746210e507875a7178df19b51b1 (diff) | |
| download | hurrycurry-af1221c3e3ba55f99d3a5dc0983c67f3bdda525f.tar hurrycurry-af1221c3e3ba55f99d3a5dc0983c67f3bdda525f.tar.bz2 hurrycurry-af1221c3e3ba55f99d3a5dc0983c67f3bdda525f.tar.zst | |
reverse instant recipe output when input is reversed
Diffstat (limited to 'server/src/interaction.rs')
| -rw-r--r-- | server/src/interaction.rs | 13 | 
1 files changed, 7 insertions, 6 deletions
| 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);                      }                  } | 
