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

Function parse_GIB

library/tests/parse.cpp:515–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513int GIB_TO_DDS[4] = {1, 0, 3, 2};
514
515bool parse_GIB(
516 const string& line,
517 DealPBN * dl,
518 DdTableResults * table)
519{
520 string st = "W:" + line.substr(0, 67);
521 strcpy(dl->remainCards, st.c_str());
522
523 int dds_strain, dds_hand;
524 for (int s = 0; s < DDS_STRAINS; s++)
525 {
526 dds_strain = (s == 0 ? 4 : s - 1);
527 for (unsigned h = 0; h < DDS_HANDS; h++)
528 {
529 dds_hand = GIB_TO_DDS[h];
530 char const c = (line.substr(
531 68 + 4*static_cast<unsigned>(s) + h, 1).c_str())[0];
532 int d;
533 if (c >= 48 && c <= 57) // 0, 9
534 d = c-48;
535 else if (c >= 65 && c <= 70) // A, F
536 d = c-55;
537 else
538 return false;
539
540 if (dds_hand & 1)
541 d = 13 - d;
542
543 table->res_table[dds_strain][dds_hand] = d;
544 }
545 }
546 return true;
547}
548
549
550bool get_any_line(

Callers 1

read_fileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected