From 6154d5ca0a5a84ed5cbf5613e26267b33cd76523 Mon Sep 17 00:00:00 2001 From: FaycoTLS Date: Mon, 26 Feb 2024 13:07:24 +0100 Subject: [PATCH] =?UTF-8?q?r=C3=A9glage=20de=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kristofer.rumeau@ynov.com/debug_wsl.md | 3 + .../kristofer.rumeau@ynov.com/rooms/kroo.sh | 7 +- .../kristofer.rumeau@ynov.com/rooms/kroo2.sh | 44 ++-- .../rooms/mainroom.sh | 1 - .../rooms/meteofrance.sh | 242 +++++++++++++++--- 5 files changed, 234 insertions(+), 63 deletions(-) diff --git a/adventure/games/kristofer.rumeau@ynov.com/debug_wsl.md b/adventure/games/kristofer.rumeau@ynov.com/debug_wsl.md index c35b5e98..7b1505e7 100644 --- a/adventure/games/kristofer.rumeau@ynov.com/debug_wsl.md +++ b/adventure/games/kristofer.rumeau@ynov.com/debug_wsl.md @@ -67,6 +67,9 @@ Il faut installer ''' sudo apt install xdg-utils ''' ainsi que ''' sudo apt inst Le levier ne fonctionne pas, « ACTIVATION STATION » mais rien ne se passe. +c'est parce que le script ne se souvient que du premiere appel du levier donc il faut le lui rappeller juste après l'action avec : + + leverstate=$(cat $MY_PATH/../logic/leverlogic.ben) diff --git a/adventure/games/kristofer.rumeau@ynov.com/rooms/kroo.sh b/adventure/games/kristofer.rumeau@ynov.com/rooms/kroo.sh index 9b8f1a11..d0afee2e 100644 --- a/adventure/games/kristofer.rumeau@ynov.com/rooms/kroo.sh +++ b/adventure/games/kristofer.rumeau@ynov.com/rooms/kroo.sh @@ -13,23 +13,22 @@ done <"$file1" echo # It's script time again... -sleep 1 echo "Vous pénétrez à l'intérieur de l'Astroport." echo -sleep 3 echo "Une voix synthétique vous accueille." espeak "Welcome. Please Identify." > /dev/null 2>&1 echo echo "Vous parcourez l'espace du regard" echo "Au nord, face à vous se trouve un foyer où brule un feu." echo -sleep 3 echo "A l'ouest sont suspendus tuyaux, ustensiles et bocaux. Une cuisine?" echo "A l'est il y a un genre de 'photomaton' " -sleep 2 +echo echo "Derrière vous, la porte par où vous êtes entré est encore ouverte." echo echo "Que voulez vous faire?" +echo +echo "Il y a également un ordinateur au millieu de la pièce avec l'inscription : 'Appuyez sur U pour lancer le jeu'" # And once again the room logic. diff --git a/adventure/games/kristofer.rumeau@ynov.com/rooms/kroo2.sh b/adventure/games/kristofer.rumeau@ynov.com/rooms/kroo2.sh index ebdb5e36..bc9b1396 100644 --- a/adventure/games/kristofer.rumeau@ynov.com/rooms/kroo2.sh +++ b/adventure/games/kristofer.rumeau@ynov.com/rooms/kroo2.sh @@ -1,40 +1,52 @@ #!/bin/bash clear + +# This room gets a little artsy with sleep commands, to help with the +# narrative of the story. This is why there are two versions - foyer and foyer2. + # Initialise the Title Art -file1="titleart.ben" +file1="../art/titleart.ben" while IFS= read -r line do echo "$line" done <"$file1" echo -# So here's a little story all about how this script got flip-turned upside down... -sleep 1 -echo "You're in a corridor, but it's quite a small one. You got here" -echo "the first time by hugging a statue of a kitten. Standard." +# It's script time again... +echo "Vous parcourez l'espace du regard" +echo "Au nord, face à vous se trouve un foyer où brule un feu." echo -echo "You see a glow coming from the rooms to your east and west, and" -echo "there's a big, old looking door to the south of you." +echo "A l'ouest sont suspendus tuyaux, ustensiles et bocaux. Une cuisine?" +echo "A l'est il y a un genre de 'photomaton' " echo -echo "What would you like to do?" +echo "Derrière vous, la porte par où vous êtes entré est encore ouverte." +echo +echo "Que voulez vous faire?" +echo +echo "Il y a toujours l'ordinateur au millieu de la pièce avec l'inscription : 'Appuyez sur U pour lancer le jeu'" -# Imma let you finish, but here's the room choices. +# And once again the room logic. while true; do read -p "> " nsewuh case $nsewuh in - n ) echo "You faceplant the wall. Idiot." ;; + n ) echo "Vous vous asseyez sur le grand tapis devant le feu. Vous vous relaxez un instant." + ./magic8.sh + ;; s ) ./bigroom.sh - exit ;; - e ) ./gameroom.sh + exit ;; + e ) ./gameroom.sh exit ;; w ) ./grue.sh exit ;; - u ) echo "There's nothing you can use right here." ;; - h ) echo "After hugging that cat you aren't sure you should try to hug yourself again." ;; - * ) echo "I'm sorry, I don't understand you. Commands are: n, e, s, w, u and h.";; + u ) echo "Vous tapotez sur le barmoètre. Une photo satellite?" + ./meteofrance.sh + exit + ;; + h ) echo "La pièce est spacieuse. La chaleur du feu agréable, à gauche on dirait une cuisine explosée, à droite une chaise moletonnée fait face à un écran." ;; + * ) echo "Je suis désolé, je ne vous comprends pas. Les commandes sont : n, e, s, w, u et h..";; esac done esac -exit \ No newline at end of file +exit diff --git a/adventure/games/kristofer.rumeau@ynov.com/rooms/mainroom.sh b/adventure/games/kristofer.rumeau@ynov.com/rooms/mainroom.sh index d8b4d8a4..ccd9bb27 100644 --- a/adventure/games/kristofer.rumeau@ynov.com/rooms/mainroom.sh +++ b/adventure/games/kristofer.rumeau@ynov.com/rooms/mainroom.sh @@ -14,7 +14,6 @@ done <"$file1" echo # Shakesphere wrote this, honest. -sleep 1 echo "Vous êtes de retour à votre point de départ." echo "La forêt qui vous entoure est immense." echo "Vous ne pouvez pas vraiment en imaginer la taille," diff --git a/adventure/games/kristofer.rumeau@ynov.com/rooms/meteofrance.sh b/adventure/games/kristofer.rumeau@ynov.com/rooms/meteofrance.sh index a3526818..a9f0ca80 100644 --- a/adventure/games/kristofer.rumeau@ynov.com/rooms/meteofrance.sh +++ b/adventure/games/kristofer.rumeau@ynov.com/rooms/meteofrance.sh @@ -1,58 +1,216 @@ #!/bin/bash -################################################################################ -# Author: Fred (support@qo-op.com) -# Version: 0.1 -# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) -################################################################################ -MOATS=$(date -u +"%Y%m%d%H%M%S%4N") -mkdir -p ~/.zen/tmp/${MOATS} -################################################################################ -# Choisir la source de capture -# https://fr.sat24.com/image?type=visual5HDComplete®ion=fr -MY_PATH="`dirname \"$0\"`" # relative -MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized -ME="${0##*/}" +# Fonction pour afficher l'interface du jeu +draw_game() { + clear + for ((i = 0; i < height; i++)); do + for ((j = 0; j < width; j++)); do + if [[ $i -eq 0 || $i -eq $((height - 1)) || $j -eq 0 || $j -eq $((width - 1)) ]]; then + echo -e "\033[1;34m#\033[0m\c" + elif [[ $i -eq $fruit_row && $j -eq $fruit_col ]]; then + echo -e "\033[1;31m@\033[0m\c" + else + local is_snake_segment=false + for ((k = 0; k < ${#snake_body_rows[@]}; k++)); do + if [[ $i -eq ${snake_body_rows[$k]} && $j -eq ${snake_body_cols[$k]} ]]; then + echo -e "\033[1;32m#\033[0m\c" + is_snake_segment=true + break + fi + done + if [[ $is_snake_segment == false ]]; then + echo -e " \c" + fi + fi + done + echo + done +} -## TEST IPFS -[[ ! $(which ipfs) ]] && echo "Missing IPFS. Please install... https://ipfs.tech" && exit 1 +# Initialisation des variables +height=20 +width=40 +snake_body_rows=() +snake_body_cols=() +snake_length=1 +direction="RIGHT" +fruit_row=$((RANDOM % (height - 2) + 1)) +fruit_col=$((RANDOM % (width - 2) + 1)) -## PREPARE FILE SYSTEM CACHE -mkdir -p ~/.zen/adventure/meteo.anim.eu -rm -f ~/.zen/adventure/meteo.anim.eu/meteo.png +# Position initiale du serpent +snake_body_rows[0]=$((height / 2)) +snake_body_cols[0]=$((width / 2)) -## SCRAPING meteo.png -curl -m 20 --output ~/.zen/adventure/meteo.anim.eu/meteo.png https://s.w-x.co/staticmaps/wu/wu/satir1200_cur/europ/animate.png +# Fonction pour déplacer le serpent +move_snake() { + local i + for ((i = ${#snake_body_rows[@]} - 1; i > 0; i--)); do + snake_body_rows[$i]=${snake_body_rows[$((i - 1))]} + snake_body_cols[$i]=${snake_body_cols[$((i - 1))]} + done -if [[ ! -f ~/.zen/adventure/meteo.anim.eu/meteo.png ]]; then + case $direction in + "UP") + snake_body_rows[0]=$((snake_body_rows[0] - 1)) + ;; + "DOWN") + snake_body_rows[0]=$((snake_body_rows[0] + 1)) + ;; + "LEFT") + snake_body_cols[0]=$((snake_body_cols[0] - 1)) + ;; + "RIGHT") + snake_body_cols[0]=$((snake_body_cols[0] + 1)) + ;; + esac +} - echo "Impossible de se connecter au service meteo" - exit 1 +# Fonction pour vérifier les collisions +check_collision() { + if [[ ${snake_body_rows[0]} -le 0 || ${snake_body_rows[0]} -ge $((height - 1)) || ${snake_body_cols[0]} -le 0 || ${snake_body_cols[0]} -ge $((width - 1)) ]]; then + return 1 + fi -else + for ((i = 1; i < ${#snake_body_rows[@]}; i++)); do + if [[ ${snake_body_rows[0]} -eq ${snake_body_rows[$i]} && ${snake_body_cols[0]} -eq ${snake_body_cols[$i]} ]]; then + return 1 + fi + done - echo "Mise à jour archive meteo : ${MOATS}" - echo ${MOATS} > ~/.zen/adventure/meteo.anim.eu/.moats + if [[ ${snake_body_rows[0]} -eq $fruit_row && ${snake_body_cols[0]} -eq $fruit_col ]]; then + generate_fruit + grow_snake + fi - OLDID=$(cat ~/.zen/adventure/.meteo.index 2>/dev/null) - # TODO : COMPARE SIMILAR OR NOT - # ipfs get "/ipfs/$OLDID/meteo.anim.eu/meteo.png" + return 0 +} - ## PREPARE NEW index.html - sed "s/_OLDID_/$OLDID/g" ${MY_PATH}/../templates/meteo_chain.html > /tmp/index.html - sed -i "s/_IPFSID_/$IPFSID/g" /tmp/index.html - sed -i "s/_DATE_/$(date -u "+%Y-%m-%d#%H:%M:%S")/g" /tmp/index.html - sed "s/_PSEUDO_/${USER}/g" /tmp/index.html > ~/.zen/adventure/index.html +# Fonction pour faire grandir le serpent +grow_snake() { + local last_index=$(( ${#snake_body_rows[@]} - 1 )) + local last_row=${snake_body_rows[$last_index]} + local last_col=${snake_body_cols[$last_index]} + snake_body_rows+=($last_row) + snake_body_cols+=($last_col) +} - # Copy style css - cp -r ${MY_PATH}/../templates/styles ~/.zen/adventure/ +# Fonction pour générer un nouveau fruit +generate_fruit() { + fruit_row=$((RANDOM % (height - 2) + 1)) + fruit_col=$((RANDOM % (width - 2) + 1)) +} - INDEXID=$(ipfs add -rHq ~/.zen/adventure/* | tail -n 1) - echo $INDEXID > ~/.zen/adventure/.meteo.index - echo "METEO INDEX : http://127.0.0.1:8080/ipfs/$INDEXID" +# Boucle principale du jeu +while true; do + draw_game + echo "Score: ${#snake_body_rows[@]}" - IPFS=$(ipfs add -q ~/.zen/adventure/meteo.anim.eu/meteo.png | tail -n 1) - echo $IPFS > ~/.zen/adventure/meteo.anim.eu/.chain + # Appel à la fonction move_snake pour que le serpent avance automatiquement + move_snake -fi + read -s -t 0.2 -n 1 action + + case $action in + "z") + if [[ $direction != "DOWN" ]]; then + direction="UP" + fi + ;; + "s") + if [[ $direction != "UP" ]]; then + direction="DOWN" + fi + ;; + "q") + if [[ $direction != "RIGHT" ]]; then + direction="LEFT" + fi + ;; + "d") + if [[ $direction != "LEFT" ]]; then + direction="RIGHT" + fi + ;; + esac + + # Vérifier les collisions après le déplacement + check_collision + if [[ $? -eq 1 ]]; then + echo "Bravo ! Vous avez eu le score de ${#snake_body_rows[@]} ! Appuyez sur \"q\" pour quitter le jeu ou sur \"r\" pour rejouer" + read -n 1 -s choice + case $choice in + q) + ./kroo2.sh + ;; + r) + ./meteofrance.sh + ;; + *) + echo "Choix non reconnu." + ;; + esac + fi +done + + + + + +# #!/bin/bash +# ################################################################################ +# # Author: Fred (support@qo-op.com) +# # Version: 0.1 +# # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) +# ################################################################################ +# MOATS=$(date -u +"%Y%m%d%H%M%S%4N") +# mkdir -p ~/.zen/tmp/${MOATS} +# ################################################################################ +# # Choisir la source de capture +# # https://fr.sat24.com/image?type=visual5HDComplete®ion=fr + +# MY_PATH="`dirname \"$0\"`" # relative +# MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized +# ME="${0##*/}" + +# ## TEST IPFS +# [[ ! $(which ipfs) ]] && echo "Missing IPFS. Please install... https://ipfs.tech" && exit 1 + +# ## PREPARE FILE SYSTEM CACHE +# mkdir -p ~/.zen/adventure/meteo.anim.eu +# rm -f ~/.zen/adventure/meteo.anim.eu/meteo.png + +# ## SCRAPING meteo.png +# curl -m 20 --output ~/.zen/adventure/meteo.anim.eu/meteo.png https://s.w-x.co/staticmaps/wu/wu/satir1200_cur/europ/animate.png + +# if [[ ! -f ~/.zen/adventure/meteo.anim.eu/meteo.png ]]; then + +# echo "Impossible de se connecter au service meteo" +# exit 1 + +# else + +# echo "Mise à jour archive meteo : ${MOATS}" +# echo ${MOATS} > ~/.zen/adventure/meteo.anim.eu/.moats + +# OLDID=$(cat ~/.zen/adventure/.meteo.index 2>/dev/null) +# # TODO : COMPARE SIMILAR OR NOT +# # ipfs get "/ipfs/$OLDID/meteo.anim.eu/meteo.png" + +# ## PREPARE NEW index.html +# sed "s/_OLDID_/$OLDID/g" ${MY_PATH}/../templates/meteo_chain.html > /tmp/index.html +# sed -i "s/_IPFSID_/$IPFSID/g" /tmp/index.html +# sed -i "s/_DATE_/$(date -u "+%Y-%m-%d#%H:%M:%S")/g" /tmp/index.html +# sed "s/_PSEUDO_/${USER}/g" /tmp/index.html > ~/.zen/adventure/index.html + +# # Copy style css +# cp -r ${MY_PATH}/../templates/styles ~/.zen/adventure/ + +# INDEXID=$(ipfs add -rHq ~/.zen/adventure/* | tail -n 1) +# echo $INDEXID > ~/.zen/adventure/.meteo.index +# echo "METEO INDEX : http://127.0.0.1:8080/ipfs/$INDEXID" + +# IPFS=$(ipfs add -q ~/.zen/adventure/meteo.anim.eu/meteo.png | tail -n 1) +# echo $IPFS > ~/.zen/adventure/meteo.anim.eu/.chain + +# fi