//	DropperTone.h - A Tone which drops Pickups
//  ----------------------------------------------------------------------------
//	This file is part of 'GameTemplate', template code for a game.
//	Copyright (C) 2011  Niall Moody
//	
//	This program is free software: you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation, either version 3 of the License, or
//	(at your option) any later version.
//
//	This program is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	You should have received a copy of the GNU General Public License
//	along with this program.  If not, see <http://www.gnu.org/licenses/>.
//	----------------------------------------------------------------------------

#ifndef DROPPERTONE_H_
#define DROPPERTONE_H_

#include "../ToneCreator.h"
#include "DebugHeaders.h"

class Pickup;

//------------------------------------------------------------------------------
///	A Tone which drops Pickups.
class DropperTone : public Tone
{
  public:
	///	Constructor.
	DropperTone(int startRail,
				int startNumRails,
				TonesSounderPtr& sound);
	///	Destructor.
	~DropperTone();

	///	Sets the Pickup this Tone is carrying.
	void setPickup(PickupPtr p);

	///	Returns the name of this tone type.
	std::wstring getName() const {return L"DropperTone";};
	///	Returns the score you get if this tone makes it to the opposite side of the screen.
	int getScore() const {return 10;};
  private:
	///	Used to determine when to drop the Pickup, and to move it.
	void tick();

	///	The Pickup this Tone is carrying.
	//PickupPtr pickup;
	weak_ptr<Pickup> pickup;

	///	The size of prevTrail.
	enum
	{
		TrailSize = 16
	};
	///	The last few places the Tone's been.
	TwoFloats prevTrail[TrailSize];
};

//------------------------------------------------------------------------------
///	The DropperTone ToneCreator.
class DropperCreator : public ToneCreator
{
  public:
	///	Constructor.
	DropperCreator() {};
	///	Destructor.
	~DropperCreator() {};

	///	Constructs this Creator's Tone, returns its pointer.
	TonePtr createTone(int startRail,
					   int startNumRails,
					   TonesSounderPtr& sounder) const
	{
		return TonePtr(NiallNew DropperTone(startRail,
											startNumRails,
											sounder));
	};

	///	Returns true if this Tone type should be generated with a Pickup.
	bool getCarriesPickup() const {return true;};

	///	Returns which side of the screen this Tone should start from.
	bool getStartingSide() const {return true;};
	///	Used to make sure the player isn't put in an unfair position.
	int getMinDistanceToOtherTones() const {return 350;};
	///	Used to make sure the player isn't put in an unfair position.
	int getMaxNumOtherTones(const std::wstring& toneType) const
	{
		int retval = -1;

		if(toneType == L"SlowTone")
			retval = 32;

		return retval;
	};
	///	Used to make sure the player isn't put in an unfair position.
	int getMaxNumWarnings() const {return 4;};
};

#endif
