From 2c4096ff2c37a464e861462934b787d356df1ddf Mon Sep 17 00:00:00 2001 From: azakhi Date: Mon, 20 Aug 2018 21:19:18 +0300 Subject: [PATCH] Add DisableDropSound block type --- .../DisableDropSoundBlockItem.cs | 23 +++++++++++++++ .../Filtration.ObjectModel.csproj | 1 + .../Services/TestItemFilterBlockTranslator.cs | 29 +++++++++++++++++-- .../Services/ItemFilterBlockTranslator.cs | 8 +++++ .../ViewModels/ItemFilterBlockViewModel.cs | 3 +- 5 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 Filtration.ObjectModel/BlockItemTypes/DisableDropSoundBlockItem.cs diff --git a/Filtration.ObjectModel/BlockItemTypes/DisableDropSoundBlockItem.cs b/Filtration.ObjectModel/BlockItemTypes/DisableDropSoundBlockItem.cs new file mode 100644 index 0000000..73ed861 --- /dev/null +++ b/Filtration.ObjectModel/BlockItemTypes/DisableDropSoundBlockItem.cs @@ -0,0 +1,23 @@ +using System.Windows.Media; +using Filtration.ObjectModel.BlockItemBaseTypes; + +namespace Filtration.ObjectModel.BlockItemTypes +{ + public sealed class DisableDropSoundBlockItem : BooleanBlockItem, IAudioVisualBlockItem + { + public DisableDropSoundBlockItem() + { + } + + public DisableDropSoundBlockItem(bool booleanValue) : base(booleanValue) + { + } + + public override string PrefixText => "DisableDropSound"; + public override string DisplayHeading => "Disable Drop Sound"; + public override Color SummaryBackgroundColor => Colors.Transparent; + public override Color SummaryTextColor => Colors.Transparent; + public override int SortOrder => 27; + + } +} diff --git a/Filtration.ObjectModel/Filtration.ObjectModel.csproj b/Filtration.ObjectModel/Filtration.ObjectModel.csproj index 72601b3..6d7ae71 100644 --- a/Filtration.ObjectModel/Filtration.ObjectModel.csproj +++ b/Filtration.ObjectModel/Filtration.ObjectModel.csproj @@ -61,6 +61,7 @@ + diff --git a/Filtration.Parser.Tests/Services/TestItemFilterBlockTranslator.cs b/Filtration.Parser.Tests/Services/TestItemFilterBlockTranslator.cs index 2b73cd3..7c1d148 100644 --- a/Filtration.Parser.Tests/Services/TestItemFilterBlockTranslator.cs +++ b/Filtration.Parser.Tests/Services/TestItemFilterBlockTranslator.cs @@ -874,7 +874,24 @@ namespace Filtration.Parser.Tests.Services Assert.AreEqual("7", blockItem.Value); Assert.AreEqual(95, blockItem.SecondValue); } - + + [Test] + public void TranslateStringToItemFilterBlock_DisableDropSound_ReturnsCorrectObject() + { + // Arrange + var inputString = "Show" + Environment.NewLine + + " DisableDropSound True"; + + // Act + var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); + + // Assert + + Assert.AreEqual(1, result.BlockItems.Count(b => b is DisableDropSoundBlockItem)); + var blockItem = result.BlockItems.OfType().First(); + Assert.IsTrue(blockItem.BooleanValue); + } + [Test] public void TranslateStringToItemFilterBlock_Everything_ReturnsCorrectObject() { @@ -907,7 +924,8 @@ namespace Filtration.Parser.Tests.Services " SetBackgroundColor 255 100 5" + Environment.NewLine + " SetBorderColor 0 0 0" + Environment.NewLine + " SetFontSize 50" + Environment.NewLine + - " PlayAlertSound 3" + Environment.NewLine; + " PlayAlertSound 3" + Environment.NewLine + + " DisableDropSound False" + Environment.NewLine; // Act var result = _testUtility.Translator.TranslateStringToItemFilterBlock(inputString, _testUtility.MockItemFilterScript); @@ -1009,6 +1027,9 @@ namespace Filtration.Parser.Tests.Services var soundblockItem = result.BlockItems.OfType().First(); Assert.AreEqual("3", soundblockItem.Value); Assert.AreEqual(79, soundblockItem.SecondValue); + + var disableDropSoundBlockItem = result.BlockItems.OfType().First(); + Assert.IsFalse(disableDropSoundBlockItem.BooleanValue); } [Test] @@ -1861,7 +1882,8 @@ namespace Filtration.Parser.Tests.Services " SetBackgroundColor 0 0 0" + Environment.NewLine + " SetBorderColor 255 1 254" + Environment.NewLine + " SetFontSize 50" + Environment.NewLine + - " PlayAlertSound 6 90"; + " PlayAlertSound 6 90" + Environment.NewLine + + " DisableDropSound True"; _testUtility.TestBlock.BlockItems.Add(new ActionBlockItem(BlockAction.Show)); _testUtility.TestBlock.BlockItems.Add(new IdentifiedBlockItem(true)); @@ -1904,6 +1926,7 @@ namespace Filtration.Parser.Tests.Services _testUtility.TestBlock.BlockItems.Add(new ShaperItemBlockItem(false)); _testUtility.TestBlock.BlockItems.Add(new ShapedMapBlockItem(true)); _testUtility.TestBlock.BlockItems.Add(new ElderMapBlockItem(true)); + _testUtility.TestBlock.BlockItems.Add(new DisableDropSoundBlockItem(true)); // Act var result = _testUtility.Translator.TranslateItemFilterBlockToString(_testUtility.TestBlock); diff --git a/Filtration.Parser/Services/ItemFilterBlockTranslator.cs b/Filtration.Parser/Services/ItemFilterBlockTranslator.cs index 81b4b17..a568ed7 100644 --- a/Filtration.Parser/Services/ItemFilterBlockTranslator.cs +++ b/Filtration.Parser/Services/ItemFilterBlockTranslator.cs @@ -286,6 +286,14 @@ namespace Filtration.Parser.Services AddBooleanItemToBlockItems(block, trimmedLine); break; } + case "DisableDropSound": + { + // Only ever use the last DisableDropSound item encountered as multiples aren't valid. + RemoveExistingBlockItemsOfType(block); + + AddBooleanItemToBlockItems(block, trimmedLine); + break; + } } } diff --git a/Filtration/ViewModels/ItemFilterBlockViewModel.cs b/Filtration/ViewModels/ItemFilterBlockViewModel.cs index 7aaca8e..62b43b2 100644 --- a/Filtration/ViewModels/ItemFilterBlockViewModel.cs +++ b/Filtration/ViewModels/ItemFilterBlockViewModel.cs @@ -173,7 +173,8 @@ namespace Filtration.ViewModels typeof (BorderColorBlockItem), typeof (FontSizeBlockItem), typeof (SoundBlockItem), - typeof (PositionalSoundBlockItem) + typeof (PositionalSoundBlockItem), + typeof (DisableDropSoundBlockItem) }; public bool BlockEnabled