function buyRaffleTicket(uint256 amount) external {
    require(raffleEndTime >= block.timestamp);  
    require(amount > 0);
        
    uint256 ticketsCost = SafeMath.mul(RAFFLE_TICKET_BASE_PRICE, amount);
    require(cards.balanceOf(msg.sender) >= ticketsCost);
        
    
    cards.updatePlayersCoinByPurchase(msg.sender, ticketsCost);
        
    
    TicketPurchases storage purchases = ticketsBoughtByPlayer[msg.sender];
        
    
    if (purchases.raffleRareId != raffleRareId) {
      purchases.numPurchases = 0;
      purchases.raffleRareId = raffleRareId;
      rafflePlayers[raffleRareId].push(msg.sender); 
    }
        
    
    if (purchases.numPurchases == purchases.ticketsBought.length) {
      purchases.ticketsBought.length = SafeMath.add(purchases.ticketsBought.length,1);
    }
    purchases.ticketsBought[purchases.numPurchases++] = TicketPurchase(raffleTicketsBought, raffleTicketsBought + (amount - 1)); 
        
    
    raffleTicketsBought = SafeMath.add(raffleTicketsBought,amount);
    
    UnitBought(msg.sender,raffleRareId,amount);
  }