#! /bin/sh # set -x # # One Dollar Pinball was created by Larry DeMar and Joe Kaminkow. # # Unix version produced by Steven J. Craig November 1, 1991 # # Bug Fixes (12/92): # # Match now checks last digit only # Game now ends when balls = 0 # Improved error checking for bad arguments # Tilt counter no longer reset after draining ball # # Also changed: # # Altered output messages; now displays current score / balls remaining # Restructured SUPER SAVE / SPECIAL, MILLION PLUS and TILT WARNING algorithm # Utilized boolean tests where needed # tilts=2 num_tilts=$tilts balls=3 temp=0 look=0 DOUBLE= JACKPOT= DRAIN= MILLION= score=0 digits=0 mult=10000000 current=$1 if [ $# -ne 3 ] # Check for all three arguments then echo "Usage: $0 <8-digit Serial Number> " exit 1 fi if [ `expr $1 : '[0-9]*'` -ne 8 -o `expr $1 : '.*'` -ne 8 \ -o `expr $2 : '[0-9]*'` -ne `expr $2 : '.*'` -o $2 -lt 1 -o $2 -gt 12 \ -o `expr $3 : '[0-9]*'` -ne `expr $3 : '.*'` ] # check for bad input then echo "Usage: $0 <8-digit Serial Number> " exit 1 fi while [ $balls -gt 0 -a $digits -lt 8 ] do i=`expr $current / $mult` # Get next digit to check case "$i" in 0) echo -n "+++ Million Plus +++ Value: " if [ $digits -eq 7 ] # check if last digit then echo -n "Nothing (HA!)" else mult=`expr $mult / 10` digits=`expr $digits + 1` i=`expr $current / $mult` score=`expr $score + $i` if [ $i -eq 0 ] then echo -n 10 Million score=`expr $score + 10` else echo -n $i Million MILLION="yes" fi fi;; 1) echo -n "=== 1 Million === " score=`expr $score + 1`;; 2) if test "$DOUBLE" = "" # Doubles score (once only) then echo -n "... Score Doubled... Value: $score Million" score=`expr $score \* 2` DOUBLE="yes" else echo -n "... 1 Million ... " score=`expr $score + 1` fi;; 3) echo -n "=== 3 Million === " score=`expr $score + 3`;; 4) if test "$JACKPOT" = "" # Jackpot (once only) then score=`expr $score + $2` echo -n "--> Jackpot!!! <-- Value: $2 Million" JACKPOT="yes" else echo -n "--> 1 Million <-- " score=`expr $score + 1` fi;; 5) balls=`expr $balls + 1` echo "!!! Extra Ball !!! Balls Left: $balls";; 6) num_tilts=`expr $num_tilts - 1` # Enough tilting loses ball if [ $num_tilts -ne 0 ] then echo "*** Tilt Warning ***" else balls=`expr $balls - 1` echo "*** TILT! TILT! *** Balls Left: $balls" num_tilts="$tilts" # Reset tilt counter fi;; [7-9]) # Ball drains, unless SPECIAL or SAVE DRAIN="yes" if [ $digits -lt 6 ] # Check for 3 in a row SPECIAL then temp=`expr $mult / 100` look=`expr $current / $temp` if [ $look -eq 777 -o $look -eq 888 -o $look -eq 999 ] then score=`expr $score + 5` echo -n "==> SPECIAL <== *klack* 5 Million" echo " Current Score: $score Million" current=`expr $current - $i \* $mult` mult=`expr $mult / 100` digits=`expr $digits + 2` i=`expr $current / $mult` DRAIN="" fi fi if test "$DRAIN" -a $digits -lt 7 # Check for 2 in a row SUPER SAVE then temp=`expr $mult / 10` look=`expr $current / $temp` if [ $look -eq 77 -o $look -eq 88 -o $look -eq 99 ] then echo ">>> Super Save! <<<" current=`expr $current - $i \* $mult` mult=`expr $mult / 10` digits=`expr $digits + 1` i=`expr $current / $mult` DRAIN="" fi fi if test "$DRAIN" # Check if drainer then balls=`expr $balls - 1` echo "Drain... }B-( Balls Left: $balls" DRAIN= fi;; esac current=`expr $current - $i \* $mult` mult=`expr $mult / 10` digits=`expr $digits + 1` # Go to next digit (stop at 8) if test "$MILLION" -o $i -lt 5 # Display score if it changed then echo " Current Score: $score Million" MILLION="" fi done score=`expr $score + $balls \* 1` # Add a million for each remaining ball echo "<<< BALLS LEFT >>> BONUS: $balls Million" match=`expr "$3" % 10` temp=`expr "$1" % 10` if [ "$match" -eq "$temp" ] # Check for match then echo "$\$$ Match $\$$ *klack* 1 Million" score=`expr $score + 1` fi echo echo "Your final score is: $score Million" echo