I did not checked all the code but this looks suspicious:
if [ "$score" -ge 1 ]; then
Number=$(($RANDOM % 52))
Gokkaart=${KAARTEN[$Number]}
oldNumber=$Number
echo "De kaart is $Gokkaart2"
fi
You are assigning a new random number to
$Number
. So the old number is no longer available and assigning the new value to
$oldNumber
later makes no sense.
You are getting the card name for the new number into
$Gokkart
but printing
$Gokkart2
.
So the above block should be probably something like:
if [ "$score" -ge 1 ]; then
oldNumber=$Number
Number=$(($RANDOM % 52))
Gokkaart2=${KAARTEN[$Number]}
echo "De kaart is $Gokkaart2"
fi
Note also that I have used the common
bash formatting (putting the
then
into the same line as the
if
and indenting conditional blocks).
Finally two tips:
You might also have a look at bash functions. If you don't know this already have also a look at the
BASH Programming - Introduction HOW-TO[
^].