diff --git a/config/template.json b/config/template.json index 5433e3d07..cc1a66c07 100644 --- a/config/template.json +++ b/config/template.json @@ -111,7 +111,8 @@ "NoEmotionWarning": false }, "ShipProperty": { - "Enable": false, + "Method": "disable", + "Factor": 1.0, "Armor": -1, "Speed": -1, "AntiAircraft": -1, diff --git a/module/config/argument/args.json b/module/config/argument/args.json index 6523328e5..d5705e3a6 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -548,9 +548,18 @@ } }, "ShipProperty": { - "Enable": { - "type": "checkbox", - "value": false + "Method": { + "type": "select", + "value": "disable", + "option": [ + "disable", + "gg_factor", + "final_properties" + ] + }, + "Factor": { + "type": "input", + "value": 1.0 }, "Armor": { "type": "input", diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 418dda65b..7f56ef649 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -166,7 +166,10 @@ HookGeneral: value: "" type: textarea ShipProperty: - Enable: false + Method: + value: disable + option: [ disable, gg_factor, final_properties ] + Factor: 1.0 Armor: -1 Speed: -1 AntiAircraft: -1 diff --git a/module/config/config_generated.py b/module/config/config_generated.py index d651968e4..36b0517c2 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -87,7 +87,8 @@ class GeneratedConfig: HookGeneral_GameLibDir = None # Group `ShipProperty` - ShipProperty_Enable = False + ShipProperty_Method = 'disable' # disable, gg_factor, final_properties + ShipProperty_Factor = 1.0 ShipProperty_Armor = -1 ShipProperty_Speed = -1 ShipProperty_AntiAircraft = -1 diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 1b3a7b7f5..1fe34b82e 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -769,9 +769,16 @@ "name": "ShipProperty._info.name", "help": "ShipProperty._info.help" }, - "Enable": { - "name": "ShipProperty.Enable.name", - "help": "ShipProperty.Enable.help" + "Method": { + "name": "ShipProperty.Method.name", + "help": "ShipProperty.Method.help", + "disable": "disable", + "gg_factor": "gg_factor", + "final_properties": "final_properties" + }, + "Factor": { + "name": "ShipProperty.Factor.name", + "help": "ShipProperty.Factor.help" }, "Armor": { "name": "ShipProperty.Armor.name", diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index a5dc09503..a949482df 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -769,9 +769,16 @@ "name": "ShipProperty._info.name", "help": "ShipProperty._info.help" }, - "Enable": { - "name": "ShipProperty.Enable.name", - "help": "ShipProperty.Enable.help" + "Method": { + "name": "ShipProperty.Method.name", + "help": "ShipProperty.Method.help", + "disable": "disable", + "gg_factor": "gg_factor", + "final_properties": "final_properties" + }, + "Factor": { + "name": "ShipProperty.Factor.name", + "help": "ShipProperty.Factor.help" }, "Armor": { "name": "ShipProperty.Armor.name", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 6d248f94d..e01fef702 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -769,9 +769,16 @@ "name": "修改舰船属性", "help": "该功能下所有的属性设置均为-1表示不修改该属性,默认为-1" }, - "Enable": { - "name": "启用", - "help": "" + "Method": { + "name": "修改方式", + "help": "", + "disable": "不使用", + "gg_factor": "GG倍率", + "final_properties": "修改最终属性" + }, + "Factor": { + "name": "倍率", + "help": "可以是小数,默认为1.0,表示不修改" }, "Armor": { "name": "装甲类型", diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 36d9dbb40..b4dbeff16 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -769,9 +769,16 @@ "name": "ShipProperty._info.name", "help": "ShipProperty._info.help" }, - "Enable": { - "name": "ShipProperty.Enable.name", - "help": "ShipProperty.Enable.help" + "Method": { + "name": "ShipProperty.Method.name", + "help": "ShipProperty.Method.help", + "disable": "disable", + "gg_factor": "gg_factor", + "final_properties": "final_properties" + }, + "Factor": { + "name": "ShipProperty.Factor.name", + "help": "ShipProperty.Factor.help" }, "Armor": { "name": "ShipProperty.Armor.name", diff --git a/module/luahook/crack.py b/module/luahook/crack.py index 06f5796be..fa9c61955 100644 --- a/module/luahook/crack.py +++ b/module/luahook/crack.py @@ -29,6 +29,23 @@ ALL_ENABLE_OPS = [ CrackOp.EnableGGFactor, ] +REMOTE_PORT = 23897 + + +class Cracker(CrackApi): + def __init__(self, config: AzurLaneConfig, device: Device): + self.config = config + self.device = device + super().__init__(f"http://127.0.0.1:{device.adb.forward_port(REMOTE_PORT)}") + + +def fix_Hook_ShipProperty_config(config: AzurLaneConfig): + enable = deep_get(config.data, "Hook.ShipProperty.Enable", False) + if not enable: + return + else: + config.modified["Hook.ShipProperty.Method"] = "final_properties" + def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp.Op], List[Type[CrackOp.Op]]]): if not deep_get(config.data, "Hook.HookGeneral.Enable", False): @@ -41,13 +58,14 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. else: l = [ops] - base_url = f"http://127.0.0.1:{device.adb.forward_port(23897)}" + base_url = f"http://127.0.0.1:{device.adb.forward_port(REMOTE_PORT)}" api = CrackApi(base_url) for op in l: if op == CrackOp.DisableAll: api.disable_all() elif op == CrackOp.EnableGlobalShipProperties: - if not deep_get(config.data, "Hook.ShipProperty.Enable", False): + fix_Hook_ShipProperty_config(config) + if deep_get(config.data, "Hook.ShipProperty.Method", "disable") != "final_properties": continue api.update_global_ship_properties( CrackApi.ShipProperties( @@ -132,9 +150,12 @@ def do_crack_op(config: AzurLaneConfig, device: Device, ops: Union[Type[CrackOp. elif op == CrackOp.DisableOpsiFastMove: api.disable_opsi_fast_move() elif op == CrackOp.EnableGGFactor: - ... + if deep_get(config.data, "Hook.ShipProperty.Method", "disable") != "gg_factor": + continue + api.update_gg_factor(deep_get(config.data, "Hook.ShipProperty.Factor", 1.0)) + api.enable_gg_factor() elif op == CrackOp.DisableGGFactor: - ... + api.disable_gg_factor() else: raise ValueError(f"Unknown op: {op}")