@Override
    //TODO caching previous button that was clicked in checking it
    public void actionPerformed(ActionEvent e) {
        ++totalClicks;
        System.out.println("total clicks " + totalClicks);
        Card cardClicked = (Card) e.getSource();
        clickNumber++;


        if(clickNumber == 1) {
            previousCard = cardClicked;
        } else if(clickNumber == 2) {
            if( (previousCard.getId() == cardClicked.getId()) && (previousCard != cardClicked) ){
                removeCard(previousCard);
                removeCard(cardClicked);
                currentNumberOfCards -= 2;
                if(currentNumberOfCards == 0) {
                    System.out.println("koniec!");
                    double score = calculateResult();
                    showResult(score);
                    repaint();




                    if(gameEndListner != null) {
                        gameEndListner.endGame(score);
                    }
                }
            }
        } else if(clickNumber > 2) {
            flipAllCards();
            clickNumber=0;
        }


        //TODO add better maping for images names to images
        String path = "cardImages/img" + cardClicked.getId() + ".png";
        cardClicked.setSelectedIcon(new ImageIcon(path));


    }