@@ -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 | } |
@@ -187,13 +187,13 @@ |
||
| 187 | 187 | |
| 188 | 188 | // deal to the player after the button first |
| 189 | 189 | $players |
| 190 | - ->each(function (PlayerContract $player) use ($hands) { |
|
| 190 | + ->each(function(PlayerContract $player) use ($hands) { |
|
| 191 | 191 | $hands->push(Hand::create(CardCollection::make([ |
| 192 | 192 | $this->dealCard(), |
| 193 | 193 | ]), $player)); |
| 194 | 194 | }) |
| 195 | - ->each(function (PlayerContract $player) use ($hands) { |
|
| 196 | - $hands->map(function (Hand $hand) use ($player, $hands) { |
|
| 195 | + ->each(function(PlayerContract $player) use ($hands) { |
|
| 196 | + $hands->map(function(Hand $hand) use ($player, $hands) { |
|
| 197 | 197 | if ($hand->player()->equals($player) === false) { |
| 198 | 198 | return false; |
| 199 | 199 | } |
@@ -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(); |
@@ -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); |