| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package com.fjalvarez.tdd.darts; |
||
| 38 | private void computeScore(int dartScore, Multiplier multiplier) { |
||
| 39 | int newScore = score - dartScore; |
||
| 40 | if (newScore == 0 && multiplier.equals(Multiplier.DOUBLE)) { |
||
| 41 | isFinished = true; |
||
| 42 | return; |
||
| 43 | } |
||
| 44 | |||
| 45 | if ((newScore == 1 && dartsLeft != 1) || (newScore <0)) { |
||
| 46 | newScore = lastTurnScore; |
||
| 47 | dartsLeft = 3; |
||
| 48 | turn++; |
||
| 49 | } else if (dartsLeft == 1) { |
||
| 50 | lastTurnScore = newScore; |
||
| 51 | dartsLeft = 3; |
||
| 52 | turn++; |
||
| 53 | } else { |
||
| 54 | dartsLeft--; |
||
| 55 | } |
||
| 56 | score = newScore; |
||
| 57 | } |
||
| 71 |