161 lines
4.7 KiB
Bash
Executable File
161 lines
4.7 KiB
Bash
Executable File
#!/usr/bin/env -S bash
|
|
#
|
|
hheellpp="echo -e \\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Usage: melvorcalc [food|pot|prod] | [--help]"
|
|
noremind="echo -e \\033[38;5;255m[ \\033[38;5;82mOK \\033[38;5;255m] \\033[38;5;248m No reminder set."
|
|
yeremind="echo -e \\033[38;5;255m[ \\033[38;5;82mOK \\033[38;5;255m] \\033[38;5;248m Reminder set."
|
|
askremnd="echo -e \\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Would you like to set a reminder? (y/n)"
|
|
okaaaaay="echo -e \\033[38;5;255m[ \\033[38;5;82mOK \\033[38;5;255m] \\033[38;5;248m"
|
|
#
|
|
if [ -z $1 ] || [ $1 == --help ] || [ $# -ne 1 ]
|
|
then
|
|
$hheellpp
|
|
exit 1
|
|
elif [ $1 == food ]
|
|
then
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Food Time Calculation"
|
|
echo Amount of Food:
|
|
read amount
|
|
echo Used per Minute:
|
|
read used
|
|
min=$(echo "scale=0; $amount/$used" | bc)
|
|
if [ $min -gt 600 ]
|
|
then
|
|
hour=$(echo "scale=0; $min/60" | bc)
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Food lasts for: ~$hour hours"
|
|
exit 0
|
|
else
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Food lasts for: ~$min minutes"
|
|
$askremnd
|
|
read remind
|
|
if [ $remind = y ]
|
|
then
|
|
$yeremind
|
|
exit 0
|
|
else
|
|
$noremind
|
|
exit 0
|
|
fi
|
|
fi
|
|
elif [ $1 == pool ]
|
|
then
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m XP Pool Calculation"
|
|
echo "Pool needed:"
|
|
read pool
|
|
echo "XP per Cycle:"
|
|
read xp
|
|
echo "Seconds per Cycle:"
|
|
read time
|
|
min=$(echo "scale=0; $pool/$xp*$time/60" | bc)
|
|
if [ $min -gt 600 ]
|
|
then
|
|
hour=$(echo "scale=0; $min/60" | bc)
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Pool full in: ~$hour hours"
|
|
exit 0
|
|
else
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Pool full in: ~$min minutes"
|
|
$askremnd
|
|
read remind
|
|
if [ $remind = y ]
|
|
then
|
|
echo "dunstify --raw_icon=/home/xbl/.icons/melvor.png 'Melvor Idle' 'Pool is filling up.'; beep -f 5000 -r 7 -l 250" | at now + $min minutes
|
|
$yeremind
|
|
exit 0
|
|
else
|
|
$noremind
|
|
exit 0
|
|
fi
|
|
fi
|
|
elif [ $1 == pool295 ]
|
|
then
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Pool95% Calculation"
|
|
echo "Pool size:"
|
|
read size
|
|
echo "XP per Cycle:"
|
|
read xp
|
|
echo "Seconds per Cycle:"
|
|
read time
|
|
95p=$(( $size*95/100 ))
|
|
min=$(echo "scale=0; $pool/$xp*$time/60" | bc)
|
|
if [ $min -gt 600 ]
|
|
then
|
|
hour=$(echo "scale=0; $min/60" | bc)
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Pool full in: ~$hour hours"
|
|
exit 0
|
|
else
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Pool full in: ~$min minutes"
|
|
$askremnd
|
|
read remind
|
|
if [ $remind = y ]
|
|
then
|
|
echo "dunstify --raw_icon=/home/xbl/.icons/melvor.png 'Melvor Idle' 'Pool is filling up.'; beep -f 5000 -r 7 -l 250" | at now + $min minutes
|
|
$yeremind
|
|
exit 0
|
|
else
|
|
$noremind
|
|
exit 0
|
|
fi
|
|
fi
|
|
elif [ $1 == pot ]
|
|
then
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Potion Time Calculation"
|
|
echo "Potions:"
|
|
read potion
|
|
echo "Charges per Potion:"
|
|
read charge
|
|
echo "Seconds per Cycle:"
|
|
read time
|
|
min=$(echo "scale=0; $potion*$charge*1.05*$time/60" | bc)
|
|
if [ $min -gt 600 ]
|
|
then
|
|
hour=$(echo "scale=0; $min/60" | bc)
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Potion lasts for: ~$hour hours"
|
|
exit 0
|
|
else
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Potion lasts for: ~$min minutes"
|
|
$askremnd
|
|
read remind
|
|
if [ $remind = y ]
|
|
then
|
|
echo "dunstify --raw_icon=/home/xbl/.icons/melvor.png 'Melvor Idle' 'Potion running out.'; beep -f 5000 -r 7 -l 250" | at now + $min minutes
|
|
$yeremind
|
|
exit 0
|
|
else
|
|
$noremind
|
|
exit 0
|
|
fi
|
|
fi
|
|
elif [ $1 == prod ]
|
|
then
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Production Time Calculation"
|
|
echo "Cycles:"
|
|
read cycles
|
|
echo "Seconds per Cycle:"
|
|
read time
|
|
echo "Dupe/Preserve:"
|
|
read dp
|
|
min=$(echo "scale=0; $cycles*1.$dp*$time/60" | bc)
|
|
if [ $min -gt 600 ]
|
|
then
|
|
hour=$(echo "scale=0; $min/60" | bc)
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Production lasts for: ~$hour hours"
|
|
exit 0
|
|
else
|
|
echo -e "\\033[38;5;255m[ \\033[38;5;6mNOTICE \\033[38;5;255m] \\033[38;5;248m Production Time: ~$min minutes"
|
|
$askremnd
|
|
read remind
|
|
if [ $remind = y ]
|
|
then
|
|
echo "dunstify --raw_icon=/home/xbl/.icons/melvor.png 'Melvor Idle' 'Production finishing.'; beep -f 5000 -r 7 -l 250" | at now + $min minutes
|
|
$yeremind
|
|
exit 0
|
|
else
|
|
$noremind
|
|
exit 0
|
|
fi
|
|
fi
|
|
else
|
|
$hheellpp
|
|
exit 2
|
|
fi
|
|
# EOF
|