J
J. J. Cale
Hi all
I'm using a strict doctype and testing in IE6 and Mozilla
I understand the basics of regexs but not the subtleties
(is that spelled right?).
I'm trying to evaluate poker hands that are saved as an object
with an array of cards. I checked John Stockton's archives
and searched google but did'nt find anything I could or would
convert or use. If someone knows where to find the routines
I need a pointer would be fine thank you. For the regex
heavyweights in this group, how would I use them to test
my card array for pairs, two pairs, three etc.
<script type="text/javascript">
function Hand(name) {
this.name = name;
this.cards = new Array();
this.suits = new Array();
this.handValue = 0;
}
var handsArr = new Array();
handsArr[0] = new Hand('dealer');
handsArr[1] = new Hand('player');
</script>
The game is stud poker and initially two cards are
dealt to 'dealer' and 'player' from a shuffled deck
of 52 cards. The cards are displayed and at this
point the above arrays are populated. The obj.cards
array holds numbers from 1 - 13
after the deck[ind] returns a number from 1 - 52
I filter it for suit and convert the number (num % 13).
I haven't decided how to populate the suit array.
Probably numbers 0 1 2 3 or 1 2 3 4
If strings would be less complicated I can do that.
At this point I intend to create strings from the arrays
and test.
if(/^exp$/.test(myCardString)) return 'pair','straight' etc;
straight == true && /^exp$/.test(mySuitString)? return 'stflush':
return 'straight';
and so on.
Any help would be appreciated. TIA
Jimbo
I'm using a strict doctype and testing in IE6 and Mozilla
I understand the basics of regexs but not the subtleties
(is that spelled right?).
I'm trying to evaluate poker hands that are saved as an object
with an array of cards. I checked John Stockton's archives
and searched google but did'nt find anything I could or would
convert or use. If someone knows where to find the routines
I need a pointer would be fine thank you. For the regex
heavyweights in this group, how would I use them to test
my card array for pairs, two pairs, three etc.
<script type="text/javascript">
function Hand(name) {
this.name = name;
this.cards = new Array();
this.suits = new Array();
this.handValue = 0;
}
var handsArr = new Array();
handsArr[0] = new Hand('dealer');
handsArr[1] = new Hand('player');
</script>
The game is stud poker and initially two cards are
dealt to 'dealer' and 'player' from a shuffled deck
of 52 cards. The cards are displayed and at this
point the above arrays are populated. The obj.cards
array holds numbers from 1 - 13
after the deck[ind] returns a number from 1 - 52
I filter it for suit and convert the number (num % 13).
I haven't decided how to populate the suit array.
Probably numbers 0 1 2 3 or 1 2 3 4
If strings would be less complicated I can do that.
At this point I intend to create strings from the arrays
and test.
if(/^exp$/.test(myCardString)) return 'pair','straight' etc;
straight == true && /^exp$/.test(mySuitString)? return 'stflush':
return 'straight';
and so on.
Any help would be appreciated. TIA
Jimbo