Commit 9db99f20 authored by user472393's avatar user472393
Browse files

clean up message printing

parent bf69f979
#!/bin/bash
name=${0##*/}
version=0.1338296
copyright="Copyright (c) 2020 user387300"
version=0.1356626
copyright="Copyright (c) 2021 user387300"
license_url="https://opensource.org/licenses/MIT"
support_url="https://gitlab.tetrisconcept.tv/user472393/tctv/-/issues"
......@@ -492,25 +492,26 @@ banner () {
# racer
#######
racer () {
printer "<<< the choice is yours @$coinwin (${elo_db[$coinwin]%.*}) >>> $(for i in "${modes[@]}"; do printf '%s\t\t' "$i"; done)"
mlister
printer "<<< the choice is yours @$coinwin (${elo_db[$coinwin]%.*}) >>> $mlist"
sleep 1
mode_select "$coinwin"
tv_updater
g1loser="$loser"
printer "<<< then the choice is yours @$loser (${elo_db[$loser]%.*}) >>> $(for i in "${modes[@]}"; do printf '%s\t' "$i"; done)"
sleep 1
mlister
printer "<<< then the choice is yours @$loser (${elo_db[$loser]%.*}) >>> $mlist"
sleep 1
mode_select "$loser"
tv_updater
sleep 1
if [[ "$g1loser" != "$loser" ]]; then
# cannot repick a mode unless you have lost it
if [[ "${mode_record[0]}" != "${mode_record[1]}" ]]; then
unset -v modes[${mode_record[0]}]
unset -v modes["${mode_record[0]}"]
fi
printer "<<< decide the victor. the choice is yours @$loser (${elo_db[$loser]%.*}) >>> $(for i in "${modes[@]}"; do printf '%s\t' "$i"; done)"
mlister
printer "<<< decide the victor. the choice is yours @$loser (${elo_db[$loser]%.*}) >>> $mlist"
sleep 1
mode_select "$loser"
tv_updater
......@@ -532,23 +533,30 @@ finisher () {
#########
# functs
#########
mlister () {
mlist=$(for i in "${modes[@]}"; do printf '%s\t' "$i"; done)
}
mode_select () {
msg3=">>> @$p1 (${elo_db[$p1]%.*}) vs. @$p2 (${elo_db[$p2]%.*}) in $ask"
msg4=">>> report with !won <<or>> !lost"
msg5=">>> report with $p1 !won <<or>> $p1 !lost"
if [ "$buffer" ]; then
while inotifywait -qq -e modify "$channel"; do
if tail -n 1 "$channel" | grep -i "$1"; then
check=$(tail -n 1 "$channel" | awk '{print $NF}' )
for entry in "${!modes[@]}"; do
if [[ "${modes[entry]}" == "$check" ]]; then
for i in "${!modes[@]}"; do
if [[ "${modes[i]}" == "$check" ]]; then
if (( ${#modes[@]} > 3 )); then
unset -v modes["$entry"]
unset -v modes["$i"]
break 2
else
printer ">>> @$p1 (${elo_db[$p1]%.*}) vs. @$p2 (${elo_db[$p2]%.*}) in $ask ${modes[entry]}" ">>> report with !won <<or>> !lost"
$tv_titler -m "${modes[entry]}"
mode_record+=("$entry")
modes[entry]=">>>${modes[entry]}"
printer "$msg3 ${modes[i]}" "$msg4"
$tv_titler -m "${modes[i]}"
mode_record+=("$i")
modes[i]=">>>${modes[i]}"
tv_updater
modes[entry]="${modes[entry]##*>}"
modes[i]="${modes[i]##*>}"
sleep 2
result_check
break 2
......@@ -559,15 +567,14 @@ mode_select () {
done
else
while read -r check ; do
for entry in "${!modes[@]}"; do
if [[ "${modes[entry]}" == "$check" ]]; then
for i in "${!modes[@]}"; do
if [[ "${modes[i]}" == "$check" ]]; then
if (( ${#modes[@]} > 3 )); then
unset -v modes["$entry"]
unset -v modes["$i"]
break 2
else
printer ">>> @$p1 (${elo_db[$p1]%.*}) vs. @$p2 (${elo_db[$p2]%.*}) in $ask ${modes[entry]}" ">>> report with $p1 !won <<or>> $p1 !lost"
#$tv_titler -m "${modes[entry]}"
mode_record+=("$entry")
printer "$msg3 ${modes[i]}" "$msg5"
mode_record+=("$i")
sleep 2
result_check
break 2
......@@ -583,7 +590,7 @@ result_check () {
while inotifywait -qq -e modify "$channel"; do
if tail -n 1 "$channel" | grep -i "$p1" | grep '!won'; then
elo_case1
results+=("${modes[entry]} (+$p1)")
results+=("${modes[i]} (+$p1)")
comment_string=$(tail -n 1 "$channel")
comment_string=${comment_string,,}
comment_string=${comment_string#*!won}
......@@ -593,7 +600,7 @@ result_check () {
return 1
elif tail -n 1 "$channel" | grep -i "$p1" | grep '!lost'; then
elo_case2
results+=("${modes[entry]} (+$p2)")
results+=("${modes[i]} (+$p2)")
comment_string=$(tail -n 1 "$channel")
comment_string=${comment_string,,}
comment_string=${comment_string#*!lost}
......@@ -603,7 +610,7 @@ result_check () {
return 1
elif tail -n 1 "$channel" | grep -i "$p2" | grep '!won'; then
elo_case2
results+=("${modes[entry]} (+$p2)")
results+=("${modes[i]} (+$p2)")
comment_string=$(tail -n 1 "$channel")
comment_string=${comment_string,,}
comment_string=${comment_string#*!won}
......@@ -613,7 +620,7 @@ result_check () {
return 1
elif tail -n 1 "$channel" | grep -i "$p2" | grep '!lost'; then
elo_case1
results+=("${modes[entry]} (+$p1)")
results+=("${modes[i]} (+$p1)")
comment_string=$(tail -n 1 "$channel")
comment_string=${comment_string,,}
comment_string=${comment_string#*!lost}
......@@ -627,8 +634,8 @@ result_check () {
while read -r result ; do
if [[ "$result" =~ $p1 && "$result" =~ !won ]]; then
elo_case1
results+=("${modes[entry]} (+$p1)")
comment_string=$(tail -n 1 "$channel")
results+=("${modes[i]} (+$p1)")
comment_string=$result
comment_string=${comment_string,,}
comment_string=${comment_string#*!won}
comments+=("$comment_string")
......@@ -637,8 +644,8 @@ result_check () {
return 1
elif [[ "$result" =~ $p1 && "$result" =~ !lost ]]; then
elo_case2
results+=("${modes[entry]} (+$p2)")
comment_string=$(tail -n 1 "$channel")
results+=("${modes[i]} (+$p2)")
comment_string=$result
comment_string=${comment_string,,}
comment_string=${comment_string#*!lost}
comments+=("$comment_string")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment