67 lines
1.8 KiB
Bash
Executable file
67 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# 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"
|
|
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)
|
|
echo "Défensive : $technique"
|
|
elif [[ "$p" -eq 1 ]]; then
|
|
technique=$(grep ",1$" "$techniques_file" | shuf -n 1 | cut -d',' -f1)
|
|
echo "Offensive : $technique"
|
|
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
|