public void calculate_the_score_for_spare_frames() { var line = BuildLine.From("-/------------------"); line.Score().Should().Be(10); line = BuildLine.From("1/------------------"); line.Score().Should().Be(10); line = BuildLine.From("1/1-----------------"); line.Score().Should().Be(12); }
public void calculate_the_score_for_strike_frames() { var line = BuildLine.From("X------------------"); line.Score().Should().Be(10); line = BuildLine.From("X1-----------------"); line.Score().Should().Be(12); line = BuildLine.From("X11----------------"); line.Score().Should().Be(14); }
public void calculate_acceptance_scores() { var line = BuildLine.From("11111111111111111111"); line.Score().Should().Be(20); line = BuildLine.From("9-9-9-9-9-9-9-9-9-9-"); line.Score().Should().Be(90); line = BuildLine.From("5/5/5/5/5/5/5/5/5/5/5"); line.Score().Should().Be(150); line = BuildLine.From("XXXXXXXXXXXX"); line.Score().Should().Be(300); }
string[] GetLines(string text, GUIStyle textblockStyle) { string[] lines; if (!mWrappedTextLines.TryGetValue(text, out lines)) { var content = new GUIContent(text); var textRect = GUILayoutUtility.GetRect(content, textblockStyle); var lineHeight = textblockStyle.lineHeight; int lineCount = (int)(textRect.height / lineHeight); int[] lineEnds = new int[lineCount]; lines = new string[lineCount]; for (int i = 0; i < lineCount; i++) { int endLineIdx = 0; for (float x = 0; x < textRect.width; x += 6) { Vector2 hitTestPos = textRect.position + new Vector2(textRect.width - x, i * lineHeight + lineHeight / 2); endLineIdx = textblockStyle.GetCursorStringIndex( textRect, content, hitTestPos); if (endLineIdx > 0) { break; } } lineEnds[i] = endLineIdx; if (i == lines.Length - 1 && lines.Length > 1) { lines[i] = BuildLine.ForIndex(text, lineEnds[i - 1] + 1); } else if (i > 0) { lines[i] = BuildLine.ForIndexAndLenght(text, lineEnds[i - 1] + 1, endLineIdx - lineEnds[i - 1] - 1); } else { lines[0] = BuildLine.ForIndexAndLenght(text, 0, Mathf.Min(text.Length, endLineIdx + 1)).Trim(); } } bool validLines = false; for (int i = 0; i < lines.Length; i++) { if (!string.IsNullOrEmpty(lines[i])) { validLines = true; break; } } if (validLines) { mWrappedTextLines.Add(text, lines); Repaint(); return(null); // The frame they are generated they shouldn't be drawn, for layout error reasons } } else { return(lines); } return(null); }
public void calculate_the_score_for_single_rolls() { var line = BuildLine.From("11--1-1-------------"); line.Score().Should().Be(4); }