| 104 | } |
| 105 | |
| 106 | void MockHandGenerator::EnsureValidTotalCards(int hand_dist[DDS_HANDS], int targetTotal) |
| 107 | { |
| 108 | int total = 0; |
| 109 | for (int hand = 0; hand < DDS_HANDS; hand++) { |
| 110 | total += hand_dist[hand]; |
| 111 | } |
| 112 | |
| 113 | // Adjust if total doesn't match target |
| 114 | if (total != targetTotal) { |
| 115 | int diff = targetTotal - total; |
| 116 | // Distribute difference across hands |
| 117 | for (int hand = 0; hand < DDS_HANDS && diff != 0; hand++) { |
| 118 | if (diff > 0 && hand_dist[hand] < 13) { |
| 119 | int add = std::min(diff, 13 - hand_dist[hand]); |
| 120 | hand_dist[hand] += add; |
| 121 | diff -= add; |
| 122 | } else if (diff < 0 && hand_dist[hand] > 0) { |
| 123 | int sub = std::min(-diff, hand_dist[hand]); |
| 124 | hand_dist[hand] -= sub; |
| 125 | diff += sub; |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | // MockPositionGenerator implementation |
| 132 | MockPositionGenerator::MockPositionGenerator(unsigned int seed) |
nothing calls this directly
no outgoing calls
no test coverage detected