public static Robot GetRobot(RobotDifficulty difficulty, DiceService diceService) { var damageMaximum = 0; var healthMaximum = 0; switch (difficulty) { case RobotDifficulty.Difficult: { damageMaximum = 50; healthMaximum = 50; break; } case RobotDifficulty.Moderate: { damageMaximum = 35; healthMaximum = 35; break; } case RobotDifficulty.Easy: { damageMaximum = 20; healthMaximum = 20; break; } } var robot = new Robot { Name = "Robot", Difficulty = difficulty, Health = diceService.Roll(healthMaximum), DamageMaximum = diceService.Roll(damageMaximum) }; return robot; }
private static BattleResult performBattle( Hero hero, Robot robot, DiceService diceService) { var battleResult = new BattleResult(); var round = 0; while (hero.Health > 0 && robot.Health > 0) { var battleRound = new BattleRound(); round++; battleRound.RoundNumber = round; battleRound.RobotHealthBeginning = robot.Health; battleRound.HeroDamageInflicted = robot.Defend(hero.Attack(diceService)); battleRound.RobotHealth = robot.Health; battleRound.HeroHealthBeginning = hero.Health; battleRound.RobotDamageInflicted = hero.Defend(robot.Attack(hero, diceService)); battleRound.HeroHealth = hero.Health; battleResult.BattleRounds.Add(battleRound); } if (hero.Health > 0) { hero.MovesRemaining--; hero.Wins++; hero.Health = hero.Health; battleResult.CreditsEarned = hero.CollectCredits(diceService, robot.Difficulty); battleResult.BonusMovesAwarded = hero.AwardBonusMoves(diceService, robot.Difficulty); } else { hero.MovesRemaining = 0; hero.Losses--; hero.Health = 0; } battleResult.Hero = hero; battleResult.Robot = robot; return battleResult; }