#ifndef _structs_h
#define _structs_h

#include "units.h"
#include "map.h"

extern _map worldmap;

typedef struct _loc
{
	int x;
	int y;

	_loc() :
		x (-1),
		y (-1)
	{}
	
	_loc(int _x, int _y) :
		x (_x),
		y (_y)
	{}
	
	bool valid()
	{
		if (x < 0)
			return false;
		if (x >= worldmap.get_length())
			return false;
		if (y < 0)
			return false;
		if (y >= worldmap.get_height())
			return false;
		return true;
	}
} _loc;

typedef struct _aipath
{
	int dir;
	int total_moves;

	_aipath() :
		dir (-1),
		total_moves(0)
	{}
} _aipath;

typedef struct _aitarget
{
	int type;
	float health;
	int damage_cost;
	int attacker_cost;
	_loc loc;
	
	_aitarget() :
		type (-1),
		health (0),
		damage_cost (0),
		attacker_cost (0),
		loc (_loc())
	{}
} _aitarget;

typedef struct _connectedlocs
{
	vector<_loc> loc;

	_connectedlocs() :
		loc (vector<_loc>())
	{}
} _connectedlocs;

typedef struct _globalsettings
{
	bool networking;
	bool sound;
	bool netgame;
	bool fullscreen;
	short surrenderval;
	int gamestatus;
	int mspeed;
	int volume;
	int music_volume;
	int maporder;
	int screen_width, screen_height;
	int scroll_divider;
	int AI_scroll_divider;
	int battle_animation;
	string orignetname, netname;  //orignetname is the user's network name, netname is what the server then tells us to use 
	string netlobby;
	string lastmap;
	vector<pair<int, int> > screenmodes;
	
	_globalsettings() :
		networking (false),
		sound (false),
		netgame (false),
		fullscreen (false),
		surrenderval (0),
		gamestatus (-1),
		mspeed (0),
		volume (0),
		music_volume (0),
		maporder (0),
		screen_width (0),
		screen_height (0),
		scroll_divider (1),
		AI_scroll_divider (1),
		battle_animation (0),
		orignetname (""),
		netname (""),
		netlobby (""),
		lastmap (""),
		screenmodes (vector<pair<int, int> >())
	{}
} _globalsettings;

typedef struct _init_variables
{
	int screenmode;
	int screen_x;
	int screen_y;
	int current_res;
} _init_variables;

typedef struct _ingameoptions
{
	bool show_damage;
	int funding;
	int time;
	void reset();
} _ingameoptions;

typedef struct _action
{
	int type;
	_loc loc;
	_loc destination;
	
	_action() :
		type (-1),
		loc (_loc()),
		destination (_loc())
	{}
} _action;

typedef struct _actionset
{
	_action action[3];
} _actionset;

typedef struct _buildorder
{
	int unit;
	float ratio;
} _buildorder;

typedef struct _maparrange
{
	string name;
	int players;
	int l, h;
	bool bad;
	
	_maparrange() :
		name (""),
		players (0),
		l (0),
		h (0),
		bad (true)
	{}
} _maparrange;

typedef struct _armystats
{
	int pricefraction;
	int attackfraction[3];
	int resistfraction[3];
	int movemod;
	int rangemaxmod;
} _armystats;

#endif
