private void GetFighterType() { grpController.Enabled = false; _invokerGameController = new GameController(); FighterFactory newFactory = new FighterFactory(); _fighter = newFactory.CreateFighter(cboFighterType.Text); labelEnergy.DataBindings.Clear(); labelEnergy.DataBindings.Add(new Binding("Text", _fighter, "Energy")); labelLocation.DataBindings.Clear(); labelLocation.DataBindings.Add(new Binding("Text", _fighter, "Location")); labelDamage.DataBindings.Clear(); labelDamage.DataBindings.Add(new Binding("Text", _fighter, "InflictedDamage")); labelUndoItems1.DataBindings.Clear(); labelUndoItems1.DataBindings.Add(new Binding("Text", _invokerGameController, "UndoStackCount")); labelRedoItems1.DataBindings.Clear(); labelRedoItems1.DataBindings.Add(new Binding("Text", _invokerGameController, "RedoStackCount")); grpController.Enabled = true; }
public Engine GetEngine(IEnumerable <IFighterStats> fighters, MatchOptionsDto optionsDto) { var qualified = fighters; if (optionsDto.MaxPowerlevel != null) { qualified = qualified.Where(o => o.Stats.PowerLevel() <= optionsDto.MaxPowerlevel); } if ((optionsDto.BotCount > 0 && optionsDto.BotCount < 1000) && optionsDto.BotPowerlevel > 10) { qualified = qualified .Union(FighterFactory.GetFighters(optionsDto.BotCount.Value, optionsDto.BotPowerlevel.Value)); } return(new Engine( cfg => { cfg.ActionsPerRound = optionsDto.ActionsPerRound; cfg.Battlefield = battlefields.FirstOrDefault(o => o.Id == optionsDto.Battlefield); cfg.Bounds = bounds.FirstOrDefault(o => o.Id == optionsDto.Bounds); cfg.Features = engineFeatures.Where(o => optionsDto.Features.Contains(o.Id)).ToList(); cfg.MoveOrder = moveOrders.FirstOrDefault(o => o.Id == optionsDto.MoveOrder); cfg.PositionGenerator = fighterPositionGenerators.FirstOrDefault(o => o.Id == optionsDto.PositionGenerator); cfg.StaleCondition = staleConditions.FirstOrDefault(o => o.Id == optionsDto.StaleCondition); cfg.WinCondition = winConditions.FirstOrDefault(o => o.Id == optionsDto.WinCondition); cfg.CalculationValues.VisionFactor = 10; return cfg; }, qualified.ToList())); }
public void Constructor_CorrectlySetsDisplayNames_TeamEntirelyComprisedOfNormalEnemies() { IFighter enemy1 = FighterFactory.GetFighter(FighterType.Goblin, 1); IFighter enemy2 = FighterFactory.GetFighter(FighterType.Goblin, 1); IFighter enemy3 = FighterFactory.GetFighter(FighterType.Fairy, 1); IFighter enemy4 = FighterFactory.GetFighter(FighterType.Fairy, 1); List <IFighter> fighters = new List <IFighter> { enemy1, enemy2, enemy3, enemy4, }; Team team = new Team(_menuManager, fighters); for (var i = 0; i < 4; ++i) { IFighter fighter = team.Fighters[i]; char expectedChar = (char)('A' + (i % 2)); Assert.AreEqual($"{expectedChar}", fighter.AppendText); } }
public void ConstructorInitializesExpGiven([Values(FighterType.Fairy, FighterType.Goblin, FighterType.Golem, FighterType.Ogre)] FighterType type, [Values(1, 2, 3)] int level) { var fighter = (EnemyFighter)FighterFactory.GetFighter(type, level); Assert.AreEqual(level * 5, fighter.ExpGivenOnDefeat); }
public void AssignNameBonuses_IgnoresCaseOfFighterName([Values("upper", "lower")] string nameCase) { string danteName = "Dante"; string arrokohName = "Arrokoh"; danteName = nameCase == "upper" ? danteName.ToUpperInvariant() : danteName.ToLowerInvariant(); arrokohName = nameCase == "upper" ? arrokohName.ToUpperInvariant() : arrokohName.ToLowerInvariant(); HumanFighter dante = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1, danteName); HumanFighter arrokoh = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1, arrokohName); int arrokohPreBonusStrength = arrokoh.Strength; int dantePreBonusSpeed = dante.Speed; _decisionManager.AssignNameBonuses(dante, arrokoh); int arrokohPostBonusStrength = arrokoh.Strength; int dantePostBonusSpeed = dante.Speed; int arrokohStrengthBonus = arrokohPostBonusStrength - arrokohPreBonusStrength; Assert.Greater(arrokohStrengthBonus, 0); int danteSpeedBonus = dantePostBonusSpeed - dantePreBonusSpeed; Assert.Greater(danteSpeedBonus, 0); }
public void Team_TestAddRange_CorrectlyUpdatesDisplayNames() { Goblin goblin1 = (Goblin)FighterFactory.GetFighter(FighterType.Goblin, 1); Goblin goblin2 = (Goblin)FighterFactory.GetFighter(FighterType.Goblin, 1); Goblin goblin3 = (Goblin)FighterFactory.GetFighter(FighterType.Goblin, 1); Goblin goblin4 = (Goblin)FighterFactory.GetFighter(FighterType.Goblin, 1); Team testTeam = new Team(TestMenuManager.GetTestMenuManager(), goblin1 ); List <Goblin> goblinsToAdd = new List <Goblin> { goblin2, goblin3, goblin4 }; testTeam.AddRange(goblinsToAdd); for (var i = 0; i < 4; ++i) { EnemyFighter enemy = testTeam.Fighters[i] as EnemyFighter; char expectedAppendedChar = (char)('A' + i); string expectedAppendStr = $"{expectedAppendedChar}"; Assert.AreEqual(expectedAppendStr, enemy?.AppendText); } }
public FighterGrouping GetGrouping(FighterGroupingConfiguration config) { FighterGrouping generatedGrouping = null; ShadeGroupingConfiguration shadeConfig = config as ShadeGroupingConfiguration; if (shadeConfig != null) { List <Shade> generatedFighters = new List <Shade>(); int minLevel = shadeConfig.MinLevel; for (int i = 0; i < shadeConfig.NumberOfShades; ++i) { int level = shadeConfig.MaxLevel == null ? minLevel : _chanceService.WhichEventOccurs(shadeConfig.MaxLevel.Value - minLevel) + minLevel; Shade generatedShade = FighterFactory.GetShade(level); generatedFighters.Add(generatedShade); } generatedGrouping = new ShadeFighterGrouping(_chanceService, generatedFighters.ToArray()); } return(generatedGrouping); }
public void SetUp() { _input = new MockInput(); _output = new MockOutput(); _menuFactory = new MenuFactory(); _manager = new MenuManager(_input, _output, _menuFactory); _logger = new EventLogger(); _playerOne = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "swordsman"); Spell fireSpell = SpellFactory.GetSpell(MagicType.Fire, 1); _playerOne.AddSpell(fireSpell); _playerOne.SetMana(fireSpell.Cost); _playerTwo = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "mage"); _playerThree = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1, "alchemist"); _playerTeam = new Team(_manager, _playerOne, _playerTwo, _playerThree); _enemyTeam = new Team(_manager, new List <IFighter> { FighterFactory.GetFighter(FighterType.Goblin, 1), FighterFactory.GetFighter(FighterType.Goblin, 1), FighterFactory.GetFighter(FighterType.Goblin, 1) }); _manager.InitializeForBattle(_playerTeam, _enemyTeam); }
public void FighterFactory_AutoInitializesHumanFighters_GodRelationshipManagerSet() { FighterFactory.SetGodRelationshipManager(_relationshipManager); _fighter = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1); Assert.DoesNotThrow(() => _relationshipManager.GetFighterRelationshipValue(_fighter, GodEnum.MachineGod)); }
public void SetupMove_PrintsCorrectPrompts() { Fairy fairy = (Fairy)FighterFactory.GetFighter(FighterType.Fairy, 1); _fighter.SetEnemy(fairy); _input.Push("1", "1"); _fighter.SetupMove(_ownTeam, _enemyTeam); MockOutputMessage[] outputs = _output.GetOutputs(); int expectedOutputLength = 5; //menu prompt for both menus, plus "back," "help," and "status" option from target menu expectedOutputLength += fairy.AvailableMoves.Count + _enemyTeam.Fighters.Count; Assert.AreEqual(expectedOutputLength, outputs.Length); int i = 0; MockOutputMessage output = outputs[i++]; Assert.AreEqual($"You are currently selecting a move for {fairy.DisplayName}. What move will you use?\n", output.Message); Assert.AreEqual(ConsoleColor.Cyan, output.Color); for (int j = 0; j < fairy.AvailableMoves.Count; ++j) { BattleMove move = fairy.AvailableMoves[j]; output = outputs[i++]; Assert.AreEqual($"{j + 1}. {move.Description}\n", output.Message); } }
public MachinesManager() { this.pilots = new List <IPilot>(); this.machines = new List <IMachine>(); this.pilotFactory = new PilotFactory(); this.fighterFactory = new FighterFactory(); this.tankFactory = new TankFactory(); }
public void SetUp() { _relationshipManager = new GodRelationshipManager(); _allGodValues = EnumHelperMethods.GetAllValuesForEnum <GodEnum>(); FighterFactory.SetGodRelationshipManager(_relationshipManager); _fighter = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1); }
public void FighterFactoryCorrectlyReturnsShade() { Shade returnedFighter = null; Assert.DoesNotThrow(() => returnedFighter = (Shade)FighterFactory.GetFighter(FighterType.Shade, 1)); Assert.NotNull(returnedFighter); }
public void FighterFactory_CorrectlyRandomizesEggType_IfNoneSpecified() { TestFighterFactory.SetChanceService(_chanceService); _chanceService.PushWhichEventOccurs(0); Egg egg = (Egg)FighterFactory.GetFighter(FighterType.Egg, 1); Assert.AreEqual(Globals.EggMagicTypes[0], egg.MagicType); }
public MachinesManager() { this.pilotFactory = new PilotFactory(); this.pilotRepository = new PilotRepository(); this.fighterFactory = new FighterFactory(); this.tankFactory = new TankFactory(); this.machineRepository = new MashineRepository(); }
public void SetUp() { _fighter = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1); _output = new MockOutput(); _printer = new EventHandlerPrinter(_output); _printer.Subscribe(_fighter); }
public void SetUp() { _menuInput = new MockInput(); _menuOutput = new MockOutput(); _menuManager = new TestMenuManager(_menuInput, _menuOutput); _player = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); Spell fireball = SpellFactory.GetSpell(MagicType.Fire, 1); Spell earthSpell = SpellFactory.GetSpell(MagicType.Earth, 1); _player.AddSpell(fireball); _player.AddSpell(earthSpell); _player.SetMana(fireball.Cost); _playerTeam = new Team(_menuManager, _player); _enemyTeam = new Team(_menuManager, (EnemyFighter)FighterFactory.GetFighter(FighterType.Goblin, 1)); _menu = (Menu)Globals.MenuFactory.GetMenu(MenuType.ChooseAttackTypeMenu, _menuInput, _menuOutput); _menu.Build(_player, _playerTeam, _enemyTeam, null); _fullSpellMenuPrompt = new List <string> { $"Which spell would you like to cast?\n{_player.DisplayName} currently has {_player.CurrentMana} / {_player.MaxMana} Mana\n", }; var spellMenu = (SpellSelectionMenu)Globals.MenuFactory.GetMenu(MenuType.ChooseSpellMenu); spellMenu.Build(_player, _playerTeam, _enemyTeam, null); var spellMenuActions = spellMenu.MenuActions; for (var i = 0; i < spellMenuActions.Count; ++i) { _fullSpellMenuPrompt.Add((i + 1) + ". " + spellMenuActions[i].DisplayText + "\n"); } _fullSpellMenuPrompt.Add(StatusPrompt); _fullSpellMenuPrompt.Add(HelpPrompt); _fullMenuPrompt = new List <string> { "How would you like to fight?\n", "1. attack\n", "2. magic\n", StatusPrompt, HelpPrompt }; _fullTargetMenuPrompt = new List <string> { "Who will you target for this action?\n", "1. " + _enemyTeam.Fighters[0].DisplayName + "\n", StatusPrompt, BackPrompt, HelpPrompt }; }
public MachinesManager() { this.pilots = new Dictionary <string, IPilot>(); this.machines = new Dictionary <string, IMachine>(); this.pilotFactory = new PilotFactory(); this.tankFactory = new TankFactory(); this.fighterFactory = new FighterFactory(); }
static void Main() { FighterFactory.SetGodRelationshipManager(Globals.GodRelationshipManager); EventHandlerPrinter printer = new EventHandlerPrinter(Globals.Output); const string testBattleOptionText = "Test Battle ('test')"; const string campaignOptionText = "Play the \"Campaign\" mode ('campaign')"; //const string demoOptionText = "Play the \"Demo\" mode (fewer battles per region)"; List <MenuAction> menuActions = new List <MenuAction> { new MenuAction(testBattleOptionText, "test"), new MenuAction(campaignOptionText, "campaign"), new MenuAction("exit") }; Menu selectGameplayModeMenu = new Menu(false, false, false, "What mode would you like to play?", null, null, menuActions, Globals.Input, Globals.Output); bool continuer = true; RegionManager regionManager; while (continuer) { Globals.Output.ClearScreen(); regionManager = Globals.RegionManager; selectGameplayModeMenu.Build(null, null, null, null); MenuSelection gameplayModeSelection = selectGameplayModeMenu.GetInput(); switch (gameplayModeSelection.Description) { case testBattleOptionText: Foo(); break; case campaignOptionText: TutorialScreens(); SetupPlayers(out var playerOne, out var playerTwo, printer); MenuManager menuManager = new MenuManager(Globals.Input, Globals.Output, Globals.MenuFactory); var playerTeam = new Team(menuManager, playerOne, playerTwo); BattleManager manager = new BattleManager(Globals.ChanceService, Globals.Input, Globals.Output); Globals.RegionManager.Battle(manager, playerTeam); break; case "exit": continuer = false; break; } } }
public void AssignNameBonuses_CorrectlySetsGodRelationship() { HumanFighter poopyCarrots = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1, "PoopyCarrots"); HumanFighter chesterton = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1, "Chesterton"); _decisionManager.AssignNameBonuses(poopyCarrots, chesterton); Assert.AreEqual(1, _relationshipManager.GetFighterRelationshipValue(poopyCarrots, GodEnum.MercyGod)); Assert.AreEqual(1, _relationshipManager.GetFighterRelationshipValue(chesterton, GodEnum.MalevolentGod)); }
public void AssignNameBonuses_CorrectlySetsPersonalityFlag() { HumanFighter poopyCarrots = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1, "PoopyCarrots"); HumanFighter chesterton = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1, "Chesterton"); _decisionManager.AssignNameBonuses(poopyCarrots, chesterton); Assert.Contains(PersonalityFlag.Heroic, poopyCarrots.PersonalityFlags); Assert.Contains(PersonalityFlag.MorallyFlexible, chesterton.PersonalityFlags); }
private static Team CreateEnemyTeam() { var list = new List <IFighter> { FighterFactory.GetFighter(FighterType.Goblin, 1), FighterFactory.GetFighter(FighterType.Goblin, 1) }; return(new Team(TestMenuManager.GetTestMenuManager(), list)); }
private void BuildMenu(IMenu menu, List <TerrainInteractable> terrainInteractables = null) { _player = (HumanFighter)FighterFactory.GetFighter(FighterType.HumanControlledPlayer, 1); var playerTeam = new Team(_menuManager, _player); _enemy = (EnemyFighter)FighterFactory.GetFighter(FighterType.Goblin, 1); var enemyTeam = new Team(_menuManager, _enemy); menu.Build(_player, playerTeam, enemyTeam, terrainInteractables ?? new List <TerrainInteractable>()); }
private static Team CreateEnemyTeam() { List <IFighter> list = new List <IFighter> { FighterFactory.GetFighter(FighterType.Goblin, 1), FighterFactory.GetFighter(FighterType.Goblin, 1) }; return(new Team(_menuManager, list)); }
public void Constructor_CorrectlyAllowsGroupingInput_AndSetsDisplayNames() { Goblin goblin1 = (Goblin)FighterFactory.GetFighter(FighterType.Goblin, 1); Goblin goblin2 = (Goblin)FighterFactory.GetFighter(FighterType.Goblin, 1); FighterGrouping grouping = new FighterGrouping(goblin1, goblin2); Team team = new Team(TestMenuManager.GetTestMenuManager(), grouping); Assert.AreEqual(2, team.Fighters.Count); Assert.True(team.Fighters.Contains(goblin1)); Assert.True(team.Fighters.Contains(goblin2)); }
public void Setup() { _input = new MockInput(); _output = new MockOutput(); _menuManager = new TestMenuManager(_input, _output); _mockChanceService = new MockChanceService(); TestFighterFactory.SetChanceService(_mockChanceService); FighterFactory.SetInput(_input); FighterFactory.SetOutput(_output); _fighter = (HumanControlledEnemyFighter)FighterFactory.GetFighter(FighterType.HumanControlledEnemy, 1, "hero"); _enemy = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1, "enemy"); }
public void SetUp() { _output = new MockOutput(); _input = new MockInput(); _chanceService = new MockChanceService(); _relationshipManager = new GodRelationshipManager(); FighterFactory.SetGodRelationshipManager(_relationshipManager); _menuFactory = new MockMenuFactory(); _decisionManager = new DecisionManager(_relationshipManager, null, _menuFactory, _input, _output); }
public void SetUp() { _menuInput = new MockInput(); _menuOutput = new MockOutput(); _menuManager = new TestMenuManager(_menuInput, _menuOutput); _enemyTeam = new Team(_menuManager, FighterFactory.GetFighter(FighterType.Goblin, 1)); _player = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1); _playerTeam = new Team(_menuManager, _player); _menu = (SpecialMoveSelectionMenu)Globals.MenuFactory.GetMenu(MenuType.ChooseSpecialAttackMenu, _menuInput, _menuOutput); _menu.Build(_player, _playerTeam, _enemyTeam, null); }
private static IEnumerable <IFighterStats> GetTeamFighters(int teamSize, int teamCount, int powerlevel) { Guid team = Guid.Empty; for (int i = 0; i < teamSize * teamCount; i++) { if (i % teamSize == 0) { team = Guid.NewGuid(); } yield return(FighterFactory.GetFighter(powerlevel, team)); } }
public string ManufactureFighter(string name, double attackPoints, double defensePoints) { if (this.machines.Any(m => m.Name == name)) { return($"{string.Format(OutputMessages.MachineExists, name)}"); } var fighter = (IFighter)FighterFactory.CreateFighter(name, attackPoints, defensePoints); //fighter.ToggleAggressiveMode(); this.machines.Add(fighter); return($"{string.Format(OutputMessages.FighterManufactured, name, fighter.AttackPoints, fighter.DefensePoints, (fighter.AggressiveMode == true ? "ON" : "OFF"))}"); }