#!/bin/sh
# Copyright (c) 2004 Jilles Tjoelker
# No warranty!

sucker=''
while getopts t opt; do
	case "$opt" in
	t) sucker=1 ;; # tourist/shirt visible or dunce cap
		# the two combined aren't treated
	*) echo "Usage: $0 [-t]" >&2; exit 64 ;;
	esac
done

printf '%-7.7s ' 'base' '   <6' '  6-7' ' 8-10' ' 11-15' ' 16-17' '   18' \
	'  >19' 'selling'
printf 'scredit'
echo
printf '%3.3s' ''
printf '%4.4s' '' '.' 'sur' '.' 'sur' '.' 'sur' '.' 'sur' \
	'.' 'sur' '.' 'sur' '.' 'sur' '.' 'sub' '.' 'sub'
echo

for price in 2 5 8 20 30 50 60 80 100 150 175 200 250 300 400 500 600 700; do
	# buying prices (depending on charisma)
	if [ -n "$sucker" ]; then
		p=$(($price*4/3))
	else
		p=$price
	fi
	q=$(($p*4/3))
	printf '%3.3s' $price
	printf '%4.4s' '' $(($p*2)) $(($q*2)) $(($p*3/2)) $(($q*3/2)) \
		$(($p*4/3)) $(($q*4/3)) $(($p)) $(($q)) \
		$(($p-$p/4)) $(($q-$q/4)) $(($p-$p/3)) $(($q-$q/3)) \
		$(($p/2)) $(($q/2))
	# selling prices
	if [ -n "$sucker" ]; then
		p=$(($price/3))
	else
		p=$(($price/2))
	fi
	if [ $p -gt 1 ]; then
		q=$(($p-$p/4))
	else
		q=$p
	fi
	printf '%4.4s' $(($p)) $(($q)) \
		$(($p*9/10+($p<=1))) $(($q*9/10+($q<=1)))
	echo
done
