Skip to content

Instantly share code, notes, and snippets.

Created October 17, 2011 12:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1292475 to your computer and use it in GitHub Desktop.
Save anonymous/1292475 to your computer and use it in GitHub Desktop.
public function getHandInfo() {
$straight_courant = 0;
foreach($this->hcard as $hcard) {
if($hcard > 0) {
if($hcard == '2') {
$this->pair++;
}
elseif($hcard == '3') {
$this->threeKind++;
}
elseif($hcard == '4') {
$this->fourKind++;
}
$straight_courant++;
}
else {
$this->straight = $straight_courant;
$straight_courant = 0;
}
}
foreach($this->hsuit as $hsuit) {
if($hsuit > $this->flush) {
$this->flush = $hsuit;
}
}
}
public function checkHand() {
if($this->fourKind > 0) {
return 'FK';
}
if($this->threeKind > 0 && $this->pair > 0) {
return 'FH';
}
if($this->flush > 3) {
if($this->flush > 4) {
return 'F';
}
else {
$this->drawingFlush = true;
}
}
if($this->straight > 3) {
if($this->straight > 4) {
return 'S';
}
else {
$this->drawingStraight = true;
}
}
if($this->threeKind > 0) {
return 'TK';
}
if($this->pair > 0) {
if($this->pair > 1) {
return 'TP';
}
else {
return 'P';
}
}
return 'HC';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment