#include "MotdState.h"
#include "GameSim.h"
#include "Math.h"
#include "Dialog.h"
#include "Graphics.h"


// TODO: localization
const char* MessageOfTheDayList[] = {
  // TODO: make actual messages
  // example ideas for messages
  "    Unlock edit slots   \n"
  "  to customize the game   ",
  
  "    Collect coins to    \n"
  "    earn more points      ",
  
  "     Example test       \n"
  "         MOTD             ",
  
  "        Another         \n"
  "         MOTD             "
};


void MotdState::Enter(GameGraphics& graphics)
{
  int messageCount = sizeof(MessageOfTheDayList) / sizeof(MessageOfTheDayList[0]);
  Math::RandomNumberGenerator gen;
  m_motdStr = MessageOfTheDayList[gen.generate(0,messageCount-1)];
}


// Should put in a utils namespace or something
std::vector<std::string> split(const std::string &s, char delim);


void MotdState::Draw(GameGraphics& graphics)
{
  graphics.prepareScreenContext();
  GameUi::DrawItems items;
  
  int i = 0;
  std::vector<std::string> strings = split(m_motdStr, '\n');
  for (std::string line : strings)
    items.addContrastString(80, 220+30*i++, line.c_str());
  
  graphics.drawAuxItems(items);
}


