dotg

a bitreich fosdem adventure
git clone git://parazyd.org/dotg.git
Log | Files | Refs

commit cdb81a83f5ba6ba11c731be0480b078535105922
parent fbb4090a34602bcd45831df1f262b4eaf8ad24c8
Author: parazyd <parazyd@dyne.org>
Date:   Fri, 23 Feb 2018 20:41:37 +0100

Reuse functions in use_generic()

Diffstat:
Mact-i/functions | 54+++++++++++++++++++++---------------------------------
1 file changed, 21 insertions(+), 33 deletions(-)

diff --git a/act-i/functions b/act-i/functions @@ -143,41 +143,29 @@ find_usecase() { } use_generic() { - case "$1" in - Cigarettes) - oldcount="$(cat $inventory/Cigarettes)" - newcount="$(( $oldcount -1 ))" - printf "$newcount" > "$inventory/Cigarettes" - if [ "$newcount" -lt 1 ]; then - rm -f "$inventory/Cigarettes" - fi - echo "You smoke a cigarette." - return - ;; - Beers) - oldcount="$(cat $inventory/Beers)" - newcount="$(( $oldcount -1 ))" - printf "$newcount" > "$inventory/Beers" - if [ "$newcount" -lt 1 ]; then - rm -f "$inventory/Beers" - fi - echo "You drink a beer." - return - ;; - Plastic_bottle_of_rakia) - cat <<EOM -You take a sip of rakia. - -You feel drunk. -EOM - ;; + case "$1" in + Cigarettes) + dropitem "$item" + echo "You smoke a cigarette." + ;; + + Beers) + dropitem "$item" + echo "You drink a beer." + ;; + + Plastic_bottle_of_rakia) + _msg "You take a sip of rakia. + + You feel drunk." + ;; + Keychain_with_a_key) - cat <<EOM -You try to unlock things, but there's no place to use the key. + _msg "You try to unlock things, but there's no place to use the key. -You put it back in your pocket. -EOM - esac + You put it back in your pocket." + ;; + esac } use_specific() {