@@ -74,22 +74,22 @@ discard block |
||
74 | 74 | { |
75 | 75 | $playerHands = $playerHands |
76 | 76 | // evaluate hands |
77 | - ->map(function (Hand $hand) use ($board) { |
|
77 | + ->map(function(Hand $hand) use ($board) { |
|
78 | 78 | return static::evaluate($board, $hand); |
79 | 79 | }) |
80 | 80 | |
81 | 81 | // sort the hands by their hand rank |
82 | - ->sortByDesc(function (SevenCardResult $result) { |
|
82 | + ->sortByDesc(function(SevenCardResult $result) { |
|
83 | 83 | return [$result->rank(), $result->value()]; |
84 | 84 | }) |
85 | 85 | |
86 | 86 | // group by the hand rank |
87 | - ->groupBy(function (SevenCardResult $result) { |
|
87 | + ->groupBy(function(SevenCardResult $result) { |
|
88 | 88 | return $result->rank(); |
89 | 89 | }) |
90 | 90 | |
91 | 91 | // sort the collection by the count |
92 | - ->sortByDesc(function (Collection $collection) { |
|
92 | + ->sortByDesc(function(Collection $collection) { |
|
93 | 93 | return $collection->count(); |
94 | 94 | }) |
95 | 95 | ; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | // if all hands in the first collection are equal |
98 | 98 | $handsAreEqual = $playerHands |
99 | 99 | ->first() |
100 | - ->groupBy(function (SevenCardResult $result) { |
|
100 | + ->groupBy(function(SevenCardResult $result) { |
|
101 | 101 | return array_sum($result->value()); |
102 | 102 | }) |
103 | 103 | ; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | // make sure that TJQKA exist in hand |
123 | 123 | $royalFlushHand = $cards |
124 | 124 | ->switchAceValue() |
125 | - ->filter(function (Card $card) { |
|
125 | + ->filter(function(Card $card) { |
|
126 | 126 | return $card->isFaceCard() || $card->value() === 10; |
127 | 127 | }); |
128 | 128 | |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | { |
201 | 201 | $groupedBySuit = $cards |
202 | 202 | ->switchAceValue() |
203 | - ->groupBy(function (Card $card) { |
|
203 | + ->groupBy(function(Card $card) { |
|
204 | 204 | return $card->suit()->name(); |
205 | 205 | }) |
206 | - ->sortByDesc(function ($group) { |
|
206 | + ->sortByDesc(function($group) { |
|
207 | 207 | return count($group); |
208 | 208 | }); |
209 | 209 | if ($groupedBySuit->first()->count() < 5) { |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | return false; |
369 | 369 | } |
370 | 370 | |
371 | - $uniqueCards = $cards->map(function (Card $card) { |
|
371 | + $uniqueCards = $cards->map(function(Card $card) { |
|
372 | 372 | return $card->value(); |
373 | 373 | })->unique(); |
374 | 374 | if ($cards->count() !== $uniqueCards->count()) { |
@@ -394,13 +394,13 @@ discard block |
||
394 | 394 | private static function nNumberOfCardsInSet(CardCollection $cards, int $numberOfCardsOfType) |
395 | 395 | { |
396 | 396 | $judgedHand = $cards |
397 | - ->groupBy(function (Card $card) { |
|
397 | + ->groupBy(function(Card $card) { |
|
398 | 398 | return $card->value(); |
399 | 399 | }) |
400 | - ->filter(function (CardCollection $group) use ($numberOfCardsOfType) { |
|
400 | + ->filter(function(CardCollection $group) use ($numberOfCardsOfType) { |
|
401 | 401 | return $group->count() === $numberOfCardsOfType; |
402 | 402 | }) |
403 | - ->sortBy(function (CardCollection $group) { |
|
403 | + ->sortBy(function(CardCollection $group) { |
|
404 | 404 | return $group->count(); |
405 | 405 | }) |
406 | 406 | ->values() |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $buyinAmount = $buyinAmount ?? $this->rules()->minimumBuyIn(); |
128 | 128 | |
129 | 129 | $playerRegistered = $this->players() |
130 | - ->filter(function (Client $player) use ($client) { |
|
130 | + ->filter(function(Client $player) use ($client) { |
|
131 | 131 | return $client->name() === $player->name(); |
132 | 132 | }); |
133 | 133 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $groupedPlayers = $this->players() |
151 | 151 | //->shuffle() |
152 | 152 | ->chunk($this->rules()->tableSize()) |
153 | - ->map(function (PlayerCollection $players) { |
|
153 | + ->map(function(PlayerCollection $players) { |
|
154 | 154 | $dealer = Dealer::startWork(new Deck(), new SevenCard()); |
155 | 155 | |
156 | 156 | return Table::setUp($dealer, $players); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | { |
205 | 205 | $this->chipPots() |
206 | 206 | ->reverse() |
207 | - ->each(function (ChipPot $chipPot) { |
|
207 | + ->each(function(ChipPot $chipPot) { |
|
208 | 208 | // if only 1 player participated to pot, he wins it no arguments |
209 | 209 | if ($chipPot->players()->count() === 1) { |
210 | 210 | $potTotal = $chipPot->chips()->total(); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | // split the pot between the number of players |
239 | 239 | $splitTotal = Chips::fromAmount(($potTotal->amount() / $evaluate->count())); |
240 | - $evaluate->each(function (CardResults $result) use ($splitTotal) { |
|
240 | + $evaluate->each(function(CardResults $result) use ($splitTotal) { |
|
241 | 241 | $result->hand()->player()->chipStack()->add($splitTotal); |
242 | 242 | }); |
243 | 243 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | { |
381 | 381 | $nextPlayer = $this->leftToAct()->getNextPlayer(); |
382 | 382 | |
383 | - return $this->players()->filter(function (PlayerContract $player) use ($nextPlayer) { |
|
383 | + return $this->players()->filter(function(PlayerContract $player) use ($nextPlayer) { |
|
384 | 384 | return $player->name() === $nextPlayer['player']; |
385 | 385 | })->first() ?? false; |
386 | 386 | } |
@@ -390,13 +390,13 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public function collectChipTotal(): ChipPotCollection |
392 | 392 | { |
393 | - $allInActionsThisRound = $this->leftToAct()->filter(function (array $value) { |
|
393 | + $allInActionsThisRound = $this->leftToAct()->filter(function(array $value) { |
|
394 | 394 | return $value['action'] === LeftToAct::ALL_IN; |
395 | 395 | }); |
396 | 396 | |
397 | 397 | if ($allInActionsThisRound->count() > 1) { |
398 | 398 | $orderedBetStacks = $this->betStacks() |
399 | - ->reject(function (Chips $chips, $playerName) { |
|
399 | + ->reject(function(Chips $chips, $playerName) { |
|
400 | 400 | $foldedPlayer = $this->foldedPlayers()->findByName($playerName); |
401 | 401 | if ($foldedPlayer) { |
402 | 402 | return true; |
@@ -406,8 +406,8 @@ discard block |
||
406 | 406 | }) |
407 | 407 | ->sortByChipAmount(); |
408 | 408 | |
409 | - $orderedBetStacks->each(function (Chips $playerChips, $playerName) use ($orderedBetStacks) { |
|
410 | - $remainingStacks = $orderedBetStacks->filter(function (Chips $chips) { |
|
409 | + $orderedBetStacks->each(function(Chips $playerChips, $playerName) use ($orderedBetStacks) { |
|
410 | + $remainingStacks = $orderedBetStacks->filter(function(Chips $chips) { |
|
411 | 411 | return $chips->amount() !== 0; |
412 | 412 | }); |
413 | 413 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | $player = $this->players()->findByName($playerName); |
418 | 418 | $allInAmount = Chips::fromAmount($orderedBetStacks->findByPlayer($player)->amount()); |
419 | 419 | |
420 | - $remainingStacks->each(function (Chips $chips, $playerName) use ($allInAmount, $orderedBetStacks) { |
|
420 | + $remainingStacks->each(function(Chips $chips, $playerName) use ($allInAmount, $orderedBetStacks) { |
|
421 | 421 | $player = $this->players()->findByName($playerName); |
422 | 422 | |
423 | 423 | $stackChips = Chips::fromAmount($allInAmount->amount()); |
@@ -434,14 +434,14 @@ discard block |
||
434 | 434 | |
435 | 435 | // sort the pots so we get rid of any empty ones |
436 | 436 | $this->chipPots = $this->chipPots |
437 | - ->filter(function (ChipPot $chipPot) { |
|
437 | + ->filter(function(ChipPot $chipPot) { |
|
438 | 438 | return $chipPot->total()->amount() !== 0; |
439 | 439 | }) |
440 | 440 | ->values(); |
441 | 441 | |
442 | 442 | // grab anyone that folded |
443 | 443 | $this->betStacks() |
444 | - ->filter(function (Chips $chips, $playerName) { |
|
444 | + ->filter(function(Chips $chips, $playerName) { |
|
445 | 445 | $foldedPlayer = $this->foldedPlayers()->findByName($playerName); |
446 | 446 | if ($foldedPlayer && $chips->amount() > 0) { |
447 | 447 | return true; |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | |
450 | 450 | return false; |
451 | 451 | }) |
452 | - ->each(function (Chips $chips, $playerName) use ($orderedBetStacks) { |
|
452 | + ->each(function(Chips $chips, $playerName) use ($orderedBetStacks) { |
|
453 | 453 | $player = $this->players()->findByName($playerName); |
454 | 454 | |
455 | 455 | $stackChips = Chips::fromAmount($chips->amount()); |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | $orderedBetStacks->put($playerName, Chips::fromAmount($chips->amount())); |
460 | 460 | }); |
461 | 461 | } else { |
462 | - $this->betStacks()->each(function (Chips $chips, $playerName) { |
|
462 | + $this->betStacks()->each(function(Chips $chips, $playerName) { |
|
463 | 463 | $this->currentPot()->addChips($chips, $this->players()->findByName($playerName)); |
464 | 464 | }); |
465 | 465 | } |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | */ |
632 | 632 | private function highestBet(): Chips |
633 | 633 | { |
634 | - return Chips::fromAmount($this->betStacks()->max(function (Chips $chips) { |
|
634 | + return Chips::fromAmount($this->betStacks()->max(function(Chips $chips) { |
|
635 | 635 | return $chips->amount(); |
636 | 636 | }) ?? 0); |
637 | 637 | } |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | */ |
659 | 659 | private function resetBetStacks() |
660 | 660 | { |
661 | - $this->players()->each(function (PlayerContract $player) { |
|
661 | + $this->players()->each(function(PlayerContract $player) { |
|
662 | 662 | $this->betStacks->put($player->name(), Chips::zero()); |
663 | 663 | }); |
664 | 664 | } |