mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
chore: tools for global servers (diff_resource & match_json)
diff_resource finds the templates in ZH server but without a corresponding global template yet. match_json sorts the json files according to ZH json
This commit is contained in:
1
tools/global_servers/.gitignore
vendored
Normal file
1
tools/global_servers/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
diff_image/
|
||||
93
tools/global_servers/diff_resource.py
Normal file
93
tools/global_servers/diff_resource.py
Normal file
@@ -0,0 +1,93 @@
|
||||
# WHAT DOES THIS TOOL DO?
|
||||
#
|
||||
# In order for MAA ZH-server features to be compatible with global servers,
|
||||
# crops/screenshots/templates of ZH servers with Chinese characters etc. must be
|
||||
# replaced with those of corresponding global servers, which needs your help.
|
||||
# This tool helps you find which templates in ZH server (usually recently added)
|
||||
# have not yet had a global server version, and copy them to a separate folder
|
||||
# so that you can easily .
|
||||
#
|
||||
# There are some ZH templates without any Chinese characters etc. which can thus
|
||||
# be used across different servers. You may add them to the ignore_list.txt
|
||||
# file.
|
||||
#
|
||||
# USAGE
|
||||
#
|
||||
# 1. Install Python
|
||||
# 2. Run "$python diff_resource.py xxx" in the terminal where xxx is the desired
|
||||
# server name i.e. YostarJP/YostarEN/YostarKR/txwy
|
||||
# 3. Results can be found in the diff_image folder
|
||||
#
|
||||
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
# Put the file names of text-less images (so that global servers use the same
|
||||
# image as the ZH (ZH_CN) server does) in this file.
|
||||
# Note you have to manually update the content of this file.
|
||||
ignore_list_file_name = "ignore_list.txt"
|
||||
|
||||
server_list = [
|
||||
"YostarJP",
|
||||
"YostarEN",
|
||||
"YostarKR",
|
||||
"txwy"
|
||||
]
|
||||
|
||||
# Get the server name from argument
|
||||
try:
|
||||
# server_name = YostarJP
|
||||
server_name = sys.argv[1]
|
||||
if server_name not in server_list:
|
||||
raise
|
||||
except:
|
||||
server_name = None
|
||||
while (not server_name):
|
||||
print("Enter one and only one server name:",
|
||||
", ".join(server_list))
|
||||
t = input()
|
||||
server_name = t if t in server_list else None
|
||||
|
||||
|
||||
# Get current directory so script is run at the correct dir
|
||||
cur_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
zh_dir = os.path.join(cur_dir, "../../resource/template/")
|
||||
gl_dir = os.path.join(cur_dir, "../../resource/global/",
|
||||
server_name, "resource/template/")
|
||||
|
||||
zh_files = [f for f in os.listdir(
|
||||
zh_dir) if os.path.isfile(os.path.join(zh_dir, f))]
|
||||
gl_files = [f for f in os.listdir(
|
||||
gl_dir) if os.path.isfile(os.path.join(gl_dir, f))]
|
||||
|
||||
with open(os.path.join(cur_dir, ignore_list_file_name)) as f:
|
||||
ignore_files = [line.rstrip('\n') for line in f]
|
||||
|
||||
# ZH server pics not found in global server nor ignored will be filtered here
|
||||
diff_files = [i for i in zh_files if
|
||||
|
||||
# NOTE: You May Customize Here
|
||||
# not i.startswith("Mizuki@Roguelike") and
|
||||
"Rogue" not in i and
|
||||
|
||||
i not in gl_files and
|
||||
i not in ignore_files
|
||||
]
|
||||
|
||||
# These pictures will be copied to the diff_image folder for reference.
|
||||
# Contributors of global servers may screenshot the corresponding files.
|
||||
# Note this folder is in .gitignore so it will not be uploaded.
|
||||
out_dir = os.path.join(cur_dir, "diff_image/", server_name)
|
||||
if os.path.exists(out_dir):
|
||||
shutil.rmtree(out_dir)
|
||||
os.makedirs(out_dir)
|
||||
|
||||
for i in diff_files:
|
||||
# print(i)
|
||||
shutil.copyfile(os.path.join(zh_dir, i), os.path.jgitoin(out_dir, i))
|
||||
|
||||
print("Pictures not included in", server_name,
|
||||
"server resources is copied to diff_image/" + server_name)
|
||||
110
tools/global_servers/ignore_list.txt
Normal file
110
tools/global_servers/ignore_list.txt
Normal file
@@ -0,0 +1,110 @@
|
||||
AddOperatorMfgGentle.png
|
||||
AddOperatorTradeGentle.png
|
||||
BattleHpFlag.png
|
||||
BattleHpFlag2.png
|
||||
BattleKillsFlag.png
|
||||
BattleOfficiallyBegin.png
|
||||
BattleOperRetreat.png
|
||||
BattleOperRoleCaster.png
|
||||
BattleOperRoleDrone.png
|
||||
BattleOperRoleMedic.png
|
||||
BattleOperRolePioneer.png
|
||||
BattleOperRoleSniper.png
|
||||
BattleOperRoleSpecial.png
|
||||
BattleOperRoleSupport.png
|
||||
BattleOperRoleTank.png
|
||||
BattleOperRoleWarrior.png
|
||||
BattleOpersFlag.png
|
||||
BattleQuickFormation-OperNameFlag-SpecialFocus.png
|
||||
BattleQuickFormation-OperNameFlag.png
|
||||
BattleQuickFormation.png
|
||||
BattleQuickFormationRole-Caster.png
|
||||
BattleQuickFormationRole-Medic.png
|
||||
BattleQuickFormationRole-Pioneer.png
|
||||
BattleQuickFormationRole-Sniper.png
|
||||
BattleQuickFormationRole-Special.png
|
||||
BattleQuickFormationRole-Support.png
|
||||
BattleQuickFormationRole-Tank.png
|
||||
BattleQuickFormationRole-Warrior.png
|
||||
BattleSkillReady.png
|
||||
BattleSkillReadyOnClick.png
|
||||
BattleSkillStopOnClick.png
|
||||
BattleSpeedUp.png
|
||||
BuyIt.png
|
||||
CloseAnno.png
|
||||
CloseAnnoTexas.png
|
||||
CloseCluePage.png
|
||||
CloseSendClue.png
|
||||
ClueGiveToNextPage.png
|
||||
ClueVacancyNo1.png
|
||||
ClueVacancyNo2.png
|
||||
ClueVacancyNo3.png
|
||||
ClueVacancyNo4.png
|
||||
ClueVacancyNo5.png
|
||||
ClueVacancyNo6.png
|
||||
ClueVacancyNo7.png
|
||||
ClusCanBeSent.png
|
||||
CreditPoint.png
|
||||
CreditShop-Bought.png
|
||||
DroneAssistMfg.png
|
||||
EndOfAction.png
|
||||
EnterChapterIS2.png
|
||||
EnterEpisode0.png
|
||||
EnterEpisode4.png
|
||||
EnterEpisode9.png
|
||||
EnterStageIS.png
|
||||
FacilityListTabMfg.png
|
||||
FacilityListTabTrade.png
|
||||
GameStart.png
|
||||
InfrastClueSelfMaybeFull.png
|
||||
InfrastFilterMenu.png
|
||||
InfrastFilterMenuConfirmButton.png
|
||||
InfrastNotification.png
|
||||
Loading2.png
|
||||
MedicineConfirm.png
|
||||
MiningActivityDiggingEnd.png
|
||||
OF-Chapter2.png
|
||||
OfflineConfirm.png
|
||||
OperLockedMfg.png
|
||||
OperLockedTrade.png
|
||||
OperSelected.png
|
||||
PopupCancel.png
|
||||
PopupConfirm.png
|
||||
RecruitConfirm.png
|
||||
RecruitNoRefresh.png
|
||||
RecruitNowConfirm.png
|
||||
RecruitSkip.png
|
||||
RecruitTimerDecrement.png
|
||||
ReplenishToMaxConfirm.png
|
||||
Return.png
|
||||
SN-10.png
|
||||
SN-8.png
|
||||
SN-9.png
|
||||
SendClueConfirm.png
|
||||
SendClues.png
|
||||
SkipThePreBattlePlotConfirm.png
|
||||
SmileyOnDistract.png
|
||||
SmileyOnRest.png
|
||||
SmileyOnWork.png
|
||||
StageAP5.png
|
||||
StageBI7.png
|
||||
StageBI8.png
|
||||
StageCA5.png
|
||||
StageCE5.png
|
||||
StageCE6.png
|
||||
StageDrops-Difficulty-Normal.png
|
||||
StageDrops-Difficulty-Normal2.png
|
||||
StageDrops-Difficulty-Tough.png
|
||||
StageDrops-Stars-2.png
|
||||
StageDrops-Stars-3.png
|
||||
StageDrops-Tough.png
|
||||
StageEpisode.png
|
||||
StageLS5.png
|
||||
StageLS6.png
|
||||
StageResource.png
|
||||
StageTheme.png
|
||||
StartLoginBServer.png
|
||||
UnableToAgent.png
|
||||
UseMedicine.png
|
||||
UseStone.png
|
||||
empty.png
|
||||
75
tools/global_servers/match_json.py
Normal file
75
tools/global_servers/match_json.py
Normal file
@@ -0,0 +1,75 @@
|
||||
# WHAT DOES THIS TOOL DO?
|
||||
#
|
||||
# This tool sorts the global json files so that they are in the same order as
|
||||
# the ZH ones. This way, it is easier to find the attributes, see what is
|
||||
# missing, etc.
|
||||
#
|
||||
# USAGE
|
||||
#
|
||||
# 1. Install Python
|
||||
# 2. Run "$python match_json.py xxx" in the terminal where xxx is the desired
|
||||
# server name i.e. YostarJP/YostarEN/YostarKR/txwy
|
||||
# 3. The json file will be updated in-place
|
||||
#
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from collections import OrderedDict
|
||||
|
||||
server_list = [
|
||||
"YostarJP",
|
||||
"YostarEN",
|
||||
"YostarKR",
|
||||
"txwy"
|
||||
]
|
||||
|
||||
# Get the server name from argument
|
||||
try:
|
||||
# server_name = YostarJP
|
||||
server_name = sys.argv[1]
|
||||
if server_name not in server_list:
|
||||
raise
|
||||
except:
|
||||
server_name = None
|
||||
while (not server_name):
|
||||
print("Enter one and only one server name:",
|
||||
", ".join(server_list))
|
||||
t = input()
|
||||
server_name = t if t in server_list else None
|
||||
|
||||
cur_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
proj_dir = os.path.join(cur_dir, "../../")
|
||||
|
||||
# File name of the json
|
||||
# NOTE: You may change this to e.g. recruitment.json
|
||||
# This is hardcoded because tasks.json is the most likely modified one
|
||||
json_name = "tasks.json"
|
||||
|
||||
zh_json_file = os.path.join(proj_dir, "resource/", json_name)
|
||||
gl_json_file = os.path.join(proj_dir, "resource/global/",
|
||||
server_name, "resource/", json_name)
|
||||
|
||||
# For test purpose
|
||||
# gl_json_file = os.path.join(cur_dir, "test.json")
|
||||
|
||||
with open(zh_json_file, 'r', encoding='utf-8') as zh_fh:
|
||||
zh_json = json.load(zh_fh)
|
||||
|
||||
with open(gl_json_file, 'r', encoding='utf-8') as gl_fh:
|
||||
gl_json = json.load(gl_fh)
|
||||
|
||||
# Sort the global json object by the order of the ZH one
|
||||
# Keys not found in ZH json will be put at the end (should not happen though)
|
||||
LAST_POSITIONS = 1e10
|
||||
key_order = {k: v for v, k in enumerate(zh_json)}
|
||||
gl_json_new = OrderedDict(
|
||||
sorted(gl_json.items(), key=lambda i: key_order.get(i[0], LAST_POSITIONS)))
|
||||
|
||||
with open(gl_json_file, 'w', encoding='utf-8') as gl_fh:
|
||||
t = json.dumps(gl_json_new, indent=4, separators=(
|
||||
',', ': '), ensure_ascii=False)
|
||||
gl_fh.write(t)
|
||||
# print(t)
|
||||
print("successfully sorted the", server_name,
|
||||
"json file (", json_name, ") by the order in ZH json file")
|
||||
52
tools/global_servers/test.json
Normal file
52
tools/global_servers/test.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"SN-8": {
|
||||
"algorithm": "JustReturn",
|
||||
"action": "DoNothing",
|
||||
"sub": [
|
||||
"SN-Open",
|
||||
"SN-Chapter2",
|
||||
"StageSN-8"
|
||||
]
|
||||
},
|
||||
"SN-9": {
|
||||
"algorithm": "JustReturn",
|
||||
"action": "DoNothing",
|
||||
"sub": [
|
||||
"SN-Open",
|
||||
"SN-Chapter3",
|
||||
"StageSN-9"
|
||||
]
|
||||
},
|
||||
"SN-10": {
|
||||
"algorithm": "JustReturn",
|
||||
"action": "DoNothing",
|
||||
"sub": [
|
||||
"SN-Open",
|
||||
"SN-Chapter3",
|
||||
"StageSN-10"
|
||||
]
|
||||
},
|
||||
"StartButton1": {
|
||||
"text": [
|
||||
"行動開始"
|
||||
]
|
||||
},
|
||||
"PRTS3": {
|
||||
"text": [
|
||||
"残り配置可能数"
|
||||
]
|
||||
},
|
||||
"VisitNextOcr": {
|
||||
"text": [
|
||||
"次を訪問"
|
||||
]
|
||||
},
|
||||
"VisitLimited": {
|
||||
"text": [
|
||||
"上限",
|
||||
"達しました",
|
||||
"Fpは入手できません",
|
||||
"再訪問の場合"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user