kickHour = 5
kickMin=0
local ts = require("ts")
local StringHelper = {}
--[[
utf-8编码规则
单字节 - 0起头
1字节 0xxxxxxx 0 - 127
多字节 - 第一个字节n个1加1个0起头
2 字节 110xxxxx 192 - 223
3 字节 1110xxxx 224 - 239
4 字节 11110xxx 240 - 247
可能有1-4个字节
--]]
function StringHelper.GetBytes(char)
if not char then
return 0
end
local code = string.byte(char)
if code < 127 then
return 1
elseif code <= 223 then
return 2
elseif code <= 239 then
return 3
elseif code <= 247 then
return 4
else
-- 讲道理不会走到这里^_^
return 0
end
end
function StringHelper.Sub(str, startIndex, endIndex)
local tempStr = str
local byteStart = 1 -- string.sub截取的开始位置
local byteEnd = -1 -- string.sub截取的结束位置
local index = 0 -- 字符记数
local bytes = 0 -- 字符的字节记数
startIndex = math.max(startIndex, 1)
endIndex = endIndex or -1
while string.len(tempStr) > 0 do
if index == startIndex - 1 then
byteStart = bytes+1;
elseif index == endIndex then
byteEnd = bytes;
break;
end
bytes = bytes + StringHelper.GetBytes(tempStr)
tempStr = string.sub(str, bytes+1)
index = index + 1
end
return string.sub(str, byteStart, byteEnd)
end
personlist = {"一箭一个蛋蛋","浪子不回头","亘陌","夏陌","依日哆","猪汪汪"}
function kick(index,offLine)
offsetX = 0
offsetY = 0
if(offLine ~= nil) then
offsetX = 150
offsetY = -65
end
if index == 1 then
touchDown(175,152)
mSleep(20)
touchMove(175,152)
mSleep(102)
touchMove(175,152)
mSleep(10)
touchUp(175,152)
mSleep(3000)
touchDown(305+offsetX,386+offsetY)
mSleep(8)
touchMove(305+offsetX,386+offsetY)
mSleep(23)
touchMove(305+offsetX,386+offsetY)
mSleep(107)
touchMove(305+offsetX,386+offsetY)
mSleep(43)
touchMove(305+offsetX,386+offsetY)
mSleep(5)
touchUp(305+offsetX,386+offsetY)
mSleep(1854)
touchDown(780,350)
mSleep(31)
touchMove(780,350)
mSleep(97)
touchMove(780,350)
mSleep(9)
touchUp(780,350)
end
if index == 2 then
touchDown(366,144)
mSleep(15)
touchMove(366,144)
mSleep(45)
touchMove(366,144)
mSleep(46)
touchMove(366,144)
mSleep(7)
touchUp(366,144)
mSleep(2049)
touchDown(463+offsetX,397+offsetY)
mSleep(28)
touchMove(463+offsetX,397+offsetY)
mSleep(38)
touchMove(463+offsetX,397+offsetY)
mSleep(48)
touchMove(463+offsetX,397+offsetY)
mSleep(7)
touchUp(463+offsetX,397+offsetY)
mSleep(1808)
touchDown(781,344)
mSleep(0)
touchMove(781,344)
mSleep(54)
touchMove(781,344)
mSleep(24)
touchMove(781,344)
mSleep(6)
touchUp(781,344)
end
if index == 3 then
touchDown(551,161)
mSleep(12)
touchMove(551,161)
mSleep(66)
touchMove(551,161)
mSleep(16)
touchUp(551,161)
mSleep(1675)
touchDown(711+offsetX,389+offsetY)
mSleep(69)
touchMove(711+offsetX,389+offsetY)
mSleep(11)
touchUp(711+offsetX,389+offsetY)
mSleep(1867)
touchDown(770,341)
mSleep(13)
touchMove(770,341)
mSleep(109)
touchMove(770,341)
mSleep(3)
touchUp(770,341)
end
if index == 4 then
touchDown(726,166)
mSleep(36)
touchMove(726,166)
mSleep(23)
touchMove(726,166)
mSleep(34)
touchUp(726,166)
mSleep(1991)
touchDown(878+offsetX,378+offsetY)
mSleep(7)
touchMove(878+offsetX,378+offsetY)
mSleep(85)
touchMove(878+offsetX,378+offsetY)
mSleep(5)
touchUp(878+offsetX,378+offsetY)
mSleep(1571)
touchDown(773,348)
mSleep(2)
touchMove(773,348)
mSleep(66)
touchMove(773,348)
mSleep(22)
touchUp(773,348)
end
if index == 5 then
touchDown(917,154)
mSleep(27)
touchMove(917,154)
mSleep(38)
touchMove(917,154)
mSleep(30)
touchUp(917,154)
mSleep(2020)
touchDown(1040+offsetX,388+offsetY)
mSleep(50)
touchMove(1040+offsetX,388+offsetY)
mSleep(25)
touchMove(1040+offsetX,388+offsetY)
mSleep(26)
touchUp(1040+offsetX,388+offsetY)
mSleep(1687)
touchDown(782,351)
mSleep(29)
touchMove(782,351)
mSleep(43)
touchMove(782,351)
mSleep(9)
touchUp(782,351)
end
if index == 6 then
touchDown(1102,139)
mSleep(0)
touchMove(1102,139)
mSleep(83)
touchMove(1102,139)
mSleep(0)
touchUp(1102,139)
mSleep(2051)
touchDown(1028+offsetX,376+offsetY)
mSleep(32)
touchMove(1028+offsetX,376+offsetY)
mSleep(47)
touchMove(1028+offsetX,376+offsetY)
mSleep(16)
touchUp(1028+offsetX,376+offsetY)
mSleep(1631)
touchDown(778,349)
mSleep(25)
touchMove(778,349)
mSleep(43)
touchMove(778,349)
mSleep(35)
touchUp(778,349)
end
end
function isOffline(index)
x,y,xx,yy = 99, 545, 266, 572
x1,y1,xx1,yy1 = 280,545,447,572
x2,y2,xx2,yy2 = 461,545,628,572
x3,y3,xx3,yy3 = 642,545,809,572
x4,y4,xx4,yy4 = 823,545,990,572
x5,y5,xx5,yy5 = 1004,545,1171,572
temp = ""
if index == 1 then
temp = ocrText(x,y,xx,yy,1)
end
if index==2 then
temp = ocrText(x1,y1,xx1,yy1,1)
end
if index==3 then
temp = ocrText(x2,y2,xx2,yy2,1)
end
if index==4 then
temp = ocrText(x3,y3,xx3,yy3,1)
end
if index==5 then
temp = ocrText(x4,y4,xx4,yy4,1)
end
if index==6 then
temp = ocrText(x5,y5,xx5,yy5,1)
end
temp = temp:trim()
return string.find(temp,"离线")
end
function parsePeople(index)
x,y,xx,yy = 99, 487, 266, 518
x1,y1,xx1,yy1 = 280,487,447,518
x2,y2,xx2,yy2 = 461,487,628,518
x3,y3,xx3,yy3 = 642,487,809,518
x4,y4,xx4,yy4 = 823,487,990,518
x5,y5,xx5,yy5 = 1004,487,1171,518
temp = ""
if index == 1 then
temp = ocrText(x,y,xx,yy,1)
end
if index==2 then
temp = ocrText(x1,y1,xx1,yy1,1)
end
if index==3 then
temp = ocrText(x2,y2,xx2,yy2,1)
end
if index==4 then
temp = ocrText(x3,y3,xx3,yy3,1)
end
if index==5 then
temp = ocrText(x4,y4,xx4,yy4,1)
end
if index==6 then
temp = ocrText(x5,y5,xx5,yy5,1)
end
temp = temp:trim()
--dialog(temp)
dstIndex =0
i=1
while personlist[i] do
j=1
kkk=0
--dialog(utf8.len(temp))
--dialog(StringHelper.Sub(temp,1,1))
while j<=utf8.len(temp) do
hh = StringHelper.Sub(temp,j,j)
--dialog(hh)
if string.find(personlist[i],hh)~=nil then
kkk = kkk+1
end
j=j+1
end
if kkk/utf8.len(personlist[i])>0.57 then
dstIndex=i
break
end
i=i+1
end
if dstIndex > 0 then
return personlist[dstIndex]
else
return nil
end
end
function checkAndKickPeople()
result =parsePeople(1)
if result == nil then
kick(1,nil)
mSleep(10000)
if(checkIfFull()) then
kick(1,isOffline(1))
end
end
result =parsePeople(2)
if result == nil then
kick(2,nil)
mSleep(10000)
if(checkIfFull()) then
kick(2,isOffline(2))
end
end
result =parsePeople(3)
if result == nil then
kick(3,nil)
mSleep(10000)
if(checkIfFull()) then
kick(3,isOffline(3))
end
end
result =parsePeople(4)
if result == nil then
kick(4,nil)
mSleep(10000)
if(checkIfFull()) then
kick(4,isOffline(4))
end
end
result =parsePeople(5)
if result == nil then
kick(5,nil)
mSleep(10000)
if(checkIfFull()) then
kick(5,isOffline(5))
end
end
result =parsePeople(6)
if result == nil then
kick(6,nil)
mSleep(10000)
if(checkIfFull()) then
kick(6,isOffline(6))
end
end
end
--rgb转hsv,返回h,s,v三个值
function rgb2hsv(r,g,b)
-- 找出r,g,b最小值和最大值
local min = math.min(r,g,b)
local max = math.max(r,g,b)
local diff = max - min
local h,s,v = 0,0,0
v = max
if max == 0 then
s = 0
else
s = diff
end
if diff ~= 0 then
if r == max then
h = 60 * (g - b) / diff
elseif g == max then
h = 60 * (b - r) / diff + 120
else
h = 60 * (r - g) / diff + 240
end
if h < 0 then
h = h + 360
end
else
h = -1
end
local tmp = math.modf(h)
return tmp,s,v
end
function sureTap(x,y)
touchDown(x,y)
mSleep(0)
touchMove(x,y)
mSleep(83)
touchMove(x,y)
mSleep(0)
touchUp(x,y)
end
function checkAndCloseMap()
--先检查有没有出卡
r1,g1,b1 = getColorRGB(707,636)
h1,s1,v1 = rgb2hsv(r1,g1,b1)
while h1>210 and s1>100 and v1>160 do
sureTap(707,636)
r1,g1,b1 = getColorRGB(707,636)
h1,s1,v1 = rgb2hsv(r1,g1,b1)
end
end
function checkIfFull()
r,g,b = getColorRGB(1155,523)
h,s,v = rgb2hsv(r,g,b)
--toast(string.format("h=%d s=%d v=%d",h,s,v))
if v<50 then
return true
end
return false
end
function openParty()
r,g,b = getColorRGB(257,642)
h,s,v = rgb2hsv(r,g,b)
if not(h<15 and s>180 and v>190) then
sureTap(884,69)
mSleep(5000)
else
sureTap(687,626)
mSleep(1000)
end
end
function getNowTime()
time = os.time()
hh = os.date("%H",time)
mm = os.date("%M",time)
hh = tonumber(hh)
mm = tonumber(mm)
return hh,mm
end
function whoShouldInCar(item)
nowtime = os.time()
currentHour = os.date("%H",nowtime)
currentMin = os.date("%M",nowtime)
currentHour = tonumber(currentHour)
currentMin = tonumber(currentMin)
index =1
while item[index] do
hour,min,name = parseItem(item[index])
if hour == currentHour and min > currentMin then
break
end
if hour>currentHour then
break
end
index = index +1
end
if index==1 then
return nil
end
hour,min,name = parseItem(item[index-1])
return name
end
function parseItem(str)
str = str:trim()
local temp = str:split(" ")
local time = temp[1]
local name = temp[2]
--dialog(time, 0)
local hour = string.sub(time,0,2)
hour = string.match(hour, "%d+")
ll = utf8.len(time)
local min = string.sub(time,ll-2,ll)
min = string.match(min, "%d+")
return tonumber(hour),tonumber(min),name
end
init(1)
path =userPath()
path = path.."/lua/jyctable.lua"
file,msg = io.open(path)
expTable=file:read("*a")
file:close()
time = os.time()
currentDate = os.date("%Y年%m月%d日",time)
num1 =string.find(expTable,currentDate)
num2,startnum = string.find(expTable,"里面就有",num1)
endnum = string.find(expTable,"拜拜收车",num1)
data = string.sub(expTable,startnum+2,endnum-2)
--dialog(data)
tableToday = data:split("\n")
--h,m,n = parseItem(tableToday[17])
--dialog(n)
oldPeople = whoShouldInCar(tableToday)
while 1 do
openParty()
currentHour,currentMin = getNowTime()
if currentHour == kickHour and currentMin == kickMin then
checkAndCloseMap()
if checkIfFull() then
checkAndKickPeople()
end
lua_restart()
end
newPeople = whoShouldInCar(tableToday)
if newPeople ~= nil then
if oldPeople ~= newPeople then
if checkIfFull() then
checkAndKickPeople()
end
oldPeople = newPeople
end
end
mSleep(10000)
end
486系统
最新推荐文章于 2023-05-31 09:47:37 发布