//	MetaGenerator.h - Generator which incorporates other Generators, and
//					  higher-level events.
//  ----------------------------------------------------------------------------
//	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 METAGENERATOR_H_
#define METAGENERATOR_H_

#include "Pickup.h"
#include "DefaultGenerator.h"
//#include "PuzzleGenerator.h"

///	Generator which incorporates other Generators, and higher-level events.
class MetaGenerator : public ToneGenerator
{
  public:
	///	Constructor.
	MetaGenerator();
	///	Destructor.
	~MetaGenerator();

	///	Called for every frame in the game.
	std::vector<TonePtr>& tick(const std::vector<TonePtr>& tonesInPlay,
							   const std::map<std::wstring, int>& toneTypesInPlay,
							   std::vector<PickupPtr>& pickupsInPlay,
							   int numWarnings,
							   int& numRails,
							   float globalSpeed,
							   int maxRailStart,
							   shared_ptr<TonesSounder>& sounder);

	///	Called to toggle pure mode.
	void setPureMode(bool val);
  private:
	///	Helper method. Returns a new 'special' tone according to its Creator's rules.
	/*!
		\return Make sure you check the return value is valid - it won't
		necessarily be so if there was no room on the rails for a new Tone.
	 */
	TonePtr getSpecialTone(const std::vector<TonePtr>& tonesInPlay,
						   const std::map<std::wstring, int>& toneTypesInPlay,
						   std::vector<PickupPtr>& pickupsInPlay,
						   int numWarnings,
						   int numRails,
						   float globalSpeed,
						   int maxRailStart,
						   shared_ptr<TonesSounder>& sounder);

	///	The default ToneGenerator.
	DefaultGenerator defaultGenerator;
	///	The puzzle ToneGenerator.
	//PuzzleGenerator puzzleGenerator;

	///	Whether we're in pure mode (no pickups, puzzles) or not.
	bool pure;

	///	Counter used to determine when to trigger special events.
	int counter;
	///	Toggle used to determine whether we're just triggering a special tone, or triggering pitch changes as well etc.
	bool countToggle;

	///	The vector returned by tick().
	/*!
		(Sometimes. Usually tick() will just return the value returned by the
		 active Default- or Puzzle- Generator.)
	 */
	std::vector<TonePtr> tickReturn;

	///	Some constants used to determine when to trigger special events.
	enum
	{
		CountMinLength = 600,
		CountRandRange = 400
	};
};

#endif
