93 lines
2.8 KiB
Bash
Executable file
93 lines
2.8 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Définir les associations de techniques
|
|
declare -A associations
|
|
associations["tan sao,fak sao"]=1
|
|
associations["pak sao,chun kuen"]=1
|
|
associations["bong sao,biu jee"]=1
|
|
associations["gam sao,chin chun"]=1
|
|
associations["jam sao,fak sao"]=1
|
|
associations["kao sao,chum sao"]=1
|
|
|
|
# Fonction pour choisir une technique aléatoire
|
|
choose_technique() {
|
|
local techniques_file="$1"
|
|
shuf -n 1 "$techniques_file"
|
|
}
|
|
|
|
# Fonction pour afficher les techniques en fonction du pattern
|
|
display_techniques() {
|
|
local techniques_file="$1"
|
|
local pattern="$2"
|
|
local previous_defensive=""
|
|
|
|
IFS='+' read -ra pattern_array <<< "$pattern"
|
|
for p in "${pattern_array[@]}"; do
|
|
technique=""
|
|
if [[ "$p" -eq 0 ]]; then
|
|
technique=$(grep ",0$" "$techniques_file" | shuf -n 1 | cut -d',' -f1)
|
|
previous_defensive="$technique"
|
|
echo "Défensive : $technique"
|
|
elif [[ "$p" -eq 1 ]]; then
|
|
if [[ -n "$previous_defensive" ]]; then
|
|
possible_offensive=$(grep ",1$" "$techniques_file" | cut -d',' -f1)
|
|
for offensive in $possible_offensive; do
|
|
if [[ "${associations["$previous_defensive,$offensive"]}" -eq 1 ]]; then
|
|
technique="$offensive"
|
|
break
|
|
fi
|
|
done
|
|
if [[ -z "$technique" ]]; then
|
|
technique=$(grep ",1$" "$techniques_file" | shuf -n 1 | cut -d',' -f1)
|
|
fi
|
|
else
|
|
technique=$(grep ",1$" "$techniques_file" | shuf -n 1 | cut -d',' -f1)
|
|
fi
|
|
echo "Offensive : $technique"
|
|
previous_defensive=""
|
|
fi
|
|
done
|
|
}
|
|
|
|
# Main
|
|
techniques_file="techniques.csv"
|
|
|
|
while true; do
|
|
choice=$(whiptail --title "Menu" --menu "Choisissez une option" 15 60 6 \
|
|
"1" "Défense + Attaque" \
|
|
"2" "Défense + Défense" \
|
|
"3" "Défense + Défense + Attaque" \
|
|
"4" "Défense + Attaque + Défense + Attaque" \
|
|
"5" "Pattern personnalisé" \
|
|
"0" "Quitter" 3>&1 1>&2 2>&3)
|
|
|
|
case "$choice" in
|
|
1)
|
|
pattern="0+1"
|
|
;;
|
|
2)
|
|
pattern="0+0"
|
|
;;
|
|
3)
|
|
pattern="0+0+1"
|
|
;;
|
|
4)
|
|
pattern="0+1+0+1"
|
|
;;
|
|
5)
|
|
pattern=$(whiptail --inputbox "Entrez le pattern personnalisé (par exemple '1+0+0+1')" 8 60 3>&1 1>&2 2>&3)
|
|
;;
|
|
0)
|
|
whiptail --msgbox "Au revoir !" 8 45
|
|
exit 0
|
|
;;
|
|
*)
|
|
whiptail --msgbox "Option invalide. Veuillez choisir une option valide." 8 45
|
|
continue
|
|
;;
|
|
esac
|
|
|
|
result=$(display_techniques "$techniques_file" "$pattern")
|
|
whiptail --msgbox "$result" 20 70
|
|
|
|
done
|