/// <summary> /// Take player index and index of a digit in BP score and return the digit. /// E.g. digit at index '2' from BP score "14 356" will be '3' /// </summary> public static DigitEnum recognizeDigitAtDigitPosForPlayer(PlayerIndex playerIndex, DigitPosition digitPos) { // We might have casted it from an int, check if it's inside enum range Dbg.assertPlayerIndexIsInRangeAndNotInvalid(playerIndex); Dbg.assertDigitPosEnumIsInRangeAndNotInvalid(digitPos); List <bool> boolDigitList = new List <bool>(); // Try to recognize ALL possible digits at that place for (int d = 0; d <= 9; d++) { boolDigitList.Add(digit[d].recognize(playerIndex, digitPos)); } Dbg.ensureMaxOneBoolIsTrue(boolDigitList); // see which one is true, if any DigitEnum recognizedDigit = DigitEnum.Error; for (int d = (int)DigitEnum.Digit0; d <= (int)DigitEnum.Digit9; d++) { // Already set it before, so we have more than 1 value => error if (boolDigitList[d] && recognizedDigit != DigitEnum.Error) { return(DigitEnum.Error); } if (boolDigitList[d]) { recognizedDigit = ( DigitEnum )d; } } Dbg.assertDigitEnumIsInRange(recognizedDigit); return(recognizedDigit); }