120 lines
2.9 KiB
Bash
120 lines
2.9 KiB
Bash
#!/bin/bash
|
|
|
|
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
|
|
# Copyright (C) 2014-2015 Vincent Riquer
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
medals() {
|
|
local \
|
|
stat \
|
|
|
|
if [[ -f .innovator ]]
|
|
then
|
|
innovator=$(<.innovator)
|
|
else
|
|
innovator=0
|
|
fi
|
|
if (( innovator >= 1 ))
|
|
then
|
|
(( bronzecount++ ))
|
|
bronzes+=( innovator )
|
|
else
|
|
nosilver["Innovator"]=1
|
|
fi
|
|
if (( innovator >= 2 ))
|
|
then
|
|
(( silvercount++ ))
|
|
silvers+=( innovator )
|
|
else
|
|
nobronze["Innovator"]=1
|
|
fi
|
|
if (( innovator >= 3 ))
|
|
then
|
|
(( goldcount++ ))
|
|
golds+=( innovator )
|
|
else
|
|
nogold["Innovator"]=1
|
|
fi
|
|
if (( innovator >= 4 ))
|
|
then
|
|
(( platinumcount++ ))
|
|
platinums+=( innovator )
|
|
else
|
|
noplatinum["Innovator"]=1
|
|
fi
|
|
if (( innovator == 5 ))
|
|
then
|
|
(( blackcount++ ))
|
|
blacks+=( innovator )
|
|
else
|
|
noblack["Innovator"]=1
|
|
fi
|
|
for stat in "${medals[@]}"
|
|
do
|
|
if (( last["$stat"] >= bronze["$stat"] ))
|
|
then
|
|
(( bronzecount++ ))
|
|
bronzes+=( "$stat" )
|
|
hasbronze["$stat"]=1
|
|
else
|
|
(( upbronze["$stat"]=last["$stat"] * 100 / bronze["$stat"]))
|
|
fi
|
|
if (( last["$stat"] >= silver["$stat"] ))
|
|
then
|
|
(( silvercount++ ))
|
|
silvers+=( "$stat" )
|
|
hassilver["$stat"]=1
|
|
elif (( last["$stat"] >= bronze["$stat"] ))
|
|
then
|
|
(( upsilver["$stat"]=( last["$stat"] - bronze["$stat"] ) * 100 / ( silver["$stat"] - bronze["$stat"] ) ))
|
|
else
|
|
nosilver["$stat"]=1
|
|
fi
|
|
if (( last["$stat"] >= gold["$stat"] ))
|
|
then
|
|
(( goldcount++ ))
|
|
golds+=( "$stat" )
|
|
hasgold["$stat"]=1
|
|
elif (( last["$stat"] >= silver["$stat"] ))
|
|
then
|
|
(( upgold["$stat"]=( last["$stat"] - silver["$stat"] ) * 100 / ( gold["$stat"] - silver["$stat"] ) ))
|
|
else
|
|
nogold["$stat"]=1
|
|
fi
|
|
if (( last["$stat"] >= platinum["$stat"] ))
|
|
then
|
|
(( platinumcount++ ))
|
|
platinums+=( "$stat" )
|
|
hasplatinum["$stat"]=1
|
|
elif (( last["$stat"] >= gold["$stat"] ))
|
|
then
|
|
(( upplatinum["$stat"]=( last["$stat"] - gold["$stat"] ) * 100 / ( platinum["$stat"] - gold["$stat"] ) ))
|
|
else
|
|
noplatinum["$stat"]=1
|
|
fi
|
|
if (( last["$stat"] >= black["$stat"] ))
|
|
then
|
|
(( blackcount++ ))
|
|
blacks+=( "$stat" )
|
|
hasblack["$stat"]=1
|
|
elif (( last["$stat"] >= platinum["$stat"] ))
|
|
then
|
|
(( upblack["$stat"]=( last["$stat"] - platinum["$stat"]) * 100 / ( black["$stat"] - platinum["$stat"] ) ))
|
|
else
|
|
noblack["$stat"]=1
|
|
fi
|
|
done
|
|
}
|