simplify-printing #7

Merged
owner merged 3 commits from simplify-printing into main 2025-03-27 12:54:28 +00:00
Showing only changes of commit aa81717fd9 - Show all commits

View File

@ -14,8 +14,6 @@ string PrintFrames::parseValue(vector<Frame> frames) {
string value; string value;
stringstream ss; stringstream ss;
int score = 0;
// There can only be 10 frames. // There can only be 10 frames.
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
ss << "|"; ss << "|";
@ -39,8 +37,6 @@ string PrintFrames::parseValue(vector<Frame> frames) {
// If the next frame has 3 or 2 rolls, then take those 2. // If the next frame has 3 or 2 rolls, then take those 2.
if (frames[i + 1].Roll.size() > 1) { if (frames[i + 1].Roll.size() > 1) {
//score += frames[i].Roll[0] + frames[i + 1].Roll[0] + frames[i + 1].Roll[1];
if (frames[i + 1].Roll[0] == 10 && frames[i + 1].Roll[1] != 10) { if (frames[i + 1].Roll[0] == 10 && frames[i + 1].Roll[1] != 10) {
ss << "X, " << frames[i + 1].Roll[0] << " "; ss << "X, " << frames[i + 1].Roll[0] << " ";
} }
@ -58,7 +54,6 @@ string PrintFrames::parseValue(vector<Frame> frames) {
} }
// Both next frames, that are not the last, are 10. // Both next frames, that are not the last, are 10.
//score += frames[i].Roll[0] + frames[i + 1].Roll[0] + frames[i + 2].Roll[0];
ss << "X "; ss << "X ";
continue; continue;
@ -67,18 +62,15 @@ string PrintFrames::parseValue(vector<Frame> frames) {
// Spare // Spare
if (frames[i].Roll[0] + frames[i].Roll[1] == 10) { if (frames[i].Roll[0] + frames[i].Roll[1] == 10) {
if (frames[i].Roll.size() == 3) { if (frames[i].Roll.size() == 3) {
score += frames[i].Roll[0] + frames[i].Roll[1] + frames[i].Roll[2];
ss << frames[i].Roll[0] << ", / "; ss << frames[i].Roll[0] << ", / ";
continue; continue;
} }
//score += 10 + frames[i + 1].Roll[0];
ss << frames[i].Roll[0] << ", /"; ss << frames[i].Roll[0] << ", /";
continue; continue;
} }
// Open frame // Open frame
//score += frames[i].Roll[0] + frames[i].Roll[1];
if (i == 9) { if (i == 9) {
ss << frames[i].Roll[0] << ", " << frames[i].Roll[1] << " "; ss << frames[i].Roll[0] << ", " << frames[i].Roll[1] << " ";
} else { } else {