PHP Classes

reduce the code class

Recommend this page to a friend!

      PHP Poker Engine  >  All threads  >  reduce the code class  >  (Un) Subscribe thread alerts  
Subject:reduce the code class
Summary:why don't u use [number] or (number)???
Messages:3
Author:AMBA
Date:2008-04-03 07:50:46
Update:2008-04-08 14:24:59
 

  1. reduce the code class   Reply   Report abuse  
Picture of AMBA AMBA - 2008-04-03 07:50:48
hi,
i see ur beautifull code but its a big one ^^
can't we use [] to simplify ???
by replacing
$this->kicker1Text
by
$this->kickerText[1]

or
getPlayer1Pocket()
by
getPlayerPocket(1)

all function are the same isn't it ???
thks
and best regards
Amba

  2. Re: reduce the code class   Reply   Report abuse  
Picture of Jayme Fishman Jayme Fishman - 2008-04-04 02:06:50 - In reply to message 1 from AMBA
I could not agree more. It is HUGE. It was the first thing that I ever wrote (and I am self taught which is why it is not very good) ... and I don't mess around with this stuff very much. However, I did just write another poker engine that is 10% of the size of this one in a client side scripting language called "autoit." I may port that code to PHP since it is much more efficient. Example, the code below is used to find a pair and all three kickers. If you look in the PHP code it is hundreds of lines. If I have time I will release a new version that is much easier to maintain/use and MUCH smaller.

Func findTwo($cardCount)
dim $findCounter ; used in the for loop
dim $innerWhileCounter =1 ; used in the while loop
dim $decimalPlace = .01 ; used for kicker score
$ccPosition =12
for $findCounter = 12 to 0 Step -1
if $cardCount[$ccPosition] = 2 Then
$text = "Pair"
$points = ($ccPosition * 2) + 1000
dim $startPos2 = 12
while $innerWhileCounter <4
If $cardCount[$startPos2] = 1 then
$kickerScore += $startPos2 * $decimalPlace
;MsgBox("","KickerScore is: ", $kickerScore) - Debug Code
$innerWhileCounter += 1
$decimalPlace *= .01
EndIf
$startPos2 -= 1
WEnd
return True
EndIf
$ccPosition -=1
Next
EndFunc

  3. Re: reduce the code class   Reply   Report abuse  
Picture of AMBA AMBA - 2008-04-08 14:24:59 - In reply to message 2 from Jayme Fishman
i reduce a part of your code functions, enjoy :

public function getPlayerPocket($player)
{
return self::$allhands[$player][0].self::$allhands[$player][1];
}
public function getpocketImg($player)
{
$pPocket[$player][1] = self::$allhands[$player][0].".jpg";
$pPocket[$player][2] = self::$allhands[$player][1].".jpg";
return self::IMAGEPATH.$pPocket[$player][1].">".self::IMAGEPATH.$pPocket[$player][2].">";;
}

public function getPocketPlusFlop($player)
{
return self::getPlayerPocket($player)." ".self::getflop()." ";
}

public function getPocketFlopTurn($player)
{
return self::getPlayerPocket($player)." ".self::getflop()." ".self::getTurn()." ";
}

public function getFinalHand($player)
{
return self::getPlayerPocket($player).self::getflop().self::getTurn().self::getRiver();
}