#include "GEnum.h"

using namespace std;

#include <hpllib/math/HPLMath.h>

namespace GEnum {
	const float PESERU_SLASH_MOVE_X = 3;
	const char* SHOT_SEQUENCE_ID_MAPPING_FILE_PATH = "data/image/Shot/ShotImageMapping.txt";
	const float EVIGEN_MINIGUN_BULLET_SPEED = 8.f;
	const float EVIGEN_MINIGUN_BULLET_ERROR_Y = 1.f;
	const float EVIGEN_MISSILE_BACK_SPEED_X = 10.f;
	const float SHOT_BLOW_SPEED = 1.f;
	const float SLASH_BLOW_SPEED = 8.f;
	const float MISSILE_BLOW_SPEED = 15.f;
	const int DAMAGE_TEXT_MERGINE = 10;
	const float TRELLAMA_FIRE_BALL_SPEED = 8.f;
	const float TRELLAMA_FIRE_BALL_ERROR_Y = 1.5f;
	const float TRELLAMA_SWORD_SLASH_SPEED_X = 5.f;
	const float EVIGEN_PINEAPPLE_THROW_SPEED_X = 5.f;
	const float EVIGEN_PINEAPPLE_THROW_SPEED_Y = 5.f;
	const float FIRE_BALL_ACCEL_X = 0.5f;
	const float PESERU_SLIDING_BLOW_SPEED = 6.f;
	const float PESERU_SLIDING_DAMAGE = 3.f;
	const float PESERU_SLIDING_SPEED_X = 20.f;
	const float PESERU_SLASH_Y = - 10;
	const float DURANDANA_GRAND_TIPER_BLOW_SPEED = 10.f;
	const float DURANDANA_GRAND_TIPER_DAMAGE = 5.f;
	const float DURANDANA_GRAND_TIPER_SPEED_X = 8.f;
	const float DURANDANA_GRAND_TIPER_SPEED_Y = 4.f;
	const float DURANDANA_ATTACK_2_BLOW_SPEED = 5.f;
	const float DURANDANA_ATTACK_2_DAMAGE = 2.f;
	const float DURANDANA_ATTACK_2_SPEED_X = 25.f;
	const float TWO_PLAYER_BOTH_BLOW_AWAY_SPEED = 8.f;
	const char* const SHOT_NAME_MAPPING_FILE_PATH = "data/image/Shot/ShotMapping.txt";
	const char* const SHOT_SETTING_FILE_PATH = "data/image/Shot/ShotPower2.txt";
	const char* const PLAYER_SETTING_LIST_FILE_PATH = "data/image/Player/SettingList.txt";
	const float UNDELSEN_THUNDER_BOLT_SPEED_Y = 20;
	const int UNDELSEN_THUNDER_BOLT_RANDOM_X = 20;
	const float ODORO_ACCEL_Y = 0.5f;
	const float ODORO_DAMAGE = 0.5f;
	const float UNDELSEN_ODORO_SPEED_X = 5.f;
	const float EVIGEN_MISSILE_SPEED_X = 20.f;
	const float GARDA_RYUHA_1_X = 110;
	const float GARDA_RYUHA_2_Y = 102;

	const int PLAYER_SELECT_COLUMN_PER_ROW = 7;
	const int PLAYER_SELECT_LEFT = 10;
	const int PLAYER_SELECT_TOP = 100;
	const int PLAYER_SELECT_INTERVAL_X = 80;
	const int PLAYER_SELECT_INTERVAL_Y = 80;
	const int PLAYER_SELECT_NAME_LEFT = 100;
	const int PLAYER_SELECT_NAME_TOP = 300;
	const int PLAYER_SELECT_ANIMATION_INTERVAL = 100;
	const int STAGE_SELECT_LEFT = 10;
	const int STAGE_SELECT_TOP = 100;
	const int STAGE_SELECT_INTERVAL_X = 160;
	const int STAGE_SELECT_INTERVAL_Y = 120;
	const int STAGE_SELECT_COLUMN_PER_ROW = 4;
	const float MAX_ENEMY_PLAYER_HP = 100;

	const float SAUCER_VELOCITY_X = 10;
	const float SAUCER_VELOCITY_Y = 8;

	const char* NET_MYACCOUNT = "-";

	const int DEFAULT_STOCK_NUM = 3;		//! デフォルトの開始ストック数
	const int RESPAWN_WAIT_FRAME_NUM = 50;

//	const int START_WAIT_FRAME_NUM = 200;	//! ゲーム開始時のウエイト（アニメーション有り）
//	const int END_WAIT_FRAME_NUM = 200;	//! ゲーム終了時（優勝確定時）のウエイト（アニメーションなし）

	/** プレイヤーの種類をランダムにする
	  * @param[in]	nExceptionPlayerIndex		除外するプレイヤーインデックス（-1なら全員ランダム）
	  * @param[in]	nExceptedPlayerType			除外された場所に入れるタイプ番号
	  */
	vector<int> randomPlayers( int nExceptionPlayerIndex, int nExceptedPlayerType ) {
		bool bAlreadySetList[ PlayerType::MAX_NUM ];
		for( int i = 0; i < PlayerType::MAX_NUM; i ++ ) {
			bAlreadySetList[i] = false;
		}

		// 全部埋まった
		bool bIsFilled = false;

		int aryTypes[PLAYER_MAX_NUM]; 
		for( int i = 0; i < PLAYER_MAX_NUM; i ++ ) {
			aryTypes[i] = 0;
		}

		for( int i = 0; i < PLAYER_MAX_NUM; i ++ ) {

			int nType = -1;
			//GPlayer* lpPlayer = &getStaticData()->m_ObjectManager.m_aryPlayerList[i];
			//int nType = lpPlayer->getType();
			if( i == nExceptionPlayerIndex ) 
			{
				aryTypes[i] = nExceptedPlayerType;
				nType = nExceptedPlayerType;
			} else {
				// ランダム
				nType = HPLMath::nextInt(0,PlayerType::MAX_NUM );
				if( bIsFilled ) {
					// 全部予約済み
					// ランダムにするしかない
					// do nothing
				} else {
					
					int nCounter = 1;
					while( bAlreadySetList[nType] && nCounter < PlayerType::MAX_NUM) {
						// 既に選択されている
						
						// 他のを探す
						nType = HPLMath::nextInt(0,PlayerType::MAX_NUM );
						nCounter ++;
					}
					if( nCounter >= PlayerType::MAX_NUM ) {
						// 全て埋まっていた

						// ランダムにする。以降は全部ランダム
						bIsFilled = true;
					}
						
				}
				aryTypes[i] = nType;
			}
			bAlreadySetList[ nType ] = true;
		}

		vector<int> vecResult;
		for( int i = 0; i < PLAYER_MAX_NUM; i ++ ) {
			vecResult.push_back( aryTypes[i] );
		}
		return vecResult;

	}

}


