From a2f8fdeb2c131ff9654d82093ab98388250bd296 Mon Sep 17 00:00:00 2001 From: ABA2396 <2396806385@qq.com> Date: Sat, 4 Jun 2022 20:10:03 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat.=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=9D=90?= =?UTF-8?q?=E6=96=99=E4=B8=8B=E6=8B=89=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserControl/FightSettingsUserControl.xaml | 27 +++++++--- .../FightSettingsUserControl.xaml.cs | 54 +++++++++++++++++++ 2 files changed, 73 insertions(+), 8 deletions(-) diff --git a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml index 66fd08804a..7d479b5217 100644 --- a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml +++ b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml @@ -15,6 +15,7 @@ + @@ -33,20 +34,30 @@ - - - + + + + + + + + - - + + SelectedValue="{Binding StageList}"/> \ No newline at end of file diff --git a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs index 85c97432f2..ea46a3de4e 100644 --- a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs +++ b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs @@ -9,6 +9,8 @@ // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY +using System; +using System.Collections.ObjectModel; using System.Windows.Controls; namespace MeoAsstGui @@ -21,6 +23,58 @@ namespace MeoAsstGui public FightSettingsUserControl() { InitializeComponent(); + BindingEnumData(); + ComboBoxCtr.ItemsSource = DropsList; + } + + public ObservableCollection DropsList { get; set; } = new ObservableCollection(); + + private void BindingEnumData() + { + foreach (Drops drop in Enum.GetValues(typeof(Drops))) + { + DropsList.Add(drop); + } + } + + public enum Drops + { + 固源岩 = 0, + 晶体元件 = 1, + 全新装置 = 2, + 固源岩组 = 3 + } + + private void ComboBoxCtr_TextChanged(object sender, TextChangedEventArgs e) + { + { + string str = ComboBoxCtr.Text.ToString(); + ComboBoxCtr.IsDropDownOpen = false; + DropsList.Clear(); + + if (string.IsNullOrEmpty(str)) + { + BindingEnumData(); + return; + } + + foreach (Drops drop in Enum.GetValues(typeof(Drops))) + { + var enumStr = drop.ToString(); + if (enumStr.Contains(str)) + DropsList.Add(drop); + } + + if (DropsList.Count > 0) + { + ComboBoxCtr.ItemsSource = DropsList; + ComboBoxCtr.IsDropDownOpen = true; + } + else + { + BindingEnumData(); + } + } } } } From f3f34e52145e427dc42f2a3672d42fad4055bf21 Mon Sep 17 00:00:00 2001 From: ABA2396 <2396806385@qq.com> Date: Sun, 5 Jun 2022 00:36:56 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat.=E5=AE=8C=E6=88=90=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E6=A8=A1=E7=B3=8A=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserControl/FightSettingsUserControl.xaml | 3 + .../FightSettingsUserControl.xaml.cs | 62 ++++++++----------- 2 files changed, 28 insertions(+), 37 deletions(-) diff --git a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml index 7d479b5217..acaa971ecd 100644 --- a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml +++ b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml @@ -38,7 +38,10 @@ diff --git a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs index ea46a3de4e..35e85a21b8 100644 --- a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs +++ b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs @@ -10,6 +10,7 @@ // but WITHOUT ANY WARRANTY using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows.Controls; @@ -23,57 +24,44 @@ namespace MeoAsstGui public FightSettingsUserControl() { InitializeComponent(); - BindingEnumData(); - ComboBoxCtr.ItemsSource = DropsList; + InitDrops(); + ComboBoxCtr.ItemsSource = Drops; } - public ObservableCollection DropsList { get; set; } = new ObservableCollection(); + public ObservableCollection Drops { get; set; } = new ObservableCollection(); - private void BindingEnumData() + private void InitDrops() { - foreach (Drops drop in Enum.GetValues(typeof(Drops))) + for (int i = 0; i < 100; i++) { - DropsList.Add(drop); + Drops.Add(new CombData { Display = i.ToString(), Value = (i * 2).ToString() }); } } - public enum Drops - { - 固源岩 = 0, - 晶体元件 = 1, - 全新装置 = 2, - 固源岩组 = 3 - } + public ObservableCollection DropsList { get; set; } = new ObservableCollection(); private void ComboBoxCtr_TextChanged(object sender, TextChangedEventArgs e) { + string str = ComboBoxCtr.Text.ToString(); + DropsList.Clear(); + + if (string.IsNullOrEmpty(str)) { - string str = ComboBoxCtr.Text.ToString(); - ComboBoxCtr.IsDropDownOpen = false; - DropsList.Clear(); + ComboBoxCtr.ItemsSource = Drops; + return; + } - if (string.IsNullOrEmpty(str)) - { - BindingEnumData(); - return; - } + foreach (CombData drop in Drops) + { + var enumStr = drop.Display; + if (enumStr.Contains(str)) + DropsList.Add(drop); + } - foreach (Drops drop in Enum.GetValues(typeof(Drops))) - { - var enumStr = drop.ToString(); - if (enumStr.Contains(str)) - DropsList.Add(drop); - } - - if (DropsList.Count > 0) - { - ComboBoxCtr.ItemsSource = DropsList; - ComboBoxCtr.IsDropDownOpen = true; - } - else - { - BindingEnumData(); - } + if (DropsList.Count > 0) + { + ComboBoxCtr.ItemsSource = DropsList; + ComboBoxCtr.IsDropDownOpen = true; } } } From 843af4b2af2dd15f7617c2f5a302dce35fb7bec6 Mon Sep 17 00:00:00 2001 From: ABA2396 <2396806385@qq.com> Date: Sun, 5 Jun 2022 01:46:53 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat.=E5=AF=BC=E5=85=A5=E4=BA=86=E6=8E=89?= =?UTF-8?q?=E8=90=BD=E7=89=A9=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FightSettingsUserControl.xaml.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs index 35e85a21b8..3ed8e91715 100644 --- a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs +++ b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs @@ -9,10 +9,11 @@ // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY -using System; -using System.Collections.Generic; +using System.IO; using System.Collections.ObjectModel; using System.Windows.Controls; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace MeoAsstGui { @@ -21,21 +22,31 @@ namespace MeoAsstGui /// public partial class FightSettingsUserControl : UserControl { + private static readonly string _DropsFilename = System.Environment.CurrentDirectory + "\\resource\\item_index.json"; + public FightSettingsUserControl() { InitializeComponent(); + InitDrops(); ComboBoxCtr.ItemsSource = Drops; } public ObservableCollection Drops { get; set; } = new ObservableCollection(); + private void InitDrops() { - for (int i = 0; i < 100; i++) + string jsonStr = File.ReadAllText(_DropsFilename); + var reader = (JObject)JsonConvert.DeserializeObject(jsonStr); + foreach (var item in reader) { - Drops.Add(new CombData { Display = i.ToString(), Value = (i * 2).ToString() }); + var val = item.Key; + var dis = item.Value["name"].ToString(); + Drops.Add(new CombData { Display = dis, Value = val }); } + + } public ObservableCollection DropsList { get; set; } = new ObservableCollection(); From 54e10f3599d47f6b3813bffda3059d15b371425b Mon Sep 17 00:00:00 2001 From: MistEO Date: Mon, 6 Jun 2022 20:26:56 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat.=E6=96=B0=E5=A2=9E=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=88=B7=E7=90=86=E6=99=BA=E6=8C=87=E5=AE=9A=E6=9D=90=E6=96=99?= =?UTF-8?q?=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/集成文档.md | 6 ++++ src/MeoAssistant/FightTask.cpp | 8 +++++ src/MeoAssistant/StageDropsTaskPlugin.cpp | 36 ++++++++++++++++++----- src/MeoAssistant/StageDropsTaskPlugin.h | 4 +++ 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/docs/集成文档.md b/docs/集成文档.md index c530f89a95..3648294adb 100644 --- a/docs/集成文档.md +++ b/docs/集成文档.md @@ -45,6 +45,12 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p "medicine": int, // 最大使用理智药数量,可选,默认 0 "stone": int, // 最大吃石头数量,可选,默认 0 "times": int, // 指定次数,可选,默认无穷大 + "quantity": { // 指定掉落数量,可选,默认不指定 + "30011": int, // key - item_id, value 数量. key 可参考 resource/item_index.json 文件 + "30062": int // 是或的关系 + }, + /* 以上全部是或的关系,即任一达到即停止任务 */ + "report_to_penguin": bool, // 是否汇报企鹅数据,可选,默认 false "penguin_id": string, // 企鹅数据汇报 id, 可选,默认为空。仅在 report_to_penguin 为 true 时有效 "server": string // 服务器,可选,默认 "CN", 会影响掉落识别及上传 diff --git a/src/MeoAssistant/FightTask.cpp b/src/MeoAssistant/FightTask.cpp index 98b7f3df9d..35aaf42ade 100644 --- a/src/MeoAssistant/FightTask.cpp +++ b/src/MeoAssistant/FightTask.cpp @@ -53,6 +53,14 @@ bool asst::FightTask::set_params(const json::value& params) std::string penguin_id = params.get("penguin_id", ""); std::string server = params.get("server", "CN"); + if (params.contains("quantity")) { + std::unordered_map specify_quantity; + for (const auto& [item_id, quantity] : params.at("drops").as_object()) { + specify_quantity.insert_or_assign(item_id, quantity.as_integer()); + } + m_stage_drops_plugin_ptr->set_specify_quantity(specify_quantity); + } + if (!m_runned) { if (stage.empty()) { m_start_up_task_ptr->set_enable(false); diff --git a/src/MeoAssistant/StageDropsTaskPlugin.cpp b/src/MeoAssistant/StageDropsTaskPlugin.cpp index d392e52051..283a442c84 100644 --- a/src/MeoAssistant/StageDropsTaskPlugin.cpp +++ b/src/MeoAssistant/StageDropsTaskPlugin.cpp @@ -61,6 +61,12 @@ bool asst::StageDropsTaskPlugin::set_server(std::string server) return true; } +bool asst::StageDropsTaskPlugin::set_specify_quantity(std::unordered_map quantity) +{ + m_specify_quantity = std::move(quantity); + return true; +} + bool asst::StageDropsTaskPlugin::_run() { LogTraceFunction; @@ -75,7 +81,9 @@ bool asst::StageDropsTaskPlugin::_run() } drop_info_callback(); - check_stage_valid(); + if (!check_stage_valid() || check_specify_quantity()) { + stop_task(); + } if (m_enable_penguid) { auto upload_future = std::async( @@ -257,12 +265,26 @@ bool asst::StageDropsTaskPlugin::check_stage_valid() info["why"] = "EX关卡"; callback(AsstMsg::SubTaskError, info); - m_cast_ptr->set_times_limit("StartButton1", 0) - .set_times_limit("StartButton2", 0) - .set_times_limit("MedicineConfirm", 0) - .set_times_limit("StoneConfirm", 0); - - return true; + return false; } return true; } + +bool asst::StageDropsTaskPlugin::check_specify_quantity() const +{ + for (const auto& [id, quantity] : m_specify_quantity) { + if (auto find_iter = m_drop_stats.find(id); + find_iter != m_drop_stats.end() && find_iter->second >= quantity) { + return true; + } + } + return false; +} + +void asst::StageDropsTaskPlugin::stop_task() +{ + m_cast_ptr->set_times_limit("StartButton1", 0) + .set_times_limit("StartButton2", 0) + .set_times_limit("MedicineConfirm", 0) + .set_times_limit("StoneConfirm", 0); +} diff --git a/src/MeoAssistant/StageDropsTaskPlugin.h b/src/MeoAssistant/StageDropsTaskPlugin.h index 716fe54efa..13a7b68a7d 100644 --- a/src/MeoAssistant/StageDropsTaskPlugin.h +++ b/src/MeoAssistant/StageDropsTaskPlugin.h @@ -24,6 +24,7 @@ namespace asst bool set_enable_penguid(bool enable); bool set_penguin_id(std::string id); bool set_server(std::string server); + bool set_specify_quantity(std::unordered_map quantity); private: virtual bool _run() override; @@ -31,6 +32,8 @@ namespace asst void drop_info_callback(); void set_startbutton_delay(); bool check_stage_valid(); + bool check_specify_quantity() const; + void stop_task(); void upload_to_penguin(); static constexpr int64_t RecognizationTimeOffset = 20; @@ -48,5 +51,6 @@ namespace asst bool m_enable_penguid = false; std::string m_penguin_id; std::string m_server = "CN"; + std::unordered_map m_specify_quantity; }; } From 0bc0757e34debd4fa2cd252138b56f94c7706910 Mon Sep 17 00:00:00 2001 From: MistEO Date: Tue, 7 Jun 2022 01:15:45 +0800 Subject: [PATCH 5/5] =?UTF-8?q?feat.=E6=8C=87=E5=AE=9A=E6=8E=89=E8=90=BD?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E9=80=82=E9=85=8D=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/集成文档.md | 2 +- src/MeoAssistant/FightTask.cpp | 8 +- src/MeoAsstGui/Helper/AsstProxy.cs | 7 +- .../UserControl/FightSettingsUserControl.xaml | 20 ++-- .../FightSettingsUserControl.xaml.cs | 49 ---------- .../ViewModels/TaskQueueViewModel.cs | 93 ++++++++++++++++--- 6 files changed, 98 insertions(+), 81 deletions(-) diff --git a/docs/集成文档.md b/docs/集成文档.md index 3648294adb..89978650a4 100644 --- a/docs/集成文档.md +++ b/docs/集成文档.md @@ -45,7 +45,7 @@ TaskId ASSTAPI AsstAppendTask(AsstHandle handle, const char* type, const char* p "medicine": int, // 最大使用理智药数量,可选,默认 0 "stone": int, // 最大吃石头数量,可选,默认 0 "times": int, // 指定次数,可选,默认无穷大 - "quantity": { // 指定掉落数量,可选,默认不指定 + "drops": { // 指定掉落数量,可选,默认不指定 "30011": int, // key - item_id, value 数量. key 可参考 resource/item_index.json 文件 "30062": int // 是或的关系 }, diff --git a/src/MeoAssistant/FightTask.cpp b/src/MeoAssistant/FightTask.cpp index 35aaf42ade..4c97cc49c8 100644 --- a/src/MeoAssistant/FightTask.cpp +++ b/src/MeoAssistant/FightTask.cpp @@ -53,12 +53,12 @@ bool asst::FightTask::set_params(const json::value& params) std::string penguin_id = params.get("penguin_id", ""); std::string server = params.get("server", "CN"); - if (params.contains("quantity")) { - std::unordered_map specify_quantity; + if (params.contains("drops")) { + std::unordered_map drops; for (const auto& [item_id, quantity] : params.at("drops").as_object()) { - specify_quantity.insert_or_assign(item_id, quantity.as_integer()); + drops.insert_or_assign(item_id, quantity.as_integer()); } - m_stage_drops_plugin_ptr->set_specify_quantity(specify_quantity); + m_stage_drops_plugin_ptr->set_specify_quantity(drops); } if (!m_runned) { diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index d8ab552425..ef352ff8f9 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -642,7 +642,7 @@ namespace MeoAsstGui return AsstAppendTask(_handle, type, JsonConvert.SerializeObject(task_params)) != 0; } - public bool AsstAppendFight(string stage, int max_medicine, int max_stone, int max_times) + public bool AsstAppendFight(string stage, int max_medicine, int max_stone, int max_times, string drops_item_id, int drops_item_quantity) { var task_params = new JObject(); task_params["stage"] = stage; @@ -650,6 +650,11 @@ namespace MeoAsstGui task_params["stone"] = max_stone; task_params["times"] = max_times; task_params["report_to_penguin"] = true; + if (drops_item_quantity != 0) + { + task_params["drops"] = new JObject(); + task_params["drops"][drops_item_id] = drops_item_quantity; + } var settings = _container.Get(); task_params["penguin_id"] = settings.PenguinId; task_params["server"] = "CN"; diff --git a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml index acaa971ecd..961a4c78fd 100644 --- a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml +++ b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml @@ -34,22 +34,20 @@ - - + - + ItemsSource="{Binding DropsList}" + SelectedValue="{Binding DropsItemId}" /> - - + + @@ -60,7 +58,7 @@ ItemsSource="{Binding StageList}" DisplayMemberPath="Display" SelectedValuePath="Value" - SelectedValue="{Binding StageList}"/> + SelectedValue="{Binding Stage}" /> \ No newline at end of file diff --git a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs index 3ed8e91715..6c3890ba77 100644 --- a/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs +++ b/src/MeoAsstGui/UserControl/FightSettingsUserControl.xaml.cs @@ -22,58 +22,9 @@ namespace MeoAsstGui /// public partial class FightSettingsUserControl : UserControl { - private static readonly string _DropsFilename = System.Environment.CurrentDirectory + "\\resource\\item_index.json"; - public FightSettingsUserControl() { InitializeComponent(); - - InitDrops(); - ComboBoxCtr.ItemsSource = Drops; - } - - public ObservableCollection Drops { get; set; } = new ObservableCollection(); - - - private void InitDrops() - { - string jsonStr = File.ReadAllText(_DropsFilename); - var reader = (JObject)JsonConvert.DeserializeObject(jsonStr); - foreach (var item in reader) - { - var val = item.Key; - var dis = item.Value["name"].ToString(); - Drops.Add(new CombData { Display = dis, Value = val }); - } - - - } - - public ObservableCollection DropsList { get; set; } = new ObservableCollection(); - - private void ComboBoxCtr_TextChanged(object sender, TextChangedEventArgs e) - { - string str = ComboBoxCtr.Text.ToString(); - DropsList.Clear(); - - if (string.IsNullOrEmpty(str)) - { - ComboBoxCtr.ItemsSource = Drops; - return; - } - - foreach (CombData drop in Drops) - { - var enumStr = drop.Display; - if (enumStr.Contains(str)) - DropsList.Add(drop); - } - - if (DropsList.Count > 0) - { - ComboBoxCtr.ItemsSource = DropsList; - ComboBoxCtr.IsDropDownOpen = true; - } } } } diff --git a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs index 9e56fe558b..bfa2a91724 100644 --- a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs +++ b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs @@ -12,8 +12,12 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.IO; using System.Threading.Tasks; using System.Windows; +using System.Windows.Controls; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Stylet; using StyletIoC; @@ -44,6 +48,7 @@ namespace MeoAsstGui } private Visibility _visible = Visibility.Collapsed; + public Visibility Visible { get { return _visible; } @@ -127,7 +132,7 @@ namespace MeoAsstGui new CombData { Display = "SV-7", Value = "SV-7" }, new CombData { Display = "SV-8", Value = "SV-8" }, new CombData { Display = "SV-9", Value = "SV-9" }, - + // “愚人号” 活动关卡 //new CombData { Display = "SN-8", Value = "SN-8" }, //new CombData { Display = "SN-9", Value = "SN-9" }, @@ -136,7 +141,9 @@ namespace MeoAsstGui //// “风雪过境” 活动关卡 //new CombData { Display = "BI-7", Value = "BI-7" }, //new CombData { Display = "BI-8", Value = "BI-8" } - }; + }; + + InitDrops(); UpdateDatePrompt(); } @@ -323,8 +330,10 @@ namespace MeoAsstGui ViewStatusStorage.Set("MainFunction.UseMedicine.Quantity", MedicineNumber); // 吃石头颗数 ViewStatusStorage.Set("MainFunction.UseStone.Quantity", StoneNumber); - // 指定刷关次数 - ViewStatusStorage.Set("MainFunction.TimesLimited.Quantity", MaxTimes); + // 指定掉落材料 + ViewStatusStorage.Set("MainFunction.Drops.ItemId", DropsItemId); + // 指定掉落材料数量 + ViewStatusStorage.Set("MainFunction.Drops.Quantity", DropsQuantity); } private bool appendFight() @@ -346,16 +355,24 @@ namespace MeoAsstGui } } int times = int.MaxValue; - if (HasTimesLimited) + if (IsSpecifiedDrops) { - if (!int.TryParse(MaxTimes, out times)) + if (!int.TryParse(DropsQuantity, out times)) { times = 0; } } + int drops_quantity = 0; + if (IsSpecifiedDrops) + { + if (!int.TryParse(DropsQuantity, out drops_quantity)) + { + drops_quantity = 0; + } + } var asstProxy = _container.Get(); - return asstProxy.AsstAppendFight(Stage, medicine, stone, times); + return asstProxy.AsstAppendFight(Stage, medicine, stone, times, DropsItemId, drops_quantity); } private bool appendInfrast() @@ -574,25 +591,71 @@ namespace MeoAsstGui } } - private bool _hasTimesLimited; + private bool _isSpecifiedDrops = System.Convert.ToBoolean(ViewStatusStorage.Get("MainFunction.Drops.Enable", bool.FalseString)); - public bool HasTimesLimited + public bool IsSpecifiedDrops { - get { return _hasTimesLimited; } + get { return _isSpecifiedDrops; } set { - SetAndNotify(ref _hasTimesLimited, value); + SetAndNotify(ref _isSpecifiedDrops, value); + ViewStatusStorage.Set("MainFunction.Drops.Enable", value.ToString()); } } - private string _maxTimes = ViewStatusStorage.Get("MainFunction.TimesLimited.Quantity", "5"); + private static readonly string _DropsFilename = System.Environment.CurrentDirectory + "\\resource\\item_index.json"; - public string MaxTimes + public List AllDrops { get; set; } = new List(); + + private void InitDrops() { - get { return _maxTimes; } + string jsonStr = File.ReadAllText(_DropsFilename); + var reader = (JObject)JsonConvert.DeserializeObject(jsonStr); + foreach (var item in reader) + { + var val = item.Key; + if (!int.TryParse(val, out _)) // 不是数字的东西都是正常关卡不会掉的(大概吧) + { + continue; + } + var dis = item.Value["name"].ToString(); + if (dis.EndsWith("双芯片") || dis.EndsWith("寻访凭证") || dis.EndsWith("加固建材") + || dis.EndsWith("许可") || dis == "资质凭证" || dis == "高级凭证" || dis == "演习券" + || dis.Contains("源石") || dis == "D32钢" || dis == "双极纳米片" || dis == "聚合剂" || dis == "晶体电子单元") + { + continue; + } + + AllDrops.Add(new CombData { Display = dis, Value = val }); + } + AllDrops.Sort((a, b) => + { + return a.Value.CompareTo(b.Value); + }); + DropsList = new ObservableCollection(AllDrops); + } + + public ObservableCollection DropsList { get; set; } + + private string _dropsItemId = ViewStatusStorage.Get("MainFunction.Drops.ItemId", "0"); + + public string DropsItemId + { + get { return _dropsItemId; } set { - SetAndNotify(ref _maxTimes, value); + SetAndNotify(ref _dropsItemId, value); + } + } + + private string _dropsQuantity = ViewStatusStorage.Get("MainFunction.Drops.Quantity", "5"); + + public string DropsQuantity + { + get { return _dropsQuantity; } + set + { + SetAndNotify(ref _dropsQuantity, value); } } }