Removing the redundant score calculation from parseValues, as the overarching logic is the same as the calculateScore function

This commit is contained in:
Rasmus Rasmussen 2025-03-27 12:26:17 +01:00
parent 7d9da3cc50
commit aa81717fd9

View File

@ -14,8 +14,6 @@ string PrintFrames::parseValue(vector<Frame> frames) {
string value;
stringstream ss;
int score = 0;
// There can only be 10 frames.
for (int i = 0; i < 10; i++) {
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 (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) {
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.
//score += frames[i].Roll[0] + frames[i + 1].Roll[0] + frames[i + 2].Roll[0];
ss << "X ";
continue;
@ -67,18 +62,15 @@ string PrintFrames::parseValue(vector<Frame> frames) {
// Spare
if (frames[i].Roll[0] + frames[i].Roll[1] == 10) {
if (frames[i].Roll.size() == 3) {
score += frames[i].Roll[0] + frames[i].Roll[1] + frames[i].Roll[2];
ss << frames[i].Roll[0] << ", / ";
continue;
}
//score += 10 + frames[i + 1].Roll[0];
ss << frames[i].Roll[0] << ", /";
continue;
}
// Open frame
//score += frames[i].Roll[0] + frames[i].Roll[1];
if (i == 9) {
ss << frames[i].Roll[0] << ", " << frames[i].Roll[1] << " ";
} else {