OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |