OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dartcombatlib; | 5 part of dartcombatlib; |
6 | 6 |
7 void spawnPlayer() { | 7 void spawnPlayer() { |
8 PlayerState state = new PlayerState(); | 8 PlayerState state = new PlayerState(); |
9 port.receive(state.dispatch); | 9 port.receive(state.dispatch); |
10 } | 10 } |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 case Constants.SUNK: | 232 case Constants.SUNK: |
233 sunk.complete(true); | 233 sunk.complete(true); |
234 break; | 234 break; |
235 case Constants.MISS: | 235 case Constants.MISS: |
236 sunk.complete(false); | 236 sunk.complete(false); |
237 break; | 237 break; |
238 } | 238 } |
239 }); | 239 }); |
240 shot.handleException((String error) { | 240 shot.handleException((String error) { |
241 _recordFailedShot(x, y); | 241 _recordFailedShot(x, y); |
242 sunk.completeException(error); | 242 sunk.completeError(error); |
243 return true; | 243 return true; |
244 }); | 244 }); |
245 // We don't actually chain sunk.cancel with shot.cancel because individual | 245 // We don't actually chain sunk.cancel with shot.cancel because individual |
246 // shots can't be cancelled. | 246 // shots can't be cancelled. |
247 } else { | 247 } else { |
248 sunk.complete(false); | 248 sunk.complete(false); |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 /** checks that a shot is in range and has not been done before. */ | 252 /** checks that a shot is in range and has not been done before. */ |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 case Constants.SUNK: | 296 case Constants.SUNK: |
297 totalHits++; | 297 totalHits++; |
298 boatsSunk++; | 298 boatsSunk++; |
299 _enemyView.addHit(x, y); | 299 _enemyView.addHit(x, y); |
300 enemyGrid.hit(x, y); | 300 enemyGrid.hit(x, y); |
301 break; | 301 break; |
302 } | 302 } |
303 _enemyView.statusBar.updateStatus(); | 303 _enemyView.statusBar.updateStatus(); |
304 } | 304 } |
305 } | 305 } |
OLD | NEW |