Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Unified Diff: samples/pop_pop_win/lib/src/html/game_manager.dart

Issue 242443008: samples/pop_pop_win: now based on StageXL (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: tiny nit Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/pop_pop_win/lib/src/html.dart ('k') | samples/pop_pop_win/lib/src/html/game_storage.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/pop_pop_win/lib/src/html/game_manager.dart
diff --git a/samples/pop_pop_win/lib/src/html/game_manager.dart b/samples/pop_pop_win/lib/src/html/game_manager.dart
deleted file mode 100644
index e07a872976d3c4b61cc82b403424eb9d7b5dffbc..0000000000000000000000000000000000000000
--- a/samples/pop_pop_win/lib/src/html/game_manager.dart
+++ /dev/null
@@ -1,92 +0,0 @@
-part of pop_pop_win.html;
-
-abstract class GameManager {
- final int _width, _height, _bombCount;
- final GameStorage _gameStorage = new GameStorage();
-
- Game _game;
- StreamSubscription _updatedEventId;
- StreamSubscription _gameStateChangedId;
- Timer _clockTimer;
-
- GameManager(this._width, this._height, this._bombCount) {
- newGame();
- }
-
- Game get game => _game;
-
- Stream<EventArgs> get bestTimeUpdated => _gameStorage.bestTimeUpdated;
-
- Future<int> get bestTimeMilliseconds =>
- _gameStorage.getBestTimeMilliseconds(_width, _height, _bombCount);
-
- void newGame() {
- if (_updatedEventId != null) {
- assert(_game != null);
- assert(_gameStateChangedId != null);
- _updatedEventId.cancel();
- _gameStateChangedId.cancel();
- _gameStateChanged(GameState.reset);
- }
- final f = new Field(_bombCount, _width, _height);
- _game = new Game(f);
- _updatedEventId = _game.updated.listen(gameUpdated);
- _gameStateChangedId = _game.stateChanged.listen(_gameStateChanged);
- }
-
- void gameUpdated(args);
-
- void resetScores() {
- _gameStorage.reset();
- }
-
- void _click(int x, int y, bool alt) {
- final ss = _game.getSquareState(x, y);
-
- if (alt) {
- if (ss == SquareState.hidden) {
- _game.setFlag(x, y, true);
- } else if (ss == SquareState.flagged) {
- _game.setFlag(x, y, false);
- } else if (ss == SquareState.revealed) {
- _game.reveal(x, y);
- }
- } else {
- if (ss == SquareState.hidden) {
- _game.reveal(x, y);
- }
- }
- }
-
- void updateClock() {
- if (_clockTimer == null && _game.state == GameState.started) {
- _clockTimer = new Timer(const Duration(seconds: 1), updateClock);
- } else if (_clockTimer != null && _game.state != GameState.started) {
- _clockTimer.cancel();
- _clockTimer = null;
- }
- }
-
- void onNewBestTime(int value) {}
-
- void onGameStateChanged(GameState value) {}
-
- bool get _canClick {
- return _game.state == GameState.reset || _game.state == GameState.started;
- }
-
- void _gameStateChanged(GameState newState) {
- _gameStorage.recordState(newState);
- if (newState == GameState.won) {
- _gameStorage.updateBestTime(_game).then((bool newBestTime) {
- if (newBestTime) {
- bestTimeMilliseconds.then((int val) {
- onNewBestTime(val);
- });
- }
- });
- }
- updateClock();
- onGameStateChanged(newState);
- }
-}
« no previous file with comments | « samples/pop_pop_win/lib/src/html.dart ('k') | samples/pop_pop_win/lib/src/html/game_storage.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698