mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 11:09:25 +08:00
add: global speedup
This commit is contained in:
90
bin/Lua/SpeedUp.lua
Normal file
90
bin/Lua/SpeedUp.lua
Normal file
@@ -0,0 +1,90 @@
|
||||
function Main1()
|
||||
SN = gg.choice({
|
||||
"设置倍速",
|
||||
"还原倍速",
|
||||
"退出",
|
||||
}, nil, "倍速面板")
|
||||
if SN==1 then
|
||||
HS9()
|
||||
end
|
||||
if SN==2 then
|
||||
HS666()
|
||||
end
|
||||
if SN==3 then
|
||||
exit()
|
||||
end
|
||||
FX=false
|
||||
end
|
||||
|
||||
function HS9()
|
||||
x = gg.prompt({"倍速(默认5倍)"},{"5.0"},{number})
|
||||
n = x[1]
|
||||
-- 清除
|
||||
gg.clearResults()
|
||||
gg.setRanges(32)
|
||||
-- 第一次搜索
|
||||
gg.searchNumber("1.0;0.33333334327;0.02999999933::9", gg.TYPE_FLOAT, false, gg.SIGN_EQUAL, 0, -1, 0)
|
||||
gg.refineNumber("1.0", gg.TYPE_AUTO, false, gg.SIGN_EQUAL, 0, -1, 0)
|
||||
results=gg.getResultCount()
|
||||
gg.getResults(100)
|
||||
gg.editAll(n, gg.TYPE_FLOAT)
|
||||
-- 判断
|
||||
if results==0 then
|
||||
-- 清除
|
||||
gg.clearResults()
|
||||
gg.setRanges(32)
|
||||
-- 第二次搜索
|
||||
gg.searchNumber("1.0;0.33333334327;0.02999999933::9", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
|
||||
gg.refineNumber("1.0", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
|
||||
gg.getResults(100)
|
||||
gg.editAll(n, gg.TYPE_DWORD)
|
||||
end
|
||||
-- 清除
|
||||
gg.clearResults()
|
||||
gg.toast("修改成功")
|
||||
end
|
||||
|
||||
function HS666()
|
||||
x = gg.prompt({"还原倍速(默认5倍)"},{"5.0"},{number})
|
||||
n = x[1]
|
||||
-- 清除
|
||||
gg.clearResults()
|
||||
gg.setRanges(32)
|
||||
-- 第一次搜索
|
||||
gg.searchNumber(n..";0.33333334327;0.02999999933::9", gg.TYPE_DOUBLE, false, gg.SIGN_EQUAL, 0, -1, 0)
|
||||
gg.refineNumber(n, gg.TYPE_DOUBLE, false, gg.SIGN_EQUAL, 0, -1, 0)
|
||||
gg.getResults(100)
|
||||
gg.editAll("1", gg.TYPE_DOUBLE)
|
||||
gg.getResultCount(results)
|
||||
-- 判断
|
||||
if results==nil then
|
||||
-- 清除
|
||||
gg.clearResults()
|
||||
gg.setRanges(32)
|
||||
-- 第二次搜索
|
||||
gg.searchNumber(n..";0.33333334327;0.02999999933::9", gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
|
||||
gg.refineNumber(n, gg.TYPE_DWORD, false, gg.SIGN_EQUAL, 0, -1)
|
||||
gg.getResults(100)
|
||||
gg.editAll("1", gg.TYPE_DWORD)
|
||||
end
|
||||
-- 清除
|
||||
gg.clearResults()
|
||||
gg.toast("还原成功")
|
||||
end
|
||||
|
||||
function exit()
|
||||
gg.alert("退出成功")
|
||||
os.exit()
|
||||
end
|
||||
|
||||
-- 循环
|
||||
-- while true do
|
||||
-- if gg.isVisible(true) then
|
||||
-- FX=true
|
||||
-- gg.setVisible(false)
|
||||
-- end
|
||||
gg.clearResults()
|
||||
-- if FX==true then
|
||||
Main1()
|
||||
-- end
|
||||
-- end
|
||||
@@ -2665,6 +2665,12 @@
|
||||
"Raid": 16500,
|
||||
"Ash": 16500
|
||||
},
|
||||
"SpeedUp": {
|
||||
"Enable": false,
|
||||
"PushLua": false,
|
||||
"Timeout": 600,
|
||||
"Rate": 5
|
||||
},
|
||||
"ChangeShip": {
|
||||
"Enable": false,
|
||||
"PushLua": false,
|
||||
@@ -2696,90 +2702,5 @@
|
||||
"Storage": {
|
||||
"Storage": {}
|
||||
}
|
||||
},
|
||||
"Dashboard": {
|
||||
"Oil": {
|
||||
"Value": 0,
|
||||
"Limit": 0,
|
||||
"Color": "^000000",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"Coin": {
|
||||
"Value": 0,
|
||||
"Limit": 0,
|
||||
"Color": "^FFAA33",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"Gem": {
|
||||
"Value": 0,
|
||||
"Color": "^FF3333",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"Pt": {
|
||||
"Value": 0,
|
||||
"Color": "^00BFFF",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"Cube": {
|
||||
"Value": 0,
|
||||
"Color": "^33FFFF",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"ActionPoint": {
|
||||
"Value": 0,
|
||||
"Total": 0,
|
||||
"Color": "^0000FF",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"YellowCoin": {
|
||||
"Value": 0,
|
||||
"Color": "^FF8800",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"PurpleCoin": {
|
||||
"Value": 0,
|
||||
"Color": "^7700BB",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"Core": {
|
||||
"Value": 0,
|
||||
"Color": "^AAAAAA",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"Medal": {
|
||||
"Value": 0,
|
||||
"Color": "^FFDD00",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"Merit": {
|
||||
"Value": 0,
|
||||
"Color": "^FFFF00",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"GuildCoin": {
|
||||
"Value": 0,
|
||||
"Color": "^AAAAAA",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"ResearchPercent": {
|
||||
"Value": 0,
|
||||
"Limit": 100,
|
||||
"Color": "^00AA00",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"PlayerLevel": {
|
||||
"Value": 0,
|
||||
"Color": "^FFAA33",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"PlayerExp": {
|
||||
"Value": 0,
|
||||
"Limit": 0,
|
||||
"Color": "^FFAA33",
|
||||
"Record": "2020-01-01 00:00:00"
|
||||
},
|
||||
"Storage": {
|
||||
"Storage": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13469,6 +13469,24 @@
|
||||
"value": 16500
|
||||
}
|
||||
},
|
||||
"SpeedUp": {
|
||||
"Enable": {
|
||||
"type": "checkbox",
|
||||
"value": false
|
||||
},
|
||||
"PushLua": {
|
||||
"type": "checkbox",
|
||||
"value": false
|
||||
},
|
||||
"Timeout": {
|
||||
"type": "input",
|
||||
"value": 600
|
||||
},
|
||||
"Rate": {
|
||||
"type": "input",
|
||||
"value": 5
|
||||
}
|
||||
},
|
||||
"ChangeShip": {
|
||||
"Enable": {
|
||||
"type": "checkbox",
|
||||
@@ -13568,275 +13586,5 @@
|
||||
"display": "disabled"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Dashboard": {
|
||||
"Oil": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Limit": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^000000",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"Coin": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Limit": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^FFAA33",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"Gem": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^FF3333",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"Pt": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^00BFFF",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"Cube": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^33FFFF",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"ActionPoint": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Total": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^0000FF",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"YellowCoin": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^FF8800",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"PurpleCoin": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^7700BB",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"Core": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^AAAAAA",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"Medal": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^FFDD00",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"Merit": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^FFFF00",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"GuildCoin": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^AAAAAA",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"ResearchPercent": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Limit": {
|
||||
"type": "input",
|
||||
"value": 100
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^00AA00",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"PlayerLevel": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^FFAA33",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"PlayerExp": {
|
||||
"Value": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Limit": {
|
||||
"type": "input",
|
||||
"value": 0
|
||||
},
|
||||
"Color": {
|
||||
"type": "input",
|
||||
"value": "^FFAA33",
|
||||
"display": "hide"
|
||||
},
|
||||
"Record": {
|
||||
"type": "datetime",
|
||||
"value": "2020-01-01 00:00:00",
|
||||
"validate": "datetime"
|
||||
}
|
||||
},
|
||||
"Storage": {
|
||||
"Storage": {
|
||||
"type": "storage",
|
||||
"value": {},
|
||||
"valuetype": "ignore",
|
||||
"display": "disabled"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1093,7 +1093,11 @@ ChangeAttribute:
|
||||
ShipData:
|
||||
type: textarea
|
||||
value: ''
|
||||
|
||||
SpeedUp:
|
||||
Enable: false
|
||||
PushLua: false
|
||||
Timeout: 600
|
||||
Rate: 5
|
||||
InfiniteDelay:
|
||||
Commission:
|
||||
value: false
|
||||
|
||||
@@ -437,6 +437,7 @@ Tool:
|
||||
- GameManager
|
||||
- GGHandler
|
||||
- PowerLimit
|
||||
- SpeedUp
|
||||
- ChangeShip
|
||||
- ChangeAttribute
|
||||
SomethingSpecial:
|
||||
|
||||
@@ -638,6 +638,12 @@ class GeneratedConfig:
|
||||
ChangeAttribute_Timeout = 600
|
||||
ChangeAttribute_ShipData = None
|
||||
|
||||
# Group `SpeedUp`
|
||||
SpeedUp_Enable = False
|
||||
SpeedUp_PushLua = False
|
||||
SpeedUp_Timeout = 600
|
||||
SpeedUp_Rate = 5
|
||||
|
||||
# Group `InfiniteDelay`
|
||||
InfiniteDelay_Commission = False
|
||||
InfiniteDelay_Research = False
|
||||
|
||||
@@ -3667,6 +3667,28 @@
|
||||
"help": "ChangeAttribute.ShipData.help"
|
||||
}
|
||||
},
|
||||
"SpeedUp": {
|
||||
"_info": {
|
||||
"name": "SpeedUp._info.name",
|
||||
"help": "SpeedUp._info.help"
|
||||
},
|
||||
"Enable": {
|
||||
"name": "SpeedUp.Enable.name",
|
||||
"help": "SpeedUp.Enable.help"
|
||||
},
|
||||
"PushLua": {
|
||||
"name": "SpeedUp.PushLua.name",
|
||||
"help": "SpeedUp.PushLua.help"
|
||||
},
|
||||
"Timeout": {
|
||||
"name": "SpeedUp.Timeout.name",
|
||||
"help": "SpeedUp.Timeout.help"
|
||||
},
|
||||
"Rate": {
|
||||
"name": "SpeedUp.Rate.name",
|
||||
"help": "SpeedUp.Rate.help"
|
||||
}
|
||||
},
|
||||
"InfiniteDelay": {
|
||||
"_info": {
|
||||
"name": "InfiniteDelay._info.name",
|
||||
|
||||
@@ -3667,6 +3667,28 @@
|
||||
"help": "ChangeAttribute.ShipData.help"
|
||||
}
|
||||
},
|
||||
"SpeedUp": {
|
||||
"_info": {
|
||||
"name": "SpeedUp._info.name",
|
||||
"help": "SpeedUp._info.help"
|
||||
},
|
||||
"Enable": {
|
||||
"name": "SpeedUp.Enable.name",
|
||||
"help": "SpeedUp.Enable.help"
|
||||
},
|
||||
"PushLua": {
|
||||
"name": "SpeedUp.PushLua.name",
|
||||
"help": "SpeedUp.PushLua.help"
|
||||
},
|
||||
"Timeout": {
|
||||
"name": "SpeedUp.Timeout.name",
|
||||
"help": "SpeedUp.Timeout.help"
|
||||
},
|
||||
"Rate": {
|
||||
"name": "SpeedUp.Rate.name",
|
||||
"help": "SpeedUp.Rate.help"
|
||||
}
|
||||
},
|
||||
"InfiniteDelay": {
|
||||
"_info": {
|
||||
"name": "InfiniteDelay._info.name",
|
||||
|
||||
@@ -3667,6 +3667,28 @@
|
||||
"help": "格式为\"舰船Id;舰船星级;类型Id:属性>目标值[;属性>目标值...]\"\n参考https://github.com/0O0o0oOoO00/SmallKai中的数据"
|
||||
}
|
||||
},
|
||||
"SpeedUp": {
|
||||
"_info": {
|
||||
"name": "全局倍速",
|
||||
"help": "需要和倍率一起使用"
|
||||
},
|
||||
"Enable": {
|
||||
"name": "启用",
|
||||
"help": ""
|
||||
},
|
||||
"PushLua": {
|
||||
"name": "始终推送Lua",
|
||||
"help": "有时推送时会失败,视情况开启或者关闭"
|
||||
},
|
||||
"Timeout": {
|
||||
"name": "时限(秒)",
|
||||
"help": "该项目的时限,该项数值与其他项目之和不得大于gg的"
|
||||
},
|
||||
"Rate": {
|
||||
"name": "速率",
|
||||
"help": ""
|
||||
}
|
||||
},
|
||||
"InfiniteDelay": {
|
||||
"_info": {
|
||||
"name": "无限推迟",
|
||||
|
||||
@@ -3667,6 +3667,28 @@
|
||||
"help": "ChangeAttribute.ShipData.help"
|
||||
}
|
||||
},
|
||||
"SpeedUp": {
|
||||
"_info": {
|
||||
"name": "SpeedUp._info.name",
|
||||
"help": "SpeedUp._info.help"
|
||||
},
|
||||
"Enable": {
|
||||
"name": "SpeedUp.Enable.name",
|
||||
"help": "SpeedUp.Enable.help"
|
||||
},
|
||||
"PushLua": {
|
||||
"name": "SpeedUp.PushLua.name",
|
||||
"help": "SpeedUp.PushLua.help"
|
||||
},
|
||||
"Timeout": {
|
||||
"name": "SpeedUp.Timeout.name",
|
||||
"help": "SpeedUp.Timeout.help"
|
||||
},
|
||||
"Rate": {
|
||||
"name": "SpeedUp.Rate.name",
|
||||
"help": "SpeedUp.Rate.help"
|
||||
}
|
||||
},
|
||||
"InfiniteDelay": {
|
||||
"_info": {
|
||||
"name": "InfiniteDelay._info.name",
|
||||
|
||||
@@ -66,6 +66,7 @@ class GGHandler:
|
||||
self.handle_u2_restart()
|
||||
success = self.change_attribute()
|
||||
success = self.multiplier() and success
|
||||
success = self.speed_up() and success
|
||||
# if not success:
|
||||
# from module.exception import GameStuckError
|
||||
# raise GameStuckError
|
||||
@@ -350,6 +351,18 @@ class GGHandler:
|
||||
# self.gg.set_on('change_attribute')
|
||||
return True
|
||||
|
||||
def speed_up(self):
|
||||
if not deep_get(self.config.data, "GameManager.SpeedUp.Enable"):
|
||||
return False
|
||||
success = timeout(self.gg.set_on,
|
||||
timeout_sec=deep_get(self.config.data, "GameManager.GGHandler.Timeout"),
|
||||
func='speedup',
|
||||
factor=self.factor)
|
||||
self.GGData.set_data(target='gg_on', value=True)
|
||||
|
||||
# success = self.gg.set_on(factor=self.factor)
|
||||
return True
|
||||
|
||||
def multiplier(self):
|
||||
logger.hr('GG Multiplier', level=2)
|
||||
success = timeout(self.gg.set_on,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from module.gg_handler.speedup import SpeedUp
|
||||
from module.logger import logger
|
||||
from module.gg_handler.gg_data import GGData
|
||||
from module.config.config import deep_get
|
||||
@@ -34,7 +35,7 @@ class GGU2(Base):
|
||||
|
||||
def set_on(self, func='multiplier', factor=200):
|
||||
"""
|
||||
func : 'multiplier' or 'change_type' or 'change_attribute'
|
||||
func : 'multiplier' or 'change_type' or 'change_attribute' or 'speedup'
|
||||
factor : factor used in multiplier
|
||||
"""
|
||||
_name_dict = {
|
||||
@@ -160,6 +161,10 @@ class GGU2(Base):
|
||||
# self.d.app_stop(self.gg_package_name)
|
||||
return 1
|
||||
|
||||
def speedup(self):
|
||||
speedup = SpeedUp(self.config, self.device)
|
||||
speedup.Run()
|
||||
|
||||
def multiplier(self):
|
||||
_run = False
|
||||
_set = False
|
||||
|
||||
81
module/gg_handler/speedup.py
Normal file
81
module/gg_handler/speedup.py
Normal file
@@ -0,0 +1,81 @@
|
||||
from module.gg_handler.gg_data import GGData
|
||||
from module.logger import logger
|
||||
from module.config.deep import deep_get, deep_set
|
||||
from module.base.base import ModuleBase
|
||||
import uiautomator2 as u2
|
||||
|
||||
|
||||
class SpeedUp(ModuleBase):
|
||||
|
||||
def __init__(self, config, device):
|
||||
super().__init__(config, device)
|
||||
self.d = u2.connect(self.device.serial)
|
||||
self.gg_package_name = deep_get(self.config.data, keys='GameManager.GGHandler.GGPackageName')
|
||||
|
||||
def Run(self):
|
||||
_run = False
|
||||
_set = False
|
||||
_confirmed = False
|
||||
import os
|
||||
rate = float(deep_get(self.config.data, keys='GameManager.SpeedUp.Rate', default=5.0))
|
||||
_repush = deep_get(self.config.data, keys='GameManager.SpeedUp.PushLua')
|
||||
if _repush:
|
||||
self.device.adb_shell("mkdir /sdcard/Notes")
|
||||
self.device.sleep(0.5)
|
||||
self.device.adb_shell("rm /sdcard/Notes/SpeedUp.lua")
|
||||
self.device.sleep(0.5)
|
||||
self.device.adb_push("bin/Lua/SpeedUp.lua", "/sdcard/Notes/SpeedUp.lua")
|
||||
self.device.sleep(0.5)
|
||||
logger.info('Lua Pushed')
|
||||
while 1:
|
||||
self.device.sleep(1)
|
||||
if self.d(resourceId=f"{self.gg_package_name}:id/search_toolbar").exists:
|
||||
self.d.xpath(
|
||||
f'//*[@resource-id="{self.gg_package_name}'
|
||||
f':id/search_toolbar"]/android.widget.ImageView[last()]'
|
||||
).click()
|
||||
logger.info('Click run Scripts')
|
||||
self.device.sleep(0.3)
|
||||
if self.d(resourceId=f"{self.gg_package_name}:id/file").exists:
|
||||
self.d(resourceId=f"{self.gg_package_name}:id/file").send_keys("/sdcard/Notes/SpeedUp.lua")
|
||||
logger.info('Lua path set')
|
||||
if self.d.xpath('//*[@text="执行"]').exists:
|
||||
self.d.xpath('//*[@text="执行"]').click()
|
||||
logger.info('Click Run')
|
||||
self.device.sleep(0.5)
|
||||
if self.d.xpath('//*[contains(@text,"设置倍速")]').exists:
|
||||
self.d.xpath('//*[contains(@text,"设置倍速")]').click()
|
||||
logger.info('Click Change Statistic')
|
||||
self.device.sleep(0.5)
|
||||
if self.d(resourceId=f"{self.gg_package_name}:id/edit").exists:
|
||||
self.d(resourceId=f"{self.gg_package_name}:id/edit").send_keys(f"{rate}")
|
||||
logger.info(f'Factor Set: {rate}')
|
||||
self.device.sleep(0.5)
|
||||
_set = True
|
||||
if _set and self.d.xpath('//*[@text="确定"]').exists:
|
||||
self.d.xpath('//*[@text="确定"]').click()
|
||||
logger.info("Click confirm")
|
||||
self.device.sleep(0.5)
|
||||
_confirmed = True
|
||||
if _confirmed:
|
||||
self.d.wait_timeout = deep_get(self.config.data, "GameManager.SpeedUp.Timeout")
|
||||
logger.info(f'Xpath timeout set to {self.d.wait_timeout} seconds')
|
||||
|
||||
if _set and _confirmed:
|
||||
try:
|
||||
# GGData(self.config).set_data(target='gg_on', value=True)
|
||||
self.d.xpath('//*[@text="确定"]').click()
|
||||
except Exception as e:
|
||||
pass
|
||||
# GGData(self.config).set_data(target='gg_on', value=True)
|
||||
logger.attr('GG', 'Enabled')
|
||||
logger.info("Close the script")
|
||||
self.d.wait_timeout = 3
|
||||
logger.info(f'Xpath timeout set to {self.d.wait_timeout} seconds')
|
||||
if _set and _confirmed:
|
||||
break
|
||||
else:
|
||||
return 0
|
||||
logger.hr('GG Enabled: SpeedUp', level=2)
|
||||
# self.d.app_stop(self.gg_package_name)
|
||||
return 1
|
||||
Reference in New Issue
Block a user