<commit_before>package Models;

import Helpers.*;
import Models.Actions.*;

// This enum declaration might need to be moved, not sure how accessible it is right now 
// (needs to be accessible by GameModel and the Controller). #JavaTroubles
enum GameState {
	ReplayMode, PlanningMode, NormalMode
}

public class GameModel {
	// VARIABLES
	private BoardModel gameBoard;
	private JavaPlayer[] players;
	private int indexOfCurrentPlayer;
	private boolean isFinalRound;
	public MAction selectedAction;

	private Stack<Action> actionHistory; // This holds a history of the actions
											// taken up to the currently held
											// state.
	private Stack<Action> actionReplays; // This holds currently undone actions
											// for the purposes of Replay Mode

	private GameState gameState;
	private int actionIDCounter; // Provides unique actionIDs to every action
									// created. To be incremented after each
									// action instantiation.

	public GameModel(int numberPlayers){
		this.isFinalRound = false;
		this.indexOfCurrentPlayer = 0;
		this.gameBoard = new BoardModel();
		this.players = new JavaPlayer[numberPlayers];
		
		actionHistory = new Stack<Action>();
		actionReplays = new Stack<Action>();
	}

	// This method is to be used by the controller to determine which buttons
	// are visible/enabled in the view (and other visual components). For
	// example, if the gameState is PlanningMode, the undo button and exit
	// planning mode buttons will be enabled/shown, as well as a Label or
	// something.
	public GameState getGameState() {
		return gameState;
	}

//	public void changeFamePoints(int playerIndex, int modifier) {
//		players[playerIndex].changeFamePoints(modifier);
//	}

	/**
	 * Backtracks GameModel state to end of current player's previous turn,
	 * storing all backtracked moves in actionReplays stack. Also changes
	 * gameState to ReplayMode.
	 */
	public void initializeReplayMode() {
		gameState = GameState.ReplayMode;

		while (actionHistory.top().getPlayerIndex() == indexOfCurrentPlayer) {
			actionReplays.add(actionHistory.top());
			actionHistory.top().undo(this);
			actionHistory.pop();
		}

		while (actionHistory.top().getPlayerIndex() != indexOfCurrentPlayer) {
			actionReplays.add(actionHistory.top());
			actionHistory.top().undo(this);
			actionHistory.pop();
		}
	}

	/**
	 * Iterates forward one move during ReplayMode. If the move replayed is the
	 * last move to be replayed, changes gameState to NormalMode.
	 * <p>
	 * This method should only be accessible while the gameState is ReplayMode!
	 * I'm leaving this responsibility to the view and controller.
	 */
	public void replayMove() {
		actionHistory.add(actionReplays.top());
		actionReplays.top().redo(this);
		actionReplays.pop();

		if (actionReplays.isEmpty())
			gameState = GameState.NormalMode;
	}

	public int getPlayerIndex() {
		return this.indexOfCurrentPlayer;
	}

	public void pressSpace() {
		selectedAction.pressSpace();
	}
	
	//Methods for MAction/selected action traversal that is needed by the controller

	public int getSelectedActionX() {
		return selectedAction.getX();
	}

	public int getSelectedActionY() {
		// TODO Auto-generated method stub
		return selectedAction.getY();
	}
	
	public String getSelectedActionImageKey() {
		return selectedAction.getImageKey();
	}

	public MAction getSelectedAction() {
		return selectedAction;
	}

	public void pressEsc() {
		selectedAction = null;
	}
}<commit_msg>Adding methods for arrow key presses and setSelectedAction, which will be used for each time you first select a new tile/developer to move to the board<commit_after>package Models;

import Helpers.*;
import Models.Actions.*;

// This enum declaration might need to be moved, not sure how accessible it is right now 
// (needs to be accessible by GameModel and the Controller). #JavaTroubles
enum GameState {
	ReplayMode, PlanningMode, NormalMode
}

public class GameModel {
	// VARIABLES
	private BoardModel gameBoard;
	private JavaPlayer[] players;
	private int indexOfCurrentPlayer;
	private boolean isFinalRound;
	public MAction selectedAction;

	private Stack<Action> actionHistory; // This holds a history of the actions
											// taken up to the currently held
											// state.
	private Stack<Action> actionReplays; // This holds currently undone actions
											// for the purposes of Replay Mode

	private GameState gameState;
	private int actionIDCounter; // Provides unique actionIDs to every action
									// created. To be incremented after each
									// action instantiation.

	public GameModel(int numberPlayers){
		this.isFinalRound = false;
		this.indexOfCurrentPlayer = 0;
		this.gameBoard = new BoardModel();
		this.players = new JavaPlayer[numberPlayers];
		
		actionHistory = new Stack<Action>();
		actionReplays = new Stack<Action>();
	}

	// This method is to be used by the controller to determine which buttons
	// are visible/enabled in the view (and other visual components). For
	// example, if the gameState is PlanningMode, the undo button and exit
	// planning mode buttons will be enabled/shown, as well as a Label or
	// something.
	public GameState getGameState() {
		return gameState;
	}

	public void changeFamePoints(int playerIndex, int modifier) {
		players[playerIndex].changeFamePoints(modifier);
	}

	/**
	 * Backtracks GameModel state to end of current player's previous turn,
	 * storing all backtracked moves in actionReplays stack. Also changes
	 * gameState to ReplayMode.
	 */
	public void initializeReplayMode() {
		gameState = GameState.ReplayMode;

		while (actionHistory.top().getPlayerIndex() == indexOfCurrentPlayer) {
			actionReplays.add(actionHistory.top());
			actionHistory.top().undo(this);
			actionHistory.pop();
		}

		while (actionHistory.top().getPlayerIndex() != indexOfCurrentPlayer) {
			actionReplays.add(actionHistory.top());
			actionHistory.top().undo(this);
			actionHistory.pop();
		}
	}

	/**
	 * Iterates forward one move during ReplayMode. If the move replayed is the
	 * last move to be replayed, changes gameState to NormalMode.
	 * <p>
	 * This method should only be accessible while the gameState is ReplayMode!
	 * I'm leaving this responsibility to the view and controller.
	 */
	public void replayMove() {
		actionHistory.add(actionReplays.top());
		actionReplays.top().redo(this);
		actionReplays.pop();

		if (actionReplays.isEmpty())
			gameState = GameState.NormalMode;
	}

	public int getPlayerIndex() {
		return this.indexOfCurrentPlayer;
	}

	public void pressSpace() {
		selectedAction.pressSpace();
	}
	
	//Methods for MAction/selected action traversal that is needed by the controller

	public int getSelectedActionX() {
		return selectedAction.getX();
	}

	public int getSelectedActionY() {
		// TODO Auto-generated method stub
		return selectedAction.getY();
	}
	
	public String getSelectedActionImageKey() {
		return selectedAction.getImageKey();
	}

	public MAction getSelectedAction() {
		return selectedAction;
	}

	public void pressEsc() {
		selectedAction = null;
	}

	public boolean pressLeft() {
		if(selectedAction != null){
			return selectedAction.pressArrow(-1,0);
		}
		return false;	
	}

	public boolean pressUp() {
		if(selectedAction != null){
			return selectedAction.pressArrow(1,0);
		}
		return false;
	}

	public boolean pressRight() {
		if(selectedAction != null){
			return selectedAction.pressArrow(0,1);
		}
		return false;		
	}

	public boolean pressDown() {
		if(selectedAction != null){
			return selectedAction.pressArrow(0,-1);
		}
		return false;
	}

	public void setSelectedAction(MAction selectedAction) {
		if(selectedAction == null){
			this.selectedAction = selectedAction;
		}
		
	}
}
{'fraction_non_alphanumeric': 0.0922576447625244, 'fraction_numerical': 0.0013012361743656475, 'mean_word_length': 3.9174664107485606, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '741494', 'n_tokens_mistral': 2445, 'n_tokens_neox': 2132, 'n_words': 719}