Skip to content
Snippets Groups Projects
Commit 9829e406 authored by kimon-satan's avatar kimon-satan Committed by Simon Katan
Browse files

The Red Desert

parent e8503ab7
Branches journey
No related merge requests found
#!/bin/bash
checksums=( "11194" "25841" )
words=("body" "conflict")
command="python"
function loadPython {
curl -s -o baseutils.py http://igor.gold.ac.uk/~skata001/underland/pt2/baseutils > /dev/null
curl -s -o levelCodes http://igor.gold.ac.uk/~skata001/underland/pt2/levelCodes > /dev/null
if hash python 2>/dev/null; then
echo "python found">/dev/null
else
var="#!/usr/bin/python2"
sed -i '1s|.*|'$var'|' baseutils.py
command="python2"
fi
chmod 777 baseutils.py
}
function checkScript {
filename=$1
loadPython
mark=$($command baseutils.py $filename "mark")
username=$($command baseutils.py $filename "getusername")
#echo $mark
}
function checkWord {
isMemoryValid=false
isPrevMemoryValid=false
local crc="00000"
old_IFS=$IFS
IFS=$'\n'
lines=($(cat memories.txt)) # array
IFS=$old_IFS
for p in "${lines[@]}"; do
crc=$($command baseutils.py "x" "addcrc" ${p:0:4} $crc)
#echo $p
#echo $crc
done
#echo $crc
local prevIndex=$(( $1 - 1 ))
if [ "$crc" = "${checksums[$1]}" ] ; then
isMemoryValid=true
local level=$((203 + $1))
$command baseutils.py $filename "score" $level ${words[$1]}
elif [ "$crc" = "${checksums[$prevIndex]}" ]; then
isPrevMemoryValid=true
fi
rm baseutils.py
rm levelCodes
}
function pause {
local count=0
while [ $count -lt $1 ]; do
echo ...
sleep 2
let count=count+1
let count=count+1
done
}
clear
echo "Hi"
pause 1
echo "I'm on a journey"
function speech1 {
clear
echo "Hi"
pause 1
echo "I see that you have come from my future."
pause 1
echo "I am on long and strange journey"
pause 1
echo "use 'git log --oneline -5' and you can see the many strange places I have been"
pause 1
echo "Add these places to my memories"
pause 1
echo "commit the changes and then RUNME again."
}
function speech2 {
clear
echo "During my journey something strange has happened to me."
pause 1
echo "Something caused my conciousness to become detatched from my brain."
pause 1
echo "You are talking to my conciousness but my brain is somewhere out there too."
pause 1
echo "Use 'git log --all --oneline --graph --decorate' to see the branch where they parted ways."
pause 1
echo "I need you to merge them back together, but this will be tricky"
pause 1
echo "First make a local branch here using 'git branch' ... don't forget to add a name for it"
pause 1
echo "now checkout the remote branch called myBrain"
pause 1
echo "once you are there make another local branch in the same way"
pause 1
echo "finally merge the two branches together with 'git merge' ."
pause 1
echo "There will undoubtedly be conflicts between my conciousness and my brain."
pause 1
echo "Fix these by editing memories.txt so that all of the memories are included but nothing else"
pause 1
echo "Commit the changes and them RUNME again"
}
function speech3 {
clear
echo "Thankyou I can finally stop this travelling"
pause 1
echo "Use 'git log --all --oneline --graph --decorate' to see what you have done for me."
pause 1
echo "My conciousness and brain are now rejoined."
pause 1
echo "The final stage is to bring all of these changes to the present."
pause 1
echo "You will need to merge this branch with master."
pause 1
echo "And you will need to edit memories.txt for conflicts"
pause 1
echo "But you are an expert time traveller now so I don't think you need help from me."
pause 1
echo "Just one bit of advice ..."
pause 1
echo "Don't forget to commit your changes here first. "
pause 1
}
function badMemory {
clear
echo "It looks like something is wrong in your memories"
pause 1
echo "Perhaps you tried to take a short cut ?"
pause 1
echo "Remember that there are no short cuts in underland"
pause 1
echo "Remove any extra memories that you just added and try again"
}
filename=$1
if [ ${#filename} = 0 ] ;then
pause 1
echo "To run me you must pass a valid path to your score file as an argument."
pause 1
echo "For example ~/Desktop/aiw_skata001"
pause 1
echo "Have another go".
exit
elif [ ! -f $filename ] ;then
pause 1
echo "The scorefile cannot be found in that location"
pause 1
echo "Have another go".
exit
else
checkScript $1
if [ $mark -eq 8 ]; then
checkWord 0
if [ "$isMemoryValid" = true ]; then
speech2
else
speech1
fi
elif [ $mark -eq 10 ]; then
checkWord 1
if [ "$isMemoryValid" = true ]; then
speech3
else
speech2
fi
else
badMemory
rm baseutils.py
rm levelCodes
fi
fi
brrr ...
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment