From 46a0d03cc257b4c8b86cb6ab494609db3d4ac7ab Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 24 May 2012 15:16:19 -0600 Subject: [PATCH] firm up p2 console, add new tank --- packages/p2/bin/p2console | 52 +++++++++++++----- packages/tanks/examples/hard/skirts/author | 1 + packages/tanks/examples/hard/skirts/color | 1 + packages/tanks/examples/hard/skirts/name | 1 + packages/tanks/examples/hard/skirts/program | 58 +++++++++++++++++++++ packages/tanks/examples/hard/skirts/sensor0 | 1 + packages/tanks/examples/hard/skirts/sensor1 | 1 + packages/tanks/examples/hard/skirts/sensor2 | 1 + packages/tanks/examples/hard/skirts/sensor3 | 1 + packages/tanks/examples/hard/skirts/sensor4 | 1 + packages/tanks/examples/hard/skirts/sensor5 | 1 + packages/tanks/examples/hard/skirts/sensor6 | 1 + packages/tanks/examples/hard/skirts/sensor7 | 1 + packages/tanks/examples/hard/skirts/sensor8 | 1 + packages/tanks/examples/hard/skirts/sensor9 | 1 + 15 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 packages/tanks/examples/hard/skirts/author create mode 100644 packages/tanks/examples/hard/skirts/color create mode 100644 packages/tanks/examples/hard/skirts/name create mode 100644 packages/tanks/examples/hard/skirts/program create mode 100644 packages/tanks/examples/hard/skirts/sensor0 create mode 100644 packages/tanks/examples/hard/skirts/sensor1 create mode 100644 packages/tanks/examples/hard/skirts/sensor2 create mode 100644 packages/tanks/examples/hard/skirts/sensor3 create mode 100644 packages/tanks/examples/hard/skirts/sensor4 create mode 100644 packages/tanks/examples/hard/skirts/sensor5 create mode 100644 packages/tanks/examples/hard/skirts/sensor6 create mode 100644 packages/tanks/examples/hard/skirts/sensor7 create mode 100644 packages/tanks/examples/hard/skirts/sensor8 create mode 100644 packages/tanks/examples/hard/skirts/sensor9 diff --git a/packages/p2/bin/p2console b/packages/p2/bin/p2console index f87e9de..4247a15 100755 --- a/packages/p2/bin/p2console +++ b/packages/p2/bin/p2console @@ -10,6 +10,10 @@ fi clear read nonce < $BASE/nonce +esc () { + printf '%s' "$*" | sed 's/[^-0-9A-Za-z ]/_/g; s/ /+/g' +} + newteam () { echo '== Team Creation ==' echo @@ -32,9 +36,18 @@ newteam () { printf '%s' "$name" > $BASE/$hash/.name - echo "Your team hash is $hash. Write that down somewhere and don't lose it." - echo "If you forget your hash, you'll have to start over from the beginning" - echo "with a new team and everybody will laugh at you." + cat < ' - read -r answer - ahash=$(printf '%s' "$answer" | md5sum | cut -d' ' -f1) + done fi +read -r name < $BASE/$hash/.name +echo "Welcome $name" echo -echo "Press [Enter] to clear the screen." -read -exit 0 +echo "Enter answer and I'll tell you if it's right or if you're a dummy." +echo -n '> ' +read -r answer +match=$(awk -v ans="$answer" '(substr($0, length($1)+2) == ans) { print substr(FILENAME, 6, length(FILENAME)-17) " " $1; }' /opt/*/answers.txt) +cat=${match% *} +points=${match#* } +fn=$BASE/$hash/$cat.$points +if [ -f $fn ]; then + echo "You've already received points for this answer." +else + printf "%s %s\n" $cat $points > $fn + echo "You get $points more points in the $cat category." + # run puzzles.cgi + # update scoreboard + echo "Check the puzzles overview for newly-unlocked content!" +fi + +done diff --git a/packages/tanks/examples/hard/skirts/author b/packages/tanks/examples/hard/skirts/author new file mode 100644 index 0000000..902019d --- /dev/null +++ b/packages/tanks/examples/hard/skirts/author @@ -0,0 +1 @@ +Neale Pickett diff --git a/packages/tanks/examples/hard/skirts/color b/packages/tanks/examples/hard/skirts/color new file mode 100644 index 0000000..10dbfa4 --- /dev/null +++ b/packages/tanks/examples/hard/skirts/color @@ -0,0 +1 @@ +#d0d054 \ No newline at end of file diff --git a/packages/tanks/examples/hard/skirts/name b/packages/tanks/examples/hard/skirts/name new file mode 100644 index 0000000..4a4b9e0 --- /dev/null +++ b/packages/tanks/examples/hard/skirts/name @@ -0,0 +1 @@ +skirts \ No newline at end of file diff --git a/packages/tanks/examples/hard/skirts/program b/packages/tanks/examples/hard/skirts/program new file mode 100644 index 0000000..7fa896f --- /dev/null +++ b/packages/tanks/examples/hard/skirts/program @@ -0,0 +1,58 @@ +15 14 set-speed! + +( Front ) +5 sensor? { + get-turret 45 + 90 < { 15 15 } { 2 2 } ifelse set-speed! + 0 set-turret! +} if + +( Rear ) +6 sensor? { + get-turret 45 + 90 < { 2 2 } { -15 -15 } ifelse set-speed! + 180 set-turret! +} if +7 sensor? { + 90 set-turret! + 5 -5 set-speed! +} if +8 sensor? { + -90 set-turret! + -5 5 set-speed! +} if + +1 sensor? { + get-turret 10 + set-turret! +} if + +2 sensor? { + get-turret 10 - set-turret! +} if + +3 sensor? { + get-turret 20 + set-turret! +} if + +4 sensor? { + get-turret 20 - set-turret! +} if + +0 sensor? { + 0 0 set-speed! + get-turret set-turret! + fire! +} if + +fire-ready? ! { + 70 60 10 random + + get-turret 90 + 180 > { exch } if + set-speed! +} if + +9 sensor? { + 5 sensor? { + -100 -100 + } { + 100 100 + } ifelse + set-speed! +} if \ No newline at end of file diff --git a/packages/tanks/examples/hard/skirts/sensor0 b/packages/tanks/examples/hard/skirts/sensor0 new file mode 100644 index 0000000..a6ab06f --- /dev/null +++ b/packages/tanks/examples/hard/skirts/sensor0 @@ -0,0 +1 @@ +50 0 7 1 diff --git a/packages/tanks/examples/hard/skirts/sensor1 b/packages/tanks/examples/hard/skirts/sensor1 new file mode 100644 index 0000000..d9fa05d --- /dev/null +++ b/packages/tanks/examples/hard/skirts/sensor1 @@ -0,0 +1 @@ +60 10 12 1 diff --git a/packages/tanks/examples/hard/skirts/sensor2 b/packages/tanks/examples/hard/skirts/sensor2 new file mode 100644 index 0000000..bee5d05 --- /dev/null +++ b/packages/tanks/examples/hard/skirts/sensor2 @@ -0,0 +1 @@ +60 -10 12 1 diff --git a/packages/tanks/examples/hard/skirts/sensor3 b/packages/tanks/examples/hard/skirts/sensor3 new file mode 100644 index 0000000..0be47b9 --- /dev/null +++ b/packages/tanks/examples/hard/skirts/sensor3 @@ -0,0 +1 @@ +90 30 40 1 diff --git a/packages/tanks/examples/hard/skirts/sensor4 b/packages/tanks/examples/hard/skirts/sensor4 new file mode 100644 index 0000000..e7609b1 --- /dev/null +++ b/packages/tanks/examples/hard/skirts/sensor4 @@ -0,0 +1 @@ +90 -30 40 1 diff --git a/packages/tanks/examples/hard/skirts/sensor5 b/packages/tanks/examples/hard/skirts/sensor5 new file mode 100644 index 0000000..26b41ae --- /dev/null +++ b/packages/tanks/examples/hard/skirts/sensor5 @@ -0,0 +1 @@ +60 0 90 0 diff --git a/packages/tanks/examples/hard/skirts/sensor6 b/packages/tanks/examples/hard/skirts/sensor6 new file mode 100644 index 0000000..b69dc3a --- /dev/null +++ b/packages/tanks/examples/hard/skirts/sensor6 @@ -0,0 +1 @@ +60 180 90 0 diff --git a/packages/tanks/examples/hard/skirts/sensor7 b/packages/tanks/examples/hard/skirts/sensor7 new file mode 100644 index 0000000..db4c883 --- /dev/null +++ b/packages/tanks/examples/hard/skirts/sensor7 @@ -0,0 +1 @@ +80 90 90 0 diff --git a/packages/tanks/examples/hard/skirts/sensor8 b/packages/tanks/examples/hard/skirts/sensor8 new file mode 100644 index 0000000..ddfc64e --- /dev/null +++ b/packages/tanks/examples/hard/skirts/sensor8 @@ -0,0 +1 @@ +80 270 90 0 diff --git a/packages/tanks/examples/hard/skirts/sensor9 b/packages/tanks/examples/hard/skirts/sensor9 new file mode 100644 index 0000000..9c9b4e8 --- /dev/null +++ b/packages/tanks/examples/hard/skirts/sensor9 @@ -0,0 +1 @@ +30 180 345 0