//Rule 1 //If a Transformer is named Optimus or Predaking, the battle ends automatically with //them as the victor BattleRoundResult CheckForSpecialsCondition(ITransformer first, ITransformer second) { var resolution = Responses.BATTLE_RESOLUTION_SPECIAL; if (first.IsSpecial) { return new BattleRoundResult { Survivor = first, ResolutionStrategy = resolution } } ; else if (second.IsSpecial) { return new BattleRoundResult { Survivor = second, ResolutionStrategy = resolution } } ; return(null); } //Rule 2 //If Transformer A exceeds Transformer B in strength by 3 or more and Transformer B //has less than 5 courage, the battle is won by Transformer A(Transformer B ran away) BattleRoundResult CheckStrengthAndCourageCondition(ITransformer first, ITransformer second) { var strengthDifference = first.Strength - second.Strength; var resolution = Responses.BATTLE_RESOLUTION_STRENGTH_AND_COURAGE_DIFFERENCE; if (strengthDifference >= 3 && second.Courage < 5) { return new BattleRoundResult { Survivor = first, ResolutionStrategy = resolution } } ; else if (strengthDifference <= -3 && first.Courage < 5) { return new BattleRoundResult { Survivor = second, ResolutionStrategy = resolution } } ; return(null); } //Rule 3 //If Transformer A’s skill rating exceeds Transformer B's rating by 5 or more, Transformer //A wins the fight. BattleRoundResult CheckSkillCondition(ITransformer first, ITransformer second) { var resolution = Responses.BATTLE_RESOLUTION_SKILLDIFFERENCE; var skilldifference = first.Skill - second.Skill; if (skilldifference >= 5) { return new BattleRoundResult { Survivor = first, ResolutionStrategy = resolution } } ; else if (skilldifference <= -5) { return new BattleRoundResult { Survivor = second, ResolutionStrategy = resolution } } ; return(null); } //Rule 4 //Otherwise, the victor is whomever of Transformer A and B has the higher overall rating. BattleRoundResult CheckRatingCondition(ITransformer first, ITransformer second) { var resolution = Responses.BATTLE_RESOLUTION_RATINGDIFFERENCE; var ratingDifference = first.GetOverallRating() - second.GetOverallRating(); if (ratingDifference > 0) { return new BattleRoundResult { Survivor = first, ResolutionStrategy = resolution } } ; else if (ratingDifference < 0) { return new BattleRoundResult { Survivor = second, ResolutionStrategy = resolution } } ; return(null); } //Rule 5 //(You can determine what to do in the event of a tie between two robots). BattleRoundResult GetRandomWinner(ITransformer first, ITransformer second) { var resolution = Responses.BATTLE_RESOLUTION_RANDOM; var rand = new Random(); var number = rand.Next(1, 3); if (number == 1) { return new BattleRoundResult { Survivor = first, ResolutionStrategy = resolution } } ; else { return new BattleRoundResult { Survivor = second, ResolutionStrategy = resolution } }; } #endregion } }