about summary refs log tree commit diff stats
path: root/data/maps/daedalus/rooms/Pumpkin Entrance.txtpb
blob: a7467463a31b106b158bdd2909b117c6d7a96bae (plain) (blame)
1
2
3
4
5
6
7
8
name: "Pumpkin Entrance"
panel_display_name: "East Area"
panels {
  name: "JACK"
  path: "Panels/Pumpkin Room/pumpkin_2"
  clue: "jack"
  answer: "lantern"
}
008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#include "ids_yaml_format.h"

#include <yaml-cpp/yaml.h>

#include <fstream>
#include <functional>

namespace com::fourisland::lingo2_archipelago {
namespace {

template <typename T>
void OperateOnSortedMap(
    const T& map, std::function<void(const std::string& name,
                                     const typename T::mapped_type& value)>
                      callback) {
  std::vector<std::string> names;
  for (const auto& it : map) {
    names.push_back(it.first);
  }

  std::sort(names.begin(), names.end());

  for (const std::string& name : names) {
    callback(name, map.at(name));
  }
}

}  // namespace

IdMappings ReadIdsFromYaml(const std::string& filename) {
  IdMappings result;

  YAML::Node document = YAML::LoadFile(filename);

  if (document["maps"]) {
    for (const auto& map_it : document["maps"]) {
      IdMappings::MapIds& map_ids =
          (*result.mutable_maps())[map_it.first.as<std::string>()];

      if (map_it.second["rooms"]) {
        for (const auto& room_it : map_it.second["rooms"]) {
          IdMappings::RoomIds& room_ids =
              (*map_ids.mutable_rooms())[room_it.first.as<std::string>()];

          if (room_it.second["panels"]) {
            for (const auto& panel_it : room_it.second["panels"]) {
              (*room_ids.mutable_panels())[panel_it.first.as<std::string>()] =
                  panel_it.second.as<uint64_t>();
            }
          }

          if (room_it.second["masteries"]) {
            for (const auto& mastery_it : room_it.second["masteries"]) {
              (*room_ids
                    .mutable_masteries())[mastery_it.first.as<std::string>()] =
                  mastery_it.second.as<uint64_t>();
            }
          }
        }
      }

      if (map_it.second["doors"]) {
        for (const auto& door_it : map_it.second["doors"]) {
          (*map_ids.mutable_doors())[door_it.first.as<std::string>()] =
              door_it.second.as<uint64_t>();
        }
      }
    }
  }

  if (document["letters"]) {
    for (const auto& letter_it : document["letters"]) {
      (*result.mutable_letters())[letter_it.first.as<std::string>()] =
          letter_it.second.as<uint64_t>();
    }
  }

  if (document["endings"]) {
    for (const auto& ending_it : document["endings"]) {
      (*result.mutable_endings())[ending_it.first.as<std::string>()] =
          ending_it.second.as<uint64_t>();
    }
  }

  if (document["special"]) {
    for (const auto& special_it : document["special"]) {
      (*result.mutable_special())[special_it.first.as<std::string>()] =
          special_it.second.as<uint64_t>();
    }
  }

  return result;
}

void WriteIdsAsYaml(const IdMappings& ids, const std::string& filename) {
  YAML::Node result;

  OperateOnSortedMap(ids.maps(), [&result](const std::string& map_name,
                                           const IdMappings::MapIds& map_ids) {
    YAML::Node map_node;

    OperateOnSortedMap(
        map_ids.rooms(), [&map_node](const std::string& room_name,
                                     const IdMappings::RoomIds& room_ids) {
          YAML::Node room_node;

          OperateOnSortedMap(
              room_ids.panels(),
              [&room_node](const std::string& panel_name, uint64_t panel_id) {
                room_node["panels"][panel_name] = panel_id;
              });

          OperateOnSortedMap(room_ids.masteries(),
                             [&room_node](const std::string& mastery_name,
                                          uint64_t mastery_id) {
                               room_node["masteries"][mastery_name] =
                                   mastery_id;
                             });

          map_node["rooms"][room_name] = std::move(room_node);
        });

    OperateOnSortedMap(
        map_ids.doors(),
        [&map_node](const std::string& door_name, uint64_t door_id) {
          map_node["doors"][door_name] = door_id;
        });

    result["maps"][map_name] = std::move(map_node);
  });

  OperateOnSortedMap(ids.letters(), [&result](const std::string& letter_name,
                                              uint64_t letter_id) {
    result["letters"][letter_name] = letter_id;
  });

  OperateOnSortedMap(ids.endings(), [&result](const std::string& ending_name,
                                              uint64_t ending_id) {
    result["endings"][ending_name] = ending_id;
  });

  OperateOnSortedMap(ids.special(), [&result](const std::string& special_name,
                                              uint64_t special_id) {
    result["special"][special_name] = special_id;
  });

  std::ofstream output_stream(filename);
  output_stream << result << std::endl;
}

}  // namespace com::fourisland::lingo2_archipelago