public void Handle(ItemSelectedMessage message) { InvokeScript("update", new List <Tuple <string, string> > { Tuple.Create("chose", string.Join("|", HeroSelectorViewModels .Where(vm => vm.SelectedItemInfo != null) .Select(vm => vm.SelectedItemInfo.Id))), Tuple.Create("map", BpStatus.Map), Tuple.Create("lang", App.Language) }); if (BpStatus.StepSelectedIndex.Contains(message.SelectorId) || // 修改本轮选过的英雄 !_listBpSteps[BpStatus.CurrentStep].Contains(message.SelectorId)) // 修改其他轮选过的英雄 { // 修改英雄选择,无需处理 } else { // 新英雄选择,判断本轮是否已选够英雄 BpStatus.StepSelectedIndex.Add(message.SelectorId); if (BpStatus.StepSelectedIndex.Count == _listBpSteps[BpStatus.CurrentStep].Count) { // 选够了,下一步 BpStatus.CurrentStep++; ProcessStep(); } } }
public void Handle(ItemSelectedMessage message) { try { if (message.ItemInfo == null) { if (IsAutoMode || BpStatus.CurrentStep <= 0) { return; } if (BpStatus.StepSelectedIndex.Any()) { foreach (var i in _listBpSteps[BpStatus.CurrentStep]) { var vm = HeroSelectorViewModels.First(v => v.Id == i); vm.Selected = false; vm.SelectedItemInfo = null; } BpStatus.StepSelectedIndex.Clear(); } else { foreach (var i in _listBpSteps[BpStatus.CurrentStep]) { var vm = HeroSelectorViewModels.First(v => v.Id == i); vm.InteractionVisible = false; } BpStatus.CurrentStep--; { var i = _listBpSteps[BpStatus.CurrentStep].Last(); var vm = HeroSelectorViewModels.First(v => v.Id == i); vm.Selected = false; vm.SelectedItemInfo = null; if (_listBpSteps[BpStatus.CurrentStep].Count > 1) { var vmSelected = HeroSelectorViewModels.First(v => v.Id != _listBpSteps[BpStatus.CurrentStep].First()); if (vmSelected != null) { BpStatus.StepSelectedIndex = new HashSet <int>() { vmSelected.Id } } ; else { BpStatus.StepSelectedIndex.Clear(); } } else { BpStatus.StepSelectedIndex.Clear(); } } } InvokeScript("update", new List <Tuple <string, string> > { Tuple.Create("chose", string.Join("|", HeroSelectorViewModels .Where(vm => vm.SelectedItemInfo != null) .Select(vm => vm.SelectedItemInfo.Id))), Tuple.Create("map", BpStatus.Map), Tuple.Create("lang", App.Language) }); return; } var idList = new List <string>(); foreach (var vm in HeroSelectorViewModels) { if (vm.SelectedItemInfo != null) { idList.Add(vm.SelectedItemInfo.Id); } } if (App.CustomConfigurationSettings.UploadBanSample && BanSteps.Contains(message.SelectorId) && !string.IsNullOrEmpty(message.ItemInfo?.Id) && message.ItemInfo.Id != "0") { if (_lastIds[message.SelectorId] != message.ItemInfo?.Id) { Task.Run(() => UploadSampleAsync(message.ItemInfo.Id, BanSteps.IndexOf(message.SelectorId))); _lastIds[message.SelectorId] = message.ItemInfo?.Id; } } InvokeScript("update", new List <Tuple <string, string> > { Tuple.Create("chose", string.Join("|", idList)), Tuple.Create("map", BpStatus.Map), Tuple.Create("lang", App.Language) }); if (BpStatus.StepSelectedIndex.Contains(message.SelectorId) || // 修改本轮选过的英雄 !_listBpSteps[BpStatus.CurrentStep].Contains(message.SelectorId)) // 修改其他轮选过的英雄 { // 修改英雄选择,无需处理 } else { // 新英雄选择,判断本轮是否已选够英雄 BpStatus.StepSelectedIndex.Add(message.SelectorId); if (BpStatus.StepSelectedIndex.Count == _listBpSteps[BpStatus.CurrentStep].Count) { // 选够了,下一步 if (BpStatus.CurrentStep < 9) { BpStatus.CurrentStep++; ProcessStep(); } } } } catch (Exception) { // TODO Ignore for test, please remove the catch } }