feat: 傀影肉鸽添加难度选择 (#12897)

* feat: 傀影肉鸽添加难度选择

* feat: 肉鸽难度选择不再显示不支持的选项
This commit is contained in:
Sherkey Asher
2025-06-17 09:28:34 +08:00
committed by GitHub
parent 219ec7278a
commit 3289bbabb8
6 changed files with 77 additions and 45 deletions

View File

@@ -4,6 +4,22 @@
"text": ["古堡笔记"]
},
"Phantom@Roguelike@ChooseDifficulty": {},
"Phantom@Roguelike@ChooseDifficulty_Easiest": {
"action": "ClickRect",
"specificRect": [1144, 472, 78, 24],
"postDelay": 800,
"template": "Phantom@Roguelike@StartExplore.png",
"roi": [1026, 470, 254, 248],
"sub": ["SwipeToTheUp*2"]
},
"Phantom@Roguelike@ChooseDifficulty_Hardest": {
"action": "ClickRect",
"specificRect": [1144, 472, 78, 24],
"postDelay": 800,
"template": "Phantom@Roguelike@StartExplore.png",
"roi": [1026, 470, 254, 248],
"sub": ["SwipeToTheDown*2"]
},
"Phantom@Roguelike@ChooseOper": {
"next": [
"Phantom@Roguelike@ChooseOperConfirm",

View File

@@ -20,13 +20,9 @@ bool asst::RoguelikeConfig::verify_and_load_params(const json::value& params)
m_theme = theme;
m_mode = mode;
if (m_theme != RoguelikeTheme::Phantom) {
m_difficulty = params.get("difficulty", 0);
}
else if (params.contains("difficulty")) {
Log.error(__FUNCTION__, "| Invalid difficulty for theme", m_theme);
return false;
}
m_difficulty = params.get("difficulty", -1);
Log.info("Roguelike theme", m_theme, "| mode", static_cast<int>(m_mode), "| difficulty", m_difficulty);
if (mode == RoguelikeMode::Collectible) {
m_collectible_mode_shopping = params.get("collectible_mode_shopping", false);

View File

@@ -8,11 +8,6 @@
bool asst::RoguelikeDifficultySelectionTaskPlugin::load_params([[maybe_unused]] const json::value& params)
{
// 集成战略 <傀影与猩红孤钻> 的难度选项没有数字标注,暂不支持难度选择功能
if (m_config->get_theme() == RoguelikeTheme::Phantom) {
return false;
}
// 深入调查和月度小队模式不需要选择难度
if (m_config->get_mode() == RoguelikeMode::Exploration || m_config->get_mode() == RoguelikeMode::Squad) {
return false;

View File

@@ -200,15 +200,11 @@ public class AsstRoguelikeTask : AsstBaseTask
{
["mode"] = Mode,
["theme"] = Theme.ToString(),
["difficulty"] = Difficulty,
["starts_count"] = Starts,
["investment_enabled"] = InvestmentEnabled,
};
if (Theme != RoguelikeTheme.Phantom)
{
taskParams["difficulty"] = Difficulty;
}
if (InvestmentEnabled)
{
taskParams["investment_with_more_score"] = InvestmentWithMoreScore;

View File

@@ -28,6 +28,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
using Theme = RoguelikeTheme;
public class RoguelikeSettingsUserControlModel : TaskViewModel
{
@@ -51,45 +52,47 @@ public class RoguelikeSettingsUserControlModel : TaskViewModel
{
int maxThemeDifficulty = GetMaxDifficultyForTheme(RoguelikeTheme);
if (RoguelikeDifficultyList.Count == 0)
var baseList = new List<GenericCombinedData<int>>
{
RoguelikeDifficultyList =
[
new() { Display = "MAX", Value = int.MaxValue }
];
for (int i = 20; i >= -1; --i)
{
RoguelikeDifficultyList.Add(new() { Display = i.ToString(), Value = i });
}
new() { Display = "MAX", Value = int.MaxValue }
};
for (int i = 20; i >= -1; --i)
{
baseList.Add(new() { Display = i.ToString(), Value = i });
}
var sortedItems = RoguelikeDifficultyList
.Select(item => item)
// 基于当前主题的最大难度过滤并排序
var sortedItems = baseList
.Where(item => item.Value == -1 || item.Value == int.MaxValue || item.Value <= maxThemeDifficulty)
.OrderBy(item => item.Value switch
{
-1 => 0,
int.MaxValue => 1,
_ when item.Value <= maxThemeDifficulty => 2 + (maxThemeDifficulty - item.Value),
_ => 2 + maxThemeDifficulty + 1 + (20 - item.Value),
_ => 2 + (maxThemeDifficulty - item.Value),
})
.ToList();
for (int newIndex = 0; newIndex < sortedItems.Count; newIndex++)
RoguelikeDifficultyList.Clear();
foreach (var item in sortedItems)
{
int currentIndex = RoguelikeDifficultyList.IndexOf(sortedItems[newIndex]);
if (currentIndex != newIndex)
{
RoguelikeDifficultyList.Move(currentIndex, newIndex);
}
int value = RoguelikeDifficultyList[newIndex].Value;
RoguelikeDifficultyList[newIndex].Display = value switch
int value = item.Value;
item.Display = value switch
{
-1 => LocalizationHelper.GetString("Current"),
int.MaxValue => "MAX",
0 => "MIN",
_ => value > maxThemeDifficulty ? $"{value} (NONSUPPORT)" : value.ToString(),
_ => value.ToString(),
};
RoguelikeDifficultyList.Add(item);
}
// 验证当前选中的难度是否在新列表中
bool currentDifficultyValid = RoguelikeDifficultyList.Any(item => item.Value == RoguelikeDifficulty);
if (!currentDifficultyValid)
{
// 如果当前难度不在有效列表中,设置为默认值
RoguelikeDifficulty = -1;
}
}
@@ -97,7 +100,7 @@ public class RoguelikeSettingsUserControlModel : TaskViewModel
{
return theme switch
{
Theme.Phantom => 0,
Theme.Phantom => SettingsViewModel.GameSettings.ClientType is "" or "Official" or "Bilibili" ? 15 : 0,
Theme.Mizuki => 18,
Theme.Sami => 15,
Theme.Sarkaz => 18,
@@ -339,15 +342,42 @@ public class RoguelikeSettingsUserControlModel : TaskViewModel
set
{
SetAndNotify(ref _roguelikeTheme, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RoguelikeTheme, value.ToString());
ConfigurationHelper.SetValue(ConfigurationKeys.RoguelikeTheme, Convert.ToString((int)value));
// Check and adjust difficulty if current value is not supported by new theme
int maxDifficulty = GetMaxDifficultyForTheme(value);
if (RoguelikeDifficulty != -1 && RoguelikeDifficulty != int.MaxValue && RoguelikeDifficulty > maxDifficulty)
{
RoguelikeDifficulty = -1; // Set to "Current" if not supported
}
// 确保在更新列表之前先更新相关属性
UpdateRoguelikeDifficultyList();
UpdateRoguelikeModeList();
UpdateRoguelikeSquadList();
UpdateRoguelikeCoreCharList();
// 强制刷新难度显示
OnPropertyChanged(nameof(RoguelikeDifficulty));
}
}
private int _roguelikeDifficulty = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeDifficulty, int.MaxValue.ToString()));
private int _roguelikeDifficulty = GetValidDifficulty();
/// <summary>
/// 获取有效的难度值,处理配置中的无效值
/// </summary>
private static int GetValidDifficulty()
{
string difficultyStr = ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeDifficulty, int.MaxValue.ToString());
if (string.IsNullOrEmpty(difficultyStr) || !int.TryParse(difficultyStr, out int difficulty))
{
// 如果配置值无效,返回默认值并保存
ConfigurationHelper.SetValue(ConfigurationKeys.RoguelikeDifficulty, int.MaxValue.ToString());
return int.MaxValue;
}
return difficulty;
}
public int RoguelikeDifficulty
{

View File

@@ -35,8 +35,7 @@
ItemsSource="{Binding RoguelikeDifficultyList}"
ScrollViewer.CanContentScroll="False"
SelectedValue="{Binding RoguelikeDifficulty}"
SelectedValuePath="Value"
Visibility="{c:Binding 'RoguelikeTheme != task:RoguelikeTheme.Phantom'}" />
SelectedValuePath="Value" />
<hc:ComboBox
Margin="0,5"
hc:InfoElement.Title="{DynamicResource Strategy}"