equal
deleted
inserted
replaced
60 if (state != GameState.Game) |
60 if (state != GameState.Game) |
61 throw new RuntimeException("Game over!"); |
61 throw new RuntimeException("Game over!"); |
62 |
62 |
63 // Score |
63 // Score |
64 int prevScore = score; |
64 int prevScore = score; |
65 score--; |
|
66 |
65 |
67 // Moving and scoring |
66 // Moving and scoring |
68 route.add(mov); |
67 route.add(mov); |
69 Coordinate robotCoord = mine.getRobotCell().getCoordinate(); |
68 Coordinate robotCoord = mine.getRobotCell().getCoordinate(); |
70 Coordinate nextRobotCoord = null; |
69 Coordinate nextRobotCoord = null; |
88 break; |
87 break; |
89 case DOWN: |
88 case DOWN: |
90 nextRobotCoord = robotCoord.down(); |
89 nextRobotCoord = robotCoord.down(); |
91 break; |
90 break; |
92 } |
91 } |
|
92 score--; |
93 Cell nextRobotCell = mine.getCell(nextRobotCoord); |
93 Cell nextRobotCell = mine.getCell(nextRobotCoord); |
94 CellContent nextRobotCellContent = getContent(nextRobotCell); |
94 CellContent nextRobotCellContent = getContent(nextRobotCell); |
95 if (nextRobotCellContent == Empty || nextRobotCellContent == Earth) { |
95 if (nextRobotCellContent == Empty || nextRobotCellContent == Earth) { |
96 moveRobot(nextRobotCell); |
96 moveRobot(nextRobotCell); |
97 } else if (nextRobotCellContent == Lambda) { |
97 } else if (nextRobotCellContent == Lambda) { |
103 score += 50 * lambdaCollectedCount; |
103 score += 50 * lambdaCollectedCount; |
104 |
104 |
105 lastScoreChange = score - prevScore; |
105 lastScoreChange = score - prevScore; |
106 state = GameState.Win; |
106 state = GameState.Win; |
107 return state; |
107 return state; |
108 } else if (robotCoord.right() == nextRobotCoord && nextRobotCellContent == Rock |
108 } else if (robotCoord.right().equals(nextRobotCoord) && nextRobotCellContent == Rock |
109 && getContent(mine.getCell(nextRobotCoord.right())) == Empty) { |
109 && getContent(mine.getCell(nextRobotCoord.right())) == Empty) { |
110 moveRobot(nextRobotCell); |
110 moveRobot(nextRobotCell); |
111 mine.getCell(nextRobotCoord.right()).setContent(Rock); |
111 mine.getCell(nextRobotCoord.right()).setContent(Rock); |
112 } else if (robotCoord.left() == nextRobotCoord && nextRobotCellContent == Rock |
112 } else if (robotCoord.left().equals(nextRobotCoord) && nextRobotCellContent == Rock |
113 && getContent(mine.getCell(nextRobotCoord.left())) == Empty) { |
113 && getContent(mine.getCell(nextRobotCoord.left())) == Empty) { |
114 moveRobot(nextRobotCell); |
114 moveRobot(nextRobotCell); |
115 mine.getCell(nextRobotCoord.left()).setContent(Rock); |
115 mine.getCell(nextRobotCoord.left()).setContent(Rock); |
116 } else { |
116 } else { |
117 mov = Movement.WAIT; |
117 mov = Movement.WAIT; |