poker-extval 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/evaluator.js +22 -1
  2. package/package.json +1 -2
package/evaluator.js CHANGED
@@ -158,7 +158,7 @@ class HandEvaluator {
158
158
  * - Pair categorization: isTopPair, isMiddlePair, isBottomPair
159
159
  * - Two pair categorization: isTopAndMiddlePair, isTopAndBottomPair, isMiddleAndBottomPair
160
160
  * - Three of a kind categorization: isTopThreeOfAKind, isMiddleThreeOfAKind, isBottomThreeOfAKind
161
- * - Draws: isFlushDraw, isBackdoorFlushDraw, isOpenEndedStraightDraw, isInsideStraightDraw
161
+ * - Draws: isFlushDraw, isBackdoorFlushDraw, isOpenEndedStraightDraw, isInsideStraightDraw, isStraightDraw
162
162
  */
163
163
  #evaluateSingleHand() {
164
164
  // Temporarily set this.evaluation to an empty object for the evaluation methods to use
@@ -188,6 +188,7 @@ class HandEvaluator {
188
188
  this.isStraightFlush();
189
189
  this.isOpenEndedStraightDraw();
190
190
  this.isInsideStraightDraw();
191
+ this.isStraightDraw();
191
192
  this.isHighCard();
192
193
 
193
194
  // Get the evaluation object and restore original
@@ -944,6 +945,26 @@ class HandEvaluator {
944
945
  return this.evaluation.isInsideStraightDrawWheel = this.getDistanceWheel(this.cards.slice(0,4)) === 4 || this.getDistanceWheel(this.cards.slice(1,5)) === 4;
945
946
  }
946
947
 
948
+ /**
949
+ * Determines if the hand is any type of straight draw (open-ended or inside, standard or wheel).
950
+ * Returns true if any of the other straight draw methods return true.
951
+ *
952
+ * @returns {boolean} True if the hand is any type of straight draw, false otherwise
953
+ * @example
954
+ * const evaluator = new HandEvaluator(['As', 'Ks', 'Qs', 'Js', '9h']);
955
+ * evaluator.isStraightDraw(); // Returns true (open-ended straight draw)
956
+ *
957
+ * @example
958
+ * const evaluator = new HandEvaluator(['As', 'Ks', 'Qs', 'Js', '8h']);
959
+ * evaluator.isStraightDraw(); // Returns true (inside straight draw)
960
+ */
961
+ isStraightDraw() {
962
+ if (this.evaluation.isStraightDraw !== undefined) return this.evaluation.isStraightDraw;
963
+ if (this.evaluation.isOpenEndedStraightDraw === undefined) this.isOpenEndedStraightDraw();
964
+ if (this.evaluation.isInsideStraightDraw === undefined) this.isInsideStraightDraw();
965
+ return this.evaluation.isStraightDraw = this.evaluation.isOpenEndedStraightDraw || this.evaluation.isInsideStraightDraw;
966
+ }
967
+
947
968
  // ==================== HIGH CARD ====================
948
969
 
949
970
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poker-extval",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Poker hand evaluator with comprehensive test suite",
5
5
  "main": "evaluator.js",
6
6
  "files": [
@@ -39,4 +39,3 @@
39
39
  "jest": "^29.7.0"
40
40
  }
41
41
  }
42
-