Skip to content

Commit

Permalink
fifteens scoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nik frank committed Apr 23, 2017
1 parent 4782dad commit 8b047e2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions canon/crib/src/util/score.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,21 @@ export default (hand, cut = {}) => {
'0110': 12,
'1010': 12,
}[runPattern] || 0;


const ranks = cards.map( c => Math.min(10, c.rank) );

const fifteenPts =
Array( Math.pow(2, ranks.length) - 1)
.fill(1).map( (d, i) => ('0000'+(i+1).toString(2)).slice(-1 * ranks.length).split('') )
.filter( b =>
(b.reduce( (p, c, i) => (p + (1 * c) * ranks[i]), 0 ) === 15)
).length * 2;

total += dibsPts;
total += pairPts;
total += flushPts;
total += runPts;

total += fifteenPts;

return total;
};

0 comments on commit 8b047e2

Please sign in to comment.