diff --git a/config/template.json b/config/template.json index a1510c74b..d9a85c7af 100644 --- a/config/template.json +++ b/config/template.json @@ -122,8 +122,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -197,8 +196,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -272,8 +270,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -356,8 +353,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -435,8 +431,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -510,8 +505,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -589,8 +583,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -668,8 +661,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -747,8 +739,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -826,8 +817,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -901,8 +891,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -963,8 +952,7 @@ "ReachLevel": 0 }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -1011,8 +999,7 @@ "ReachLevel": 0 }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -1447,8 +1434,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", @@ -1522,8 +1508,7 @@ "DistanceToBoss": "2_grid_to_boss" }, "Emotion": { - "CalculateEmotion": true, - "IgnoreLowEmotionWarn": false, + "Mode": "calculate", "Fleet1Value": 119, "Fleet1Record": "2020-01-01 00:00:00", "Fleet1Control": "prevent_yellow_face", diff --git a/module/campaign/gems_farming.py b/module/campaign/gems_farming.py index 6f97e3bbe..2f46d44b8 100644 --- a/module/campaign/gems_farming.py +++ b/module/campaign/gems_farming.py @@ -24,7 +24,7 @@ class GemsCampaignOverride(CampaignBase): If GEMS_LOW_EMOTION_WITHDRAW is True, withdraw combat and change flag ship """ if self.config.GemsFarming_LowEmotionRetreat: - if not self.config.Emotion_IgnoreLowEmotionWarn: + if not self.emotion.is_ignore: return False if self.handle_popup_cancel('IGNORE_LOW_EMOTION'): self.config.GEMS_EMOTION_TRIGGRED = True diff --git a/module/campaign/run.py b/module/campaign/run.py index 8cb854556..ffe75cc56 100644 --- a/module/campaign/run.py +++ b/module/campaign/run.py @@ -108,7 +108,7 @@ class CampaignRun(CampaignEvent): Returns: bool: If triggered a restart condition. """ - if not self.campaign.config.Emotion_IgnoreLowEmotionWarn: + if not self.campaign.emotion.is_ignore: if self.campaign.emotion.triggered_bug(): logger.info('Triggered restart avoid emotion bug') return True diff --git a/module/combat/auto_search_combat.py b/module/combat/auto_search_combat.py index df6384c51..ff7be9cf5 100644 --- a/module/combat/auto_search_combat.py +++ b/module/combat/auto_search_combat.py @@ -312,7 +312,7 @@ class AutoSearchCombat(MapOperation, Combat, CampaignStatus): Note that fleet index == 1 is mob fleet, 2 is boss fleet. It's not the fleet index in fleet preparation or auto search setting. """ - emotion_reduce = emotion_reduce if emotion_reduce is not None else self.config.Emotion_CalculateEmotion + emotion_reduce = emotion_reduce if emotion_reduce is not None else self.emotion.is_calculate self.device.stuck_record_clear() self.auto_search_combat_execute(emotion_reduce=emotion_reduce, fleet_index=fleet_index) diff --git a/module/combat/combat.py b/module/combat/combat.py index c37b70720..7e9b702e5 100644 --- a/module/combat/combat.py +++ b/module/combat/combat.py @@ -472,7 +472,7 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan fleet_index (int): 1 or 2 """ balance_hp = balance_hp if balance_hp is not None else self.config.HpControl_UseHpBalance - emotion_reduce = emotion_reduce if emotion_reduce is not None else self.config.Emotion_CalculateEmotion + emotion_reduce = emotion_reduce if emotion_reduce is not None else self.emotion.is_calculate if auto_mode is None: auto_mode = self.config.Fleet_Fleet1Mode if fleet_index == 1 else self.config.Fleet_Fleet2Mode if submarine_mode is None: diff --git a/module/combat/emotion.py b/module/combat/emotion.py index f0b27e7e6..f0f9d5dc9 100644 --- a/module/combat/emotion.py +++ b/module/combat/emotion.py @@ -152,6 +152,14 @@ class Emotion: self.fleet_2 = FleetEmotion(self.config, fleet=2) self.fleets = [self.fleet_1, self.fleet_2] + @property + def is_calculate(self): + return 'calculate' in self.config.Emotion_Mode + + @property + def is_ignore(self): + return 'ignore' in self.config.Emotion_Mode + def update(self): """ Update emotion value. This should be called before doing anything. @@ -199,7 +207,7 @@ class Emotion: Raise: ScriptEnd: Delay current task to prevent emotion control in the future. """ - if not self.config.Emotion_CalculateEmotion: + if not self.is_calculate: return method = self.config.Fleet_FleetOrder diff --git a/module/config/argument/args.json b/module/config/argument/args.json index fa76cf8c6..e526467e8 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -630,13 +630,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -1002,13 +1003,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -1374,13 +1376,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -1846,13 +1849,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -2283,13 +2287,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -2714,13 +2719,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -3162,13 +3168,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -3610,13 +3617,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -4058,13 +4066,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -4506,13 +4515,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -4945,13 +4955,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -5218,13 +5229,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -5441,13 +5453,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -7248,13 +7261,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", @@ -7643,13 +7657,14 @@ } }, "Emotion": { - "CalculateEmotion": { - "type": "checkbox", - "value": true - }, - "IgnoreLowEmotionWarn": { - "type": "checkbox", - "value": false + "Mode": { + "type": "select", + "value": "calculate", + "option": [ + "calculate", + "ignore", + "calculate_ignore" + ] }, "Fleet1Value": { "type": "input", diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index d7bad54a0..93fe56589 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -171,8 +171,9 @@ Submarine: value: '2_grid_to_boss' option: [ to_boss_position, 1_grid_to_boss, 2_grid_to_boss, use_open_ocean_support ] Emotion: - CalculateEmotion: true - IgnoreLowEmotionWarn: false + Mode: + value: calculate + option: [ calculate, ignore, calculate_ignore ] Fleet1Value: 119 Fleet1Record: value: 2020-01-01 00:00:00 diff --git a/module/config/config_generated.py b/module/config/config_generated.py index 665aa5c67..2c73d92f7 100644 --- a/module/config/config_generated.py +++ b/module/config/config_generated.py @@ -108,8 +108,7 @@ class GeneratedConfig: Submarine_DistanceToBoss = '2_grid_to_boss' # to_boss_position, 1_grid_to_boss, 2_grid_to_boss, use_open_ocean_support # Group `Emotion` - Emotion_CalculateEmotion = True - Emotion_IgnoreLowEmotionWarn = False + Emotion_Mode = 'calculate' # calculate, ignore, calculate_ignore Emotion_Fleet1Value = 119 Emotion_Fleet1Record = datetime.datetime(2020, 1, 1, 0, 0) Emotion_Fleet1Control = 'prevent_yellow_face' # keep_exp_bonus, prevent_green_face, prevent_yellow_face, prevent_red_face diff --git a/module/config/config_updater.py b/module/config/config_updater.py index b79a6dfab..5beb73910 100644 --- a/module/config/config_updater.py +++ b/module/config/config_updater.py @@ -501,6 +501,17 @@ class ConfigUpdater: ('General.Retirement.OldRetireSR', 'General.OldRetire.SR'), ('General.Retirement.OldRetireSSR', 'General.OldRetire.SSR'), ] + redirection += [ + ( + (f'{task}.Emotion.CalculateEmotion', f'{task}.Emotion.IgnoreLowEmotionWarn'), + f'{task}.Emotion.Mode', + emotion_mode_redirect + ) for task in [ + 'Main', 'Main2', 'Main3', 'GemsFarming', + 'Event', 'Event2', 'EventA', 'EventB', 'EventC', 'EventD', 'EventSp', 'Raid', 'RaidDaily', + 'Sos', 'WarArchives', + ] + ] @cached_property def args(self): diff --git a/module/config/i18n/en-US.json b/module/config/i18n/en-US.json index 680bfb320..9733b2fc6 100644 --- a/module/config/i18n/en-US.json +++ b/module/config/i18n/en-US.json @@ -895,13 +895,12 @@ "name": "Emotion Settings", "help": "At least one or both \"Calculate Emotion Consumption\" and \"Ignore Low Emotion Warning\" is used for these settings to be enabled" }, - "CalculateEmotion": { - "name": "Calculate Emotion Consumption", - "help": "Calculates emotion according to settings, if ship(s) have changed in fleet should manually edit the corresponding value for accuracy" - }, - "IgnoreLowEmotionWarn": { - "name": "Ignore Low Emotion Warning", - "help": "If emotion warning triggers, it will be ignored and proceed into next battle regardless" + "Mode": { + "name": "Emotion Settings", + "help": "", + "calculate": "Calculate Emotion Consumption", + "ignore": "Ignore Low Emotion Warning", + "calculate_ignore": "Calculate + Ignore" }, "Fleet1Value": { "name": "Fleet 1 Emotion Value", diff --git a/module/config/i18n/ja-JP.json b/module/config/i18n/ja-JP.json index 62955b2ca..c1c0ccd94 100644 --- a/module/config/i18n/ja-JP.json +++ b/module/config/i18n/ja-JP.json @@ -895,13 +895,12 @@ "name": "Emotion._info.name", "help": "Emotion._info.help" }, - "CalculateEmotion": { - "name": "Emotion.CalculateEmotion.name", - "help": "Emotion.CalculateEmotion.help" - }, - "IgnoreLowEmotionWarn": { - "name": "Emotion.IgnoreLowEmotionWarn.name", - "help": "Emotion.IgnoreLowEmotionWarn.help" + "Mode": { + "name": "Emotion.Mode.name", + "help": "Emotion.Mode.help", + "calculate": "calculate", + "ignore": "ignore", + "calculate_ignore": "calculate_ignore" }, "Fleet1Value": { "name": "Emotion.Fleet1Value.name", diff --git a/module/config/i18n/zh-CN.json b/module/config/i18n/zh-CN.json index 87b3a7901..29adc7ce5 100644 --- a/module/config/i18n/zh-CN.json +++ b/module/config/i18n/zh-CN.json @@ -893,16 +893,15 @@ "Emotion": { "_info": { "name": "心情设置", - "help": "\"计算心情消耗\" 和 \"无视红脸出击警告\" 之间至少需要打开一个" - }, - "CalculateEmotion": { - "name": "计算心情消耗", - "help": "根据设置和出击计算心情消耗\n如果你更换了队伍中的舰船,需要修改对应的心情值" - }, - "IgnoreLowEmotionWarn": { - "name": "无视红脸出击警告", "help": "" }, + "Mode": { + "name": "心情设置", + "help": "", + "calculate": "计算心情消耗", + "ignore": "无视红脸出击警告", + "calculate_ignore": "计算心情消耗 + 无视红脸出击警告" + }, "Fleet1Value": { "name": "一队心情值", "help": "" diff --git a/module/config/i18n/zh-TW.json b/module/config/i18n/zh-TW.json index 6a42f3744..049306a55 100644 --- a/module/config/i18n/zh-TW.json +++ b/module/config/i18n/zh-TW.json @@ -893,16 +893,15 @@ "Emotion": { "_info": { "name": "心情設定", - "help": "\"計算心情消耗\" 和 \"無視紅臉出擊警告\" 之間至少需要打開一個" - }, - "CalculateEmotion": { - "name": "計算心情消耗", - "help": "根據設定和出擊計算心情消耗\n如果你更換了隊伍中的艦船,需要修改為對應的心情值" - }, - "IgnoreLowEmotionWarn": { - "name": "無視紅臉出擊警告", "help": "" }, + "Mode": { + "name": "心情設定", + "help": "", + "calculate": "計算心情消耗", + "ignore": "無視紅臉出擊警告", + "calculate_ignore": "計算心情消耗 + 無視紅臉出擊警告" + }, "Fleet1Value": { "name": "一隊心情值", "help": "" diff --git a/module/config/redirect_utils/utils.py b/module/config/redirect_utils/utils.py index f6a893584..20bf18fd4 100644 --- a/module/config/redirect_utils/utils.py +++ b/module/config/redirect_utils/utils.py @@ -61,3 +61,21 @@ def enhance_check_redirect(value): if value < 5: return 5 return value + + +def emotion_mode_redirect(value): + """ + CalculateEmotion + IgnoreLowEmotionWarn -> Emotion.Mode + """ + calculate, ignore = value + if calculate: + if ignore: + return 'calculate_ignore' + else: + return 'calculate' + else: + if ignore: + return 'ignore' + else: + # Invalid, fallback to calculate + return 'calculate' diff --git a/module/handler/info_handler.py b/module/handler/info_handler.py index c8ab615f1..90963ffaf 100644 --- a/module/handler/info_handler.py +++ b/module/handler/info_handler.py @@ -158,7 +158,7 @@ class InfoHandler(ModuleBase): return appear def handle_combat_low_emotion(self): - if not self.config.Emotion_IgnoreLowEmotionWarn: + if not self.emotion.is_ignore: return False result = self.handle_popup_confirm('IGNORE_LOW_EMOTION') diff --git a/module/hard/hard.py b/module/hard/hard.py index d824e209d..3b2da4240 100644 --- a/module/hard/hard.py +++ b/module/hard/hard.py @@ -22,7 +22,7 @@ class CampaignHard(CampaignRun): Campaign_UseFleetLock=True, Campaign_UseAutoSearch=True, Fleet_FleetOrder='fleet1_all_fleet2_standby' if self.config.Hard_HardFleet == 1 else 'fleet1_standby_fleet2_all', - Emotion_CalculateEmotion=False, + Emotion_Mode='nothing', # Dont calculate and dont ignore ) # Equipment take on # campaign/campaign_hard/campaign_hard.py Campaign.fleet_preparation() diff --git a/module/map/map.py b/module/map/map.py index 51a592dc3..1c850004c 100644 --- a/module/map/map.py +++ b/module/map/map.py @@ -22,7 +22,7 @@ class Map(Fleet): logger.info('Clear enemy: %s' % grid) expected = f'combat_{expected}' if expected else 'combat' self.show_fleet() - if self.config.Emotion_CalculateEmotion and self.config.Campaign_UseFleetLock: + if self.emotion.is_calculate and self.config.Campaign_UseFleetLock: self.emotion.wait(fleet_index=self.fleet_current_index) self.goto(grid, expected=expected) @@ -708,7 +708,7 @@ class Map(Fleet): self.show_fleet() prev = self.battle_count for n, grid in enumerate(itertools.cycle(route)): - if self.config.Emotion_CalculateEmotion and self.config.Campaign_UseFleetLock: + if self.emotion.is_calculate and self.config.Campaign_UseFleetLock: self.emotion.wait(fleet_index=self.fleet_current_index) self.goto(grid, expected='combat_nothing')