#include <map>
#include <string>
#include "entities.h"


// L4: Function.

std::string memory_generateConstPlayfield(
  MemoryContext& c
) {
  std::map<int, int> idGroups = { };
  auto id = 0;
  for (auto gid = 0; gid < c.playfieldSize; ++gid) {
    idGroups[id] = gid;
    id += 1;
    idGroups[id] = gid;
    id += 1;
  }
  c.playfieldItems = idGroups;
  return "MemoryContext.playfieldItems";
}

// L20: Test.

std::string test_memory_generateConstPlayfield(
) {
  auto c = memory_createEmptyContext();
  c.playfieldSize = 2;
  auto fieldName = memory_generateConstPlayfield(c);
  if (
    fieldName == "MemoryContext.playfieldItems" &&
    c.playfieldItems.size() == 4 &&
    c.playfieldItems[0] == 0 &&
    c.playfieldItems[1] == 0 &&
    c.playfieldItems[2] == 1 &&
    c.playfieldItems[3] == 1
  ) {
    return "OK: memory_generateConstPlayfield";
  }
  return "ERR: memory_generateConstPlayfield";
}

