/*!
 * @file GameLogger.cpp
 * @brief GameLoggerクラスの定義
 * @date 2013/12/11
 * @author Deskull
 * 2013 Sikabane Works.
 */

#include "stdafx.h"
#include "GameLogger.h"

namespace Deeangband
{
	GameLogger::GameLogger(void)
	{
		time_t t = time(0);
	    tm tx;
		setlocale(LC_CTYPE, "ja_JP.UTF-8");
		localtime_s(&tx, &t);
		ofs.open("Deeangband.log");
		if(ofs.fail())
		{
			exit(0);
		}
		ofs << std::put_time(&tx, "%Y-%m-%d %H:%M:%S =") << "D\'angband 開始 \n";
	}

	void GameLogger::PutLog(std::string log)
	{
		time_t t = time(0);
	    tm tx;
		setlocale(LC_CTYPE, "ja_JP.UTF-8");
		localtime_s(&tx, &t);
		ofs << std::put_time(&tx, "%Y-%m-%d %H:%M:%S =") << log << "\n";
	}

	GameLogger::~GameLogger(void)
	{
		time_t t = time(0);
	    tm tx;
		setlocale(LC_CTYPE, "ja_JP.UTF-8");
		localtime_s(&tx, &t);
		ofs << std::put_time(&tx, "%Y-%m-%d %H:%M:%S =") << "D\'angband 終了 \n";
	}

	void GameLogger::CreatureMoved(ID creatureID, NAME name, DIRECTION dir)
	{
		GameLogger::PutLog((boost::format("[%1%]%2%が方向%3%に移動") % creatureID % name.c_str() % dir).str());
	}

	void GameLogger::CreaturesCombated(NAME attackerName, NAME targetName)
	{
		GameLogger::PutLog((boost::format("%1%が%2%への白兵戦に移行") % attackerName.c_str() % targetName.c_str()).str());
	}

}