1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #!/bin/bash
function extracting_word () {
the_words_box=(java javascript oracle delphi perl pithon linux unix mandreva vista database visualbasic
mysql )
nbrword=${#the_words_box}
word=${the_word_box[$((RANDOM%nbrword)+1)]}
}
function hiding_word () {
word=$(extracting_word)
hideword=echo $word|tr "[a-z-A-Z]" "_")
}
function presentation () {
ResetColor="$(tput sgr0)"
bold=$(tput smso)
offbold=$(tput rmso)
Red="$(tput bold ; tput setaf 1)"
Green="$(tput bold ; tput setaf 2)"
Yellow="$(tput bold ; tput setaf 3)"
Blue="$(tput bold ; tput setaf 4)"
BlueCyan="$(tput bold ; tput setaf 6)"
letter=""
using_letter=""
lives=14
tput cup 0 20
echo -e "${BlueCyan}##########################################${ResetColor}
tput cup 1 20
echo -e "${BlueCyan}# HANGMAN #${ResetColor}
tput cup 2 20
echo -e "${BlueCyan}##########################################${ResetColor}
tput cup 5 10
echo -e " Are you ready to play now if yaes enter 1 ELSE ENTER 2:\c"
read choice
if choice=1
then
tput cup 7 10
echo -e "${Green}the word is composed to ${#word} letters: $hiding_word ${ResetColor}"
tput cup 8 10
echo -e "${Red} You have a ${lives} lives${ResetColor}
tput cup 9 10
echo -e "${Green}You asked the following letter ${using_letter}${ResetColor}"
tput cup 10 10
echo -e "${BlueCyan}Enter a letter please not special caractere or numerique just letter${ResetColor}"
read letter
letter <<< $using_letter >/dev/null
testing_letter
else
echo -e "${Red} Good bye say you soon!${ResetColor}
fi
} |
Partager