Opt: Re-organise CalculateEmotion and IgnoreLowEmotionWarn

This commit is contained in:
LmeSzinc 2023-02-18 01:19:04 +08:00
parent b63cf43568
commit d191d16649
18 changed files with 211 additions and 178 deletions

View File

@ -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",

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -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

View File

@ -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",

View File

@ -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

View File

@ -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

View File

@ -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):

View File

@ -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",

View File

@ -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",

View File

@ -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": ""

View File

@ -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": ""

View File

@ -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'

View File

@ -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')

View File

@ -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()

View File

@ -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')