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

Unified Diff: samples/pop_pop_win/lib/src/game/field.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/game.dart ('k') | samples/pop_pop_win/lib/src/game/game.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/game/field.dart
diff --git a/samples/pop_pop_win/lib/src/game/field.dart b/samples/pop_pop_win/lib/src/game/field.dart
index 91f26806f4da612c100ba75a3cef8e4648f472eb..7123732909c98953ba32b419dec753a73298ce2d 100644
--- a/samples/pop_pop_win/lib/src/game/field.dart
+++ b/samples/pop_pop_win/lib/src/game/field.dart
@@ -4,12 +4,13 @@ class Field extends Array2d<bool> {
final int bombCount;
final Array2d<int> _adjacents;
- factory Field([bombCount = 40, cols = 16, rows = 16, int seed = null]) {
- final squares = new List<bool>.filled(rows * cols, false);
+ factory Field([int bombCount = 40, int cols = 16, int rows = 16,
+ int seed = null]) {
+ var squares = new List<bool>.filled(rows * cols, false);
assert(bombCount < squares.length);
assert(bombCount > 0);
- final rnd = new math.Random(seed);
+ var rnd = new Random(seed);
// This is the most simple code, but it'll get slow as
// bombCount approaches the square count.
@@ -24,7 +25,7 @@ class Field extends Array2d<bool> {
}
return new Field._internal(bombCount, cols,
- new ReadOnlyCollection<bool>(squares));
+ new UnmodifiableListView<bool>(squares));
}
factory Field.fromSquares(int cols, int rows, List<bool> squares) {
@@ -42,19 +43,19 @@ class Field extends Array2d<bool> {
assert(count < squares.length);
return new Field._internal(count, cols,
- new ReadOnlyCollection<bool>(squares));
+ new UnmodifiableListView<bool>(squares));
}
- Field._internal(this.bombCount, int cols, ReadOnlyCollection<bool> source) :
- this._adjacents = new Array2d<int>(cols, source.length ~/ cols),
- super.wrap(cols, source.toList()) {
+ Field._internal(this.bombCount, int cols, UnmodifiableListView<bool> source)
+ : this._adjacents = new Array2d<int>(cols, source.length ~/ cols),
+ super.wrap(cols, source.toList()) {
assert(width > 0);
assert(height > 0);
assert(bombCount > 0);
assert(bombCount < length);
int count = 0;
- for (final m in this) {
+ for (var m in this) {
if (m) {
count++;
}
@@ -71,7 +72,7 @@ class Field extends Array2d<bool> {
if (val == null) {
val = 0;
- for (final i in getAdjacentIndices(x, y)) {
+ for (var i in getAdjacentIndices(x, y)) {
if (this[i]) {
val++;
}
« no previous file with comments | « samples/pop_pop_win/lib/src/game.dart ('k') | samples/pop_pop_win/lib/src/game/game.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698