| 185 | } |
| 186 | |
| 187 | auto dict_to_dd_table_deal(const py::dict& table_input) -> DdTableDeal |
| 188 | { |
| 189 | DdTableDeal table_deal{}; |
| 190 | const auto cards_rows = py::cast<py::sequence>(table_input["cards"]); |
| 191 | if (cards_rows.size() != DDS_HANDS) { |
| 192 | throw py::value_error( |
| 193 | "cards must have " + std::to_string(DDS_HANDS) + " rows"); |
| 194 | } |
| 195 | |
| 196 | for (int hand = 0; hand < DDS_HANDS; ++hand) { |
| 197 | const auto row = py::cast<py::sequence>(cards_rows[hand]); |
| 198 | if (row.size() != DDS_SUITS) { |
| 199 | throw py::value_error( |
| 200 | "each cards row must have " + std::to_string(DDS_SUITS) + " values"); |
| 201 | } |
| 202 | for (int suit = 0; suit < DDS_SUITS; ++suit) { |
| 203 | const int value = py::cast<int>(row[suit]); |
| 204 | if (value < 0 || value > MaxSuitBitmask) { |
| 205 | throw py::value_error( |
| 206 | "cards has invalid value " + std::to_string(value) + |
| 207 | " (expected range 0..0x7FFC)"); |
| 208 | } |
| 209 | table_deal.cards[hand][suit] = static_cast<unsigned int>(value); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | return table_deal; |
| 214 | } |
| 215 | |
| 216 | auto dict_to_dd_table_results(const py::dict& table_input) -> DdTableResults |
| 217 | { |
no outgoing calls
no test coverage detected