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

Method MakeSpecific

library/src/moves/moves.cpp:371–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

369}
370
371auto Moves::MakeSpecific(const MoveType &ourMply, const int trick,
372 const int relHand) -> void {
373 trackp = &track[trick];
374
375 if (relHand == 0) {
376 trackp->move[0].suit = ourMply.suit;
377 trackp->move[0].rank = ourMply.rank;
378 trackp->move[0].sequence = ourMply.sequence;
379 trackp->high[0] = 0;
380
381 trackp->lead_suit = ourMply.suit;
382 } else if (ourMply.suit == trackp->move[relHand - 1].suit) {
383 if (ourMply.rank > trackp->move[relHand - 1].rank) {
384 trackp->move[relHand].suit = ourMply.suit;
385 trackp->move[relHand].rank = ourMply.rank;
386 trackp->move[relHand].sequence = ourMply.sequence;
387 trackp->high[relHand] = relHand;
388 } else {
389 trackp->move[relHand] = trackp->move[relHand - 1];
390 trackp->high[relHand] = trackp->high[relHand - 1];
391 }
392 } else if (ourMply.suit == trump) {
393 trackp->move[relHand].suit = ourMply.suit;
394 trackp->move[relHand].rank = ourMply.rank;
395 trackp->move[relHand].sequence = ourMply.sequence;
396 trackp->high[relHand] = relHand;
397 } else {
398 trackp->move[relHand] = trackp->move[relHand - 1];
399 trackp->high[relHand] = trackp->high[relHand - 1];
400 }
401
402 trackp->play_suits[relHand] = ourMply.suit;
403 trackp->play_ranks[relHand] = ourMply.rank;
404
405 // When trick completes (4th card played), prepare next trick's state.
406 if (relHand == 3) {
407 TrackType *newp = &track[trick - 1];
408
409 // Winner of this trick leads the next one.
410 newp->lead_hand = (trackp->lead_hand + trackp->high[3]) % 4;
411
412 // Update removed ranks to include all cards played in this trick.
413 int r, s;
414 for (s = 0; s < DDS_SUITS; s++)
415 newp->removed_ranks[s] = trackp->removed_ranks[s];
416
417 for (int h = 0; h < DDS_HANDS; h++) {
418 r = trackp->play_ranks[h];
419 s = trackp->play_suits[h];
420 newp->removed_ranks[s] |= bit_map_rank[r];
421 }
422 }
423}
424
425auto Moves::MakeNext(const int trick, const int relHand,
426 const unsigned short ourWinRanks[DDS_SUITS])

Callers 1

make_specificMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected