Skip to content

Commit

Permalink
Removing unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
autoreleasefool committed Oct 13, 2015
1 parent dca7f1c commit 5a08c19
Showing 1 changed file with 0 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,168 +283,6 @@ private static Bitmap createImageFromGame(boolean[][][] pinState,
}

/**
<<<<<<< HEAD
* Gets an array of points to draw lines between to outline a game.
*
* @return array of floats representing the vertices of the lines
*/
private static float[] getPts() {
return new float[]{
0,
0,
BITMAP_GAME_WIDTH,
0,
0,
0,
0,
BITMAP_GAME_HEIGHT,
0,
BITMAP_GAME_HEIGHT - 1,
BITMAP_GAME_WIDTH,
BITMAP_GAME_HEIGHT - 1,
BITMAP_GAME_WIDTH - 1,
0,
BITMAP_GAME_WIDTH - 1,
BITMAP_GAME_HEIGHT,
0,
BITMAP_GAME_BALL_HEIGHT,
BITMAP_GAME_WIDTH - BITMAP_GAME_FRAME_WIDTH,
BITMAP_GAME_BALL_HEIGHT,
BITMAP_GAME_FRAME_WIDTH * Constants.NUMBER_OF_FRAMES,
0,
BITMAP_GAME_FRAME_WIDTH * Constants.NUMBER_OF_FRAMES,
BITMAP_GAME_HEIGHT
};
}

/**
* Calculates the score for a single frame and stores it in {@code frameScores}.
*
* @param pinState pins which have been knocked over
* @param frameScores score of the game by frame
* @param frame current frame
*/
private static void calculateFrameScore(boolean[][][] pinState, int[] frameScores, int frame) {
if (frame == Constants.LAST_FRAME) {
for (int b = Constants.NUMBER_OF_BALLS - 1; b >= 0; b--) {
switch (b) {
case 2:
frameScores[frame] += Score.getValueOfFrame(pinState[frame][b], true);
break;
case 1:
case 0:
if (Arrays.equals(pinState[frame][b], Constants.FRAME_PINS_DOWN))
frameScores[frame] += Score.getValueOfFrame(pinState[frame][b], true);
break;
default:
//do nothing
}
}
} else {
for (int b = 0; b < Constants.NUMBER_OF_BALLS; b++) {
if (b < 2 && Arrays.equals(pinState[frame][b], Constants.FRAME_PINS_DOWN)) {
frameScores[frame] += Score.getValueOfFrame(pinState[frame][b], true);
frameScores[frame] += Score.getValueOfFrame(pinState[frame + 1][0], true);
if (b == 0) {
if (frame == Constants.LAST_FRAME - 1) {
if (frameScores[frame] == Constants.STRIKE_VALUE * 2) {
frameScores[frame] += Score.getValueOfFrame(pinState[frame + 1][1], true);
} else {
frameScores[frame] += Score.getValueOfFrameDifference(pinState[frame + 1][0],
pinState[frame + 1][1]);
}
} else if (frameScores[frame] < Constants.STRIKE_VALUE * 2) {
frameScores[frame] += Score.getValueOfFrameDifference(pinState[frame + 1][0],
pinState[frame + 1][1]);
} else {
frameScores[frame] += Score.getValueOfFrame(pinState[frame + 2][0], true);
}
}
break;
} else if (b == 2) {
frameScores[frame] += Score.getValueOfFrame(pinState[frame][b], true);
}
}
}
}

/**
* Draws the value of 3 balls to the canvas.
*
* @param canvas context to draw to
* @param paintText font formatting
* @param frame current frame
* @param ballString ball value to draw
*/
private static void drawBalls(Canvas canvas, Paint paintText, int frame, String[] ballString) {
canvas.drawText(ballString[0], BITMAP_GAME_BALL_WIDTH / 2 + BITMAP_GAME_FRAME_WIDTH
* frame, BALL_TEXT_Y, paintText);
canvas.drawText(ballString[1], BITMAP_GAME_BALL_WIDTH + BITMAP_GAME_BALL_WIDTH / 2
+ BITMAP_GAME_FRAME_WIDTH * frame, BALL_TEXT_Y, paintText);
canvas.drawText(ballString[2], BITMAP_GAME_BALL_WIDTH * 2 + BITMAP_GAME_BALL_WIDTH / 2
+ BITMAP_GAME_FRAME_WIDTH * frame, BALL_TEXT_Y, paintText);
}

/**
* Calculates the number of points earned in each ball of a frame and stores it in {@code ballString}.
*
* @param pinState pins which have been knocked over
* @param frame current frame
* @param ballString score earned in the ball
*/
private static void calculateBalls(boolean[][][] pinState, int frame, String[] ballString) {
if (frame == Constants.LAST_FRAME) {
if (Arrays.equals(pinState[frame][0], Constants.FRAME_PINS_DOWN)) {
//If first ball is a strike, next two can be strikes/spares
ballString[0] = Constants.BALL_STRIKE;
if (Arrays.equals(pinState[frame][1], Constants.FRAME_PINS_DOWN)) {
ballString[1] = Constants.BALL_STRIKE;
ballString[2] = Score.getValueOfBall(pinState[frame][2], 2, true, false);
} else {
ballString[1] = Score.getValueOfBall(pinState[frame][1], 1, false, false);
if (Arrays.equals(pinState[frame][2], Constants.FRAME_PINS_DOWN))
ballString[2] = Constants.BALL_SPARE;
else
ballString[2] = Score.getValueOfBallDifference(pinState[frame], 2, false, false);
}
} else {
//If first ball is not a strike, score is calculated normally
ballString[0] = Score.getValueOfBall(pinState[frame][0], 0, false, false);
if (Arrays.equals(pinState[frame][1], Constants.FRAME_PINS_DOWN)) {
ballString[1] = Constants.BALL_SPARE;
ballString[2] = Score.getValueOfBall(pinState[frame][2], 2, true, false);
} else {
ballString[1] = Score.getValueOfBallDifference(pinState[frame], 1, false, false);
ballString[2] = Score.getValueOfBallDifference(pinState[frame], 2, false, false);
}
}
} else {
ballString[0] = Score.getValueOfBallDifference(pinState[frame], 0, false, false);
if (!Arrays.equals(pinState[frame][0], Constants.FRAME_PINS_DOWN)) {
if (Arrays.equals(pinState[frame][1], Constants.FRAME_PINS_DOWN)) {
ballString[1] = Constants.BALL_SPARE;
ballString[2] = Score.getValueOfBallDifference(pinState[frame + 1], 0, false, true);
} else {
ballString[1] = Score.getValueOfBallDifference(pinState[frame], 1, false, false);
ballString[2] = Score.getValueOfBallDifference(pinState[frame], 2, false, false);
}
} else {
ballString[1] = Score.getValueOfBallDifference(pinState[frame + 1], 0, false, true);
if (Arrays.equals(pinState[frame + 1][0], Constants.FRAME_PINS_DOWN)) {
if (frame < Constants.LAST_FRAME - 1)
ballString[2] = Score.getValueOfBallDifference(pinState[frame + 2], 0, false, true);
else
ballString[2] = Score.getValueOfBall(pinState[frame + 1][1], 1, false, true);
} else {
ballString[2] = Score.getValueOfBallDifference(pinState[frame + 1], 1, false, true);
}
}
}
}

/**
=======
>>>>>>> parent of 7ca83f7... Fixing compiler warnings, refactoring code
* Loads the data of each game in a series and creates a single image to.
*
* @param context context used to get an instance of the database
Expand Down

0 comments on commit 5a08c19

Please sign in to comment.