1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-15 15:09:26 +08:00

Fix: An more accurate way to change ShipType

This commit is contained in:
Zuosizhu
2024-07-19 01:16:48 +08:00
parent 5096d7b702
commit a560e66cb0
3 changed files with 21 additions and 17 deletions

View File

@@ -5,26 +5,27 @@ function string.split(s, p)
end
function ChangeShip()
local Result = gg.prompt({"舰船Id", "舰船星级", "当前舰种Id", "目标舰种Id"}
local Result = gg.prompt({"舰船Id", "舰船稀有度", "舰船星级", "当前舰种Id", "目标舰种Id"}
,{}
,{"number", "number", "number", "number"})
,{"number", "number", "number", "number", "number"})
local ShipIdList = string.split(tostring(Result[1]), ";")
local ShipStarList = string.split(tostring(Result[2]), ";")
local ShipTypeIdList = string.split(tostring(Result[3]), ";")
local TargetShipTypeIdList = string.split(tostring(Result[4]), ";")
local ShipRarityList = string.split(tostring(Result[2]), ";")
local ShipStarList = string.split(tostring(Result[3]), ";")
local ShipTypeIdList = string.split(tostring(Result[4]), ";")
local TargetShipTypeIdList = string.split(tostring(Result[5]), ";")
if #ShipIdList ~= #ShipTypeIdList or #ShipIdList ~= #TargetShipTypeIdList or #ShipIdList ~= #ShipStarList then
if #ShipIdList ~= #ShipTypeIdList or #ShipIdList ~= #TargetShipTypeIdList or #ShipIdList ~= #ShipStarList or #ShipIdList ~= #ShipRarityList then
Exit("参数数量不匹配!")
end
for i = 1, #ShipIdList do
gg.searchNumber(ShipIdList[i]..";"..ShipStarList[i]..";"..ShipTypeIdList[i].."::610", gg.TYPE_DOUBLE)
gg.searchNumber(ShipIdList[i]..";"..ShipRarityList[i]..";"..ShipStarList[i]..";"..ShipTypeIdList[i].."::610", gg.TYPE_DOUBLE)
gg.refineNumber(ShipTypeIdList[i], gg.TYPE_DOUBLE)
local SearchResult = gg.getResults(1024)
if next(SearchResult) == nil then
gg.clearResults()
gg.searchNumber(ShipIdList[i]..";"..ShipStarList[i]..";"..ShipTypeIdList[i].."::610", gg.TYPE_DWORD)
gg.searchNumber(ShipIdList[i]..";"..ShipRarityList[i]..";"..ShipStarList[i]..";"..ShipTypeIdList[i].."::610", gg.TYPE_DWORD)
gg.refineNumber(ShipTypeIdList[i], gg.TYPE_DWORD)
gg.getResults(1024)
gg.editAll(TargetShipTypeIdList[i], gg.TYPE_DWORD)

View File

@@ -1206,7 +1206,7 @@
"FlagshipFilter": {
"_info": {
"name": "后排主力过滤器",
"help": ""
"help": "使用改船时请务必确认此选项。尤其是更改驱逐舰时白鹰船国籍会同时改变!"
},
"Sort": {
"name": "排序",
@@ -1284,7 +1284,7 @@
"VanguardFilter": {
"_info": {
"name": "前排先锋过滤器",
"help": ""
"help": "使用改船时请务必确认此选项。尤其是更改驱逐舰时白鹰船国籍会同时改变!"
},
"Sort": {
"name": "排序",
@@ -2802,7 +2802,7 @@
},
"ShipData": {
"name": "舰船数据",
"help": "格式为\"舰船Id;星级;舰种Id;目标类型Id\"\n参考https://github.com/0O0o0oOoO00/SmallKai中的数据\n清空会恢复默认"
"help": "格式为\"舰船Id;舰船稀有度;星级;舰种Id;目标类型Id\"\n参考https://github.com/0O0o0oOoO00/SmallKai中的数据\n清空会恢复默认"
}
},
"ChangeAttribute": {

View File

@@ -12,9 +12,10 @@ class ShipData:
def __init__(self, DataStr: str):
DataList = DataStr.split(";")
self.ShipId = DataList[0]
self.Star = DataList[1]
self.ShipType = DataList[2]
self.TargetType = DataList[3]
self.Rarity = DataList[1]
self.Star = DataList[2]
self.ShipType = DataList[3]
self.TargetType = DataList[4]
class ChangeShip(ModuleBase):
@@ -74,15 +75,17 @@ class ChangeShip(ModuleBase):
if self.d(resourceId=f"{self.gg_package_name}:id/edit").exists:
ShipDataList = self.GetShipData()
ShipIdStr = ";".join([str(i.ShipId) for i in ShipDataList])
ShipRarityStr = ";".join([str(i.Rarity) for i in ShipDataList])
ShipStarStr = ";".join([str(i.Star) for i in ShipDataList])
CurrentShipTypeStr = ";".join([str(i.ShipType) for i in ShipDataList])
TargetShipTypeStr = ";".join([str(i.TargetType) for i in ShipDataList])
while 1:
try:
self.d(resourceId=f"{self.gg_package_name}:id/edit")[0].send_keys(ShipIdStr)
self.d(resourceId=f"{self.gg_package_name}:id/edit")[1].send_keys(ShipStarStr)
self.d(resourceId=f"{self.gg_package_name}:id/edit")[2].send_keys(CurrentShipTypeStr)
self.d(resourceId=f"{self.gg_package_name}:id/edit")[3].send_keys(TargetShipTypeStr)
self.d(resourceId=f"{self.gg_package_name}:id/edit")[1].send_keys(ShipRarityStr)
self.d(resourceId=f"{self.gg_package_name}:id/edit")[2].send_keys(ShipStarStr)
self.d(resourceId=f"{self.gg_package_name}:id/edit")[3].send_keys(CurrentShipTypeStr)
self.d(resourceId=f"{self.gg_package_name}:id/edit")[4].send_keys(TargetShipTypeStr)
break
except UiObjectNotFoundError:
self.d(className="android.widget.ScrollView")[0].scroll.toEnd()