diff options
-rw-r--r-- | src/js/index.js | 20 | ||||
-rw-r--r-- | tests.js | 38 |
2 files changed, 56 insertions, 2 deletions
diff --git a/src/js/index.js b/src/js/index.js index 6a81601..f4163ee 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -894,6 +894,26 @@ | |||
894 | if (uniqueCards.length == 52) { | 894 | if (uniqueCards.length == 52) { |
895 | cardDetail.unshift("full deck"); | 895 | cardDetail.unshift("full deck"); |
896 | } | 896 | } |
897 | // Detect missing cards | ||
898 | var values = "A23456789TJQK"; | ||
899 | var suits = "CDHS"; | ||
900 | var missingCards = []; | ||
901 | for (var i=0; i<suits.length; i++) { | ||
902 | for (var j=0; j<values.length; j++) { | ||
903 | var card = values[j] + suits[i]; | ||
904 | if (!(card in dupeTracker)) { | ||
905 | missingCards.push(card); | ||
906 | } | ||
907 | } | ||
908 | } | ||
909 | // Display missing cards if six or less, ie clearly going for full deck | ||
910 | if (missingCards.length > 0 && missingCards.length <= 6) { | ||
911 | var msg = missingCards.length + " missing: " + missingCards.slice(0,3).join(" "); | ||
912 | if (missingCards.length > 3) { | ||
913 | msg += "..."; | ||
914 | } | ||
915 | cardDetail.push(msg); | ||
916 | } | ||
897 | // Add card details to typeStr | 917 | // Add card details to typeStr |
898 | if (cardDetail.length > 0) { | 918 | if (cardDetail.length > 0) { |
899 | typeStr += " (" + cardDetail.join(", ") + ")"; | 919 | typeStr += " (" + cardDetail.join(", ") + ")"; |
@@ -2650,7 +2650,7 @@ page.open(url, function(status) { | |||
2650 | }, | 2650 | }, |
2651 | { | 2651 | { |
2652 | entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d", | 2652 | entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d", |
2653 | type: "card (2 duplicates: 3d 4d)", | 2653 | type: "card (2 duplicates: 3d 4d, 1 missing: KS)", |
2654 | events: 53, | 2654 | events: 53, |
2655 | bits: 232, | 2655 | bits: 232, |
2656 | words: 27, | 2656 | words: 27, |
@@ -2658,7 +2658,7 @@ page.open(url, function(status) { | |||
2658 | }, | 2658 | }, |
2659 | { | 2659 | { |
2660 | entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d5d6d", | 2660 | entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d5d6d", |
2661 | type: "card (4 duplicates: 3d 4d 5d...)", | 2661 | type: "card (4 duplicates: 3d 4d 5d..., 1 missing: KS)", |
2662 | events: 53, | 2662 | events: 53, |
2663 | bits: 243, | 2663 | bits: 243, |
2664 | words: 27, | 2664 | words: 27, |
@@ -2690,6 +2690,40 @@ page.open(url, function(status) { | |||
2690 | words: 0, | 2690 | words: 0, |
2691 | strength: "extremely weak", | 2691 | strength: "extremely weak", |
2692 | }, | 2692 | }, |
2693 | // Missing cards are detected | ||
2694 | { | ||
2695 | entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", | ||
2696 | type: "card (1 missing: 9C)", | ||
2697 | events: 51, | ||
2698 | bits: 226, | ||
2699 | words: 27, | ||
2700 | strength: "extremely strong", | ||
2701 | }, | ||
2702 | { | ||
2703 | entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", | ||
2704 | type: "card (2 missing: 9C 5D)", | ||
2705 | events: 50, | ||
2706 | bits: 225, | ||
2707 | words: 24, | ||
2708 | strength: "extremely strong", | ||
2709 | }, | ||
2710 | { | ||
2711 | entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjd kdah2h3h 5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", | ||
2712 | type: "card (4 missing: 9C 5D QD...)", | ||
2713 | events: 48, | ||
2714 | bits: 221, | ||
2715 | words: 24, | ||
2716 | strength: "extremely strong", | ||
2717 | }, | ||
2718 | // More than six missing cards does not show message | ||
2719 | { | ||
2720 | entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d 8d9d jd kdah2h3h 5h6h7h8h9hthjhqhkh 2s3s4s5s6s7s8s9stsjsqsks", | ||
2721 | type: "card", | ||
2722 | events: 45, | ||
2723 | bits: 214, | ||
2724 | words: 24, | ||
2725 | strength: "extremely strong", | ||
2726 | }, | ||
2693 | ]; | 2727 | ]; |
2694 | // use entropy | 2728 | // use entropy |
2695 | page.evaluate(function() { | 2729 | page.evaluate(function() { |