MCPcopy Create free account
hub / github.com/dds-bridge/dds / EnsureValidTotalCards

Method EnsureValidTotalCards

library/tests/trans_table/mock_data_generators.cpp:106–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106void 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
132MockPositionGenerator::MockPositionGenerator(unsigned int seed)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected