<commit_before>package gameengine.player;

import java.util.HashMap;
import java.util.Map;
import javafx.scene.input.KeyCode;
import gamedata.action.Action;
import gamedata.gamecomponents.Level;


/**
 * A player object that contains the logic for playing each level. This object
 * requires no parameters for initialization.
 *
 */

public class Player {

    private int myNumMovesPlayed;
    private int myID;
    private Map<KeyCode, Action> myKeyMap;

    /**
     * Default constructor
     */
    public Player(){
        this(0);
    }
    
    public Player (int id) {
        myNumMovesPlayed = 0;
        myID = id;
        setKeyMap(myKeyMap);
    }

    /**
     * Until you run out of moves, play the level. Return true if the level was
     * won. Otherwise, play the next move until your turn is over. Return false
     * if your turn is over and the level was not won
     * 
     * @param level
     */
    public boolean levelWon (Level level) {
        while (!level.checkTurnEnd(myNumMovesPlayed)) {
            // play a move
            if (level.levelCompleted()) { return true; }
            myNumMovesPlayed++;
        }
        this.resetMovesPlayed();
        return false;
    }

    public void resetMovesPlayed () {
        myNumMovesPlayed = 0;
    }

    public int getID () {
        return myID;
    }

    /**
     * used by game player (GUI) so that it knows what action to perform
     * when certain keycodes are pressed/used.
     * 
     * @return myKeyMap which maps actions to pre-defined keycodes
     */
    public Map<KeyCode, Action> getKeyMap () {
        return myKeyMap;
    }

    /**
     * needs to get info from the authoring environment to set up the map..
     * 
     * @param myKeyMap
     */
    public void setKeyMap (Map<KeyCode, Action> myKeyMap) {
        myKeyMap = new HashMap<KeyCode, Action>();
    }
}<commit_msg>key control for GUI<commit_after>package gameengine.player;

import java.util.HashMap;
import java.util.Map;
import javafx.geometry.Point2D;
import javafx.scene.input.KeyCode;
import gamedata.action.Action;
import gamedata.gamecomponents.Level;


/**
 * A player object that contains the logic for playing each level. This object
 * requires no parameters for initialization.
 *
 */

public class Player {

    private int myNumMovesPlayed;
    private int myID;
    private Map<KeyCode, Action> myActionKeyMap;
    //for keypressed, when keys don't trigger actions. ex) arrow keys
    private Map<KeyCode, Point2D> myMovementKeyMap;


    /**
     * Default constructor
     */
    public Player(){
        this(0);
    }
    
    public Player (int id) {
        myNumMovesPlayed = 0;
        myID = id;
        setActionKeyMap(myActionKeyMap);
        setMovementKeyMap(myMovementKeyMap);

    }
    

    /**
     * Until you run out of moves, play the level. Return true if the level was
     * won. Otherwise, play the next move until your turn is over. Return false
     * if your turn is over and the level was not won
     * 
     * @param level
     */
    public boolean levelWon (Level level) {
        while (!level.checkTurnEnd(myNumMovesPlayed)) {
            // play a move
            if (level.levelCompleted()) { return true; }
            myNumMovesPlayed++;
        }
        this.resetMovesPlayed();
        return false;
    }

    public void resetMovesPlayed () {
        myNumMovesPlayed = 0;
    }

    public int getID () {
        return myID;
    }

    /**
     * used by game player (GUI) so that it knows what action to perform
     * when certain keycodes are pressed/used.
     * 
     * @return myKeyMap which maps actions to pre-defined keycodes
     */
    public Map<KeyCode, Action> getActionKeyMap () {
        return myActionKeyMap;
    }

    /**
     * needs to get info from the authoring environment to set up the map..
     * 
     * @param myKeyMap
     */
    public void setActionKeyMap (Map<KeyCode, Action> myActionKeyMap) {
        myActionKeyMap = new HashMap<KeyCode, Action>();
    }
    
    public Map<KeyCode, Point2D> getMovementKeyMap () {
        return myMovementKeyMap;
    }
    
    public void setMovementKeyMap (Map<KeyCode, Point2D> myMovementKeyMap2) {
        myMovementKeyMap2 = new HashMap<KeyCode, Point2D>();
    }
}
{'fraction_non_alphanumeric': 0.08754681647940075, 'fraction_numerical': 0.003043071161048689, 'mean_word_length': 2.274329501915709, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '7370912', 'n_tokens_mistral': 1279, 'n_tokens_neox': 1249, 'n_words': 402}