moth

Monarch Of The Hill game server
git clone https://git.woozle.org/neale/moth.git

moth / cmd / mothd / testdata
Neale Pickett  ·  2020-10-16

testpiler.sh

 1#! /bin/sh -e
 2
 3fail () {
 4    echo "$@" 1>&2
 5    exit 1
 6}
 7
 8case "$ACTION:$CAT:$POINTS" in
 9    inventory::)
10        cat <<EOT
11{
12    "pategory": [1, 2, 3, 4, 5, 10, 20, 300],
13    "nealegory": [1, 3, 2]
14}
15EOT
16        ;;
17    open:*:*)
18        case "$CAT:$POINTS:$FILENAME" in
19            *:*:moo.txt)
20                echo "Moo."
21                ;;
22            *)
23                fail "Cannot open: $FILENAME"
24                ;;
25        esac
26        ;;
27    answer:pategory:1)
28        if [ "$ANSWER" = "answer" ]; then
29            echo '{"Correct":true}'
30        else
31            echo '{"Correct":false}'
32        fi
33        ;;
34    answer:pategory:2)
35        fail "Internal error"
36        ;;
37    *)
38        fail "ERROR: Unknown action: $action"
39        ;;
40esac