69 lines
1.9 KiB
Bash
69 lines
1.9 KiB
Bash
|
#!/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=$(choose_technique "$techniques_file" | cut -d',' -f1)
|
||
|
echo "Défensive : $technique"
|
||
|
elif [[ "$p" -eq 1 ]]; then
|
||
|
technique=$(choose_technique "$techniques_file" | cut -d',' -f2)
|
||
|
echo "Offensive : $technique"
|
||
|
fi
|
||
|
done
|
||
|
}
|
||
|
|
||
|
# Main
|
||
|
techniques_file="techniques.csv"
|
||
|
|
||
|
while true; do
|
||
|
clear
|
||
|
echo "Menu :"
|
||
|
echo "1) Défense + Attaque"
|
||
|
echo "2) Défense + Défense"
|
||
|
echo "3) Défense + Défense + Attaque"
|
||
|
echo "4) Défense + Attaque + Défense + Attaque"
|
||
|
echo "5) Pattern personnalisé"
|
||
|
echo "0) Quitter"
|
||
|
read -p "Choisissez une option : " choice
|
||
|
|
||
|
case "$choice" in
|
||
|
1)
|
||
|
display_techniques "$techniques_file" "0+1"
|
||
|
;;
|
||
|
2)
|
||
|
display_techniques "$techniques_file" "0+0"
|
||
|
;;
|
||
|
3)
|
||
|
display_techniques "$techniques_file" "0+0+1"
|
||
|
;;
|
||
|
4)
|
||
|
display_techniques "$techniques_file" "0+1+0+1"
|
||
|
;;
|
||
|
5)
|
||
|
read -p "Entrez le pattern personnalisé (par exemple '1+0+0+1') : " custom_pattern
|
||
|
display_techniques "$techniques_file" "$custom_pattern"
|
||
|
;;
|
||
|
0)
|
||
|
echo "Au revoir !"
|
||
|
exit 0
|
||
|
;;
|
||
|
*)
|
||
|
echo "Option invalide. Veuillez choisir une option valide."
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
read -p "Appuyez sur Entrée pour afficher le menu à nouveau..." input
|
||
|
done
|
||
|
|