๐ŸŽฒ ๐ŸŽฒ Craps Domain

Pub coverage License: MIT style: very good analysis


Core Craps Logic

Craps library that provides the components and game play for craps, the casino game. This is intended to be the core elements that allows creators to make the craps UI without having to build out the components

Installation ๐Ÿ’ป

Add craps_domain to your pubspec.yaml:

dependencies:
  craps_domain:

Install it:

dart pub get

Running Tests ๐Ÿงช

To run all unit tests:

dart pub global activate coverage 1.2.0
dart test --coverage=coverage
dart pub global run coverage:format_coverage --packages=.dart_tool/package_config.json --check-ignore --report-on=lib --lcov -o ./coverage/lcov.info -i ./coverage

To view the generated coverage report you can use lcov.

# Generate Coverage Report
genhtml -o ./coverage/report ./coverage/lcov.info

# Open Coverage Report
open ./coverage/report/index.html

Simulate 10 rolls ๐ŸŽฒ ๐ŸŽฒ

import 'package:craps_domain/craps_domain.dart';

void main() {
  final dice = Dice.generic();
  final puck = Puck();

  for (var i = 1; i < 11; i++) {
    final roll = dice.roll();
    roll.log();
    puck.evalRoll(roll.value);
  }
}

...should return ...

Connecting to VM Service at http://127.0.0.1:64072/P2Op5b6-B1s=/
[log] Roll: 7 - <5, 2>
[log] Front line Winner!
[log] Roll: 4 - <3, 1>
[log] (4); Mark the point
[log] Roll: 7 - <4, 3>
[log] Seven out; take the line; pay behind
[log] Roll: 6 - <2, 4>
[log] (6); Mark the point
[log] Roll: 6 - <3, 3>
[log] Point Made (6); pay the line
[log] Roll: 11 - <6, 5>
[log] Front line Winner!
[log] Roll: 6 - <5, 1>
[log] (6); Mark the point
[log] Roll: 7 - <4, 3>
[log] Seven out; take the line; pay behind
[log] Roll: 11 - <6, 5>
[log] Front line Winner!
[log] Roll: 5 - <2, 3>
[log] (5); Mark the point
Exited

Libraries

craps_domain
Core Craps Logic