@@ -74,23 +74,23 @@ 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 | |
79 | 79 | return static::evaluate($board, $hand); |
80 | 80 | }) |
81 | 81 | |
82 | 82 | // sort the hands by their hand rank |
83 | - ->sortByDesc(function (SevenCardResult $result) { |
|
83 | + ->sortByDesc(function(SevenCardResult $result) { |
|
84 | 84 | return [$result->rank(), $result->value()]; |
85 | 85 | }) |
86 | 86 | |
87 | 87 | // group by the hand rank |
88 | - ->groupBy(function (SevenCardResult $result) { |
|
88 | + ->groupBy(function(SevenCardResult $result) { |
|
89 | 89 | return $result->rank(); |
90 | 90 | }) |
91 | 91 | |
92 | 92 | // sort the collection by the count |
93 | - ->sortByDesc(function (Collection $collection) { |
|
93 | + ->sortByDesc(function(Collection $collection) { |
|
94 | 94 | return $collection->count(); |
95 | 95 | }) |
96 | 96 | ; |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | // if all hands in the first collection are equal |
99 | 99 | $handsAreEqual = $playerHands |
100 | 100 | ->first() |
101 | - ->groupBy(function (SevenCardResult $result) { |
|
101 | + ->groupBy(function(SevenCardResult $result) { |
|
102 | 102 | return array_sum($result->value()); |
103 | 103 | }) |
104 | 104 | ; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | // make sure that TJQKA exist in hand |
124 | 124 | $royalFlushHand = $cards |
125 | 125 | ->switchAceValue() |
126 | - ->filter(function (Card $card) { |
|
126 | + ->filter(function(Card $card) { |
|
127 | 127 | return $card->isFaceCard() || $card->value() === 10; |
128 | 128 | }); |
129 | 129 | |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | { |
202 | 202 | $groupedBySuit = $cards |
203 | 203 | ->switchAceValue() |
204 | - ->groupBy(function (Card $card) { |
|
204 | + ->groupBy(function(Card $card) { |
|
205 | 205 | return $card->suit()->name(); |
206 | 206 | }) |
207 | - ->sortByDesc(function ($group) { |
|
207 | + ->sortByDesc(function($group) { |
|
208 | 208 | return count($group); |
209 | 209 | }); |
210 | 210 | if ($groupedBySuit->first()->count() < 5) { |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | return false; |
370 | 370 | } |
371 | 371 | |
372 | - $uniqueCards = $cards->map(function (Card $card) { |
|
372 | + $uniqueCards = $cards->map(function(Card $card) { |
|
373 | 373 | return $card->value(); |
374 | 374 | })->unique(); |
375 | 375 | if ($cards->count() !== $uniqueCards->count()) { |
@@ -395,13 +395,13 @@ discard block |
||
395 | 395 | private static function nNumberOfCardsInSet(CardCollection $cards, int $numberOfCardsOfType) |
396 | 396 | { |
397 | 397 | $judgedHand = $cards |
398 | - ->groupBy(function (Card $card) { |
|
398 | + ->groupBy(function(Card $card) { |
|
399 | 399 | return $card->value(); |
400 | 400 | }) |
401 | - ->filter(function (CardCollection $group) use ($numberOfCardsOfType) { |
|
401 | + ->filter(function(CardCollection $group) use ($numberOfCardsOfType) { |
|
402 | 402 | return $group->count() === $numberOfCardsOfType; |
403 | 403 | }) |
404 | - ->sortBy(function (CardCollection $group) { |
|
404 | + ->sortBy(function(CardCollection $group) { |
|
405 | 405 | return $group->count(); |
406 | 406 | }) |
407 | 407 | ->values() |
@@ -166,7 +166,6 @@ |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | - * @param PlayerContract $player |
|
170 | 169 | * |
171 | 170 | * @return int |
172 | 171 | */ |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | public function findSeat(PlayerContract $findPlayer): int |
143 | 143 | { |
144 | 144 | return $this->players() |
145 | - ->filter(function (PlayerContract $player) use ($findPlayer) { |
|
145 | + ->filter(function(PlayerContract $player) use ($findPlayer) { |
|
146 | 146 | return $player->equals($findPlayer); |
147 | 147 | }) |
148 | 148 | ->keys() |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | public function findPlayerByName($playerName): PlayerContract |
158 | 158 | { |
159 | 159 | return $this->players() |
160 | - ->filter(function (PlayerContract $player) use ($playerName) { |
|
160 | + ->filter(function(PlayerContract $player) use ($playerName) { |
|
161 | 161 | return $player->name() === $playerName; |
162 | 162 | }) |
163 | 163 | ->first(); |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | { |
228 | 228 | $this->chipPots() |
229 | 229 | ->reverse() |
230 | - ->each(function (ChipPot $chipPot) { |
|
230 | + ->each(function(ChipPot $chipPot) { |
|
231 | 231 | // if only 1 player participated to pot, he wins it no arguments |
232 | 232 | if ($chipPot->players()->count() === 1) { |
233 | 233 | $potTotal = $chipPot->chips()->total(); |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | |
261 | 261 | // split the pot between the number of players |
262 | 262 | $splitTotal = Chips::fromAmount(($potTotal->amount() / $evaluate->count())); |
263 | - $evaluate->each(function (CardResults $result) use ($splitTotal) { |
|
263 | + $evaluate->each(function(CardResults $result) use ($splitTotal) { |
|
264 | 264 | $result->hand()->player()->chipStack()->add($splitTotal); |
265 | 265 | }); |
266 | 266 | |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | { |
420 | 420 | $nextPlayer = $this->leftToAct()->getNextPlayer(); |
421 | 421 | |
422 | - return $this->players()->filter(function (PlayerContract $player) use ($nextPlayer) { |
|
422 | + return $this->players()->filter(function(PlayerContract $player) use ($nextPlayer) { |
|
423 | 423 | return $player->name() === $nextPlayer['player']; |
424 | 424 | })->first() ?? false; |
425 | 425 | } |
@@ -429,13 +429,13 @@ discard block |
||
429 | 429 | */ |
430 | 430 | public function collectChipTotal(): ChipPotCollection |
431 | 431 | { |
432 | - $allInActionsThisRound = $this->leftToAct()->filter(function (array $value) { |
|
432 | + $allInActionsThisRound = $this->leftToAct()->filter(function(array $value) { |
|
433 | 433 | return $value['action'] === LeftToAct::ALL_IN; |
434 | 434 | }); |
435 | 435 | |
436 | 436 | if ($allInActionsThisRound->count() > 1) { |
437 | 437 | $orderedBetStacks = $this->betStacks() |
438 | - ->reject(function (Chips $chips, $playerName) { |
|
438 | + ->reject(function(Chips $chips, $playerName) { |
|
439 | 439 | $foldedPlayer = $this->foldedPlayers()->findByName($playerName); |
440 | 440 | if ($foldedPlayer) { |
441 | 441 | return true; |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | }) |
446 | 446 | ->sortByChipAmount(); |
447 | 447 | |
448 | - $orderedBetStacks->each(function (Chips $playerChips, $playerName) use ($orderedBetStacks) { |
|
449 | - $remainingStacks = $orderedBetStacks->filter(function (Chips $chips) { |
|
448 | + $orderedBetStacks->each(function(Chips $playerChips, $playerName) use ($orderedBetStacks) { |
|
449 | + $remainingStacks = $orderedBetStacks->filter(function(Chips $chips) { |
|
450 | 450 | return $chips->amount() !== 0; |
451 | 451 | }); |
452 | 452 | |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | $player = $this->players()->findByName($playerName); |
457 | 457 | $allInAmount = Chips::fromAmount($orderedBetStacks->findByPlayer($player)->amount()); |
458 | 458 | |
459 | - $remainingStacks->each(function (Chips $chips, $playerName) use ($allInAmount, $orderedBetStacks) { |
|
459 | + $remainingStacks->each(function(Chips $chips, $playerName) use ($allInAmount, $orderedBetStacks) { |
|
460 | 460 | $player = $this->players()->findByName($playerName); |
461 | 461 | |
462 | 462 | $stackChips = Chips::fromAmount($allInAmount->amount()); |
@@ -473,14 +473,14 @@ discard block |
||
473 | 473 | |
474 | 474 | // sort the pots so we get rid of any empty ones |
475 | 475 | $this->chipPots = $this->chipPots |
476 | - ->filter(function (ChipPot $chipPot) { |
|
476 | + ->filter(function(ChipPot $chipPot) { |
|
477 | 477 | return $chipPot->total()->amount() !== 0; |
478 | 478 | }) |
479 | 479 | ->values(); |
480 | 480 | |
481 | 481 | // grab anyone that folded |
482 | 482 | $this->betStacks() |
483 | - ->filter(function (Chips $chips, $playerName) { |
|
483 | + ->filter(function(Chips $chips, $playerName) { |
|
484 | 484 | $foldedPlayer = $this->foldedPlayers()->findByName($playerName); |
485 | 485 | if ($foldedPlayer && $chips->amount() > 0) { |
486 | 486 | return true; |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | return false; |
490 | 490 | }) |
491 | 491 | // and add their chips into the first created pot |
492 | - ->each(function (Chips $chips, $playerName) use ($orderedBetStacks) { |
|
492 | + ->each(function(Chips $chips, $playerName) use ($orderedBetStacks) { |
|
493 | 493 | $player = $this->players()->findByName($playerName); |
494 | 494 | |
495 | 495 | $stackChips = Chips::fromAmount($chips->amount()); |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | $orderedBetStacks->put($playerName, Chips::fromAmount($chips->amount())); |
500 | 500 | }); |
501 | 501 | } else { |
502 | - $this->betStacks()->each(function (Chips $chips, $playerName) { |
|
502 | + $this->betStacks()->each(function(Chips $chips, $playerName) { |
|
503 | 503 | $this->currentPot()->addChips($chips, $this->players()->findByName($playerName)); |
504 | 504 | }); |
505 | 505 | } |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | */ |
691 | 691 | private function highestBet(): Chips |
692 | 692 | { |
693 | - return Chips::fromAmount($this->betStacks()->max(function (Chips $chips) { |
|
693 | + return Chips::fromAmount($this->betStacks()->max(function(Chips $chips) { |
|
694 | 694 | return $chips->amount(); |
695 | 695 | }) ?? 0); |
696 | 696 | } |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | */ |
718 | 718 | private function resetBetStacks() |
719 | 719 | { |
720 | - $this->players()->each(function (PlayerContract $player) { |
|
720 | + $this->players()->each(function(PlayerContract $player) { |
|
721 | 721 | $this->betStacks->put($player->name(), Chips::zero()); |
722 | 722 | }); |
723 | 723 | } |
@@ -374,7 +374,7 @@ |
||
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
377 | - * @return PlayerContract|false |
|
377 | + * @return PlayerContract |
|
378 | 378 | */ |
379 | 379 | public function whosTurnIsIt() |
380 | 380 | { |
@@ -228,7 +228,7 @@ |
||
228 | 228 | |
229 | 229 | return new static( |
230 | 230 | self::HIGH_CARD, |
231 | - $cardValues->map(function (Card $card) { |
|
231 | + $cardValues->map(function(Card $card) { |
|
232 | 232 | return $card->value(); |
233 | 233 | })->toArray(), |
234 | 234 | $cards, |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | public function all() |
10 | 10 | { |
11 | 11 | return $this |
12 | - ->map(function (Action $action) { |
|
12 | + ->map(function(Action $action) { |
|
13 | 13 | return $action->toString(); |
14 | 14 | }) |
15 | 15 | ->toArray(); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | public function hasAction(int $actionValue): bool |
24 | 24 | { |
25 | 25 | $count = $this |
26 | - ->filter(function (Action $action) use ($actionValue) { |
|
26 | + ->filter(function(Action $action) use ($actionValue) { |
|
27 | 27 | return $action->action() === $actionValue; |
28 | 28 | }) |
29 | 29 | ->count(); |
@@ -103,7 +103,7 @@ |
||
103 | 103 | public function __toString() |
104 | 104 | { |
105 | 105 | $players = $this->players() |
106 | - ->map(function (Player $player) { |
|
106 | + ->map(function(Player $player) { |
|
107 | 107 | return $player->name(); |
108 | 108 | }) |
109 | 109 | ->implode(', '); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function setup(PlayerCollection $players): self |
26 | 26 | { |
27 | - $collection = $players->map(function (Player $player, $seatNumber) { |
|
27 | + $collection = $players->map(function(Player $player, $seatNumber) { |
|
28 | 28 | // everyone is still left to act |
29 | 29 | return [ |
30 | 30 | 'seat' => $seatNumber, |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | public function resetActions(): self |
60 | 60 | { |
61 | 61 | $collection = $this |
62 | - ->transform(function ($array) { |
|
62 | + ->transform(function($array) { |
|
63 | 63 | if ($array['action'] !== self::ALL_IN) { |
64 | 64 | $array['action'] = self::STILL_TO_ACT; |
65 | 65 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | public function sortBySeats(): self |
78 | 78 | { |
79 | 79 | $collection = $this |
80 | - ->sortBy(function ($array) { |
|
80 | + ->sortBy(function($array) { |
|
81 | 81 | return $array['seat']; |
82 | 82 | }, SORT_NUMERIC) |
83 | 83 | ->values(); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | { |
111 | 111 | // var_dump($this); |
112 | 112 | $result = $this |
113 | - ->filter(function ($array) use ($player) { |
|
113 | + ->filter(function($array) use ($player) { |
|
114 | 114 | return $array['player'] === $player; |
115 | 115 | }) |
116 | 116 | ; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | return self::make($this->values()->toArray()); |
143 | 143 | } |
144 | 144 | |
145 | - $new = $this->sortBy(function ($value) use ($seatNumber) { |
|
145 | + $new = $this->sortBy(function($value) use ($seatNumber) { |
|
146 | 146 | if ($value['seat'] < $seatNumber) { |
147 | 147 | return ($value['seat'] + 1) * 10; |
148 | 148 | } |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | public function removePlayer(Player $player): self |
160 | 160 | { |
161 | 161 | $collection = $this |
162 | - ->reject(function ($array) use ($player) { |
|
162 | + ->reject(function($array) use ($player) { |
|
163 | 163 | return $array['player'] === $player->name(); |
164 | 164 | }); |
165 | 165 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | public function getNextPlayer() |
173 | 173 | { |
174 | 174 | return $this |
175 | - ->reject(function ($value) { |
|
175 | + ->reject(function($value) { |
|
176 | 176 | return in_array($value['action'], [self::ACTIONED, self::AGGRESSIVELY_ACTIONED, self::ALL_IN]); |
177 | 177 | }) |
178 | 178 | ->first() |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function total(): Chips |
14 | 14 | { |
15 | - return Chips::fromAmount($this->sum(function (ChipPot $chipPot) { |
|
15 | + return Chips::fromAmount($this->sum(function(ChipPot $chipPot) { |
|
16 | 16 | return $chipPot->total()->amount(); |
17 | 17 | })); |
18 | 18 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function remove(ChipPot $removeChipPot) |
26 | 26 | { |
27 | - return $this->reject(function (ChipPot $chipPot) use ($removeChipPot) { |
|
27 | + return $this->reject(function(ChipPot $chipPot) use ($removeChipPot) { |
|
28 | 28 | return $chipPot->equals($removeChipPot); |
29 | 29 | })->values(); |
30 | 30 | } |
@@ -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); |