/// <summary> /// Checks if it is possible to pass the skill check /// </summary> public bool CheckIfPossible() { if (CheckType == SkillCheckType.Soft) { //check if target value > 0 var targetValue = GetValueOfTarget(); int compareResult = TypeUtils.CompareNumericValues(targetValue, 0); return(compareResult > 0); } else if (CheckType == SkillCheckType.Hard) { return(Check()); //must pass check to be possible } else { throw new NotImplementedException(); } }
/// <summary> /// Does the skill check and returns if it passed or failed /// </summary> public bool Check() { if (CheckType == SkillCheckType.Soft) { var targetValue = GetValueOfTarget(); float baseValue = Convert.ToSingle(targetValue); float neededValue = Convert.ToSingle(Value); if (GetOutcomeForCompareResult(baseValue.CompareTo(neededValue))) { return(true); } float passChance; if (ComparisonType == SkillCheckComparison.Less || ComparisonType == SkillCheckComparison.LessEqual) { passChance = neededValue / baseValue; //this might not be correct } else { passChance = baseValue / neededValue; } float chanceValue = UnityEngine.Random.Range(0f, 1f); return(chanceValue <= passChance); } else if (CheckType == SkillCheckType.Hard) { var targetValue = GetValueOfTarget(); int compareResult = TypeUtils.CompareNumericValues(targetValue, Value); return(GetOutcomeForCompareResult(compareResult)); } else { throw new NotImplementedException(); } }