public bool BlastSuccess(FightDataFormat attacker, FightDataFormat defender) { this.IsBlast = null; SkillDataManager.Instance.ActiveSkill(TURN_STATES.JUDGE_BLAST, attacker, defender); if (this.IsBlast != null) { return(this.IsBlast.Value); } var _defenderAC = defender.FinalAttributesCache.AC; this.IgnoreDefenderAttributeList.ForEach(type => { if (type == ATTRIBUTE_TYPE.AC) { _defenderAC = 0.0F; } }); float _t = Mathf.Clamp(_defenderAC - attacker.FinalAttributesCache.PEN, FIGHT.BLAST_SUCCESS_AC_MINUS_PEN_MIN, FIGHT.BLAST_SUCCESS_AC_MINUS_PEN_MAX); var _resultValue = attacker.FinalAttributesCache.CRI * FIGHT.BLAST_SUCCESS_CRI_CP_0 * Mathf.FloorToInt(FIGHT.BLAST_SUCCESS_CP_0 - _t); this.IsBlast = ProbabilityHelper.TrySuccess(Mathf.FloorToInt(_resultValue)); return(this.IsBlast.Value); }
public void IsValidProbability_NaNIsValid_ReturnTrue() { // Call bool isValid = ProbabilityHelper.IsValidProbability(double.NaN, true); // Assert Assert.IsTrue(isValid); }
public void ValidateProbability_ValidProbability_DoesNotThrow(double probability) { // Call TestDelegate call = () => ProbabilityHelper.ValidateProbability(probability, "A"); // Assert Assert.DoesNotThrow(call); }
public void IsValidProbability_InvalidProbability_ReturnFalse(double value) { // Call bool isValid = ProbabilityHelper.IsValidProbability(value); // Assert Assert.IsFalse(isValid); }
public void ValidateProbability_AllowNaN_DoesNotThrow() { // Call TestDelegate call = () => ProbabilityHelper.ValidateProbability(double.NaN, "A", true); // Assert Assert.DoesNotThrow(call); }
public void ValidateProbability_InvalidProbability_ThrowsArgumentOutOfRangeException(double invalidProbabilityValue, string expectedParamName) { // Call TestDelegate call = () => ProbabilityHelper.ValidateProbability(invalidProbabilityValue, expectedParamName); // Assert const string message = "Kans moet in het bereik [0,0, 1,0] liggen."; string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(call, message).ParamName; Assert.AreEqual(expectedParamName, paramName); }
public void ValidateProbability_WithCustomMessageAndAllowNaN_DoesNotThrow() { // Setup const string customMessage = "Test {0}"; // Call TestDelegate call = () => ProbabilityHelper.ValidateProbability(double.NaN, "A", customMessage, true); // Assert Assert.DoesNotThrow(call); }
public void ValidateProbability_WithCustomMessageAndValidProbability_DoesNotThrow(double probability) { // Setup const string customMessage = "Test {0}"; // Call TestDelegate call = () => ProbabilityHelper.ValidateProbability(probability, "A", customMessage); // Assert Assert.DoesNotThrow(call); }
// GET: Probability public ActionResult Index(HomeViewModel homeVm) { //validation if (homeVm.NumCities < 1) { homeVm.StatusMessage = "Stop trying to break my code JC! You need a number greater than 0"; return(RedirectToAction("Index", "Home", homeVm)); } var probVM = ProbabilityHelper.CreateProbHomeVM(homeVm.NumCities); //check the model return(View(probVM)); }
public void ValidateProbability_WithCustomMessageAndInvalidProbability_ThrowsArgumentOutOfRangeException(double invalidProbabilityValue, string expectedParamName) { // Setup const string customMessage = "Test {0}"; // Call TestDelegate call = () => ProbabilityHelper.ValidateProbability(invalidProbabilityValue, expectedParamName, customMessage); // Assert const string message = "Test [0,0, 1,0]"; string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(call, message).ParamName; Assert.AreEqual(expectedParamName, paramName); }
public void ValidateProbability_WithInvalidCustomMessage_ThrowsArgumentException() { // Setup const string customMessage = "Test"; // Call TestDelegate call = () => ProbabilityHelper.ValidateProbability(1.0, "value", customMessage); // Assert const string expectedMessage = "The custom message should have a insert location (\"{0}\") where the validity range is to be inserted."; string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, expectedMessage).ParamName; Assert.AreEqual("customMessage", paramName); }
/// <summary> /// Creates a new instance of <see cref="HydraulicLoadsOutput"/>. /// </summary> /// <param name="targetProbability">The target probability used during the calculation.</param> /// <param name="targetReliability">The reliability index used during the calculation.</param> /// <param name="calculatedProbability">The calculated probability.</param> /// <param name="calculatedReliability">The calculated reliability index.</param> /// <param name="calculationConvergence">The convergence status of the calculation.</param> /// <param name="generalResult">The general result with the fault tree illustration points.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="targetProbability"/> /// or <paramref name="calculatedProbability"/> falls outside the [0.0, 1.0] range and is not <see cref="double.NaN"/>.</exception> protected HydraulicLoadsOutput(double targetProbability, double targetReliability, double calculatedProbability, double calculatedReliability, CalculationConvergence calculationConvergence, GeneralResult <TopLevelFaultTreeIllustrationPoint> generalResult) { ProbabilityHelper.ValidateProbability(targetProbability, nameof(targetProbability), true); ProbabilityHelper.ValidateProbability(calculatedProbability, nameof(calculatedProbability), true); TargetProbability = targetProbability; TargetReliability = new RoundedDouble(5, targetReliability); CalculatedProbability = calculatedProbability; CalculatedReliability = new RoundedDouble(5, calculatedReliability); CalculationConvergence = calculationConvergence; GeneralResult = generalResult; }
public bool HitSuccess(FightDataFormat attacker, FightDataFormat defender) { this.IsHitSuccess = null; SkillDataManager.Instance.ActiveSkill(TURN_STATES.JUDGE_HIT, attacker, defender); if (this.IsHitSuccess != null) { return(this.IsHitSuccess.Value); } float _t = Mathf.Clamp(defender.FinalAttributesCache.AVD - attacker.FinalAttributesCache.HIT, FIGHT.HIT_SUCCESS_PROBABILITY_MIN, FIGHT.HIT_SUCCESS_PROBABILITY_MAX); int _resultValue = FIGHT.HIT_SUCCESS_CP_0 - Mathf.FloorToInt(_t); this.IsHitSuccess = ProbabilityHelper.TrySuccess(_resultValue); return(this.IsHitSuccess.Value); }
/// <summary> /// Creates a new instance of <see cref="HydraulicBoundaryLocationCalculationOutput"/>. /// </summary> /// <param name="result">The calculation result.</param> /// <param name="targetProbability">The target probability used during the calculation.</param> /// <param name="targetReliability">The reliability index used during the calculation.</param> /// <param name="calculatedProbability">The calculated probability.</param> /// <param name="calculatedReliability">The calculated reliability.</param> /// <param name="calculationConvergence">The convergence status of the calculation.</param> /// <param name="generalResult">The general result of this output with sub mechanism illustration points.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="targetProbability"/> /// or <paramref name="calculatedProbability"/> falls outside the [0.0, 1.0] range and is not <see cref="double.NaN"/>.</exception> public HydraulicBoundaryLocationCalculationOutput(double result, double targetProbability, double targetReliability, double calculatedProbability, double calculatedReliability, CalculationConvergence calculationConvergence, GeneralResult <TopLevelSubMechanismIllustrationPoint> generalResult) { ProbabilityHelper.ValidateProbability(targetProbability, nameof(targetProbability), true); ProbabilityHelper.ValidateProbability(calculatedProbability, nameof(calculatedProbability), true); Result = new RoundedDouble(2, result); TargetProbability = targetProbability; TargetReliability = new RoundedDouble(5, targetReliability); CalculatedProbability = calculatedProbability; CalculatedReliability = new RoundedDouble(5, calculatedReliability); CalculationConvergence = calculationConvergence; GeneralResult = generalResult; }
/// <summary> /// Creates a new instance of <see cref="DuneLocationCalculationOutput"/>. /// </summary> /// <param name="calculationConvergence">The convergence status of the calculation.</param> /// <param name="constructionProperties">The container for the properties for the <see cref="DuneLocationCalculationOutput"/>.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="constructionProperties"/> is <c>null</c>.</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown when <see cref="ConstructionProperties.TargetProbability"/> /// or <see cref="ConstructionProperties.CalculatedProbability"/> falls outside the [0.0, 1.0] range.</exception> public DuneLocationCalculationOutput(CalculationConvergence calculationConvergence, ConstructionProperties constructionProperties) { if (constructionProperties == null) { throw new ArgumentNullException(nameof(constructionProperties)); } WaterLevel = new RoundedDouble(2, constructionProperties.WaterLevel); WaveHeight = new RoundedDouble(2, constructionProperties.WaveHeight); WavePeriod = new RoundedDouble(2, constructionProperties.WavePeriod); ProbabilityHelper.ValidateProbability(constructionProperties.TargetProbability, nameof(TargetProbability), true); ProbabilityHelper.ValidateProbability(constructionProperties.CalculatedProbability, nameof(CalculatedProbability), true); TargetProbability = constructionProperties.TargetProbability; TargetReliability = new RoundedDouble(5, constructionProperties.TargetReliability); CalculatedProbability = constructionProperties.CalculatedProbability; CalculatedReliability = new RoundedDouble(5, constructionProperties.CalculatedReliability); CalculationConvergence = calculationConvergence; }