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

Side by Side Diff: samples/dartcombat/player.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/dartcombat/grids.dart ('k') | samples/isolate_html/isolate_sample.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** A local player (API known to the main isolate when creating players). */ 7 /** A local player (API known to the main isolate when creating players). */
8 class Player { 8 class Player {
9 9
10 factory Player() => new PlayerImpl(); 10 factory Player() => new PlayerImpl();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 * which contains the actual enemy state. 68 * which contains the actual enemy state.
69 */ 69 */
70 class EnemyImpl implements Enemy { 70 class EnemyImpl implements Enemy {
71 SendPort portToEnemy; 71 SendPort portToEnemy;
72 72
73 EnemyImpl(this.portToEnemy) {} 73 EnemyImpl(this.portToEnemy) {}
74 74
75 Future<int> ready() { 75 Future<int> ready() {
76 Completer<int> res = new Completer<int>(); 76 Completer<int> res = new Completer<int>();
77 return portToEnemy.call({ "action" : MessageIds.ENEMY_IS_READY }) 77 return portToEnemy.call({ "action" : MessageIds.ENEMY_IS_READY })
78 .transform((message) { 78 .then((message) {
79 if (!message[0]) throw message[1]; 79 if (!message[0]) throw message[1];
80 return 0; 80 return 0;
81 }); 81 });
82 } 82 }
83 83
84 Future<int> shoot(int x, int y) { 84 Future<int> shoot(int x, int y) {
85 Completer<int> res = new Completer<int>(); 85 Completer<int> res = new Completer<int>();
86 return portToEnemy.call({ "action" : MessageIds.SHOOT, "args" : [x, y] }) 86 return portToEnemy.call({ "action" : MessageIds.SHOOT, "args" : [x, y] })
87 .transform((message) { 87 .then((message) {
88 if (!message[0]) throw message[1]; 88 if (!message[0]) throw message[1];
89 return message[1][0]; 89 return message[1][0];
90 }); 90 });
91 } 91 }
92 } 92 }
93 93
94 /** Collection of message IDs used to communicate with player isolates. */ 94 /** Collection of message IDs used to communicate with player isolates. */
95 class MessageIds { 95 class MessageIds {
96 /** message to set up a new player. */ 96 /** message to set up a new player. */
97 static const SETUP = 1; 97 static const SETUP = 1;
98 98
99 /** message to initialize the enemy of a player. */ 99 /** message to initialize the enemy of a player. */
100 static const SET_ENEMY = 2; 100 static const SET_ENEMY = 2;
101 101
102 /** message indicating that the enemy is ready to play. */ 102 /** message indicating that the enemy is ready to play. */
103 static const ENEMY_IS_READY = 3; 103 static const ENEMY_IS_READY = 3;
104 104
105 /** message describing a shoot action. */ 105 /** message describing a shoot action. */
106 static const SHOOT = 4; 106 static const SHOOT = 4;
107 107
108 /** message to set up a test port, used to make tests non-flaky. */ 108 /** message to set up a test port, used to make tests non-flaky. */
109 static const SET_PORT_FOR_TEST = 5; 109 static const SET_PORT_FOR_TEST = 5;
110 } 110 }
OLDNEW
« no previous file with comments | « samples/dartcombat/grids.dart ('k') | samples/isolate_html/isolate_sample.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698