feat: find mushrooms
also some debug options
This commit is contained in:
parent
a8116f42ea
commit
e5d6d00834
123
game.sh
123
game.sh
@ -9,7 +9,10 @@
|
|||||||
# print status: wheels
|
# print status: wheels
|
||||||
# generate a map of where we have been
|
# generate a map of where we have been
|
||||||
|
|
||||||
playintro=0
|
# debug options
|
||||||
|
enablestory=0
|
||||||
|
enablebattery=1
|
||||||
|
enablehazards=1
|
||||||
|
|
||||||
# $1 message
|
# $1 message
|
||||||
echowait () {
|
echowait () {
|
||||||
@ -18,6 +21,8 @@ echowait () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
intro () {
|
intro () {
|
||||||
|
[ $enablestory -eq 1 ] || return
|
||||||
|
|
||||||
echowait "CRASH!!!"
|
echowait "CRASH!!!"
|
||||||
echowait "ah!!"
|
echowait "ah!!"
|
||||||
echowait "..."
|
echowait "..."
|
||||||
@ -27,21 +32,45 @@ intro () {
|
|||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
[ $playintro -eq 1 ] && intro
|
meetsplork () {
|
||||||
|
[ $enablestory -eq 1 ] || return
|
||||||
|
|
||||||
|
echowait "...waht?"
|
||||||
|
echowait "i was down in the tunnel and my batteries died..."
|
||||||
|
echowait "how did i get back?"
|
||||||
|
echo
|
||||||
|
# we need to make this visually distinct so it's not confusing...
|
||||||
|
echowait "i can help with that!"
|
||||||
|
echo
|
||||||
|
echowait "AHHHHHHH"
|
||||||
|
echo
|
||||||
|
echowait "whoa there! its ok!"
|
||||||
|
echowait "i saw ya down there in the depths and figured"
|
||||||
|
echowait "you's prolly what made this here light-hole."
|
||||||
|
echowait "figured you came from up there so maybe you's a light-thing!"
|
||||||
|
echo
|
||||||
|
echowait "you're a... you're a..."
|
||||||
|
echo
|
||||||
|
echowait "brave n mighty rescuer, yup. that's me. name's splork, nice to meet ya!"
|
||||||
|
echo
|
||||||
|
echowait "..."
|
||||||
|
}
|
||||||
|
|
||||||
maxbattery=10
|
maxbattery=10
|
||||||
|
|
||||||
depletebattery () {
|
depletebattery () {
|
||||||
|
[ $enablebattery -eq 1 ] || return
|
||||||
battery=$((battery-1))
|
battery=$((battery-1))
|
||||||
}
|
}
|
||||||
|
|
||||||
# position id
|
# position id
|
||||||
# start roughly in the middle
|
# start roughly in the middle
|
||||||
# vertical movement +/- battery
|
# vertical movement +/- battery*2
|
||||||
# horizontal movement +/- 1
|
# horizontal movement +/- 1
|
||||||
# this setup allows for different "cells" of different values which can be hashed for fun and profit
|
# this setup allows for different "cells" of different values which can be hashed for fun and profit
|
||||||
# without actually needing to do any 2d math or *shudder* collision detection
|
# without actually needing to do any 2d math or *shudder* collision detection
|
||||||
# making the number of columns equal to double the battery means that we can never reach the edge of the map
|
# making the number of columns equal to double the battery means that we can never reach the edge of the map
|
||||||
|
# battery is doubled to allow us to move at most battery units in any direction
|
||||||
posid=200 # (2*maxbattery)^2/2
|
posid=200 # (2*maxbattery)^2/2
|
||||||
|
|
||||||
# $1 direction
|
# $1 direction
|
||||||
@ -68,14 +97,14 @@ move () {
|
|||||||
checkhazard
|
checkhazard
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: generate a map
|
|
||||||
# TODO: put hazards on the map
|
|
||||||
# 80 random cells out of ~400 (calculated from maxbattery^2)
|
# 80 random cells out of ~400 (calculated from maxbattery^2)
|
||||||
hazards=($(shuf -i 0-400 -n 120))
|
hazards=($(shuf -i 0-400 -n 120))
|
||||||
#echo "${hazards[@]}"
|
#echo "${hazards[@]}"
|
||||||
# split the hazard cells proportionally into sand traps and hard rocks
|
# split the hazard cells proportionally into sand traps and hard rocks
|
||||||
|
|
||||||
checkhazard () {
|
checkhazard () {
|
||||||
|
[ $enablehazards -eq 1 ] && return
|
||||||
|
|
||||||
# are we in a hazard cell?
|
# are we in a hazard cell?
|
||||||
for hazard in "${hazards[@]}"; do
|
for hazard in "${hazards[@]}"; do
|
||||||
[ $posid -ne $hazard ] && continue
|
[ $posid -ne $hazard ] && continue
|
||||||
@ -90,23 +119,54 @@ checkhazard () {
|
|||||||
|
|
||||||
# is there something to find upon examination?
|
# is there something to find upon examination?
|
||||||
mushrooms=($(shuf -i 0-400 -n 200))
|
mushrooms=($(shuf -i 0-400 -n 200))
|
||||||
|
foundmushrooms=() # list of positions we found mushrooms at during a run
|
||||||
|
|
||||||
# inentory should be persistent between runs
|
# inentory should be persistent between runs
|
||||||
inventory=0
|
inventory=0
|
||||||
|
|
||||||
examine () {
|
|
||||||
# are we in a hazard cell?
|
|
||||||
for mushroom in "${hazards[@]}"; do
|
|
||||||
[ $posid -ne $mushroom ] && continue
|
|
||||||
|
|
||||||
echowait "there's something growing here! found a mushroom, yay!!!"
|
|
||||||
|
|
||||||
inventory=$((inventory+1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# lightning mushrooms
|
# lightning mushrooms
|
||||||
# round mushrooms
|
# round mushrooms
|
||||||
|
checkmushroom () {
|
||||||
|
for floormushroom in "${mushrooms[@]}"
|
||||||
|
do
|
||||||
|
[ $posid -ne $floormushroom ] && continue
|
||||||
|
|
||||||
|
# don't find the same mushroom twice
|
||||||
|
for foundmushroom in "${foundmushrooms[@]}"
|
||||||
|
do
|
||||||
|
[ $posid -eq $foundmushroom ] && return 0
|
||||||
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
done
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
examine () {
|
||||||
|
depletebattery
|
||||||
|
|
||||||
|
checkmushroom
|
||||||
|
local result=$?
|
||||||
|
if [ $result -eq 1 ]
|
||||||
|
then
|
||||||
|
echowait "there's something growing here! found a mushroom, yay!!!"
|
||||||
|
|
||||||
|
# TODO: make it so we can't pick up the same mushroom twice
|
||||||
|
|
||||||
|
inventory=$((inventory+1))
|
||||||
|
foundmushrooms+=($posid)
|
||||||
|
else
|
||||||
|
echowait "didn't find anything :("
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
endrun () {
|
||||||
|
echowait "my battery is low and it's getting dark ;-;"
|
||||||
|
|
||||||
|
# reset run-specific memory
|
||||||
|
foundmushrooms=()
|
||||||
|
}
|
||||||
|
|
||||||
run=0
|
run=0
|
||||||
while [ 1 ]
|
while [ 1 ]
|
||||||
@ -114,30 +174,7 @@ do
|
|||||||
run=$((run+1))
|
run=$((run+1))
|
||||||
echo "day $run"
|
echo "day $run"
|
||||||
echo "...awake and fully charged!"
|
echo "...awake and fully charged!"
|
||||||
|
[ $run -eq 2 ] && meetsplork
|
||||||
if [ $run -eq 2 ]
|
|
||||||
then
|
|
||||||
echowait "...waht?"
|
|
||||||
echowait "i was down in the tunnel and my batteries died..."
|
|
||||||
echowait "how did i get back?"
|
|
||||||
echo
|
|
||||||
# we need to make this visually distinct so it's not confusing...
|
|
||||||
echowait "i can help with that!"
|
|
||||||
echo
|
|
||||||
echowait "AHHHHHHH"
|
|
||||||
echo
|
|
||||||
echowait "whoa there! its ok!"
|
|
||||||
echowait "i saw ya down there in the depths and figured"
|
|
||||||
echowait "you's prolly what made this here light-hole."
|
|
||||||
echowait "figured you came from up there so maybe you's a light-thing!"
|
|
||||||
echo
|
|
||||||
echowait "you're a... you're a..."
|
|
||||||
echo
|
|
||||||
echowait "brave n mighty rescuer, yup. that's me. name's splork, nice to meet ya!"
|
|
||||||
echo
|
|
||||||
echowait "..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# we have access to the shop after the first run.
|
# we have access to the shop after the first run.
|
||||||
if [ $run -gt 1 ]
|
if [ $run -gt 1 ]
|
||||||
@ -173,14 +210,12 @@ do
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
"examine")
|
"examine")
|
||||||
echowait "you look around and see many interesting things!"
|
examine
|
||||||
depletebattery
|
|
||||||
;;
|
;;
|
||||||
"move")
|
"move")
|
||||||
move $(gum choose "north" "east" "south" "west")
|
move $(gum choose "north" "east" "south" "west")
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
echowait "my battery is low and it's getting dark ;-;"
|
endrun
|
||||||
|
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user