| @@ 65-107 (lines=43) @@ | ||
| 62 | ]); |
|
| 63 | } |
|
| 64 | ||
| 65 | public function checkFullRow(): void |
|
| 66 | { |
|
| 67 | // LOOP FOR EACH ROW |
|
| 68 | for ($row = 0; $row < 5; $row++) { |
|
| 69 | for ($column = 0; $column < 5; $column++) { |
|
| 70 | $this->notScoredYet = true; |
|
| 71 | // initial length is 0, if not then session contians card |
|
| 72 | // ROW SUITS AND VALUES |
|
| 73 | // if a card is existing (form length has 235) |
|
| 74 | $this->currentSession = session('grid.' . $row . $column); |
|
| 75 | if (strlen($this->currentSession) != 235) { |
|
| 76 | // collect suit HDSC and value 02-14 for row |
|
| 77 | array_push($this->suitsRow, substr($this->currentSession, 23, 1)); |
|
| 78 | array_push($this->valuesRow, substr($this->currentSession, 21, 2)); |
|
| 79 | } |
|
| 80 | // ROW SAVE AND SCORE DATA |
|
| 81 | // if five cards (five suits), push suits and values arrays |
|
| 82 | if ($column == 4 && count($this->suitsRow) == 5) { |
|
| 83 | // session('dataRow00', [[H,D,C,S,D],[03,05,01,13,10]]) |
|
| 84 | session()->push('dataRow' . $row, $this->suitsRow); |
|
| 85 | session()->push('dataRow' . $row, $this->valuesRow); |
|
| 86 | // send array of suits and values for row to score function |
|
| 87 | $this->sortHand('Row' . $row); |
|
| 88 | // when match is found, $this->notScoredYet = false and rest of functions will not proceed |
|
| 89 | $this->scoreSameSuit('Row' . $row); |
|
| 90 | $this->checkValueOccurrence('Row' . $row); |
|
| 91 | $this->fourOfaKind('Row' . $row); |
|
| 92 | $this->fullHouse('Row' . $row); |
|
| 93 | $this->threeOfAKind('Row' . $row); |
|
| 94 | $this->twoPairsOrPair('Row' . $row); |
|
| 95 | $this->straightOrNothing('Row' . $row); |
|
| 96 | ||
| 97 | // before next loop, reset to false |
|
| 98 | $this->setNotScoredYetBackToFalse(); |
|
| 99 | } |
|
| 100 | // reset suits and values before next column |
|
| 101 | if ($column == 4) { |
|
| 102 | $this->suitsRow = []; |
|
| 103 | $this->valuesRow = []; |
|
| 104 | } |
|
| 105 | } |
|
| 106 | } |
|
| 107 | } |
|
| 108 | ||
| 109 | public function checkFullColumn(): void |
|
| 110 | { |
|
| @@ 109-148 (lines=40) @@ | ||
| 106 | } |
|
| 107 | } |
|
| 108 | ||
| 109 | public function checkFullColumn(): void |
|
| 110 | { |
|
| 111 | // LOOP FOR EACH COLUMN |
|
| 112 | for ($column = 0; $column < 5; $column++) { |
|
| 113 | for ($row = 0; $row < 5; $row++) { |
|
| 114 | $this->notScoredYet = true; |
|
| 115 | // ROW SUITS AND VALUES |
|
| 116 | // if a card is existing (form length has 233) |
|
| 117 | $this->currentSession = session('grid.' . $row . $column); |
|
| 118 | if (strlen($this->currentSession) != 235) { |
|
| 119 | // collect suit HDSC and value 02-14 for column |
|
| 120 | array_push($this->suitsColumn, substr($this->currentSession, 23, 1)); |
|
| 121 | array_push($this->valuesColumn, substr($this->currentSession, 21, 2)); |
|
| 122 | } |
|
| 123 | // COLUMN SAVE AND SCORE DATA |
|
| 124 | if ($row == 4 && count($this->suitsColumn) == 5) { |
|
| 125 | session()->push('dataColumn' . $column, $this->suitsColumn); |
|
| 126 | session()->push('dataColumn' . $column, $this->valuesColumn); |
|
| 127 | ||
| 128 | //begin with sorting hand and set |
|
| 129 | $this->sortHand('Column' . $column); |
|
| 130 | // when match is found, $this->notScoredYet = false and rest of functions will not proceed |
|
| 131 | $this->scoreSameSuit('Column' . $column); |
|
| 132 | $this->checkValueOccurrence('Column' . $column); |
|
| 133 | $this->fourOfaKind('Column' . $column); |
|
| 134 | $this->fullHouse('Column' . $column); |
|
| 135 | $this->threeOfAKind('Column' . $column); |
|
| 136 | $this->twoPairsOrPair('Column' . $column); |
|
| 137 | $this->straightOrNothing('Column' . $column); |
|
| 138 | // before next loop, reset to false |
|
| 139 | $this->setNotScoredYetBackToFalse(); |
|
| 140 | } |
|
| 141 | // reset suits and values before next column |
|
| 142 | if ($row == 4) { |
|
| 143 | $this->suitsColumn = []; |
|
| 144 | $this->valuesColumn = []; |
|
| 145 | } |
|
| 146 | } |
|
| 147 | } |
|
| 148 | } |
|
| 149 | ||
| 150 | public function sortHand($type) |
|
| 151 | { |
|