<commit_before>package hu.unideb.inf.JCardGamesFX.klondike;

import hu.unideb.inf.JCardGamesFX.model.Card;
import hu.unideb.inf.JCardGamesFX.model.CardPile;
import hu.unideb.inf.JCardGamesFX.view.CardPileView;
import hu.unideb.inf.JCardGamesFX.view.CardTheme;
import hu.unideb.inf.JCardGamesFX.view.CardView;
import hu.unideb.inf.JCardGamesFX.view.CardViewFactory;
import javafx.application.Application;
import javafx.collections.ListChangeListener;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import org.json.simple.parser.ParseException;

import java.io.IOException;
import java.util.Iterator;

public class KlondikeApp extends Application {

  private static final double WIDTH = 1280;
  private static final double HEIGHT = 800;

  private KlondikeGame game;
  private KlondikeGameArea gameArea;
  private KlondikeMouseUtil mouseUtil;

  public static void main(String[] args) {
    launch(args);
  }

  @Override
  public void start(Stage primaryStage) {

    // Game area
    gameArea = new KlondikeGameArea(new Image("/tableaous/green-felt.png"));

    // Menu bar
    KlondikeMenu menuBar = new KlondikeMenu();

    // Status bar
    KlondikeStatusBar statusBar = new KlondikeStatusBar();

    // Main element
    BorderPane bord = new BorderPane();
    bord.setCenter(gameArea);
    bord.setTop(menuBar);
    bord.setBottom(statusBar);

    Scene scene = new Scene(bord, WIDTH, HEIGHT);

    try {
      CardViewFactory.setCardTheme(new CardTheme("/cardfaces/classic/theme.json", "/backfaces/bb.png"));
    } catch (IOException | ParseException e) {
      e.printStackTrace();
    }

    game = new KlondikeGame();
    game.startNewGame();
    mouseUtil = new KlondikeMouseUtil(game, gameArea);
    prepareGameAreaForNewGame();

    // auto-flip cards
    for (int i = 0; i < game.getStandardPiles().size(); i++) {
      CardPileView actPileView = gameArea.getStandardPileViews().get(i);
      CardPile actPile = game.getPileById(actPileView.getShortID());

      actPileView.getCards().addListener(
          (ListChangeListener<CardView>) c -> {
            while (c.next()) {
              if (c.wasRemoved()) {
                if (!actPileView.isEmpty()) {
                  CardView toFlip = actPileView.getTopCardView();
                  toFlip.setMouseTransparent(false);
                  if (!toFlip.isFaceDown())
                    toFlip.flip();
                }
                if (!actPile.isEmpty())
                  actPile.getTopCard().flip();
              }
            }
          });
    }<commit_msg>Fixed possible extra flipping of "model" card<commit_after>package hu.unideb.inf.JCardGamesFX.klondike;

import hu.unideb.inf.JCardGamesFX.model.Card;
import hu.unideb.inf.JCardGamesFX.model.CardPile;
import hu.unideb.inf.JCardGamesFX.view.CardPileView;
import hu.unideb.inf.JCardGamesFX.view.CardTheme;
import hu.unideb.inf.JCardGamesFX.view.CardView;
import hu.unideb.inf.JCardGamesFX.view.CardViewFactory;
import javafx.application.Application;
import javafx.collections.ListChangeListener;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
import org.json.simple.parser.ParseException;

import java.io.IOException;
import java.util.Iterator;

public class KlondikeApp extends Application {

  private static final double WIDTH = 1280;
  private static final double HEIGHT = 800;

  private KlondikeGame game;
  private KlondikeGameArea gameArea;
  private KlondikeMouseUtil mouseUtil;

  public static void main(String[] args) {
    launch(args);
  }

  @Override
  public void start(Stage primaryStage) {

    // Game area
    gameArea = new KlondikeGameArea(new Image("/tableaous/green-felt.png"));

    // Menu bar
    KlondikeMenu menuBar = new KlondikeMenu();

    // Status bar
    KlondikeStatusBar statusBar = new KlondikeStatusBar();

    // Main element
    BorderPane bord = new BorderPane();
    bord.setCenter(gameArea);
    bord.setTop(menuBar);
    bord.setBottom(statusBar);

    Scene scene = new Scene(bord, WIDTH, HEIGHT);

    try {
      CardViewFactory.setCardTheme(new CardTheme("/cardfaces/classic/theme.json", "/backfaces/bb.png"));
    } catch (IOException | ParseException e) {
      e.printStackTrace();
    }

    game = new KlondikeGame();
    game.startNewGame();
    mouseUtil = new KlondikeMouseUtil(game, gameArea);
    prepareGameAreaForNewGame();

    // auto-flip cards
    for (int i = 0; i < game.getStandardPiles().size(); i++) {
      CardPileView actPileView = gameArea.getStandardPileViews().get(i);
      CardPile actPile = game.getPileById(actPileView.getShortID());

      actPileView.getCards().addListener(
          (ListChangeListener<CardView>) c -> {
            while (c.next()) {
              if (c.wasRemoved()) {
                if (!actPileView.isEmpty()) {
                  CardView toFlip = actPileView.getTopCardView();
                  toFlip.setMouseTransparent(false);
                  if (!toFlip.isFaceDown())
                    toFlip.flip();
                }
                if (!actPile.isEmpty())
                  if (actPile.getTopCard().isFaceDown())
                    actPile.getTopCard().flip();
              }
            }
          });
    }
{'fraction_non_alphanumeric': 0.11271839188427578, 'fraction_numerical': 0.0030058237835806877, 'mean_word_length': 2.9233603537214443, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4044660', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1653, 'n_words': 316}