Exemple #1
0
void Hand::SetPairSwaps(
  const ResultType& res, 
  ValetEntryType& entry, 
  unsigned& decl,
  unsigned& leader)
{
  // This function takes care of assigning the scores to the right
  // players within a pair.  pairNo is negative if the players are
  // internally stored in the opposite order to the one that happens
  // to be at the table.

  unsigned swapNS, swapEW;
  int pairNoNS = pairs.GetPairNumber(res.north, res.south);
  assert(pairNoNS != 0);
  if (pairNoNS < 0)
  {
    entry.pairNo = static_cast<unsigned>(-pairNoNS);
    swapNS = 1;
  }
  else
  {
    entry.pairNo = static_cast<unsigned>(pairNoNS);
    swapNS = 0;
  }

  int pairNoEW = pairs.GetPairNumber(res.east, res.west);
  assert(pairNoEW != 0);
  if (pairNoEW < 0)
  {
    entry.oppNo = static_cast<unsigned>(-pairNoEW);
    swapEW = 1;
  }
  else
  {
    entry.oppNo = static_cast<unsigned>(pairNoEW);
    swapEW = 0;
  }

  if (res.declarer == VALET_NORTH || res.declarer == VALET_SOUTH)
  {
    decl = Hswap[swapNS][res.declarer == VALET_SOUTH];
    leader = Hswap[swapEW][res.declarer == VALET_SOUTH];
  }
  else if (res.declarer == VALET_EAST || res.declarer == VALET_WEST)
  {
    decl = Hswap[swapEW][res.declarer == VALET_WEST];
    leader = Hswap[swapNS][res.declarer == VALET_EAST];
  }
  else
  {
    decl = 0;
    leader = 0;
    assert(false);
  }
}
Exemple #2
0
void Hand::SetPassout(
  const ResultType& res,
  const float totalIMPs,
  ValetEntryType& entry)
{
  // Pass-out.
  int pairNoNS = pairs.GetPairNumber(res.north, res.south);
  assert(pairNoNS != 0);
  if (pairNoNS < 0)
    pairNoNS = -pairNoNS; // Doesn't matter for pass-out

  int pairNoEW = pairs.GetPairNumber(res.east, res.west);
  assert(pairNoEW != 0);
  if (pairNoEW < 0)
    pairNoEW = -pairNoEW; // Doesn't matter for pass-out

  entry.pairNo = static_cast<unsigned>(pairNoNS);
  entry.oppNo = static_cast<unsigned>(pairNoEW);
  entry.overall = totalIMPs;
  entry.bidScore = totalIMPs;
}