mirror of
https://github.com/0O0o0oOoO00/Alas.git
synced 2026-05-14 14:29:26 +08:00
Add: change ship's attribute
This commit is contained in:
72
bin/Lua/ShipFucker.lua
Normal file
72
bin/Lua/ShipFucker.lua
Normal file
@@ -0,0 +1,72 @@
|
||||
function string.split(s, p)
|
||||
local Result= {}
|
||||
string.gsub(s, '[^'..p..']+', function(w) table.insert(Result, w) end)
|
||||
return Result
|
||||
end
|
||||
-- 199034;6;3:60>-100;417>-100
|
||||
-- {Id};{Star};{Type}:{Attribute}>{Target}[;{Attribute}>{Target}...][|{Id};{Star};{Type}:{Attribute}>{Target}[;{Attribute}>{Target}...]]
|
||||
function ChangeShipAttribute()
|
||||
local Result = gg.prompt({"格式:{舰船Id};{舰船星级};{类型Id}:{属性}>{目标值}[;{属性}>{目标值}...],多个之间用'|'连接"}
|
||||
,{}
|
||||
,{"text"})
|
||||
|
||||
local TargetList = string.split(tostring(Result[1]), "|")
|
||||
for i = 1, #TargetList do
|
||||
local SplitedTarget = string.split(TargetList[i], ":")
|
||||
local ShipData = SplitedTarget[1] -- {Id};{Star};{Type}
|
||||
local ShipAttributeList = string.split(SplitedTarget[2], ";")
|
||||
--[[
|
||||
{
|
||||
{Attribute}>{Target},
|
||||
{Attribute}>{Target},
|
||||
...
|
||||
}
|
||||
--]]
|
||||
|
||||
gg.searchNumber(ShipData.."::610", gg.TYPE_DOUBLE)
|
||||
gg.refineNumber(string.split(ShipData, ";")[1], gg.TYPE_AUTO)
|
||||
|
||||
local SearchResult = gg.getResults(1024)
|
||||
for j = 1, #SearchResult do
|
||||
local MemoryFrom = SearchResult[j].address - 0x1000
|
||||
local MemoryTo = SearchResult[j].address + 0x1000
|
||||
for k = 1, #ShipAttributeList do
|
||||
-- fuck gg
|
||||
-- fuck lua
|
||||
-- fuck dynamic type
|
||||
-- fuck everything
|
||||
local SplitedAttribute = string.split(tostring(ShipAttributeList[k]), ">")
|
||||
local AttributeToSearchList = SplitedAttribute[1]
|
||||
local TargetAttributeList = SplitedAttribute[2]
|
||||
gg.searchNumber(AttributeToSearchList, gg.TYPE_DOUBLE, false, gg.SIGN_EQUAL, MemoryFrom, MemoryTo)
|
||||
gg.getResults(1024)
|
||||
gg.editAll(TargetAttributeList, gg.TYPE_DOUBLE)
|
||||
gg.clearResults()
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Exit("修改成功!")
|
||||
end
|
||||
|
||||
function Exit(Message)
|
||||
gg.alert(Message)
|
||||
os.exit()
|
||||
end
|
||||
|
||||
function Main()
|
||||
Choice = gg.choice({
|
||||
"改属性",
|
||||
"退出",
|
||||
}, nil, nil)
|
||||
if Choice == 1 then
|
||||
ChangeShipAttribute()
|
||||
end
|
||||
if Choice == 2 then
|
||||
Exit("退出成功!")
|
||||
end
|
||||
FX=false
|
||||
end
|
||||
|
||||
gg.clearResults()
|
||||
Main()
|
||||
@@ -1972,6 +1972,11 @@
|
||||
"TargetType": "BB",
|
||||
"ShipData": "106021;1;6\n107041;1;6\n206011;1;6\n107011;1;6\n"
|
||||
},
|
||||
"ChangeAttribute": {
|
||||
"Enable": false,
|
||||
"PushLua": false,
|
||||
"ShipData": null
|
||||
},
|
||||
"Storage": {
|
||||
"Storage": {}
|
||||
}
|
||||
|
||||
@@ -9455,6 +9455,20 @@
|
||||
"value": "106021;1;6\n107041;1;6\n206011;1;6\n107011;1;6\n"
|
||||
}
|
||||
},
|
||||
"ChangeAttribute": {
|
||||
"Enable": {
|
||||
"type": "checkbox",
|
||||
"value": false
|
||||
},
|
||||
"PushLua": {
|
||||
"type": "checkbox",
|
||||
"value": false
|
||||
},
|
||||
"ShipData": {
|
||||
"type": "textarea",
|
||||
"value": ""
|
||||
}
|
||||
},
|
||||
"Storage": {
|
||||
"Storage": {
|
||||
"type": "storage",
|
||||
|
||||
@@ -743,6 +743,12 @@ ChangeShip:
|
||||
107041;1;6
|
||||
206011;1;6
|
||||
107011;1;6
|
||||
ChangeAttribute:
|
||||
Enable: false
|
||||
PushLua: false
|
||||
ShipData:
|
||||
type: textarea
|
||||
value: ''
|
||||
|
||||
InfiniteDelay:
|
||||
Commission:
|
||||
|
||||
@@ -344,6 +344,7 @@ Tool:
|
||||
- GGHandler
|
||||
- PowerLimit
|
||||
- ChangeShip
|
||||
- ChangeAttribute
|
||||
SomethingSpecial:
|
||||
- InfiniteDelay
|
||||
- TurnOffForcedOnSettings
|
||||
|
||||
@@ -457,6 +457,11 @@ class GeneratedConfig:
|
||||
ChangeShip_TargetType = 'BB' # CV, BB
|
||||
ChangeShip_ShipData = '106021;1;6\n107041;1;6\n206011;1;6\n107011;1;6\n'
|
||||
|
||||
# Group `ChangeAttribute`
|
||||
ChangeAttribute_Enable = False
|
||||
ChangeAttribute_PushLua = False
|
||||
ChangeAttribute_ShipData = None
|
||||
|
||||
# Group `InfiniteDelay`
|
||||
InfiniteDelay_Commission = False
|
||||
InfiniteDelay_Research = False
|
||||
|
||||
@@ -2551,6 +2551,24 @@
|
||||
"help": "ChangeShip.ShipData.help"
|
||||
}
|
||||
},
|
||||
"ChangeAttribute": {
|
||||
"_info": {
|
||||
"name": "ChangeAttribute._info.name",
|
||||
"help": "ChangeAttribute._info.help"
|
||||
},
|
||||
"Enable": {
|
||||
"name": "ChangeAttribute.Enable.name",
|
||||
"help": "ChangeAttribute.Enable.help"
|
||||
},
|
||||
"PushLua": {
|
||||
"name": "ChangeAttribute.PushLua.name",
|
||||
"help": "ChangeAttribute.PushLua.help"
|
||||
},
|
||||
"ShipData": {
|
||||
"name": "ChangeAttribute.ShipData.name",
|
||||
"help": "ChangeAttribute.ShipData.help"
|
||||
}
|
||||
},
|
||||
"InfiniteDelay": {
|
||||
"_info": {
|
||||
"name": "InfiniteDelay._info.name",
|
||||
|
||||
@@ -2551,6 +2551,24 @@
|
||||
"help": "ChangeShip.ShipData.help"
|
||||
}
|
||||
},
|
||||
"ChangeAttribute": {
|
||||
"_info": {
|
||||
"name": "ChangeAttribute._info.name",
|
||||
"help": "ChangeAttribute._info.help"
|
||||
},
|
||||
"Enable": {
|
||||
"name": "ChangeAttribute.Enable.name",
|
||||
"help": "ChangeAttribute.Enable.help"
|
||||
},
|
||||
"PushLua": {
|
||||
"name": "ChangeAttribute.PushLua.name",
|
||||
"help": "ChangeAttribute.PushLua.help"
|
||||
},
|
||||
"ShipData": {
|
||||
"name": "ChangeAttribute.ShipData.name",
|
||||
"help": "ChangeAttribute.ShipData.help"
|
||||
}
|
||||
},
|
||||
"InfiniteDelay": {
|
||||
"_info": {
|
||||
"name": "InfiniteDelay._info.name",
|
||||
|
||||
@@ -2551,6 +2551,24 @@
|
||||
"help": "格式为\"舰船Id;星级;舰种Id\"\n参考https://github.com/0O0o0oOoO00/SmallKai中的数据\n清空会恢复默认"
|
||||
}
|
||||
},
|
||||
"ChangeAttribute": {
|
||||
"_info": {
|
||||
"name": "改属性",
|
||||
"help": "需要和倍率一起使用"
|
||||
},
|
||||
"Enable": {
|
||||
"name": "启用",
|
||||
"help": ""
|
||||
},
|
||||
"PushLua": {
|
||||
"name": "始终推送Lua",
|
||||
"help": "有时推送时会失败,视情况开启或者关闭"
|
||||
},
|
||||
"ShipData": {
|
||||
"name": "舰船数据",
|
||||
"help": "格式为\"舰船Id;舰船星级;类型Id:属性>目标值[;属性>目标值...]\"\n参考https://github.com/0O0o0oOoO00/SmallKai中的数据"
|
||||
}
|
||||
},
|
||||
"InfiniteDelay": {
|
||||
"_info": {
|
||||
"name": "无限推迟",
|
||||
|
||||
@@ -2551,6 +2551,24 @@
|
||||
"help": "ChangeShip.ShipData.help"
|
||||
}
|
||||
},
|
||||
"ChangeAttribute": {
|
||||
"_info": {
|
||||
"name": "ChangeAttribute._info.name",
|
||||
"help": "ChangeAttribute._info.help"
|
||||
},
|
||||
"Enable": {
|
||||
"name": "ChangeAttribute.Enable.name",
|
||||
"help": "ChangeAttribute.Enable.help"
|
||||
},
|
||||
"PushLua": {
|
||||
"name": "ChangeAttribute.PushLua.name",
|
||||
"help": "ChangeAttribute.PushLua.help"
|
||||
},
|
||||
"ShipData": {
|
||||
"name": "ChangeAttribute.ShipData.name",
|
||||
"help": "ChangeAttribute.ShipData.help"
|
||||
}
|
||||
},
|
||||
"InfiniteDelay": {
|
||||
"_info": {
|
||||
"name": "InfiniteDelay._info.name",
|
||||
|
||||
77
module/gg_handler/change_attribute.py
Normal file
77
module/gg_handler/change_attribute.py
Normal file
@@ -0,0 +1,77 @@
|
||||
from module.logger import logger
|
||||
from module.config.config import deep_get
|
||||
from module.base.base import ModuleBase
|
||||
import uiautomator2 as u2
|
||||
|
||||
class ChangeAttribute(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 GetShipData(self):
|
||||
DataList: str = deep_get(self.config.data, "GameManager.ChangeAttribute.ShipData").split("\n")
|
||||
DataString = "|".join(DataList)
|
||||
return DataString
|
||||
|
||||
def PushLua(self):
|
||||
IsPush = deep_get(self.config.data, keys='GameManager.ChangeAttribute.PushLua')
|
||||
if IsPush:
|
||||
import os
|
||||
os.popen(f'"toolkit/Lib/site-packages/adbutils/binaries/adb.exe" -s'
|
||||
f' {self.device.serial} shell mkdir /sdcard/Notes')
|
||||
self.device.sleep(0.5)
|
||||
os.popen(f'"toolkit/Lib/site-packages/adbutils/binaries/adb.exe" -s'
|
||||
f' {self.device.serial} shell rm /sdcard/Notes/ShipFucker.lua')
|
||||
self.device.sleep(0.5)
|
||||
os.popen(f'"toolkit/Lib/site-packages/adbutils/binaries/adb.exe" -s'
|
||||
f' {self.device.serial} push "bin/Lua/ShipFucker.lua" /sdcard/Notes/ShipFucker.lua')
|
||||
self.device.sleep(0.5)
|
||||
logger.info('Lua Pushed')
|
||||
|
||||
def ChangeAttribute(self):
|
||||
_set = False
|
||||
_confirmed = False
|
||||
while 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()
|
||||
self.device.sleep(1)
|
||||
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/ShipFucker.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:
|
||||
ShipDataString = self.GetShipData()
|
||||
self.d(resourceId=f"{self.gg_package_name}:id/edit")[0].send_keys(ShipDataString)
|
||||
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
|
||||
self.d.wait_timeout = 90.0
|
||||
|
||||
if _set and _confirmed:
|
||||
try:
|
||||
self.d.xpath('//*[@text="确定"]').click()
|
||||
self.device.sleep(0.5)
|
||||
self.d.xpath('//*[@text="确定"]').click()
|
||||
finally:
|
||||
pass
|
||||
self.d.wait_timeout = 3
|
||||
if _set and _confirmed:
|
||||
break
|
||||
else:
|
||||
return 0
|
||||
@@ -4,6 +4,7 @@ from module.config.config import deep_get
|
||||
from module.base.base import ModuleBase as Base
|
||||
import uiautomator2 as u2
|
||||
from module.gg_handler.change_ship import ChangeShip
|
||||
from module.gg_handler.change_attribute import ChangeAttribute
|
||||
|
||||
|
||||
class GGU2(Base):
|
||||
@@ -132,6 +133,8 @@ class GGU2(Base):
|
||||
_repush = deep_get(self.config.data, keys='GameManager.GGHandler.RepushLua')
|
||||
ShipChanger = ChangeShip(self.config, self.device)
|
||||
ShipChanger.PushLua()
|
||||
AttributeChanger = ChangeAttribute(self.config, self.device)
|
||||
AttributeChanger.PushLua()
|
||||
if _repush:
|
||||
os.popen(f'"toolkit/Lib/site-packages/adbutils/binaries/adb.exe" -s'
|
||||
f' {self.device.serial} shell mkdir /sdcard/Notes')
|
||||
@@ -144,6 +147,7 @@ class GGU2(Base):
|
||||
self.device.sleep(0.5)
|
||||
logger.info('Lua Pushed')
|
||||
ShipChanger.ChangeShipType()
|
||||
AttributeChanger.ChangeAttribute()
|
||||
while 1:
|
||||
self.device.sleep(1)
|
||||
if self.d(resourceId=f"{self.gg_package_name}:id/search_toolbar").exists:
|
||||
|
||||
Reference in New Issue
Block a user