Skip to content

Instantly share code, notes, and snippets.

@jpjones76
Last active February 6, 2023 16:18
Show Gist options
  • Save jpjones76/e0dd09c1ff6865e6b8717323ee8bcd54 to your computer and use it in GitHub Desktop.
Save jpjones76/e0dd09c1ff6865e6b8717323ee8bcd54 to your computer and use it in GitHub Desktop.
For a more immersive Zork experience...
#!/bin/bash
# INSTRUCTIONS
# (0) Save this file as zork.sh
# (1) Change SRCDIR, ZILF, and DOTNET for your system
# (2) Add to path with "source ./zork.sh"
# (3) Now you can have the true Zork experience while installing it! Try it!
#
# get zilf
# build zilf
# get zork
# build zork
# play zork
#
# Only works in Ubuntu Linux, because trying is hard
export SRCDIR='/data2/Code/src'
export ZILF='zilf-0.9.0-linux-x64'
export DOTNET='/usr/bin/dotnet'
export ZORK='zork1'
export ZORKDIR=${SRCDIR}/${ZORK}
get() {
if [[ $@ == "zilf" ]]; then
if [[ -d ${SRCDIR}/${ZILF} ]]; then
echo "Nothing to do; zilf installed."
else
cd ${SRCDIR}
wget https://bitbucket.org/jmcgrew/zilf/downloads/${ZILF}.tar.gz
tar -zxvf ./${ZILF}.tar.gz
export ZILFHOME=${SRCDIR}/${ZILF}/bin
PATH=$PATH:${ZILFHOME}
fi
elif [[ $@ == "zork" ]]; then
if [[ -d ${ZORKDIR} ]]; then
echo "Nothing to do; zork installed."
else
cd ${SRCDIR}
git clone https://github.com/historicalsource/${ZORK}
fi
else
command get "$@"
fi
}
build() {
if [[ $@ == "zork" ]]; then
export ZILFSRC=${SRCDIR}/zilf/bin/Release/netcoreapp2.2/linux-x64/publish/
if [[ -d ${ZILFSRC} ]]; then
export ZILFHOME=${ZILFSRC}
else
export ZILFHOME=${SRCDIR}/${ZILF}/bin
fi
PATH=$PATH:${ZILFHOME}
cd ${ZORKDIR}
zilf zork1.zil
zapf zork1.zap
elif [[ $@ == "zilf" ]]; then
cd ${SRCDIR}
# dotnet-sdk-2.2
if [[ ! -f ${DOTNET} ]]; then
echo "Installing dotnet-sdk-2.2..."
# I'm not sure this is a good idea; works in Ubuntu 18.04
if [[ ! -e packages-microsoft-prod.deb ]]; then
export VUBUNTU=`lsb_release -r | cut -d ':' -f 2 | sed -e 's/^[[:space:]]*//'`
wget -q https://packages.microsoft.com/config/ubuntu/${VUBUNTU}/packages-microsoft-prod.deb
fi
sudo dpkg -i packages-microsoft-prod.deb
sudo apt install --assume-yes apt-transport-https
sudo apt update
sudo apt install --assume-yes dotnet-sdk-2.2
fi
if [[ ! -d ${SRCDIR}/zilf ]]; then
# mercurial
if [[ ! -x "$(command -v hg)" ]]; then
sudo apt install --assume-yes mercurial
fi
# zilf
hg clone https://bitbucket.org/jmcgrew/zilf/
fi
cd zilf
# build
for i in Zilf Zapf; do dotnet publish src/$i --self-contained -c Release -r linux-x64; done
else
command build "$@"
fi
}
play() {
if [[ $@ == "zork" ]]; then
if [[ ! -x "$(command -v frotz)" ]]; then
sudo apt install --assume-yes frotz
fi
cd ${ZORKDIR}
if [[ -e zork1.z3 ]]; then
frotz zork1.z3
else
cd COMPILED
frotz zork1.z3
fi
else
command play "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment