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

Side by Side Diff: 2-4-extended/lib/common/utils.dart

Issue 1056193003: Rename methods to better match new terminology and get rid of json data file. (Closed) Base URL: https://github.com/dart-lang/one-hour-codelab.git@server2
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « 2-4-extended/lib/common/messages.dart ('k') | 2-4-extended/lib/server/piratenames.json » ('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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library pirate.utils; 5 library pirate.utils;
6 6
7 import 'dart:math' show Random; 7 import 'dart:math' show Random;
8 8
9 import 'messages.dart'; 9 import 'messages.dart';
10 10
11 List<String> _forbiddenAppellations = [ 11 // Proper pirate names and appellations.
12 const Map<String, List<String>> properPirateNames = const {
13 "names": const [ "Anne", "Bette", "Cate", "Dawn",
14 "Elise", "Faye", "Ginger", "Harriot",
15 "Izzy", "Jane", "Kaye", "Liz",
16 "Maria", "Nell", "Olive", "Pat",
17 "Queenie", "Rae", "Sal", "Tam",
18 "Uma", "Violet", "Wilma", "Xana",
19 "Yvonne", "Zelda",
20 "Abe", "Billy", "Caleb", "Davie",
21 "Eb", "Frank", "Gabe", "House",
22 "Icarus", "Jack", "Kurt", "Larry",
23 "Mike", "Nolan", "Oliver", "Pat",
24 "Quib", "Roy", "Sal", "Tom",
25 "Ube", "Val", "Walt", "Xavier",
26 "Yvan", "Zeb"],
27 "appellations": const [ "Awesome", "Captain",
28 "Even", "Fighter", "Great", "Hearty",
29 "Jackal", "King", "Lord",
30 "Mighty", "Noble", "Old", "Powerful",
31 "Quick", "Red", "Stalwart", "Tank",
32 "Ultimate", "Vicious", "Wily", "aXe", "Young",
33 "Brave", "Eager",
34 "Kind", "Sandy",
35 "Xeric", "Yellow", "Zesty"]
36 };
37
38 // Clearly invalid pirate appellations.
39 const List<String> _forbiddenAppellations = const [
12 null, 40 null,
13 '', 41 '',
14 'sweet', 42 'sweet',
15 'handsome', 43 'handsome',
16 'beautiful', 44 'beautiful',
17 'weak', 45 'weak',
18 'wuss', 46 'wuss',
19 'chicken', 47 'chicken',
20 'fearful', 48 'fearful',
21 ]; 49 ];
(...skipping 19 matching lines...) Expand all
41 Pirate shanghaiAPirate({String name, String appellation}) { 69 Pirate shanghaiAPirate({String name, String appellation}) {
42 var pirate = new Pirate(); 70 var pirate = new Pirate();
43 pirate.name = 71 pirate.name =
44 name != null ? name : names[indexGen.nextInt(names.length)]; 72 name != null ? name : names[indexGen.nextInt(names.length)];
45 pirate.appellation = appellation != null 73 pirate.appellation = appellation != null
46 ? appellation 74 ? appellation
47 : appellations[indexGen.nextInt(appellations.length)]; 75 : appellations[indexGen.nextInt(appellations.length)];
48 return truePirate(pirate) ? pirate : null; 76 return truePirate(pirate) ? pirate : null;
49 } 77 }
50 } 78 }
OLDNEW
« no previous file with comments | « 2-4-extended/lib/common/messages.dart ('k') | 2-4-extended/lib/server/piratenames.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698