Skip to content

Commit

Permalink
some scripts added
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf Mueller committed Jul 24, 2024
1 parent 639fd99 commit 1e55920
Show file tree
Hide file tree
Showing 9 changed files with 719 additions and 0 deletions.
55 changes: 55 additions & 0 deletions shell/attack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

if [ $# -ne 1 ]; then
echo give pipe arg
exit 1
fi

export PIPE="$1"

source poke-lib.sh

fight()
{
# while sleep 0.01
# while ! check_color 285 182 5 5 5 5 1
# while ! check_color 176 624 253 253 243 10 1
while sleep 0.1
do
click 245 890
click 145 890

click 164 821 1

for (( x = 50; x < 450 ; x += 100 ))
do
# check_color 285 182 5 5 5 5 || return
for (( y = 370; y < 777; y += 130 ))
do
sleep 0.15
click $x $y
done
click 260 821 1
sleep 0.15
click 230 871 1

done

done
}

# back_home
# Menu
# go_battle

fight

exit 0


click 350 742
sleep 3
click 350 742
sleep 3
wait_color_fail 317 137 70 207 181 10
sleep 3
69 changes: 69 additions & 0 deletions shell/battle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

if [ $# -ne 1 ]; then
echo give pipe arg
exit 1
fi

export PIPE="$1"

source poke-lib.sh

claim_reward()
{
echo claim reward
click 123 976
exit 0
}

scroll_up()
{
s=$1
y=$(( 120 + $1 ))
button_down 50 $y
for (( y ; y >= 120; y -= 3))
do
echo $y
motion 50 $y
sleep 0.05
done
sleep 1
button_up 50 $y
}

next_battle()
{
echo Next battle
while ! check_color 200 950 150 215 155 20
do
scroll_up 15
done
sleep 1
click 206 950
sleep 1
click 185 641
sleep 1
click 292 894
sleep 5
fight

}


# scroll_up 100
# exit 0
back_home
Menu
go_battle
# sleep 1
# click 162 408 1
# sleep 3
# fight

while true
do
check_color 123 976 254 179 79 5 && claim_reward

next_battle

done
22 changes: 22 additions & 0 deletions shell/delete-with-conf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

if [ $# -ne 1 ]; then
echo give pipe arg
exit 1
fi

export PIPE="$1"

source poke-lib.sh


click 82 322
sleep 1.5
click 401 913
sleep 1.5
click 347 820
sleep 1
click 176 563
sleep 1
click 255 535

27 changes: 27 additions & 0 deletions shell/notes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# start A71 master
./run x --window-title="gift-send" -s R58M67HLZPY -m 1024 --max-fps=4

# start s7 gold
./run x --window-title="gift-send" -s ce0117119076d82a0c -m 1024 --max-fps=4 --no-audio-playback --turn-screen-off

# Schlumpiz
./run x --window-title="schlumpiz" -s ce091609f2237a1904 -m 1024 --max-fps=4 --no-audio-playback --turn-screen-off

export PIPE="/tmp/schlumpiz" ; c=0 ; while sleep 1; do c=$(( c = c +1 )) ; echo gift $c; bash send-gifts.sh ; done

# pokeralle
./run x --window-title="poke" -s ce091719d290250304 -m 1024 --max-fps=4 --no-audio-playback --turn-screen-off

export PIPE="/tmp/poke" ; c=0 ; while sleep 1; do c=$(( c = c +1 )) ; echo gift $c; bash send-gifts.sh ; done


# aphex
./run x --window-title="aphex" -s R58M93ND7BF -m 1024 --max-fps=4 --no-audio-playback --turn-screen-off

./attack.sh /tmp/aphex

# faker
./run x --window-title="faker" -s R58MB2R1RSK -m 1024 --max-fps=4 --no-audio-playback --turn-screen-off
./attack.sh /tmp/faker

export PIPE="/tmp/poke" ; c=0 ; while sleep 1; do c=$(( c = c +1 )) ; echo gift $c; bash send-gifts.sh ; done
45 changes: 45 additions & 0 deletions shell/play.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

if [ $# -ne 1 ]; then
echo give pipe arg
exit 1
fi

export PIPE="$1"

source poke-lib.sh

fight()
{
# while sleep 0.01
# while ! check_color 285 182 5 5 5 5 1
while ! check_color 176 624 253 253 243 10 1
do

for (( x = 226; x < 240 ; x += 25 ))
do
# check_color 285 182 5 5 5 5 || return
for (( y = 530; y < 700; y += 30 ))
do
click $x $y
done
done

done
}

# back_home
# Menu
# go_battle

fight

exit 0


click 350 742
sleep 3
click 350 742
sleep 3
wait_color_fail 317 137 70 207 181 10
sleep 3
158 changes: 158 additions & 0 deletions shell/poke-lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
click()
{
echo click:$1,$2,1,30 >$PIPE
echo click:$1,$2,1,30
sleep 0.04
}

motion()
{
echo motion:$1,$2 >$PIPE
echo motion:$1,$2
}

button_up()
{
echo button_up:$1,$2,1,50 >$PIPE
}

button_down()
{
echo button_down:$1,$2,1,50 >$PIPE
}

start_trade()
{
click 494,849 >$PIPE
}

get_friend()

{
click 59 931 1
sleep 0.5
click 475 236 1
}


get_rgb()
{

if [ $# -lt 2 ] ; then
echo get_rgb needs x y
echo "Got count $# '$@'"
exit 1
fi
printf "color:$1,$2\n" >$PIPE
sleep 0.75
values="$(tail -n 1 ${PIPE}.sh | sed "s/.*color://")"
rgb=($(echo $values |cut -d ',' -f 3) $(echo $values |cut -d ',' -f 4) $(echo $values |cut -d ',' -f 5))
echo RGB ${rgb[@]}
}

check_color()
{
max=3
if [[ $# -ne 6 && $# -ne 7 ]] ; then
echo check_color needs x y r g b threshold
echo "Got count $# '$@'"
return 1
fi
x=$1; y=$2
r=$3; g=$4 ; b=$5
t=$6
[ $# -eq 7 ] && max=$7

echo "check color : ${@}"
for (( i = 0; i < $max; i++ )); do
echo "RGB round $i"
get_rgb $x $y
if [[ \
${rgb[0]} -lt $(( r + t )) && ${rgb[1]} -lt $(( g + t )) && ${rgb[2]} -lt $(( b + t )) && \
${rgb[0]} -gt $(( r - t )) && ${rgb[1]} -gt $(( g - t )) && ${rgb[2]} -gt $(( b - t ))
]]
then
echo "Color match"
return 0
fi
done
echo "Color miss"
return 1
}

wait_color()
{
while ! check_color $1 $2 $3 $4 $5 $6
do
echo Waiting for RGB $3 $4 $5 thres $6
sleep 0.5
done
}

wait_color_fail()
{
while check_color $1 $2 $3 $4 $5 $6
do
echo Waiting for RGB $3 $4 $5 thres $6
sleep 0.5
done
}

click_ok()
{
click 237 898 1
}

# click 237 898 1
go_battle()
{
click 285 945
sleep 1
click 458 547 1
sleep 1
}

fight()
{
# while sleep 0.01
while ! check_color 285 182 0 0 0 5
do
click 245 890
click 145 890

click 164 821 1

for (( x = 50; x < 450 ; x += 130 ))
do
check_color 285 182 0 0 0 5 || return
for (( y = 520; y < 777; y += 130 ))
do
click $x $y
done
click 164 821 1
done
done
}

back_home()
{
echo "Back home"
sleep 1
# get_rgb 285 916
# while [[ ${rgb[0]} -lt 255 && ${rgb[1]} -gt 100 && ${rgb[2]} -gt 100 ]]
while ! check_color 285 916 245 55 72 20 1
do
echo Not home color ${rgb[@]}
sleep 1
get_rgb 285 916
click 285 945
if check_color 285 916 254 55 72 10
then
echo Send home screen step bak
# click 275 945
fi
# get_rgb 285 916
echo Not home color ${rgb[@]}
done
}

Loading

0 comments on commit 1e55920

Please sign in to comment.