From fe033bdfaaa35db3d89beb0d0a062b9f94f01103 Mon Sep 17 00:00:00 2001 From: Meshulam Silk Date: Sun, 12 Apr 2015 05:22:06 +0300 Subject: [PATCH] Added relationships category builder --- lib/geek_code_312.dart | 1 + .../relationships_geek_code_category.dart | 59 +++++++++++++++++++ lib/src/312/geek_code_v312_categories.dart | 6 +- pubspec.yaml | 2 +- test/all_test.dart | 2 +- 5 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 lib/src/312/categories/relationships_geek_code_category.dart diff --git a/lib/geek_code_312.dart b/lib/geek_code_312.dart index c44fc8b..c4993cf 100644 --- a/lib/geek_code_312.dart +++ b/lib/geek_code_312.dart @@ -19,5 +19,6 @@ part "src/312/categories/unix_geek_code_category.dart"; part "src/312/categories/dress_geek_code_category.dart"; part "src/312/categories/shape_geek_code_category.dart"; part "src/312/categories/age_geek_code_category.dart"; +part "src/312/categories/relationships_geek_code_category.dart"; part "src/312/geek_code_types.dart"; part "src/312/geek_code_v312_categories.dart"; \ No newline at end of file diff --git a/lib/src/312/categories/relationships_geek_code_category.dart b/lib/src/312/categories/relationships_geek_code_category.dart new file mode 100644 index 0000000..b515d12 --- /dev/null +++ b/lib/src/312/categories/relationships_geek_code_category.dart @@ -0,0 +1,59 @@ +// Copyright (c) 2015, Meshulam Silk (moomoohk@ymail.com). All rights reserved. Use of this source code +// is governed by a BSD-style license that can be found in the LICENSE file. + +part of geek_code.v312; + +/** + * Class that builds [DressGeekCodeCategory]s. + * + * Adds 2 variable setting methods: + * + * * [crossDresser] + * * [sameClothes] + */ +class RelationshipsGeekCodeCategoryBuilder extends ExtremeGenericGeekCodeCategoryBuilder { + bool _dumped = false; + + /** + * Creates a new [DressGeekCodeCategoryBuilder] object. + * + * See [GeekCodeCategoryBuilder.GeekCodeCategoryBuilder] for a description of the parameters. + */ + RelationshipsGeekCodeCategoryBuilder(String code, int minGrade, int maxGrade) : super(code, minGrade, maxGrade); + + /** + * Original documentation: + * + * r% + * I was going out with someone, but the asshole dumped me. + */ + RelationshipsGeekCodeCategory dumped() { + this._dumped = true; + return subValidate(null, false, false); + } + + /** + * Returns a [DressGeekCodeCategory] without performing any additional validations. + * + * See [GeekCodeCategoryBuilder.subValidate] for a fuller explanation of this method. + */ + RelationshipsGeekCodeCategory subValidate(GeekCodeGrade grade, bool refuse, bool noKnowledge) => new RelationshipsGeekCodeCategory(this, grade); +} + +/** + * Original documentation: + * + * It is said that "clothes make the man". Well, I understood that I was made by a mommy and a daddy (and there's even a category to describe the process below!). Maybe the people who made up that saying aren't being quite that literal... + */ +class RelationshipsGeekCodeCategory extends ExtremeGeekCodeCategory { + final RelationshipsGeekCodeCategoryBuilder _builder; + + /** + * See [GeekCodeCategory.GeekCodeCategory] for a description of the parameters. + */ + RelationshipsGeekCodeCategory(RelationshipsGeekCodeCategoryBuilder builder, GeekCodeGrade grade) + : this._builder = builder, + super(builder, grade); + + String toString() => super.toString() + (_builder._dumped ? "%" : ""); +} diff --git a/lib/src/312/geek_code_v312_categories.dart b/lib/src/312/geek_code_v312_categories.dart index d248c3a..0a51e3d 100644 --- a/lib/src/312/geek_code_v312_categories.dart +++ b/lib/src/312/geek_code_v312_categories.dart @@ -787,10 +787,8 @@ final ExtremeGenericGeekCodeCategoryBuilder h = getBuilder("h") as ExtremeGeneri * signifying membership in the SBCA (Sour Bachelor(ette)'s Club of America). The motto is 'Bitter, but not Desperate'. First founded at Caltech. * r% * I was going out with someone, but the asshole dumped me. - * - * Note: r% is not supported currently. */ -final ExtremeGenericGeekCodeCategoryBuilder r = getBuilder("r") as ExtremeGenericGeekCodeCategoryBuilder; //TODO: Support r% +final RelationshipsGeekCodeCategoryBuilder r = getBuilder("r") as RelationshipsGeekCodeCategoryBuilder; /** * Builds the Sex category @@ -936,7 +934,7 @@ GeekCodeCategoryBuilder getBuilder(String categoryCode) { return new ExtremeGenericGeekCodeCategoryBuilder("h", -4, 2); case "r": - return new ExtremeGenericGeekCodeCategoryBuilder("r", -3, 3); + return new RelationshipsGeekCodeCategoryBuilder("r", -3, 3); case "x": return new SexGeekCodeCategoryBuilder("z", -3, 5).female(); diff --git a/pubspec.yaml b/pubspec.yaml index 554b354..003ee57 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: geek_code -version: 1.1.0 +version: 2.0.0 author: Meshulam Silk description: Dart implementation of The Geek Code homepage: http://moomoohk.github.io/projects/geek_code diff --git a/test/all_test.dart b/test/all_test.dart index 4b106a4..45762e4 100644 --- a/test/all_test.dart +++ b/test/all_test.dart @@ -36,7 +36,7 @@ main() { ..addCategory(GCode.grade(new GeekCodeGrade(2))) ..addCategory(e.grade(new GeekCodeGrade(0))) ..addCategory(h.living().grade(new GeekCodeGrade(-2))) - ..addCategory(r.refuse()) + ..addCategory(r.dumped()) ..addCategory(z.refuse()); print(code.generate()); }