/***

  World class

***/

#ifndef _WORLD_H_
#define _WORLD_H_

#include "DisplayInterface.h"
#include "Globals.h"
#include "Object.h"

class Object;

class World {
public:

	World( DisplayInterface &d );

	// returns true if a world was successfully loaded
	bool load( DisplayInterface &d, int level_number);
	bool load( DisplayInterface &d, int level_number, World *oldworld);

	// acts on the current active object and advances to another object
	// returns the value that the current objects act routine returns
	bool advance( DisplayInterface &d );

	// set the current active object
	void set_current( int _x, int _y );

	// return a pointer to a specified object
	Object *get_object( int _x, int _y );

	// sets an object in the world
	void set_object( DisplayInterface &d, int _x, int _y, Object *o );

	// swaps two objects in the world
	void swap_object( DisplayInterface &d, int x1, int y1, int x2, int y2 );

	void ChangeScoreBy (DisplayInterface &d, int score_delta);
	void ChangeLivesBy (DisplayInterface &d, int lives_delta);

	int GetLevel () const;
	int GetLives () const;
	int GetScore () const;

	void AtePellet (DisplayInterface &d);
	void UserDied (DisplayInterface &d, int dx, int dy);

	int get_width( ) { return width; }

	int get_height( ) { return height; }

	// destructor
	~World( );

private:

	Object ***objects;  // objects in the world
	int width, height;  // width and height of the world
	int x, y;           // position of the active object in the world
	int time;           // time of the world
	Object *wallobject; // wall object to be returned to out of bounds queries

	int pellets_in_world;

	int lives;
	int score;
	int level;
	int new_lives;

	bool game_over;

	// destroys a world
	void destroy( );

	// copys from another world to this world
	void copy( const World &w );

};

#endif