Last active
March 9, 2018 15:50
-
-
Save leekiernan/f473016123d1568672f209461f1348e8 to your computer and use it in GitHub Desktop.
Botr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
p1 = 910x2065 | |
p2 = 910x1560 | |
p3 = 910x1055 | |
p4 = 910x551 | |
p5 = 910x46 | |
]] | |
CREATETIME="2017-01-27 19:57:16"; | |
adaptResolution(1242, 2208); | |
adaptOrientation(ORIENTATION_TYPE.PORTRAIT); | |
SECOND = 1000000; | |
COLOR_AVAILABLE = 1381653; | |
COLOR_BID = 1645343; | |
COLOR_FACEBOOK = 3889560; | |
-- COLOR_WON = 6406497; | |
COLOR_WON = 6736998; | |
COLOR_SOLD = 13251379; | |
COLOR_LOADING = 16777215; | |
COLOR_CONFIRM = 44708; | |
COLOR_PROMO = 15390084; | |
data = { | |
initial = { 40, 2170 }, | |
facebook = { 650, 1010 }, | |
refresh_button = { 170, 60 }, | |
buy_modal = { 995, 1685 }, | |
buy_button = { 1120, 1685 }, | |
continue_button = { 1120, 1685 }, | |
failed_button = { 885, 1685 }, | |
sidebar_button = { 650, 2194 }, | |
loading_button = { 760, 1104 }, | |
market_button = { 1180, 1975 }, | |
logout_modal = { 299, 1180 }, | |
promo = { 33, 1450 }, | |
p1 = { 911, 2065 }, | |
p2 = { 911, 1561 }, | |
p3 = { 911, 1056 }, | |
p4 = { 911, 552 }, | |
p5 = { 911, 47 } | |
}; | |
function login() | |
touch(data.facebook); | |
usleep(6000000) | |
touch(data.sidebar_button); | |
usleep(2000000); | |
touch(data.market_button); | |
usleep(2000000); | |
end | |
function wait_for_end(location, clr) | |
while color(location) == clr do | |
usleep(50000); | |
end | |
return true; | |
end | |
function wait_for(location, clr) | |
while color(location) ~= clr do | |
usleep(50000); | |
end | |
return false; | |
end | |
function touch(location) | |
touchDown(0, location[1], location[2]); | |
usleep(75000); | |
touchUp(0, location[1], location[2]); | |
usleep(100000); | |
end | |
function available(player) | |
return color(player) == COLOR_AVAILABLE; | |
end | |
function color(position) | |
return getColor(position[1], position[2]); | |
end | |
function buy(player) | |
touch(player); | |
wait_for(data.buy_modal, COLOR_BID); | |
usleep(50000); | |
touch(data.buy_button); | |
while (color(data.continue_button) ~= COLOR_CONFIRM) and (color(data.failed_button) ~= COLOR_CONFIRM) do | |
usleep(50000); | |
end | |
usleep(50000); | |
while color({ 945, 2125 }) ~= COLOR_AVAILABLE do | |
touch(data.failed_button); | |
touch(data.continue_button); | |
usleep(50000); | |
end | |
end | |
if( color(data.logout_modal) == COLOR_PROMO ) then | |
usleep(2000000); | |
touch({ 850, 1180 }); | |
usleep(300000); -- 0.3s | |
wait_for_end(data.loading_button, COLOR_LOADING); | |
usleep(10000000); -- 10s | |
end | |
if( color(data.initial) == COLOR_FACEBOOK ) then | |
usleep(1000000); | |
touch({ 600, 600 }); | |
usleep(1000000); | |
end | |
if( color(data.facebook) == COLOR_FACEBOOK ) then | |
usleep(1000000); | |
login(); | |
usleep(2000000); | |
end | |
if( color(data.promo) == COLOR_PROMO ) then | |
usleep(1000000); | |
touch({ 1120, 1560 }); | |
usleep(1000000); | |
end | |
touch(data.refresh_button); | |
usleep(50000); | |
wait_for_end(data.loading_button, COLOR_LOADING); | |
usleep(50000); | |
bought = 0; | |
attempt = 0; | |
if( available(data.p1) ) then | |
buy(data.p1); | |
wait_for_end(data.continue_button, COLOR_CONFIRM); | |
usleep(50000); | |
attempt = attempt + 1; | |
if( color(data.p1) == COLOR_WON ) then | |
bought = bought + 1; | |
end | |
end | |
if( available(data.p2) ) then | |
buy(data.p2); | |
wait_for_end(data.continue_button, COLOR_CONFIRM); | |
usleep(50000); | |
attempt = attempt + 1; | |
if( color(data.p2) == COLOR_WON ) then | |
bought = bought + 1; | |
end | |
end | |
if( available(data.p3) ) then | |
buy(data.p3); | |
wait_for_end(data.continue_button, COLOR_CONFIRM); | |
usleep(50000); | |
attempt = attempt + 1; | |
if( color(data.p3) == COLOR_WON ) then | |
bought = bought + 1; | |
end | |
end | |
if( available(data.p4) ) then | |
buy(data.p4); | |
wait_for_end(data.continue_button, COLOR_CONFIRM); | |
usleep(50000); | |
attempt = attempt + 1; | |
if( color(data.p4) == COLOR_WON ) then | |
bought = bought + 1; | |
end | |
end | |
if( available(data.p5) ) then | |
buy(data.p5); | |
wait_for_end(data.continue_button, COLOR_CONFIRM); | |
usleep(50000); | |
attempt = attempt + 1; | |
if( color(data.p5) == COLOR_WON ) then | |
bought = bought + 1; | |
end | |
end | |
if( attempt > 0 ) then | |
log(string.format("%d attempts, %d buys", attempt, bought)); | |
end | |
if( bought > 0 ) then | |
local d = os.date("%Y%m%d-%H%M%S"); | |
screenshot(string.format("%s.bmp", d), nil); | |
vibrate(); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment