2024-02-07 19:20:08 +01:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
###################################################################
|
|
|
|
|
# This Launch script is based on BashVenture.
|
|
|
|
|
#
|
|
|
|
|
# Remember, kids - sharing is caring! Keep it open. Spread the love.
|
|
|
|
|
# - @BenNunney
|
|
|
|
|
# Thanks and gratitude to all living creatures and the whole creation.
|
|
|
|
|
# - @Fred
|
|
|
|
|
# $AGE×365,25×24×60×60×9,807÷299792458 = RELATIVE LIGHT GRAVITY SPEED
|
|
|
|
|
###################################################################
|
|
|
|
|
# Guide avancé d'écriture des scripts Bash : https://abs.traduc.org/abs-fr/
|
|
|
|
|
# GAMESHELL : https://github.com/phyver/GameShell/
|
|
|
|
|
###################################################################
|
|
|
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
|
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|
|
|
|
ME="${0##*/}"
|
|
|
|
|
###################################################################
|
|
|
|
|
### CREER VOTRE PROPRE VERSION DU JEU
|
2024-02-10 13:52:32 +01:00
|
|
|
|
### List games/E@MAIL/ directories
|
2024-02-13 19:55:56 +01:00
|
|
|
|
## ADD PROPOSAL ON THE METHOD
|
|
|
|
|
GAMES_DIR="games"
|
2024-02-07 19:20:08 +01:00
|
|
|
|
GAMES=$(find "$GAMES_DIR" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
|
|
|
|
|
GAMES=$(ls $MY_PATH/games/)
|
2024-02-10 13:52:32 +01:00
|
|
|
|
GAMES=($(ls -d $MY_PATH/games/))
|
|
|
|
|
# Above methods are breaking with games names containing SPACE !
|
2024-02-07 19:20:08 +01:00
|
|
|
|
|
2024-02-13 19:55:56 +01:00
|
|
|
|
# BASH is CREOLE
|
|
|
|
|
# this cd *@* METHOD resist to " " space
|
2024-02-19 14:51:00 +01:00
|
|
|
|
cd ${MY_PATH}/games \
|
2024-02-13 19:55:56 +01:00
|
|
|
|
&& GAMES=(".." *@*) && cd .. \
|
|
|
|
|
|| GAMES=".."
|
|
|
|
|
## but can still be fooled by file...
|
|
|
|
|
|
|
|
|
|
## personalisez le prompt
|
|
|
|
|
PS3="CHOIX DU GAME : __ "
|
2024-02-07 19:20:08 +01:00
|
|
|
|
|
|
|
|
|
select game in "${GAMES[@]}"; do
|
|
|
|
|
|
2024-02-10 13:52:32 +01:00
|
|
|
|
# MY_GAME is the absolute path to selected game files
|
2024-02-07 19:20:08 +01:00
|
|
|
|
MY_GAME="$MY_PATH/games/$game"
|
|
|
|
|
echo "SELECTION: "${MY_GAME}
|
|
|
|
|
|
2024-02-20 19:16:24 +01:00
|
|
|
|
diff --recursive --brief ${MY_GAME}/ ${MY_GAME}/../_votre\ jeu/
|
|
|
|
|
|
|
|
|
|
echo "confirm ?"
|
|
|
|
|
read ENTER
|
|
|
|
|
|
|
|
|
|
if [[ ! $ENTER ]]; then
|
|
|
|
|
# test game start protocol compatibility
|
|
|
|
|
if [[ -x ${MY_GAME}/rooms/start.sh ]]; then
|
|
|
|
|
sleep 1
|
|
|
|
|
echo "Charging game..."
|
|
|
|
|
sleep 1
|
|
|
|
|
break
|
|
|
|
|
else
|
|
|
|
|
# not compatible
|
|
|
|
|
echo "ERROR - not compatible game - SELECT ANOTHER - "
|
|
|
|
|
fi
|
2024-02-07 19:20:08 +01:00
|
|
|
|
else
|
2024-02-20 19:16:24 +01:00
|
|
|
|
echo "CHOOSE NEXT"
|
2024-02-07 19:20:08 +01:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
2024-02-10 13:52:32 +01:00
|
|
|
|
########################################
|
|
|
|
|
# copy game files to user specific executable space
|
|
|
|
|
# $HOME/.zen/adventure/$newplayer
|
|
|
|
|
########################################
|
|
|
|
|
homefolder=$(pwd)
|
|
|
|
|
newplayer=$(head /dev/urandom | tr -dc 'A-Za-z0-9' | head -c 10)
|
|
|
|
|
## Copy Player Game Files
|
|
|
|
|
mkdir -p $HOME/.zen/adventure/$newplayer
|
|
|
|
|
cp -r ${MY_GAME}/rooms $HOME/.zen/adventure/$newplayer/rooms
|
|
|
|
|
cp -r ${MY_GAME}/art $HOME/.zen/adventure/$newplayer/art
|
|
|
|
|
cp -r ${MY_GAME}/script $HOME/.zen/adventure/$newplayer/script
|
|
|
|
|
cp -r ${MY_GAME}/logic $HOME/.zen/adventure/$newplayer/logic
|
|
|
|
|
|
|
|
|
|
|
2024-02-07 19:20:08 +01:00
|
|
|
|
###################################################################
|
2024-02-10 13:52:32 +01:00
|
|
|
|
echo "Loading... $newplayer/rooms/start.sh"
|
2024-02-07 19:20:08 +01:00
|
|
|
|
echo
|
|
|
|
|
sleep 2
|
|
|
|
|
###################################################################
|
2024-02-10 13:52:32 +01:00
|
|
|
|
cd $HOME/.zen/adventure/$newplayer/rooms
|
|
|
|
|
./start.sh
|
|
|
|
|
|
2024-02-07 19:20:08 +01:00
|
|
|
|
###################################################################
|
|
|
|
|
# cleaning game files
|
2024-02-10 13:52:32 +01:00
|
|
|
|
cd "$homefolder"
|
|
|
|
|
rm -r $HOME/.zen/adventure/$newplayer
|
|
|
|
|
|
2024-02-07 19:20:08 +01:00
|
|
|
|
echo "To continue..."
|
|
|
|
|
exit
|