#!/bin/bash name=karldermittelmaessige nextsave=16 while read command a1 a2 a3; do case $command in HELO) echo "AUTH $name Ich bin bereit!" ;; TURN) echo "Spielstand ${a1}:${a2}" >&2 if (($a1 >= $nextsave));; then echo "SAVE Das reicht erstmal ..." if (($nextsave >= 30)); then nextsave=50 else let nextsave=(50+$a1)/2 fi active=0 else echo "ROLL Auf gut Glück!" active=1 fi ;; THRW) if [ "$active" = "1" ]; then echo "Ich würfle eine $a1." >&2 if [ "$a1" = "6" ]; then echo "Du bist dran!" >&2 active=0 fi else echo "Du würfelst eine $a1." >&2 if [ "$a1" = "6" ]; then echo "Ich bin dran!" >&2 active=1 fi fi ;; WIN|DEF) echo "Spielende: $command" >&2 exit 0 ;; *) echo "Unbekannt: $command" >&2 ;; esac done