-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcoliseum.lib
258 lines (190 loc) · 8.15 KB
/
coliseum.lib
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# $HOME/$twm_dir/coliseum.lib
# Copyright (c) 2019-2024 Ueliton Alves Dos Santos
# Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
fShow() {
printf "\n 🙇 "
w3m -dump -T text/html "$mSrcRam"|head -n 18|sed '0,/^\([a-z]\{2\}\)[[:space:]]\([0-9]\{2,5\}\)\([0-9]\{2\}\):\([0-9]\{2\}\)/s//\♥️\2 ⏰\3:\4/;s,\[0\]\ ,\🔴,g;s,\[1\]\ ,\🔵,g;s,\[stone\],\ 💪,;s,\[herb\],\ 🌿,;s,\[grass\],\ 🌿,g;s,\[potio\],\ 💊,;s,\ \[health\]\ ,\ 🧡,;s,\ \[icon\]\ ,\ 🐾,g;s,\[rip\],\ 💀,g'
}
fDredHp() {
case $1 in h)
if ( grep -q "alt='hp'/> <span class='dred'>" $mSrcRam && \
grep -q "nbtn b_green' href='/coliseum/heal" $mSrcRam ); then
exit 0
else
exit 1
fi ;;
d)
if ( ! grep -q -o 'txt smpl grey' $mSrcRam && \
grep -q "nbtn b_green' href='/coliseum/dodge" $mSrcRam && \
! grep -q "$vUserHp" $mSrcRam ); then
exit 0
else
exit 1
fi ;;
r)
if ( ! grep -q -o 'txt smpl grey' $mSrcRam ) && [ "$(echo $(($vUserHp*2)))" -lt "`fRivalHp`" ] || ( ! grep -q -o 'txt smpl grey' $mSrcRam ) && $(case $vAllies in (*`fUserName 2>/dev/null`*) exit 0 ;; (*) exit 1 ;; esac); then
exit 0
else
exit 1
fi ;;
esac
}
coliseum_fight() {
if [ -d "/dev/shm" ]; then
local vDirRam="/dev/shm/"
else
local vDirRam="$TMPDIR"
fi
mkdir -p $vDirRam
local mSrcRam=$(mktemp -p $vDirRam data.XXXXXX)
local mFullRam=$(mktemp -p $vDirRam data.XXXXXX)
local mTmpRam=$(mktemp -d -t twmdir.XXXXXX)
cp -r $TMP/* $mTmpRam
cd $mTmpRam
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "$URL/train" -o user_agent="$vUserAgent"|grep -o -E '\(([0-9]+)\)'|sed 's/[()]//g' >$mFullRam
) </dev/null &>/dev/null &
time_exit 15
printf "\n$(G_T "Coliseum") ...\n"
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug $URL/settings/graphics/0 -o user_agent="$vUserAgent" >$mSrcRam
) </dev/null &>/dev/null &
time_exit 15
printf "/settings/graphics/0\n"
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "$URL/coliseum" -o user_agent="$vUserAgent" >$mSrcRam
) </dev/null &>/dev/null &
time_exit 15
if grep -q -o '?end_fight' $mSrcRam; then
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug "$URL/coliseum/?end_fight=true" -o user_agent="$vUserAgent"|head -n 11|tail -n 7|sed "/\[2hit/d;/\[str/d;/combat/d"
) </dev/null &>/dev/null &
time_exit 15
printf "/coliseum/?end_fight=true\n"
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "$URL/coliseum" -o user_agent="$vUserAgent" >$mSrcRam
) </dev/null &>/dev/null &
time_exit 15
fi
local vAccessLink=$(grep -o -E '/coliseum(/[A-Za-z]+/[?]r[=][0-9]+|/)' $mSrcRam|sed -n '1p')
local vGoStop=$(grep -o -E '/coliseum/enterFight/[?]r[=][0-9]+' $mSrcRam)
if [ -n "$vGoStop" ]; then
printf " 👣 $(G_T "Entering")...\n${vGoStop}\n"
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "${URL}${vGoStop}" -o user_agent="$vUserAgent" >$mSrcRam
) </dev/null &>/dev/null &
time_exit 15
local vAccessLink=$(grep -o -E '/coliseum(/[A-Za-z]+/[?]r[=][0-9]+|/)' $mSrcRam|grep -v 'dodge'|sed -n 1p)
#/wait
printf " 😴 $(G_T "Waiting")...\n"
until grep -q 'coliseum/dodge/' $mSrcRam; do
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "${URL}$vAccessLink" -o user_agent="$vUserAgent" >$mSrcRam
) </dev/null &>/dev/null &
time_exit 15
local vAccessLink=$(grep -o -E '/(coliseum/[A-Za-z]+/[?]r[=][0-9]+|coliseum)' $mSrcRam|grep -v 'dodge'|sed -n 1p)
printf " 💤 ...\n${vAccessLink}\n"
sleep 3s
done
vAllies=`dd if=allies.txt 2>/dev/null`
vBreakLoop=""
vUserHp=$(grep -o -E '(hp)[^A-z0-9]{1,4}[0-9]{1,6}' $mSrcRam|grep -o -E '[0-9]{2,5}'|sed 's,\ ,,g')
fRivalHp() { grep -o -E '(nbsp)[^A-Za-z0-9]{1,2}[0-9]{1,6}' $mSrcRam|sed -n 's,nbsp[;],,;s,\ ,,;1p'; }
fUserName() { grep -o -E '([[:upper:]][[:lower:]]{0,15}( [[:upper:]][[:lower:]]{0,13})?)[[:space:]][^[:alnum:]]s' $mSrcRam|sed -n 's,\ [<]s,,;s,\ ,_,;2p'; }
fAttack() { grep -o -E '/coliseum/atk/[?]r[=][0-9]+' $mSrcRam|sed -n 1p; }
fRndAtk() { grep -o -E '/coliseum/atkrnd/[?]r[=][0-9]+' $mSrcRam; }
fDodge() { grep -o -E '/coliseum/dodge/[?]r[=][0-9]+' $mSrcRam; }
fHeal() { grep -o -E '/coliseum/heal/[?]r[=][0-9]+' $mSrcRam; }
until [ -n "$vBreakLoop" ]; do
case `date +%X` in
*:*:?1|*:*:?2|*:*:?3|*:*:?4|*:*:?6|*:*:?7|*:*:?8|*:*:?9)
#/heal
if `fDredHp h`; then
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "${URL}`fHeal`" -o user_agent="$vUserAgent" >$mSrcRam
) </dev/null &>/dev/null &
time_exit 15
vUserHp=$(grep -o -E '(hp)[^A-z0-9]{1,4}[0-9]{1,6}' $mSrcRam|grep -o -E '[0-9]{2,5}'|sed 's,\ ,,g')
fShow
#/dodge
elif `fDredHp d`; then
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "${URL}`fDodge`" -o user_agent="$vUserAgent" >$mSrcRam
) </dev/null &>/dev/null &
time_exit 15
vUserHp=$(grep -o -E '(hp)[^A-z0-9]{1,4}[0-9]{1,6}' $mSrcRam|grep -o -E '[0-9]{2,5}'|sed 's,\ ,,g')
fShow
#/random
elif `fDredHp r`; then
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "${URL}`fRndAtk`" -o user_agent="$vUserAgent" >$mSrcRam
) </dev/null &>/dev/null &
time_exit 15
vUserHp=$(grep -o -E '(hp)[^A-z0-9]{1,4}[0-9]{1,6}' $mSrcRam|grep -o -E '[0-9]{2,5}'|sed 's,\ ,,g')
fShow
fi ;;
#/attack
*:*:?0|*:*:?5)
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "${URL}`fAttack`" -o user_agent="$vUserAgent" >$mSrcRam
) </dev/null &>/dev/null &
time_exit 15
fShow ;;
esac
if ! grep -q '?out_gate' $mSrcRam; then
fShow|head -n 1
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "${URL}/coliseum" -o user_agent="$vUserAgent" >$mSrcRam
) </dev/null &>/dev/null &
time_exit 15
if ! grep -q '?end_fight' $mSrcRam; then
vBreakLoop=1
printf "${BLACK_YELLOW}$(G_T "Battle is over").${COLOR_RESET}\n" ; sleep 2s
fi
sleep 9s
fi
sleep "0.85"
done
rm $mSrcRam $mFullRam
unset vLastHeal vLastDodge vLastAtk vUserHp fRivalHp fUserName fAttack fRndAtk fDodge fHeal vBreakLoop
#/end
func_unset
if [ "$RUN" != "acl" ]; then
printf "\nYou can run ./twmu -cl\n"
fi
printf "${GREEN_BLACK}$(G_T "Coliseum") (✔)${COLOR_RESET}\n"
else
printf "${WHITEb_BLACK}$(G_T "It was not possible to start the battle at this moment").${COLOR_RESET}\n"
fi
}
coliseum_start() {
if $(case $(date +%H:%M) in
(09:2[4-9]|9:5[4-9]|10:1[0-4]|10:2[4-9]|10:5[4-9]|12:2[4-9]|13:5[4-9]|14:5[4-9]|15:5[4-9]|16:1[0-4]|16:2[4-9]|18:5[4-9]|20:5[4-9]|21:2[4-9]|21:5[4-9]|22:2[4-9])
exit 1 ;;
esac); then
if [ "$RUN" = "aboot" ]; then
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "${URL}/quest/" -o user_agent="$vUserAgent" >$TMP/SRC
) </dev/null &>/dev/null &
time_exit 15
while grep -q -E '/coliseum/[?]quest_t[=]quest&quest_id[=]11&qz[=][a-z0-9]+' $TMP/SRC; do
coliseum_fight
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "${URL}/quest/" -o user_agent="$vUserAgent" >$TMP/SRC
) </dev/null &>/dev/null &
time_exit 15
local vEndquest=$(grep -o -E '/quest/end/11[?]r[=][A_z0-9]+' $TMP/SRC)
if [ ! -z "$vEndquest" ]; then
(
w3m -cookie -o http_proxy=$PROXY -o accept_encoding=UTF-8 -debug -dump_source "${URL}${vEndquest}" -o user_agent="$vUserAgent" >$TMP/SRC
) </dev/null &>/dev/null &
time_exit 15
fi
done
elif [ "$RUN" = "acl" ]; then
coliseum_fight
fi
else
printf "$(G_T "Battle or event time")...\n" && sleep 5s
fi
}