<commit_before>package main.java.player;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.ResourceBundle;
import java.util.Set;

import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.AbstractAction;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JTextArea;

import main.java.reflection.MethodAction;

public class Player {

	public static final String LOAD_GAME_DATA = "Load Game Data";
	public static final String LOAD_LIBRARY = "Browse library";
	public static final String FILELABEL = "File";
	public static final String HELP = "Click on Play/Pause to begin game. Click to add towers. \nAdding towers uses up money. Right click on towers to sell. \nA proportion of the tower's original cost will be added to money";
	public static final String DIFFICULTY = "Difficulty";
	public static final String EASY = "Easy Mode";
	public static final String MEDIUM = "Medium Mode";
	public static final String HARD = "Hard Mode";
	public static final String SOUND = "Sound";
	public static final String ON = "On";
	public static final String OFF = "Off";
	public static final String CREDITS = "Game Authoring Environment\n<NAME>, <NAME>, <NAME>, <NAME>\n\nGame Data\nIn-Yo<NAME>, <NAME>\n\nGame Engine\n<NAME>, <NAME>, <NAME>, <NAME>\n\nGame Player\n<NAME>, <NAME>";
	public static final int BUTTON_PADDING = 10;
	public static final String USER_DIR = "user.dir";	

	private JFrame frame;
	private JPanel cards;
	private CardLayout cardLayout;
	private static final JFileChooser fileChooser = new JFileChooser(System.getProperties().getProperty(USER_DIR));
	private ResourceBundle myResources = ResourceBundle.getBundle("main.resources.GUI");
	private TDPlayerEngine engine;
	private Sound song;
	private boolean soundOn;
	private TowerChooser towerChooser;

	public Player() throws LineUnavailableException, IOException, UnsupportedAudioFileException {
		initSong();
		makeFrame();
		makeCards();
		addWelcomeCard();
		addGameCard();
		addHelpCard();
		addOptionsCard();
		addCreditsCard();
		show();
	}

	private void initSong() throws LineUnavailableException, IOException, UnsupportedAudioFileException{
		song = new Sound("src/main/resources/fox.wav");
		soundOn = false;
	}

	public void showCard(String cardName){
		cardLayout.show(cards,  cardName);
	}

	private void makeFrame() {
		frame = new JFrame();

		frame.setTitle("OOGA Loompas Tower Defense");
		frame.setLocationRelativeTo(null);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setJMenuBar(makeMenuBar());
	}

	@SuppressWarnings("serial")
	private JMenu makeFileMenu(){
		JMenu files = new JMenu(FILELABEL);
		files.add(new AbstractAction(LOAD_GAME_DATA){
			public void actionPerformed(ActionEvent e){
				int response = fileChooser.showOpenDialog(null);
				if(response == JFileChooser.APPROVE_OPTION){
					File file = fileChooser.getSelectedFile();
					engine.loadMapFile(file.getAbsolutePath());
					System.out.println("FILE CHOSEN: " + file.getName());
				}
			}
		});
		files.add(new RepositoryViewer(LOAD_LIBRARY));
		return files;
	}

	private JMenuBar makeMenuBar(){
		JMenuBar menuBar = new JMenuBar();
		menuBar.add(makeFileMenu());
		return menuBar;
	}

	private void makeCards() {
		cards = new JPanel(cardLayout = new CardLayout());
	}

	private void addWelcomeCard() {
		JPanel welcomeCard = new JPanel();
		welcomeCard.setLayout(new BoxLayout(welcomeCard, BoxLayout.Y_AXIS));
		welcomeCard.add(makeWelcomeLabel());
		welcomeCard.add(makeWelcomeButtonPanel());
		cards.add(welcomeCard, "welcomeCard");
	}

	private JLabel makeWelcomeLabel() {
		JLabel welcomeLabel = new JLabel("Ooga Loompas Tower Defense");
		welcomeLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
		welcomeLabel.setFont(new Font("SansSerif", Font.PLAIN, 32));<commit_msg>altered player to only create gamecard with file load<commit_after>package main.java.player;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.util.ResourceBundle;
import java.util.Set;

import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.AbstractAction;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JTextArea;

import main.java.reflection.MethodAction;

public class Player {

	public static final String LOAD_GAME_DATA = "Load Game Data";
	public static final String LOAD_LIBRARY = "Browse library";
	public static final String FILELABEL = "File";
	public static final String HELP = "Click on Play/Pause to begin game. Click to add towers. \nAdding towers uses up money. Right click on towers to sell. \nA proportion of the tower's original cost will be added to money";
	public static final String DIFFICULTY = "Difficulty";
	public static final String EASY = "Easy Mode";
	public static final String MEDIUM = "Medium Mode";
	public static final String HARD = "Hard Mode";
	public static final String SOUND = "Sound";
	public static final String ON = "On";
	public static final String OFF = "Off";
	public static final String CREDITS = "Game Authoring Environment\n<NAME>, <NAME>, <NAME>, <NAME>\n\nGame Data\nIn-Young Jo, <NAME>\n\nGame Engine\n<NAME>, <NAME>, <NAME>, <NAME>\n\nGame Player\n<NAME>, <NAME>";
	public static final int BUTTON_PADDING = 10;
	public static final String USER_DIR = "user.dir";	

	private JFrame frame;
	private JPanel cards;
	private CardLayout cardLayout;
	private static final JFileChooser fileChooser = new JFileChooser(System.getProperties().getProperty(USER_DIR));
	private ResourceBundle myResources = ResourceBundle.getBundle("main.resources.GUI");
	private TDPlayerEngine engine;
	private Sound song;
	private boolean soundOn;
	private TowerChooser towerChooser;

	public Player() throws LineUnavailableException, IOException, UnsupportedAudioFileException {
		initSong();
		makeFrame();
		makeCards();
		addWelcomeCard();
		//addGameCard();
		addHelpCard();
		addOptionsCard();
		addCreditsCard();
		show();
	}

	private void initSong() throws LineUnavailableException, IOException, UnsupportedAudioFileException{
		song = new Sound("src/main/resources/fox.wav");
		soundOn = false;
	}

	public void showCard(String cardName){
		cardLayout.show(cards,  cardName);
	}

	private void makeFrame() {
		frame = new JFrame();

		frame.setTitle("OOGA Loompas Tower Defense");
		frame.setLocationRelativeTo(null);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setJMenuBar(makeMenuBar());
	}

	@SuppressWarnings("serial")
	private JMenu makeFileMenu(){
		JMenu files = new JMenu(FILELABEL);
		files.add(new AbstractAction(LOAD_GAME_DATA){
			public void actionPerformed(ActionEvent e){
				int response = fileChooser.showOpenDialog(null);
				if(response == JFileChooser.APPROVE_OPTION){
					File file = fileChooser.getSelectedFile();
					engine.loadMapFile(file.getAbsolutePath());
					addGameCard();
					System.out.println("FILE CHOSEN: " + file.getName());
				}
			}
		});
		files.add(new RepositoryViewer(LOAD_LIBRARY));
		return files;
	}

	private JMenuBar makeMenuBar(){
		JMenuBar menuBar = new JMenuBar();
		menuBar.add(makeFileMenu());
		return menuBar;
	}

	private void makeCards() {
		cards = new JPanel(cardLayout = new CardLayout());
	}

	private void addWelcomeCard() {
		JPanel welcomeCard = new JPanel();
		welcomeCard.setLayout(new BoxLayout(welcomeCard, BoxLayout.Y_AXIS));
		welcomeCard.add(makeWelcomeLabel());
		welcomeCard.add(makeWelcomeButtonPanel());
		cards.add(welcomeCard, "welcomeCard");
	}

	private JLabel makeWelcomeLabel() {
		JLabel welcomeLabel = new JLabel("Ooga Loompas Tower Defense");
		welcomeLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
		welcomeLabel.setFont(new Font("SansSerif", Font.PLAIN, 32));
{'fraction_non_alphanumeric': 0.10762788592123132, 'fraction_numerical': 0.0009053870529651426, 'mean_word_length': 5.431586608442504, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, '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': '224923', 'n_tokens_mistral': 2905, 'n_tokens_neox': 2712, 'n_words': 715}