-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrate.sh
executable file
·86 lines (76 loc) · 2.14 KB
/
rate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh
# rate.sh [-e evolved_species] [-c max_candy] [-x max_xl_candy] species.team
#
# Used to help decide which pokemon to keep go pvp.
#
# Reads stats from file species.team and creates species.team.great
# and species.team.ultra. Then use "best [-a] species.team.great" or
# "best [-a] species.team.*" to sort by stat product or attack and
# decide which pokemon to keep.
# Default is to rate for all three leagues.
great=t
ultra=t
master=t
little=
while getopts ":e:c:x:lgum" opt; do
case ${opt} in
e)
evolved_species="$OPTARG"
evolved="-e $evolved_species"
;;
c)
max_candy="-c $OPTARG"
;;
x)
max_xl_candy="-x $OPTARG"
;;
g)
great=t; ultra=; master=; little=
;;
u)
great=; ultra=t; master=; little=
;;
m)
great=; ultra=; master=t; little=
;;
l)
great=; ultra=; master=; little=t
;;
\?)
echo "Usage: $0 [-e evolved_species] [-c max_candy] [-x max_xl_candy] [-g] [-u] [-m]"
exit 2
;;
esac
done
shift $((OPTIND-1))
dir=${1%/*} # Remove filename, keep directory.
file=${1##*/} # Remove directory, keep filename.
species=${file%.*} # Remove team, keep species from species.team.
team=${file#*.} # Remove species, keep team from species.team.
if [[ "$evolved_species" == "" ]]; then
if [[ "$little" ]]; then
evolved_species="$species"
else
evolved_species=$(./evolvecp $species | tail -n 1 | sed "s/:.*//")
fi
fi
rate() {
league="$1"
while read stats; do
# If the line is a comment then ignore it.
if [[ "$stats" != \#* ]]; then
# If the stats line starts with a letter then it already includes
# the species, else prepend the species.
if [[ "$stats" != [a-z]* ]]; then
stats="$species $stats"
fi
echo $stats >&2
./bulk -s $max_candy $max_xl_candy $evolved $league $stats
fi
done | egrep -v "too high"
}
out=$dir/$evolved_species.$team
[ "$great" ] && rate -g <$1 >$out.great
[ "$ultra" ] && rate -u <$1 >$out.ultra
[ "$master" ] && rate -m <$1 >$out.master
[ "$little" ] && rate --little <$1 >$out.little