Exemplo n.º 1
0
int		addScoreFromFrame(int *score, int *i)
{
  if (itsRolls[*i] == 10)
    {
      *score = 10 + itsRolls[*i + 1] + itsRolls[*i + 2];
      (*i)++;
    }
  else if (isSpare(*i))
    {
      (*score) += spareScore(*i);
      *i += 2;
    }
  else
    {
      (*score) += sumOfBallsInFrame(*i);
      *i += 2;
    }
}
Exemplo n.º 2
0
static void score(player* p)
{
	uint8_t i; 
	uint8_t j = 0;

	p->totalScore = 0;

	int8_t k = p -> numOfThrow / 2;
	
	for (i = 0; i < k; i++) 
	{
		if (p -> points[j] == ALL_PINS_DOWN)            
		{	
			if(j < LAST_FRAME_FIRST_THROW)
			{
				if (p -> points[j + 2] == ALL_PINS_DOWN)           // Double
				{
					p -> frames[i] = p -> totalScore += (ALL_PINS_DOWN + p -> points[j + 2] + p -> points[j + 4]);
				}							
				else				                   // Strike
				{
					p -> frames[i] = p -> totalScore += (ALL_PINS_DOWN + p -> points[j + 2] + p -> points[j + 3]);
				}
			}
			else
			{	
				p -> frames[i] = p -> totalScore += (ALL_PINS_DOWN + p -> points[j + 1] + p -> points[j + 2]);
			}
		}
		else if (isSpare(p, j) && (j <= LAST_FRAME_FIRST_THROW))           // Spare
		{
			p -> frames[i] = p -> totalScore += (ALL_PINS_DOWN + p -> points[j + 2]);
		}
		else
		{
			p -> frames[i] = p -> totalScore += (p -> points[j] + p -> points[j + 1]);
		}
		j += 2;
	}
}