<commit_before>package gamePlayer;

import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.List;
import javafx.scene.paint.Color;
import gamedata.action.Action;
import gamedata.gamecomponents.Game;
import gamedata.gamecomponents.Inventory;
import gamedata.gamecomponents.Piece;
import gamedata.stats.Stats;
import gameengine.movement.Movement;


/**
 * Class representing the state of the grid when a particular action
 * has been selected and is ready to be applied on the grid
 *
 */
public class ApplyState implements IGridState {

    private ViewController myController;
    private Game myGame;

    public ApplyState (ViewController controller) {
        System.out.println("new ApplyState");
        myController = controller;
        myGame = controller.getGame();
        myController
                .getGrid()
                .setOnMouseEntered(event -> {
                                       myController.changeCursor(myController.CURSOR_ATTACK_TEST);

                                       myController
                                               .getGrid()
                                               .getChildren()
                                               .forEach(node -> {
                                                            node.setOnMouseEntered(event2 -> {
                                                                myController
                                                                        .highLightEffectRange(event2,
                                                                                              Color.RED);
                                                            });
                                                            node.setOnMouseExited(event3 -> {
                                                                myController.highLightActionRange();
                                                                if (myController.getActivePiece() != null) {
                                                                    myController
                                                                            .highlightCurrent(myController
                                                                                                      .getActivePiece()
                                                                                                      .getLoc(),
                                                                                              Color.BLUE);
                                                                }
                                                            });

                                                        });

                                   });

    }

    @Override
    public void onClick (Piece piece) {

        Piece actor = myController.getActivePiece();
        if (piece == null) {
            piece = new Piece(actor);
            piece.setLoc(myController.getCurrentClick());
        }
        myController.getActiveAction().doBehavior(actor, piece);

        myController.setGridState(new SelectState(myController));

        myController.changeCursor(myController.CURSOR_GLOVE_TEST);
        myController.getGame().getCurrentLevel().garbageCollectPieces();
        myController.getGrid().populateGrid(myController.getGame().getCurrentLevel().getGrid()
                                                    .getAllPatches(),
                                            myController.getGame().getCurrentLevel().getGrid()
                                                    .getAllPieces());

        myController.setActivePiece(null);
        myController.setActiveAction(null);
        checkLevelState();
        checkPlayerState();
    }

    private void checkLevelState () {
        if (myGame.getCurrentLevel().levelCompleted()) {
            myGame.nextLevel();
        }
    }

    private void checkPlayerState () {
        if (myGame.getCurrentLevel().checkTurnEnd(myGame.getCurrentPlayer().getNumMovesPlayed())) {
            myGame.nextPlayer();
        }
    }
}<commit_msg>Initial Setup for New GameLoop<commit_after>package gamePlayer;

import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.List;
import javafx.scene.paint.Color;
import gamedata.action.Action;
import gamedata.gamecomponents.Game;
import gamedata.gamecomponents.Inventory;
import gamedata.gamecomponents.Piece;
import gamedata.stats.Stats;
import gameengine.movement.Movement;


/**
 * Class representing the state of the grid when a particular action
 * has been selected and is ready to be applied on the grid
 *
 */
public class ApplyState implements IGridState {

    private ViewController myController;
    private Game myGame;

    public ApplyState (ViewController controller) {
        //System.out.println("new ApplyState");
        myController = controller;
        myGame = controller.getGame();
        myController
                .getGrid()
                .setOnMouseEntered(event -> {
                                       myController.changeCursor(myController.CURSOR_ATTACK_TEST);

                                       myController
                                               .getGrid()
                                               .getChildren()
                                               .forEach(node -> {
                                                            node.setOnMouseEntered(event2 -> {
                                                                myController
                                                                        .highLightEffectRange(event2,
                                                                                              Color.RED);
                                                            });
                                                            node.setOnMouseExited(event3 -> {
                                                                myController.highLightActionRange();
                                                                if (myController.getActivePiece() != null) {
                                                                    myController
                                                                            .highlightCurrent(myController
                                                                                                      .getActivePiece()
                                                                                                      .getLoc(),
                                                                                              Color.BLUE);
                                                                }
                                                            });

                                                        });

                                   });

    }

    @Override
    public void onClick (Piece piece) {

        Piece actor = myController.getActivePiece();
        if (piece == null) {
            piece = new Piece(actor);
            piece.setLoc(myController.getCurrentClick());
        }
        myController.getActiveAction().doBehavior(actor, piece);

        myController.setGridState(new SelectState(myController));

        myController.changeCursor(myController.CURSOR_GLOVE_TEST);
        myController.getGame().getCurrentLevel().garbageCollectPieces();
        myController.getGrid().populateGrid(myController.getGame().getCurrentLevel().getGrid()
                                                    .getAllPatches(),
                                            myController.getGame().getCurrentLevel().getGrid()
                                                    .getAllPieces());

        myController.setActivePiece(null);
        myController.setActiveAction(null);
        
        checkLevelState();
        checkPlayerState();
    }

    /**
     * TODO: Temporary Location of GameLoop Check
     */
    private void checkLevelState () {
        if (myGame.getCurrentLevel().levelCompleted()) {
            myGame.nextLevel();
        }
    }

    /**
     * TODO: Temporary Location of GameLoop Check
     */
    private void checkPlayerState () {
        if (myGame.getCurrentLevel().checkTurnEnd(myGame.getCurrentPlayer().getNumMovesPlayed())) {
            myGame.nextPlayer();
        }
    }
}
{'fraction_non_alphanumeric': 0.071205945816351, 'fraction_numerical': 0.0011987532965715656, 'mean_word_length': 0.9384293680297398, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 114, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1185446', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1487, 'n_words': 276}