contract CountBasedRaffle is Raffle {
  
  uint public drawTicketCount;

  /// @dev Constructor for conventional raffle
  /// @param _ticketPrice The ticket price.
  /// @param _drawTicketCount The number of tickets for a draw to take place.
  function CountBasedRaffle(uint _ticketPrice, uint _drawTicketCount, address _rewardDistributor) Raffle(_ticketPrice, _rewardDistributor) public {
    drawTicketCount = _drawTicketCount;
  }

  /// @dev Gets the projected jackpot.
  function getAbsoluteProjectedJackpot() internal constant returns (uint) {
    uint totalTicketCount = getTotalTickets();
    uint ticketCount = drawTicketCount > totalTicketCount ? drawTicketCount : totalTicketCount;
    return ticketCount.mul(ticketPrice); 
  }

  /// @dev Gets the actual jackpot
  function getAbsoluteJackpot() internal constant returns (uint) {
    if (ticketHolders.length == 0) {
      return 0;
    }

    return this.balance.sub(totalPendingPayments);
  }

    /* @dev Purchases tickets to the raffle.
  * @param numTickets Number of tickets to purchase.
  * @param referrer The address of the referrer.
  */
  function purchaseTicket(uint numTickets, address referrer) public payable costsExactly(numTickets.mul(ticketPrice)) {
    require(raffleState != RaffleState.InActive);
    require(numTickets < drawTicketCount);

    // Add the address to the ticketHolders.
    uint totalTickets = getTotalTickets();
    ticketHolders.push(TicketHolder(msg.sender, uint16(numTickets), uint80(totalTickets.add(numTickets))));
    TicketPurchased(msg.sender, gameId, numTickets, ticketPrice.mul(numTickets), now);
    if (rewardDistributor != address(0)) {
      rewardDistributor.registerReferral(msg.sender, referrer);
      rewardDistributor.transferRewards(msg.sender, msg.value, gameId);
    }

    if (shouldChooseWinner()) {
      chooseWinner();
    }
  }
  
  /// An abstract function which determines whether a it is appropriate to choose a winner.
  /// @return True if it is appropriate to choose the winner, false otherwise.
  function shouldChooseWinner() internal returns (bool) {
    return getTotalTickets() >= drawTicketCount;
  }
}
function CountBasedRaffle(uint _ticketPrice, uint _drawTicketCount, address _rewardDistributor) Raffle(_ticketPrice, _rewardDistributor) public {
  drawTicketCount = _drawTicketCount;
}

/// @dev Constructor for conventional raffle
/// @param _ticketPrice The ticket price.
/// @param _drawTicketCount The number of tickets for a draw to take place.