@Override
	public void update(GameContainer gc, StateBasedGame arg1, int delta)
			throws SlickException {
		if(firstRun) {
			gc.getInput().isKeyPressed(Input.KEY_ENTER);//reset ENTER key state
			firstRun = false;
		}
		if(battle.isOver()) {
			if(gc.getInput().isKeyPressed(Input.KEY_ENTER)) {
				selectedMove = -1;
				arg1.enterState(PlayingGameState.PLAYING_STATE_ID);
			}
			return;
		}
		
		if(gc.getInput().isKeyPressed(Input.KEY_DOWN)) {
			System.out.println("hi " + selectedMove);
			selectMove(selectedMove + 1);
		} else if(gc.getInput().isKeyPressed(Input.KEY_UP)) {
			System.out.println("ha " + selectedMove);
			selectMove(selectedMove - 1);
		}
		if(gc.getInput().isKeyPressed(Input.KEY_ENTER)) {
			battle.executeMove(battle.getPlayer().getPokemon().get_moves()[selectedMove], true);
			
			if(battle.isOver())
				return;
			
			//now execute opponents move
			IMove[] enemyMoves = battle.getEnemy().get_moves();
			IMove bestMove = null;
			float bestDesirability = -Float.MAX_VALUE;
			for(int i = 0; i < enemyMoves.length; i++) { //get the best move from the opponent
				float desirability = enemyMoves[i].get_desirability(battle.getEnemy(), battle.getPlayer().getPokemon());
				if(desirability > bestDesirability) {
					bestMove = enemyMoves[i];
					bestDesirability = desirability;
				}
			}
			battle.executeMove(bestMove, false);
		}
		
		super.update(gc, arg1, delta);
	}