public SelectEnemyFighterMenu(IInput input, IOutput output, bool allowBack) : base(allowBack, false, false, "Select an enemy type", null, null, null, input, output) { IEnumerable <FighterType> fighterTypes = EnumHelperMethods.GetAllValuesForEnum <FighterType>(); fighterTypes = fighterTypes.Where(ft => ft != FighterType.HumanControlledPlayer && ft != FighterType.HumanControlledEnemy && ft != FighterType.DancerBoss); MenuActions = new List <MenuAction>(); NumberInputMenu numberSubMenu = new NumberInputMenu("select a level for this fighter (between 1 and 5)", input, output, 1, 5); foreach (FighterType fighterType in fighterTypes) { string fighterTypeString = fighterType.ToString(); if (fighterType == FighterType.Barbarian) { MenuAction menuAction = new TypedMenuAction <BattleConfigurationSpecialFlag>(BattleConfigurationSpecialFlag.FirstBarbarianBattle, fighterType + " (first battle)", fighterTypeString, subMenu: numberSubMenu); MenuActions.Add(menuAction); } else { MenuAction menuAction = new TypedMenuAction <BattleConfigurationSpecialFlag>(BattleConfigurationSpecialFlag.None, fighterTypeString, fighterTypeString, subMenu: numberSubMenu); MenuActions.Add(menuAction); } } _hasBeenBuilt = true; }
public void PickNextAreaMethod_SecretOptionsAreHidden_DesertGroupings() { //Arrange MapGrouping <SubRegion, WorldSubRegion> firstGrouping, secondGrouping; MockMenu firstMenu, secondMenu; PickNextArea_GroupingSetup_DesertGroupings(out firstGrouping, out secondGrouping); PickNextArea_MenuSetup_DesertGroupings(WorldSubRegion.DesertCrypt, WorldSubRegion.TempleOfDarkness, out firstMenu, out secondMenu); Team team = PickNextArea_TeamSetup_DesertGroupings(); //Act _decisionManager.PickNextArea(firstGrouping, team); List <TypedMenuAction <WorldSubRegion> > firstMenuActions = firstMenu.MenuActions.OfType <TypedMenuAction <WorldSubRegion> >().ToList(); TypedMenuAction <WorldSubRegion> firstSecretOption = firstMenuActions.Single(ma => ma.Item == WorldSubRegion.Oasis); Assert.True(firstSecretOption.IsHidden); List <TypedMenuAction <WorldSubRegion> > secondMenuActions = secondMenu.MenuActions.OfType <TypedMenuAction <WorldSubRegion> >().ToList(); TypedMenuAction <WorldSubRegion> secondSecretOption = secondMenuActions.Single(ma => ma.Item == WorldSubRegion.BeastTemple); Assert.True(secondSecretOption.IsHidden); }
public void ConvertToMenuSelection_ReturnsCorrectResult_TypedMenuAction([Values(MagicType.Lightning, MagicType.Water, MagicType.None)] MagicType actionMagicType) { TypedMenuAction <MagicType> basicMenuAction = new TypedMenuAction <MagicType>(actionMagicType, DisplayText, move: DoNothingMove, fighter: Fighter); TypedMenuSelection <MagicType> returnedSelection = basicMenuAction.ConvertToMenuSelection() as TypedMenuSelection <MagicType>; Assert.NotNull(returnedSelection); Assert.AreEqual(DisplayText, returnedSelection.Description); Assert.AreEqual(DoNothingMove, returnedSelection.Move); Assert.AreEqual(Fighter, returnedSelection.Target); Assert.AreEqual(actionMagicType, returnedSelection.Item); }
protected override MenuSelection GetSubMenuInput(IMenu subMenu, MenuAction selectedAction) { NumberInputMenuSelection numberInputSelection = subMenu.GetInput() as NumberInputMenuSelection; if (numberInputSelection == null) { throw new InvalidOperationException("SelectEnemyFighterMenu's action's subMenu did not return a MenuAction of type NumberInputMenuSelection"); } TypedMenuAction <BattleConfigurationSpecialFlag> typedSelectedAction = selectedAction as TypedMenuAction <BattleConfigurationSpecialFlag>; if (typedSelectedAction == null) { throw new InvalidOperationException("SelectEnemyFighterMenu should have initialized its menu actions as TypedMenuAction<BattleConfigurationSpecialFlags>"); } FighterType selectedType = (FighterType)Enum.Parse(typeof(FighterType), selectedAction.CommandText); var menuSelection = new SelectEnemyFighterMenuSelection(selectedType, numberInputSelection.Number, typedSelectedAction.Item); return(menuSelection); }