package client_package;

import java.util.ArrayList;

import javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction;

import org.lwjgl.input.Mouse;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.gui.MouseOverArea;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

import map_package.Map;
import map_package.MapHandler;
import menu_package.Button;
import menu_package.Toast;

public class Game extends BasicGameState {
	
	Button launchbtn;
	Button decline_btn;
	Button end;
	
	GameController gameController = new GameController();
	
	public ArrayList<MouseOverArea> moa = new ArrayList<MouseOverArea>();

	public Game(int state) {
		// TODO Auto-generated constructor stub
		
		
	}

	@Override
	public void render(GameContainer gc, StateBasedGame sbg, org.newdawn.slick.Graphics g) throws SlickException {

		for (int i = 0; i < Map.fields.size(); i++) {
			Map.fields.get(i).image.draw(Map.fields.get(i).getPosX(), Map.fields.get(i).getPosY());
		}

		Toast.draw(g);

		launchbtn.display();
		decline_btn.display();
		end.display();
	}

	@Override
	public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
//		GameController.addPlayers(2);
//		GameController.setPair(0, 0);
//		MapHandler.initialize(GameController.players.size());
		// GameController.launched = true;
		//GameController.addPlayers(2);
		// GameController.setPair(0, 0);

		// GameController.initialize();
		launchbtn = new Button(gc, new Image("assets/combo_shop.png"), 500, 500);
		decline_btn = new Button(gc, new Image("assets/decline.png"), 450, 0);
		end = new Button(gc, new Image("assets/end.png"), 650, 10);

		//MapHandler.initialize(GameController.players.size());
		//GameController.launched = true;
	}

	@Override
	public void update(GameContainer gc, StateBasedGame sbg, int arg2) throws SlickException {

		if (launchbtn.isPressed()) {
			Popup popup = new Popup();
		}
		
		updateFields(gc);

	}

	int mouseX = 0;
	int mouseY = 0;

	public void updateFields(GameContainer gc) {
		
		if(decline_btn.isPressed()){
			gameController.decline(gameController.CURRENT_ACTIVE_PLAYER);
		}

		// If the MouseOverArea ArrayList is empty then it should be populated.
		if (moa.isEmpty()) {
			for (int i = 0; i < Map.fields.size(); i++) {
				moa.add(new MouseOverArea(gc, Map.fields.get(i).image, Map.fields.get(i).getPosX(),
						Map.fields.get(i).getPosY()));
			}
		}

		// if (mouseX < 0 && mouseX > gc.getWidth())
		mouseX = gc.getInput().getAbsoluteMouseX();
		//
		// if (mouseY < 0 && mouseY > gc.getHeight())
		mouseY = gc.getInput().getAbsoluteMouseY();

		for (int i = 0; i < Map.fields.size(); i++) {

			if ((mouseX - moa.get(i).getX()) > 0 && (mouseX - moa.get(i).getX()) < moa.get(i).getWidth()
					&& (mouseY - moa.get(i).getY()) > 0 && (mouseY - moa.get(i).getY()) < moa.get(i).getHeight()
					&& moa.get(i).isMouseOver()) {

				if (mouseX - moa.get(i).getX() > 0 && mouseY - moa.get(i).getY() > 0) {
					Color c = Map.fields.get(i).image.getColor(mouseX - moa.get(i).getX(), mouseY - moa.get(i).getY());
					int alpha = c.getAlpha();

					if (alpha > 0 && gc.getInput().isMousePressed(0)) {
						GameController.players.get(0).conquer(Map.fields.get(i));
					}
				}
			}
		}
	}

	@Override
	public int getID() {
		// TODO Auto-generated method stub
		return 3;
	}
}

@@ -14,24 +14,46 @@
 t_package;%0A%0A
+import java.awt.Font;%0A
 import java.
@@ -68,16 +68,16 @@
 ayList;%0A
-
 %0Aimport 
@@ -305,24 +305,63 @@
 kException;%0A
+import org.newdawn.slick.TrueTypeFont;%0A
 import org.n
@@ -698,16 +698,40 @@
  end;%0A%09%0A
+%09TrueTypeFont font;%0A%09%0A%09%0A
 %09GameCon
@@ -1191,24 +1191,84 @@
 PosY());%0A%09%09%7D
+%0A%09%09%0A%09%09font.drawString(100, 20, %22YOUR SCORE:%22, Color.yellow);
 %0A%0A%09%09Toast.dr
@@ -1700,17 +1700,132 @@
 ialize()
-;
+%0A%0A%09%09Font awtFont = new Font(%22Times New Roman%22, Font.BOLD, 24);%0A%09    font = new TrueTypeFont(awtFont, false);%0A%09    %09%09
 %0A%09%09launc

Add your score text (maybe a bit too big?)