Skip to content

Commit

Permalink
Added relationships category builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Meshulam Silk committed Apr 12, 2015
1 parent 238717f commit fe033bd
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/geek_code_312.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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";
59 changes: 59 additions & 0 deletions lib/src/312/categories/relationships_geek_code_category.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) 2015, Meshulam Silk ([email protected]). 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 ? "%" : "");
}
6 changes: 2 additions & 4 deletions lib/src/312/geek_code_v312_categories.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: geek_code
version: 1.1.0
version: 2.0.0
author: Meshulam Silk <[email protected]>
description: Dart implementation of The Geek Code
homepage: http://moomoohk.github.io/projects/geek_code
Expand Down
2 changes: 1 addition & 1 deletion test/all_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit fe033bd

Please sign in to comment.