code:
#include "Database/EventCommands/CommonEvent.hpp"

#include "Database/Database.hpp"

CommonEventCommand::CommonEventCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(event);
}

void CommonEventCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(event); }

std::string CommonEventCommand::stringRep(const Database& db, const bool colored) const {
  const auto eventName = db.commonEventNameOrId(event);
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Common Event") + colon.data() + eventName + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"

struct CommonEventCommand final : IEventCommand {
  CommonEventCommand() = default;
  explicit CommonEventCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~CommonEventCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Common_Event; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<CommonEventCommand>(*this); }
  bool hasReference(int targetId, SearchType type) override {
    if (type == SearchType::CommonEvent) {
      return event == targetId;
    }
    return false;
  };
  bool setReference(int targetId, int newId, SearchType type) override {
    if (hasReference(targetId, type)) {
      event = newId;
      return true;
    }
    return false;
  }
  int event = 1;
};

repo_name: Antidote/openrpgeditor

license: mit


code:
#include "Database/EventCommands/ConditionalBranch.hpp"

#include "Database/Database.hpp"

ConditionalBranchCommand::ConditionalBranchCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(type);
  switch (type) {
  case ConditionType::Switch: {
    parameters.at(1).get_to(globalSwitch.switchIdx);
    parameters.at(2).get_to(globalSwitch.checkIfOn);
    break;
  }
  case ConditionType::Variable: {
    parameters.at(1).get_to(variable.id);
    parameters.at(2).get_to(variable.source);
    if (variable.source == VariableComparisonSource::Constant) {
      parameters.at(3).get_to(variable.constant);
    } else {
      parameters.at(3).get_to(variable.otherId);
    }
    parameters.at(4).get_to(variable.comparison);
    break;
  }
  case ConditionType::Self_Switch: {
    parameters.at(1).get_to(selfSw);
    parameters.at(2).get_to(selfSwitch.checkIfOn);
    break;
  }
  case ConditionType::Timer: {
    parameters.at(1).get_to(timer.comparison);
    parameters.at(2).get_to(timer.sec);
    break;
  }
  case ConditionType::Actor: {
    parameters.at(1).get_to(actor.id);
    parameters.at(2).get_to(actor.type);
    switch (actor.type) {
    case ActorConditionType::Name:
    case ActorConditionType::In_The_Party:
      if (parameters.size() > 3 && parameters.at(3).is_string()) {
        parameters.at(3).get_to(name);
      }
      break;
    case ActorConditionType::Class:
    case ActorConditionType::Skill:
    case ActorConditionType::Weapon:
    case ActorConditionType::Armor:
    case ActorConditionType::State:
      parameters.at(3).get_to(actor.checkId);
      break;
    default:
      break;
    }
    break;
  }
  case ConditionType::Enemy: {
    parameters.at(1).get_to(enemy.id);
    parameters.at(2).get_to(enemy.type);
    if (enemy.type == EnemyConditionType::State) {
      parameters.at(3).get_to(enemy.stateId);
    }
    break;
  }
  case ConditionType::Character: {
    parameters.at(1).get_to(character.id);
    parameters.at(2).get_to(character.facing);
    break;
  }
  case ConditionType::Gold: {
    parameters.at(1).get_to(gold.value);
    parameters.at(2).get_to(gold.type);
    break;
  }
  case ConditionType::Item: {
    parameters.at(1).get_to(item.id);
    break;
  }
  case ConditionType::Weapon:
  case ConditionType::Armor: {
    parameters.at(1).get_to(equip.equipId);
    parameters.at(2).get_to(equip.includeEquipment);
    break;
  }
  case ConditionType::Button: {
    std::string buttonText;
    parameters.at(1).get_to(buttonText);
    button = magic_enum::enum_cast<Button>(buttonText, magic_enum::case_insensitive).value_or(Button::OK);
    break;
  }
  case ConditionType::Script: {
    parameters.at(1).get_to(script);
    break;
  }
  case ConditionType::Vehicle: {
    parameters.at(1).get_to(vehicle.id);
    break;
  }
  default:
    break;
  }
}

void ConditionalBranchCommand::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(type);
  switch (type) {
  case ConditionType::Switch: {
    out.push_back(globalSwitch.switchIdx);
    out.push_back(globalSwitch.checkIfOn);
    break;
  }
  case ConditionType::Variable: {
    out.push_back(variable.id);
    out.push_back(variable.source);
    if (variable.source == VariableComparisonSource::Constant) {
      out.push_back(variable.constant);
    } else {
      out.push_back(variable.otherId);
    }
    out.push_back(variable.comparison);
    break;
  }
  case ConditionType::Self_Switch: {
    out.push_back(selfSw);
    out.push_back(selfSwitch.checkIfOn);
    break;
  }
  case ConditionType::Timer: {
    out.push_back(timer.comparison);
    out.push_back(timer.sec);
    break;
  }
  case ConditionType::Actor: {
    out.push_back(actor.id);
    out.push_back(actor.type);
    switch (actor.type) {
    case ActorConditionType::Name:
    case ActorConditionType::In_The_Party:
      if (!name.empty()) {
        out.push_back(name);
      }
      break;
    case ActorConditionType::Class:
    case ActorConditionType::Skill:
    case ActorConditionType::Weapon:
    case ActorConditionType::Armor:
    case ActorConditionType::State:
      out.push_back(actor.checkId);
      break;
    default:
      break;
    }
    break;
  }
  case ConditionType::Enemy: {
    out.push_back(enemy.id);
    out.push_back(enemy.type);
    if (enemy.type == EnemyConditionType::State) {
      out.push_back(enemy.stateId);
    }
    break;
  }
  case ConditionType::Character: {
    out.push_back(character.id);
    out.push_back(character.facing);
    break;
  }
  case ConditionType::Gold: {
    out.push_back(gold.value);
    out.push_back(gold.type);
    break;
  }
  case ConditionType::Item: {
    out.push_back(item.id);
    break;
  }
  case ConditionType::Weapon:
  case ConditionType::Armor: {
    out.push_back(equip.equipId);
    out.push_back(equip.includeEquipment);
    break;
  }
  case ConditionType::Button: {
    std::string buttonText = magic_enum::enum_name(button).data();
    std::ranges::transform(buttonText, buttonText.begin(), [](const char c) { return std::tolower(c); });
    out.push_back(buttonText);
    break;
  }
  case ConditionType::Script: {
    out.push_back(script);
    break;
  }
  case ConditionType::Vehicle: {
    out.push_back(vehicle.id);
    break;
  }
  default:
    break;
  }
}

std::string ConditionalBranchCommand::conditionalFormat(const std::string& text, const bool colored) const {
  return std::format("{}{}{}If{}{}{}", indentText(indent()), symbol(code()), ColorFormatter::getColorCode(code(), colored), colon, text, ColorFormatter::popColor(colored));
}

std::string ConditionalBranchCommand::stringRep(const Database& db, const bool colored) const {
  std::string strBuild;
  if (type == ConditionType::Variable) {
    std::string var = db.system.variable(variable.id);
    std::string other;
    if (variable.source == VariableComparisonSource::Variable) {
      other = db.variableNameOrId(variable.otherId);
    } else {
      other = std::to_string(variable.otherId);
    }
    var = var.empty() ? std::format("#{:04}", variable.id) : var;
    return conditionalFormat(std::format("{} {} {}", var, DecodeEnumName(variable.comparison), other), colored);
  }
  if (type == ConditionType::Switch) {
    // TL-NOTE: Equivalence, a == b
    return conditionalFormat(trFormat("{0} is {1}", db.switchNameOrId(globalSwitch.switchIdx), DecodeEnumName(globalSwitch.checkIfOn)), colored);
  }
  if (type == ConditionType::Self_Switch) {
    // TL-NOTE: Equivalence, a == b
    return conditionalFormat(trFormat("Self Switch {0} is {1}", selfSw, DecodeEnumName(selfSwitch.checkIfOn)), colored);
  }
  if (type == ConditionType::Timer) {
    std::string min;
    std::string sec;

    if (timer.sec > 59) {
      min = std::to_string(timer.sec / 60);
      sec = std::to_string(timer.sec % 60);
    } else {
      min = "0";
      sec = std::to_string(timer.sec);
    }
    // TL-NOTE: Comparison operator, minutes, seconds
    return conditionalFormat(trFormat("Timer {0} {1} min {1} sec", DecodeEnumName(timer.comparison), min, sec), colored);
  }
  if (type == ConditionType::Actor) {
    const auto act = db.actorNameOrId(actor.id);
    switch (actor.type) {
    case ActorConditionType::Name: {
      return conditionalFormat(trFormat("Name of {0} is {1}", act, name), colored);
    }
    case ActorConditionType::Class: {
      return conditionalFormat(trFormat("Class of {0} is {1}", act, db.classNameOrId(actor.checkId)), colored);
    }
    case ActorConditionType::Skill: {
      return conditionalFormat(trFormat("{0} has learned {1}", act, db.skillNameOrId(actor.checkId)), colored);
    }
    case ActorConditionType::Weapon: {
      return conditionalFormat(trFormat("{0} has equipped {1}", act, db.weaponNameOrId(actor.checkId)), colored);
    }
    case ActorConditionType::Armor: {
      return conditionalFormat(trFormat("{0} has equipped {1}", act, db.armorNameOrId(actor.checkId)), colored);
    }
    case ActorConditionType::State: {
      return conditionalFormat(trFormat("{0} is affected by {1}", act, db.stateNameOrId(actor.checkId)), colored);
    }
    case ActorConditionType::In_The_Party: {
      return conditionalFormat(trFormat("{0} is in the party", act), colored);
    }
    }
  }
  if (type == ConditionType::Enemy) {
    auto name = db.troopMemberName(m_troopId, enemy.id);
    if (enemy.id >= 0) {
      name = std::format("#{} {}", enemy.id + 1, name);
    }
    if (enemy.type == EnemyConditionType::State) {
      return conditionalFormat(trFormat("{0} is affected by {1}", name, db.stateNameOrId(enemy.stateId)), colored);
    }
    return conditionalFormat(trFormat("{0} is appeared", name), colored);
  }
  if (type == ConditionType::Character) {
    std::string name = db.eventNameOrId(character.id);
    return conditionalFormat(trFormat("{0} is facing {1}", name, DecodeEnumName(character.facing)), colored);
  }
  if (type == ConditionType::Vehicle) {
    return conditionalFormat(trFormat("{0} is driven", DecodeEnumName(vehicle.id)), colored);
  }
  if (type == ConditionType::Gold) {
    return conditionalFormat(std::format("Gold {0} {1}", DecodeEnumName(gold.type), gold.value), colored);
  }
  if (type == ConditionType::Item) {
    return conditionalFormat(trFormat("Party has {0}", db.itemNameOrId(item.id)), colored);
  }
  if (type == ConditionType::Weapon) {
    std::string ret = conditionalFormat(trFormat("Party has {0}", db.weaponNameOrId(equip.equipId)), colored);
    if (equip.includeEquipment) {
      ret += ColorFormatter::getColor(FormatColor::Gray, colored) + db.parentheses(trNOOP("Include Equipment")) + ColorFormatter::popColor(colored);
    }
    return ret;
  }
  if (type == ConditionType::Armor) {
    std::string ret = conditionalFormat(trFormat("Party has {0}", db.armorNameOrId(equip.equipId)), colored);
    if (equip.includeEquipment) {
      ret += ColorFormatter::getColor(FormatColor::Gray, colored) + db.parentheses(trNOOP("Include Equipment")) + ColorFormatter::popColor(colored);
    }
    return ret;
  }
  if (type == ConditionType::Button) {
    return conditionalFormat(trFormat("Button [{0}] is pressed down", DecodeEnumName(button)), colored);
  }
  if (type == ConditionType::Script) {
    std::string tmpScript = script;
    std::ranges::replace(tmpScript, '\n', ' ');
    return conditionalFormat(tr("Script") + ": " + tmpScript.substr(0, std::min<size_t>(80, tmpScript.length())) + (tmpScript.length() >= 80 ? "..." : ""), colored);
  }
  return indentText(indent()) + diamond.data() + (colored ? "&push-color=255,0,255;Condition&pop-color;&push-color=0,255,0;TBD&pop-color;" : "ConditionType TBD");
}


code:
#pragma once
#include "Database/Database.hpp"
#include "Database/EventCommands/IEventCommand.hpp"

struct ConditionalBranchCommand final : IEventCommand {
  ConditionalBranchCommand() = default;
  explicit ConditionalBranchCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~ConditionalBranchCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Conditional_Branch; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<ConditionalBranchCommand>(*this); }
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  [[nodiscard]] std::string conditionalFormat(const std::string& text, bool colored) const;
  [[nodiscard]] constexpr bool collapsable() const override { return true; }
  [[nodiscard]] bool isCollapsed() const override { return m_collapsed; }
  void setCollapsed(const bool collapsed) override { m_collapsed = collapsed; }
  bool isPartner(const EventCode code, const std::optional<int>& codeIndent) override {
    if (!codeIndent) {
      return false;
    }

    return (code == EventCode::Else || code == EventCode::End) && *codeIndent == indent();
  }

  bool isTerminatingPartner(const EventCode code, const std::optional<int>& codeIndent) const override {
    if (!codeIndent) {
      return false;
    }
    return (code == EventCode::End) && *codeIndent == indent();
  }
  [[nodiscard]] constexpr int partnerCount() const override { return 2; }

  [[nodiscard]] constexpr bool hasPartner() const override { return true; }
  [[nodiscard]] constexpr bool isParent() const override { return true; }

  bool hasReference(int targetId, SearchType searchType) override {
    if (searchType == SearchType::Variable) {
      if (type == ConditionType::Variable) {
        if (variable.id == targetId) {
          return true;
        }
        return variable.source == VariableComparisonSource::Variable && variable.otherId == targetId;
      }
      if (type == ConditionType::Script) {
        std::string cnst = Database::instance()->gameConstants.variables[targetId];
        if (cnst.empty()) {
          return false;
        }
        if (script.contains("gameVariables") && script.contains(cnst)) {
          return true;
        }
      }
    }
    if (searchType == SearchType::Switch) {
      if (type == ConditionType::Script) {
        std::string cnst = Database::instance()->gameConstants.switches[targetId];
        if (cnst.empty()) {
          // Return a warning, we want everything to have a constant
          return false;
        }
        if (script.contains("gameSwitches") && script.contains(cnst)) {
          return true;
        }
      }
      return type == ConditionType::Switch && globalSwitch.switchIdx == targetId;
    }

    if (searchType == SearchType::ConditionSwitchOFF) {
      if (type == ConditionType::Switch) {
        if (globalSwitch.checkIfOn == ValueControl::OFF) {
          return true;
        }
      }
    }

    if (searchType == SearchType::Armors || searchType == SearchType::Weapons) {
      if (type == ConditionType::Armor || type == ConditionType::Weapon) {
        return equip.equipId == targetId;
      }
    }
    if (searchType == SearchType::Items) {
      if (type == ConditionType::Item) {
        return item.id == targetId;
      }
    }
    if (searchType == SearchType::Enemy) {
      if (type == ConditionType::Enemy) {
        return enemy.id == targetId;
      }
    }
    if (searchType == SearchType::State) {
      if (type == ConditionType::Actor) {
        if (actor.type == ActorConditionType::State) {
          return actor.checkId == targetId;
        }
      }
      if (type == ConditionType::Enemy) {
        return enemy.stateId == targetId;
      }
    }
    if (searchType == SearchType::Actor) {
      if (type == ConditionType::Actor) {
        return actor.id == targetId;
      }
    }
    if (searchType == SearchType::Skill) {
      if (type == ConditionType::Actor) {
        if (actor.type == ActorConditionType::Skill) {
          return actor.checkId == targetId;
        }
      }
    }
    if (searchType == SearchType::Class) {
      if (type == ConditionType::Actor) {
        if (actor.type == ActorConditionType::Class) {
          return actor.checkId == targetId;
        }
      }
    }

    return false;
  };

  bool setReference(int targetId, int newId, SearchType searchType) override {
    if (hasReference(targetId, searchType)) {

      if (searchType == SearchType::Variable) {
        if (type == ConditionType::Variable) {
          if (variable.id == targetId) {
            variable.id = newId;
          }
          if (variable.source == VariableComparisonSource::Variable && variable.otherId == targetId) {
            variable.id = newId;
          }
          return true;
        }
      }
      if (searchType == SearchType::Switch) {
        if (type == ConditionType::Switch && globalSwitch.switchIdx == targetId) {
          globalSwitch.switchIdx = newId;
        }
        return true;
      }
      if (searchType == SearchType::Armors || searchType == SearchType::Weapons) {
        if (equip.equipId == targetId) {
          equip.equipId = newId;
        }
      }
      if (searchType == SearchType::Items) {
        if (type == ConditionType::Item && item.id == targetId) {
          item.id = newId;
        }
      }
      if (searchType == SearchType::Enemy) {
        if (type == ConditionType::Enemy && enemy.id == targetId) {
          enemy.id = newId;
        }
      }
      if (searchType == SearchType::State) {
        if (type == ConditionType::Actor) {
          if (actor.type == ActorConditionType::State && actor.checkId == targetId) {
            actor.checkId = newId;
          }
        }
        if (type == ConditionType::Enemy && enemy.stateId == targetId) {
          enemy.id = newId;
        }
      }

      if (searchType == SearchType::Actor) {
        if (actor.id == targetId) {
          actor.id = newId;
        }
      }
      if (searchType == SearchType::Skill) {
        if (type == ConditionType::Actor) {
          if (actor.type == ActorConditionType::Skill && actor.checkId == targetId) {
            actor.checkId = newId;
          }
        }
      }
      if (searchType == SearchType::Class) {
        if (type == ConditionType::Actor) {
          if (actor.type == ActorConditionType::Class && actor.checkId == targetId) {
            actor.checkId = newId;
          }
        }
      }
      return true;
    }
    return false;
  }

  ConditionType type{};
  struct {
    int switchIdx{1};
    ValueControl checkIfOn = ValueControl::ON;
  } globalSwitch{};
  struct {
    int id{};
    VariableComparisonSource source{};
    VariableComparisonType comparison{};
    union {
      int constant;
      int otherId{};
    };
  } variable{};
  struct {
    ValueControl checkIfOn;
  } selfSwitch{};
  struct {
    TimerComparisonType comparison{};
    int sec{};
  } timer{};
  struct {
    int id{};
    ActorConditionType type{};
    int checkId{};
  } actor{};
  struct {
    int id{};
    EnemyConditionType type{};
    int stateId{}; // For "State" condition
  } enemy;
  struct {
    int id{};
    Direction facing{};
  } character{};
  struct {
    VehicleType id{};
  } vehicle;
  struct {
    GoldComparisonType type{};
    int value{};
  } gold{};
  struct {
    int id{};
  } item{};
  /* For Weapon and Armor conditions */
  struct {
    int equipId{};
    bool includeEquipment{};
  } equip{};
  Button button;
  std::string selfSw; // A, B, C, D
  std::string name;
  std::string script;

  bool m_collapsed{false};
  int m_troopId{0};
};

struct ElseCommand final : IEventCommand {
  ElseCommand() = default;
  explicit ElseCommand(const std::optional<int>& indent)
  : IEventCommand(indent) {}
  ~ElseCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Else; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<ElseCommand>(*this); }

  [[nodiscard]] constexpr bool collapsable() const override { return true; }
  [[nodiscard]] bool isCollapsed() const override { return m_collapsed; }
  [[nodiscard]] bool isCollapseEnd() const override { return false; }
  void setCollapsed(const bool collapsed) override { m_collapsed = collapsed; }
  bool isPartner(const EventCode code, const std::optional<int>& codeIndent) override {
    if (!codeIndent) {
      return false;
    }

    return (code == EventCode::Conditional_Branch || code == EventCode::End) && *codeIndent == indent();
  }
  bool isTerminatingPartner(const EventCode code, const std::optional<int>& codeIndent) const override {
    if (!codeIndent) {
      return false;
    }
    return (code == EventCode::End) && *codeIndent == indent();
  }
  [[nodiscard]] constexpr bool hasPartner() const override { return true; }
  [[nodiscard]] constexpr int partnerCount() const override { return 2; }
  [[nodiscard]] bool reverseSelection() const override { return m_reverseSelection; }
  void setReverseSelection(const bool reverseSelection) override { m_reverseSelection = reverseSelection; }
  bool m_reverseSelection = false;
  bool m_collapsed{false};
};


code:
#include "Database/EventCommands/ControlSelfSwitch.hpp"

ControlSelfSwitchCommand::ControlSelfSwitchCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(selfSw);
  parameters.at(1).get_to(turnOff);
}

void ControlSelfSwitchCommand::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(selfSw);
  out.push_back(turnOff);
}

std::string ControlSelfSwitchCommand::stringRep(const Database& db, const bool colored) const {
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Control Self Switch") + colon.data() + selfSw + " = " + DecodeEnumName(turnOff) +
         ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"

struct ControlSelfSwitchCommand final : IEventCommand {
  ControlSelfSwitchCommand() = default;
  explicit ControlSelfSwitchCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~ControlSelfSwitchCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Control_Self_Switch; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<ControlSelfSwitchCommand>(*this); }

  std::string selfSw = "A"; // A, B, C, D
  ValueControl turnOff{};
};


code:
#include "Database/EventCommands/ControlSwitches.hpp"

#include "Database/Database.hpp"

ControlSwitches::ControlSwitches(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(start);
  parameters.at(1).get_to(end);
  parameters.at(2).get_to(turnOff); // It's inverted because why the fuck not
}

void ControlSwitches::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(start);
  out.push_back(end);
  out.push_back(turnOff);
}

std::string ControlSwitches::stringRep(const Database& db, const bool colored) const {
  if (start != end) {
    return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Control Switches") + colon.data() + std::format("#{:04}..{:04}", start, end) + " = " +
           DecodeEnumName(turnOff) + ColorFormatter::popColor(colored);
  }
  const auto swName = db.system.switche(start);
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Control Switches") + colon.data() + db.nameAndId(swName, start) + " = " +
         DecodeEnumName(turnOff) + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct ControlSwitches : IEventCommand {
  ControlSwitches() = default;
  explicit ControlSwitches(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~ControlSwitches() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Control_Switches; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<ControlSwitches>(*this); }
  bool hasReference(int targetId, SearchType type) override {
    if (type == SearchType::Switch) {
      return start == targetId && end == targetId;
    }
    if (type == SearchType::Range) {
      if (start != end) {
        return true; // within range
      }
    }
    return false;
  };

  bool setReference(int targetId, int newId, SearchType type) override {
    if (hasReference(targetId, type)) {
      if (start == targetId && end == targetId) {
        start = newId;
        end = newId;
      }
      return true;
    }
    return false;
  }

  int start{1};
  int end{1};
  ValueControl turnOff = ValueControl::ON;
};


code:
#include "Database/EventCommands/ControlTimer.hpp"

ControlTimerCommand::ControlTimerCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(control);
  if (control == TimerControl::Start) {
    parameters.at(1).get_to(seconds);
  }
}

void ControlTimerCommand::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(control);
  if (control == TimerControl::Start) {
    out.push_back(seconds);
  }
}

std::string ControlTimerCommand::stringRep(const Database& db, const bool colored) const {
  std::string min;
  std::string sec;

  if (seconds > 59) {
    min = std::to_string(seconds / 60);
    sec = std::to_string(seconds % 60);
  } else {
    min = "0";
    sec = std::to_string(seconds);
  }
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Control Timer") + colon.data() + DecodeEnumName(control) + ", " +
         // TL-NOTE: Minutes and Seconds
         trFormat("{} min {} sec", min, sec) + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"

struct ControlTimerCommand final : IEventCommand {
  ControlTimerCommand() = default;
  explicit ControlTimerCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~ControlTimerCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Control_Timer; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<ControlTimerCommand>(*this); }

  TimerControl control = TimerControl::Start;
  int seconds = 0;
};


code:
#include "Database/EventCommands/ControlVariables.hpp"
#include "Database/Database.hpp"

ControlVariables::ControlVariables(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(start);
  parameters.at(1).get_to(end);
  parameters.at(2).get_to(operation);
  parameters.at(3).get_to(operand);
  switch (operand) {
  case VariableControlOperand::Constant:
    parameters.at(4).get_to(constant);
    break;
  case VariableControlOperand::Variable:
    parameters.at(4).get_to(variable);
    break;
  case VariableControlOperand::Random:
    parameters.at(4).get_to(random.min);
    parameters.at(5).get_to(random.max);
    break;
  case VariableControlOperand::Game_Data:
    parameters.at(4).get_to(gameData.type);
    parameters.at(5).get_to(gameData.value);
    parameters.at(6).get_to(gameData.rawSource);
    break;
  case VariableControlOperand::Script:
    parameters.at(4).get_to(script);
    break;
  }
}

void ControlVariables::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(start);
  out.push_back(end);
  out.push_back(operation);
  out.push_back(operand);
  switch (operand) {
  case VariableControlOperand::Constant:
    out.push_back(constant);
    break;
  case VariableControlOperand::Variable:
    out.push_back(variable);
    break;
  case VariableControlOperand::Random:
    out.push_back(random.min);
    out.push_back(random.max);
    break;
  case VariableControlOperand::Game_Data:
    out.push_back(gameData.type);
    out.push_back(gameData.value);
    out.push_back(gameData.rawSource);
    break;
  case VariableControlOperand::Script:
    out.push_back(script);
    break;
  }
}

std::string ControlVariables::variableFormat(const std::string& text, const bool colored) const {
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + DecodeEnumName(code()) + colon.data() + text + ColorFormatter::popColor(colored);
}

std::string ControlVariables::stringRep(const Database& db, const bool colored) const {
  std::string varText;
  if (start != end) {
    varText = std::format("#{:04}..#{:04} {}", start, end, DecodeEnumName(operation));
  } else {
    varText = std::format("{} {}", db.variableNameAndId(start), DecodeEnumName(operation));
  }

  switch (operand) {
  case VariableControlOperand::Constant:
    return variableFormat(std::format("{} {}", varText, constant), colored);
  case VariableControlOperand::Random: {
    return variableFormat(varText + " " + trNOOP("Random") + std::format(" {}..{}", random.min, random.max), colored);
  }
  case VariableControlOperand::Variable: {
    return variableFormat(varText + " " + db.variableNameOrId(variable), colored);
  }
  case VariableControlOperand::Game_Data: {
    switch (gameData.type) {
    case GameDataType::Item: {
      return variableFormat(varText + " " + Database::theNumberOf(db.itemNameOrId(gameData.value)), colored);
    }
    case GameDataType::Weapon: {
      return variableFormat(varText + " " + Database::theNumberOf(db.weaponNameOrId(gameData.value)), colored);
    }
    case GameDataType::Armor: {
      return variableFormat(varText + " " + Database::theNumberOf(db.armorNameOrId(gameData.value)), colored);
    }
    case GameDataType::Actor: {
      return variableFormat(varText + " " + Database::AOfB(DecodeEnumName(gameData.actorSource), db.actorNameOrId(gameData.value)), colored);
    }
    case GameDataType::Enemy: {
      std::string enemyName;
      if (m_troopId == 0) {
        enemyName = std::format("#{}", gameData.value + 1);
      } else {
        enemyName = db.troopMemberName(m_troopId, gameData.value);
      }
      return variableFormat(varText + " " + Database::AOfB(DecodeEnumName(gameData.enemySource), enemyName), colored);
    }
    case GameDataType::Character: {
      return variableFormat(varText + " " + Database::AOfB(DecodeEnumName(gameData.characterSource), db.eventNameOrId(gameData.value)), colored);
    }
    case GameDataType::Party: {
      return variableFormat(varText + " " + trFormat("Actor ID of the party member #{0}", gameData.value + 1), colored);
    }
    case GameDataType::Other: {
      return variableFormat(varText + " " + DecodeEnumName(gameData.otherSource), colored);
    }
    }
  }
  case VariableControlOperand::Script:
    std::string tmpScript = script;
    std::ranges::replace(tmpScript, '\n', ' ');
    return variableFormat(varText + " " + tmpScript.substr(0, std::min<size_t>(80, tmpScript.length())) + (tmpScript.length() >= 80 ? "..." : ""), colored);
  }

  return "ERROR!";
}


code:
#pragma once
#include "Database/Database.hpp"
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct ControlVariables : IEventCommand {
  ControlVariables() {};
  explicit ControlVariables(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~ControlVariables() override {};
  [[nodiscard]] EventCode code() const override { return EventCode::Control_Variables; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  [[nodiscard]] std::string variableFormat(const std::string& text, bool colored) const;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<ControlVariables>(*this); }
  bool hasReference(const int targetId, const SearchType type) override {
    if (type == SearchType::Variable) {
      if (start == targetId && end == targetId) {
        return true;
      }
      if (operand == VariableControlOperand::Script) {
        const std::string constVal = Database::instance()->gameConstants.variables[targetId];
        if (constVal.empty()) {
          return false;
        }
        if (script.contains("gameVariables") && script.contains(constVal)) {
          return true;
        }
      }
      return (variable == targetId && operand == VariableControlOperand::Variable);
    }
    // ControlVariables can change switches by using scripts
    if (type == SearchType::Switch) {
      if (operand == VariableControlOperand::Script) {
        const std::string constVal = Database::instance()->gameConstants.switches[targetId];
        if (constVal.empty()) {
          return false;
        }
        if (script.contains("gameSwitches") && script.contains(constVal)) {
          return true;
        }
      }
    }
    if (type == SearchType::Range) {
      if (start != end) {
        return true;
      }
    }
    return false;
  };

  bool setReference(const int targetId, const int newId, const SearchType type) override {
    if (hasReference(targetId, type)) {
      if (start == targetId && end == targetId) {
        start = newId;
        end = newId;
      }
      return true;
    }
    return false;
  }

  int start{1};
  int end{1};
  VariableControlOperation operation = VariableControlOperation::_set__del_Set;
  VariableControlOperand operand = VariableControlOperand::Constant;
  int constant{0};
  int variable{0};
  struct {
    int min{0};
    int max{0};
  } random;

  struct {
    GameDataType type = GameDataType::Other;
    union {
      OtherDataSource otherSource;
      int value{0};
    };
    union {
      ActorDataSource actorSource;
      EnemyDataSource enemySource;
      CharacterDataSource characterSource;
      int rawSource{0};
    };
  } gameData;

  std::string script{};
  int m_troopId{0};
};


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct EndCommand final : IEventCommand {
  EndCommand() = default;
  explicit EndCommand(const std::optional<int>& indent)
  : IEventCommand(indent) {}
  ~EndCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::End; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<EndCommand>(*this); }

  bool isPartner(const EventCode code, const std::optional<int>& codeIndent) override {
    if (!codeIndent) {
      return false;
    }

    return (code == EventCode::Conditional_Branch || code == EventCode::Else) && *codeIndent == indent();
  }
  [[nodiscard]] constexpr bool hasPartner() const override { return true; }
  [[nodiscard]] bool reverseSelection() const override { return true; }
  bool m_collapsed{false};
};


code:
#include "Database/EventCommands/EnemyAppear.hpp"
#include "Database/Database.hpp"

EnemyAppearCommand::EnemyAppearCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(troopMember);
}

void EnemyAppearCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(troopMember); }

std::string EnemyAppearCommand::stringRep(const Database& db, const bool colored) const {

  std::string name = db.troopMemberName(m_troopId, troopMember);
  if (troopMember >= 0) {
    name = std::format("#{} {}", troopMember + 1, name);
  }

  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Enemy Appear") + colon.data() + name + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct EnemyAppearCommand final : IEventCommand {
  EnemyAppearCommand() = default;
  explicit EnemyAppearCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~EnemyAppearCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Enemy_Appear; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<EnemyAppearCommand>(*this); }

  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;

  int troopMember{0};

  int m_troopId = 0;
};


code:
#include "Database/EventCommands/EnemyRecoverAll.hpp"

#include "Database/Database.hpp"

EnemyRecoverAllCommand::EnemyRecoverAllCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(troopMember);
}

void EnemyRecoverAllCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(troopMember); }

std::string EnemyRecoverAllCommand::stringRep(const Database& db, const bool colored) const {
  std::string name = db.troopMemberName(m_troopId, troopMember);
  if (troopMember >= 0) {
    name = std::format("#{} {}", troopMember + 1, name);
  }
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Enemy Recover All") + colon.data() + name + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct EnemyRecoverAllCommand final : IEventCommand {
  EnemyRecoverAllCommand() = default;
  explicit EnemyRecoverAllCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~EnemyRecoverAllCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Enemy_Recover_All; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<EnemyRecoverAllCommand>(*this); }

  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;

  int troopMember{-1};

  int m_troopId = 0;
};


code:
#include "Database/EventCommands/EnemyTransform.hpp"
#include "Database/Database.hpp"

EnemyTransformCommand::EnemyTransformCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(troopMember);
  parameters.at(1).get_to(enemy);
}

void EnemyTransformCommand::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(troopMember);
  out.push_back(enemy);
}

std::string EnemyTransformCommand::stringRep(const Database& db, const bool colored) const {
  std::string name = db.troopMemberName(m_troopId, troopMember);
  if (troopMember >= 0) {
    name = std::format("#{} {}", troopMember + 1, name);
  }
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Enemy Transform") + colon.data() + " " + name + ", " + db.enemyNameOrId(enemy) +
         ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct EnemyTransformCommand final : IEventCommand {
  EnemyTransformCommand() = default;
  explicit EnemyTransformCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~EnemyTransformCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Enemy_Transform; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<EnemyTransformCommand>(*this); }

  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  bool hasReference(const int targetId, const SearchType type) override {
    if (type == SearchType::Enemy) {
      return targetId == enemy;
    }
    return false;
  };
  bool setReference(const int targetId, const int newId, const SearchType type) override {
    if (hasReference(targetId, type)) {
      if (type == SearchType::Enemy) {
        enemy = newId;
      }
      return true;
    }
    return false;
  }
  int troopMember{0};
  int enemy{1};
  int m_troopId{0};
};


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct EraseEventCommand final : IEventCommand {
  EraseEventCommand() = default;
  explicit EraseEventCommand(const std::optional<int>& indent)
  : IEventCommand(indent) {}
  ~EraseEventCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Erase_Event; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<EraseEventCommand>(*this); }
};


code:
#include "Database/EventCommands/ErasePicture.hpp"

ErasePictureCommand::ErasePictureCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(picture);
}

void ErasePictureCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(picture); }

std::string ErasePictureCommand::stringRep(const Database& db, const bool colored) const {
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Erase Picture") + colon.data() + "#" + std::to_string(picture) +
         ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct ErasePictureCommand final : IEventCommand {
  ErasePictureCommand() = default;
  explicit ErasePictureCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~ErasePictureCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Erase_Picture; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<ErasePictureCommand>(*this); }
  bool hasReference(int targetId, SearchType type) override {
    if (type == SearchType::PictureId) {
      return targetId == picture;
    }
    return false;
  };
  bool setReference(int targetId, int newId, SearchType type) override {
    if (hasReference(targetId, type)) {
      if (type == SearchType::PictureId) {
        picture = newId;
      }
      return true;
    }
    return false;
  }
  int picture;
};


code:
#pragma once
#include "Database/ColorFormatter.hpp"
#include "Database/EventCommands/IEventCommand.hpp"

struct EventDummy : IEventCommand {
  EventDummy() = default;
  explicit EventDummy(const std::optional<int>& _indent)
  : IEventCommand(_indent) {}
  ~EventDummy() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Event_Dummy; }
  [[nodiscard]] std::string stringRep(const Database& db, const bool colored = true) const override { return indentText(indent()) + symbol(code()); }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<EventDummy>(*this); };
};


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"

struct ExitEventProcessingCommand final : IEventCommand {
  ExitEventProcessingCommand() = default;
  explicit ExitEventProcessingCommand(const std::optional<int>& indent)
  : IEventCommand(indent) {}
  ~ExitEventProcessingCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Exit_Event_Processing; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<ExitEventProcessingCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct FadeinScreenCommand final : IEventCommand {
  FadeinScreenCommand() = default;
  explicit FadeinScreenCommand(const std::optional<int>& indent)
  : IEventCommand(indent) {}
  ~FadeinScreenCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Fadein_Screen; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<FadeinScreenCommand>(*this); }
};


code:
#include "Database/EventCommands/FadeoutBGM.hpp"

#include "Database/Database.hpp"

FadeoutBGM::FadeoutBGM(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(duration);
}

void FadeoutBGM::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(duration); }

std::string FadeoutBGM::stringRep(const Database& db, const bool colored) const {
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Fadeout BGM") + colon.data() + db.secondsText(duration) + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct FadeoutBGM : IEventCommand {
  FadeoutBGM() = default;
  explicit FadeoutBGM(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~FadeoutBGM() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Fadeout_BGM; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<FadeoutBGM>(*this); }

  int duration{10};
};


code:
#include "Database/EventCommands/FadeoutBGS.hpp"

#include "Database/Database.hpp"

FadeoutBGS::FadeoutBGS(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(duration);
}

void FadeoutBGS::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(duration); }

std::string FadeoutBGS::stringRep(const Database& db, const bool colored) const {
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Fadeout BGS") + colon.data() + db.secondsText(duration) + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct FadeoutBGS : IEventCommand {
  FadeoutBGS() = default;
  explicit FadeoutBGS(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~FadeoutBGS() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Fadeout_BGS; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<FadeoutBGS>(*this); }

  int duration{10};
};


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct FadeoutScreenCommand final : IEventCommand {
  FadeoutScreenCommand() = default;
  explicit FadeoutScreenCommand(const std::optional<int>& indent)
  : IEventCommand(indent) {}
  ~FadeoutScreenCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Fadeout_Screen; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<FadeoutScreenCommand>(*this); }
};


code:
#include "Database/EventCommands/FlashScreen.hpp"

#include "Database/Database.hpp"

FlashScreenCommand::FlashScreenCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  auto colorValue = parameters.at(0);

  colorValue[0].get_to(color.r);
  colorValue[1].get_to(color.g);
  colorValue[2].get_to(color.b);
  colorValue[3].get_to(color.intensity);

  parameters.at(1).get_to(duration);
  parameters.at(2).get_to(waitForCompletion);
}

void FlashScreenCommand::serializeParameters(nlohmann::ordered_json& out) const {
  auto colorValue = nlohmann::ordered_json();

  colorValue.push_back(color.r);
  colorValue.push_back(color.g);
  colorValue.push_back(color.b);
  colorValue.push_back(color.intensity);

  out.push_back(colorValue);
  out.push_back(duration);
  out.push_back(waitForCompletion);
}

std::string FlashScreenCommand::stringRep(const Database& db, const bool colored) const {
  std::string suffix;
  if (waitForCompletion) {
    suffix = ColorFormatter::getColor(FormatColor::Gray, colored) + " " + db.parentheses(trNOOP("Wait")) + ColorFormatter::popColor(colored);
  }
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Flash Screen") + colon.data() +
         std::format("({},{},{},{}), {}", color.r, color.g, color.b, color.intensity, db.framesText(duration)) + ColorFormatter::popColor(colored) + suffix;
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct FlashScreenCommand final : IEventCommand {
  FlashScreenCommand() = default;
  explicit FlashScreenCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~FlashScreenCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Flash_Screen; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<FlashScreenCommand>(*this); }

  struct {
    int r{255};
    int g{255};
    int b{255};
    int intensity{170};
  } color;
  int duration{60};
  bool waitForCompletion{true};
};


code:
#include "Database/EventCommands/ForceAction.hpp"

#include "Database/Database.hpp"

ForceActionCommand::ForceActionCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(sourceComparison);
  parameters.at(1).get_to(source);
  parameters.at(2).get_to(skill);
  parameters.at(3).get_to(target);
}

void ForceActionCommand::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(sourceComparison);
  out.push_back(source);
  out.push_back(skill);
  out.push_back(target);
}

std::string ForceActionCommand::stringRep(const Database& db, const bool colored) const {
  const std::string targetString = target == -2 ? trNOOP("Last Target") : target == -1 ? trNOOP("Random") : tr("Index") + " " + std::to_string(target + 1);
  const auto attack = db.skillNameOrId(skill);
  if (sourceComparison == SubjectComparisonSource::Enemy) {
    return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Force Action") + colon.data() + "#" + std::to_string(source + 1) + ", " + attack + ", " +
           targetString + ColorFormatter::popColor(colored);
  }
  const auto actor = db.actorNameOrId(source);
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Force Action") + colon.data() + actor + ", " + attack + ", " + targetString +
         ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct ForceActionCommand final : IEventCommand {
  ForceActionCommand() = default;
  explicit ForceActionCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~ForceActionCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Force_Action; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<ForceActionCommand>(*this); }

  SubjectComparisonSource sourceComparison;
  int source;
  int skill;
  int target;
};


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct GameOverCommand final : IEventCommand {
  GameOverCommand() = default;
  explicit GameOverCommand(const std::optional<int>& indent)
  : IEventCommand(indent) {}
  ~GameOverCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Game_Over; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<GameOverCommand>(*this); }
};


code:
//
// Created by antidote on 6/28/24.
//

#include "GatherFollowers.hpp"


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct GatherFollowersCommand final : IEventCommand {
  GatherFollowersCommand() = default;
  explicit GatherFollowersCommand(const std::optional<int>& indent)
  : IEventCommand(indent) {}
  ~GatherFollowersCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Gather_Followers; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<GatherFollowersCommand>(*this); }
};


code:
#include "Database/EventCommands/GetLocationInfo.hpp"
#include "Database/Database.hpp"

GetLocationInfoCommand::GetLocationInfoCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(variable);
  parameters.at(1).get_to(type);
  parameters.at(2).get_to(source);
  parameters.at(3).get_to(x);
  parameters.at(4).get_to(y);
}

void GetLocationInfoCommand::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(variable);
  out.push_back(type);
  out.push_back(source);
  out.push_back(x);
  out.push_back(y);
}

std::string GetLocationInfoCommand::stringRep(const Database& db, const bool colored) const {
  std::string var = db.system.variable(variable);
  var = var.empty() ? std::format("#{:04}", variable) : var;
  if (source == LocationSource::Designation_with_variables) {
    auto varX = db.system.variable(x);
    auto varY = db.system.variable(y);
    varX = varX.empty() ? std::format("#{:04}", x) : varX;
    varY = varY.empty() ? std::format("#{:04}", y) : varY;
    return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Get Location Info") + colon.data() + var + ", " + DecodeEnumName(type) +
           std::format(", ({{{}}},{{{}}})", varX, varY) + ColorFormatter::popColor(colored);
  }

  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Get Location Info") + colon.data() + var + ", " + DecodeEnumName(type) +
         std::format(", ({},{})", x, y) + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct GetLocationInfoCommand final : IEventCommand {
  GetLocationInfoCommand() = default;
  explicit GetLocationInfoCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~GetLocationInfoCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Get_Location_Info; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<GetLocationInfoCommand>(*this); }
  bool hasReference(int targetId, SearchType type) override {
    if (type == SearchType::Variable) {
      return targetId == variable;
    }
    return false;
  };
  bool setReference(int targetId, int newId, SearchType type) override {
    if (hasReference(targetId, type)) {
      variable = newId;
      return true;
    }
    return false;
  }
  int variable;
  TileType type;
  LocationSource source;
  int x;
  int y;
};


code:
#include "Database/EventCommands/GetOnOffVehicle.hpp"

std::string GetOnOffVehicleCommand::stringRep(const Database& db, const bool colored) const {
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Get on/off Vehicle") + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct GetOnOffVehicleCommand final : IEventCommand {
  GetOnOffVehicleCommand() = default;
  explicit GetOnOffVehicleCommand(const std::optional<int>& indent)
  : IEventCommand(indent) {}
  ~GetOnOffVehicleCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Get_on_fwsl_off_Vehicle; }
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<GetOnOffVehicleCommand>(*this); }
};


code:
#include "Database/EventCommands/IEventCommand.hpp"

IEventCommand::IEventCommand(const std::optional<int>& _indent)
: m_indent(_indent) {}

void IEventCommand::serialize(nlohmann::ordered_json& out, const bool doIndent, const bool doParameters, bool oldValues) const {
  out["code"] = code();

  if (doIndent) {
    out["indent"] = indent();
  }

  if (doParameters) {
    out["parameters"] = nlohmann::json::array();
    serializeParameters(out["parameters"]);
  }
}

std::string IEventCommand::stringRep(const Database& db, const bool colored) const {
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + DecodeEnumName(code()) + ColorFormatter::popColor(colored);
}

std::string IEventCommand::symbol(EventCode code) const { return static_cast<int>(code) < 400 ? diamond.data() : colon.data(); }

std::string IEventCommand::indentText(std::optional<int> indent) const {
  std::string text;
  for (int i = 0; i < indent; ++i) {
    text += "  ";
  }
  return text;
}


code:
#pragma once
#include "Database/ColorFormatter.hpp"
#include "Database/Globals.hpp"
#include "Database/IModifiable.hpp"
#include "nlohmann/json.hpp"

struct Database;
class IEventCommand : public IModifiable {
  friend class CommandParser;

public:
  static constexpr std::string_view diamond = "\u25c6";
  static constexpr std::string_view colon = "\uff1a";

  IEventCommand() = default;
  explicit IEventCommand(const std::optional<int>& _indent);

  IEventCommand(const IEventCommand& other)
  : IModifiable(other)
  , m_indent(other.m_indent) {}
  IEventCommand& operator=(const IEventCommand& other) {
    IModifiable::operator=(other);
    m_indent = other.m_indent;
    return *this;
  }
  IEventCommand(IEventCommand&& other) noexcept
  : IModifiable(std::move(other))
  , m_indent(std::move(other.m_indent)) {}

  IEventCommand& operator=(IEventCommand&& other) noexcept {
    IModifiable::operator=(std::move(other));
    m_indent = std::move(other.m_indent);
    return *this;
  }

  ~IEventCommand() override = default;
  [[nodiscard]] virtual EventCode code() const = 0;
  virtual void serializeParameters(nlohmann::ordered_json& out) const {}
  virtual void serialize(nlohmann::ordered_json& out, bool doIndent = true, bool doParameters = true, bool oldValues = false) const;
  [[nodiscard]] virtual std::string stringRep(const Database& db, bool colored = true) const;
  virtual std::string symbol(EventCode code) const;
  virtual std::string indentText(std::optional<int> indent) const;
  virtual void adjustIndent(const int offset) {
    if (m_indent) {
      m_indent.value() += offset;
    } else {
      m_indent.emplace(0);
      m_indent.value() += offset;
    }
    setModified();
  }

  [[nodiscard]] virtual constexpr bool collapsable() const { return false; }
  [[nodiscard]] virtual bool isCollapsed() const { return false; }
  [[nodiscard]] virtual bool isCollapseEnd() const { return true; }
  virtual void setCollapsed(bool collapsed) {}
  [[nodiscard]] virtual bool isPartner(EventCode code, const std::optional<int>& codeIndent) { return false; }
  [[nodiscard]] virtual constexpr bool hasPartner() const { return false; }
  [[nodiscard]] virtual constexpr int partnerCount() const { return 0; }
  [[nodiscard]] virtual bool reverseSelection() const { return false; }
  [[nodiscard]] virtual bool isParent() const { return false; }
  [[nodiscard]] virtual bool isTerminatingPartner(EventCode code, const std::optional<int>& codeIndent) const { return false; }
  virtual void setReverseSelection(bool reverseSelection) {}

  std::optional<int> indent() const { return m_indent; }
  virtual void setIndent(int indent) {
    m_indent = indent;
    setModified();
  }

  virtual std::shared_ptr<IEventCommand> clone() const = 0;

private:
  std::optional<int> m_indent{};
};


code:
#include "Database/EventCommands/InputNumber.hpp"

#include "Database/Database.hpp"

InputNumberCommand::InputNumberCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(variable);
  parameters.at(1).get_to(digits);
}

void InputNumberCommand::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(variable);
  out.push_back(digits);
}

std::string InputNumberCommand::stringRep(const Database& db, const bool colored) const {
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Input Number") + colon.data() + db.variableNameOrId(variable) + ", " + std::to_string(digits) +
         +" " + (digits > 1 ? trNOOP("digits") : trNOOP("digit")) + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"

struct InputNumberCommand final : IEventCommand {
  InputNumberCommand() = default;
  explicit InputNumberCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~InputNumberCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Input_Number; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<InputNumberCommand>(*this); }
  bool hasReference(int targetId, SearchType type) override {
    if (type == SearchType::Variable) {
      return variable == targetId;
    }
    return false;
  };
  bool setReference(int targetId, int newId, SearchType type) override {
    if (hasReference(targetId, type)) {
      variable = newId;
      return true;
    }
    return false;
  }
  int variable = 1;
  int digits = 1;
};


code:
#include "Database/EventCommands/JumpToLabel.hpp"

JumpToLabelCommand::JumpToLabelCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(label);
}

void JumpToLabelCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(label); }

std::string JumpToLabelCommand::stringRep(const Database& db, const bool colored) const {
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Jump to Label") + colon.data() + label + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"

struct JumpToLabelCommand final : IEventCommand {
  JumpToLabelCommand() = default;
  explicit JumpToLabelCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~JumpToLabelCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Jump_To_Label; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<JumpToLabelCommand>(*this); }
  std::string label;
};


code:
#include "Database/EventCommands/Label.hpp"

LabelCommand::LabelCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(label);
}

void LabelCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(label); }

std::string LabelCommand::stringRep(const Database& db, const bool colored) const {
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Label") + colon.data() + label + ColorFormatter::popColor(colored);
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"

struct LabelCommand final : IEventCommand {
  LabelCommand() = default;
  explicit LabelCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~LabelCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Label; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<LabelCommand>(*this); }
  std::string label;

  bool isPartner(const EventCode code, const std::optional<int>& codeIndent) override {
    if (!codeIndent) {
      return false;
    }

    return (code == EventCode::Label || code == EventCode::Event_Dummy) && *codeIndent == indent();
  }
  [[nodiscard]] constexpr bool collapsable() const override { return true; }
  [[nodiscard]] bool isCollapsed() const override { return m_collapsed; }
  [[nodiscard]] bool isCollapseEnd() const override { return false; }
  void setCollapsed(const bool collapsed) override { m_collapsed = collapsed; }
  bool isTerminatingPartner(const EventCode code, const std::optional<int>& codeIndent) const override {
    if (!codeIndent) {
      return false;
    }
    return (code == EventCode::Label || code == EventCode::Event_Dummy) && *codeIndent == indent();
  }
  [[nodiscard]] constexpr bool hasPartner() const override { return true; }
  [[nodiscard]] constexpr int partnerCount() const override { return 2; }
  [[nodiscard]] bool reverseSelection() const override { return m_reverseSelection; }
  void setReverseSelection(const bool reverseSelection) override { m_reverseSelection = reverseSelection; }
  bool m_reverseSelection = false;
  bool m_collapsed{false};
};


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"

struct LoopCommand final : IEventCommand {
  LoopCommand() = default;
  explicit LoopCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
  : IEventCommand(indent) {}
  ~LoopCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Loop; }
  [[nodiscard]] constexpr bool collapsable() const override { return true; }
  [[nodiscard]] bool isCollapsed() const override { return m_collapsed; }
  void setCollapsed(const bool collapsed) override { m_collapsed = collapsed; }
  [[nodiscard]] constexpr bool hasPartner() const override { return true; }
  [[nodiscard]] constexpr int partnerCount() const override { return 1; }
  [[nodiscard]] constexpr bool isParent() const override { return true; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<LoopCommand>(*this); }

  [[nodiscard]] bool isPartner(const EventCode code, const std::optional<int>& codeIndent) override {
    if (!codeIndent) {
      return false;
    }
    return code == EventCode::Repeat_Above && indent() == *codeIndent;
  }

  bool m_collapsed = false;
};


code:
#include "Database/EventCommands/MovePicture.hpp"
#include "Database/Database.hpp"

MovePictureCommand::MovePictureCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IEventCommand(indent) {
  parameters.at(0).get_to(picture);
  // param[1] is not used
  parameters.at(2).get_to(origin);
  parameters.at(3).get_to(pictureLocation);
  parameters.at(4).get_to(x);
  parameters.at(5).get_to(y);
  parameters.at(6).get_to(width);
  parameters.at(7).get_to(height);
  parameters.at(8).get_to(opacity);
  parameters.at(9).get_to(blendMode);
  parameters.at(10).get_to(duration);
  parameters.at(11).get_to(waitForCompletion);
}

void MovePictureCommand::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(picture);
  out.push_back(0); // param[1] is not used
  out.push_back(origin);
  out.push_back(pictureLocation);
  out.push_back(x);
  out.push_back(y);
  out.push_back(width);
  out.push_back(height);
  out.push_back(opacity);
  out.push_back(blendMode);
  out.push_back(duration);
  out.push_back(waitForCompletion);
}

std::string MovePictureCommand::stringRep(const Database& db, const bool colored) const {
  std::string suffix;
  if (waitForCompletion) {
    suffix = ColorFormatter::getColor(FormatColor::Gray, colored) + " " + db.parentheses(trNOOP("Wait")) + ColorFormatter::popColor(colored);
  }
  if (pictureLocation == PictureDesignationSource::Designation_with_variables) {
    std::string varX = db.system.variable(x);
    std::string varY = db.system.variable(y);
    varX = varX.empty() ? std::format("#{:04}", x) : varX;
    varY = varY.empty() ? std::format("#{:04}", y) : varY;
    return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Move Picture") + colon.data() +
           std::format("#{}, {} ({{{}}},{{{}}}), ({}%, {}%), {}, {}, {}", picture, DecodeEnumName(origin), varX, varY, width, height, opacity, DecodeEnumName(blendMode), db.framesText(duration)) +
           ColorFormatter::popColor(colored) + suffix;
  }
  return indentText(indent()) + symbol(code()) + ColorFormatter::getColorCode(code(), colored) + trNOOP("Move Picture") + colon.data() +
         std::format("#{}, {} ({},{}), ({}%, {}%), {}, {}, {}", picture, DecodeEnumName(origin), x, y, width, height, opacity, DecodeEnumName(blendMode), db.framesText(duration)) +
         ColorFormatter::popColor(colored) + suffix;
}


code:
#pragma once
#include "Database/EventCommands/IEventCommand.hpp"
#include <format>

struct MovePictureCommand final : IEventCommand {
  MovePictureCommand() = default;
  explicit MovePictureCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~MovePictureCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_Picture; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovePictureCommand>(*this); }
  bool hasReference(const int targetId, const SearchType type) override {
    if (type == SearchType::PictureId) {
      return targetId == picture;
    }
    return false;
  };
  bool setReference(const int targetId, const int newId, const SearchType type) override {
    if (hasReference(targetId, type)) {
      picture = newId;
      return true;
    }
    return false;
  }
  int picture{1};
  PictureOrigin origin = PictureOrigin::Upper_Left;
  PictureDesignationSource pictureLocation = PictureDesignationSource::Direct_designation;
  int x{1};
  int y{1};
  int width{100};
  int height{100};
  int opacity{255};
  Blend blendMode = Blend::Normal;
  int duration{60};
  bool waitForCompletion{false};
};


code:
#pragma once

#include "Database/EventCommands/MovementRoute/BlendMode.hpp"
#include "Database/EventCommands/MovementRoute/ChangeImage.hpp"
#include "Database/EventCommands/MovementRoute/ChangeOpacity.hpp"
#include "Database/EventCommands/MovementRoute/DirectionFixOFF.hpp"
#include "Database/EventCommands/MovementRoute/DirectionFixON.hpp"
#include "Database/EventCommands/MovementRoute/Frequency.hpp"
#include "Database/EventCommands/MovementRoute/Jump.hpp"
#include "Database/EventCommands/MovementRoute/Move1StepBackward.hpp"
#include "Database/EventCommands/MovementRoute/Move1StepForward.hpp"
#include "Database/EventCommands/MovementRoute/MoveAtRandom.hpp"
#include "Database/EventCommands/MovementRoute/MoveAwayFromPlayer.hpp"
#include "Database/EventCommands/MovementRoute/MoveDown.hpp"
#include "Database/EventCommands/MovementRoute/MoveLeft.hpp"
#include "Database/EventCommands/MovementRoute/MoveLowerLeft.hpp"
#include "Database/EventCommands/MovementRoute/MoveLowerRight.hpp"
#include "Database/EventCommands/MovementRoute/MoveRight.hpp"
#include "Database/EventCommands/MovementRoute/MoveTowardPlayer.hpp"
#include "Database/EventCommands/MovementRoute/MoveUp.hpp"
#include "Database/EventCommands/MovementRoute/MoveUpperLeft.hpp"
#include "Database/EventCommands/MovementRoute/MoveUpperRight.hpp"
#include "Database/EventCommands/MovementRoute/PlaySE.hpp"
#include "Database/EventCommands/MovementRoute/Script.hpp"
#include "Database/EventCommands/MovementRoute/Speed.hpp"
#include "Database/EventCommands/MovementRoute/SteppingAnimationOFF.hpp"
#include "Database/EventCommands/MovementRoute/SteppingAnimationON.hpp"
#include "Database/EventCommands/MovementRoute/SwitchOFF.hpp"
#include "Database/EventCommands/MovementRoute/SwitchON.hpp"
#include "Database/EventCommands/MovementRoute/ThroughOFF.hpp"
#include "Database/EventCommands/MovementRoute/ThroughON.hpp"
#include "Database/EventCommands/MovementRoute/TransparentOFF.hpp"
#include "Database/EventCommands/MovementRoute/TransparentON.hpp"
#include "Database/EventCommands/MovementRoute/Turn180Deg.hpp"
#include "Database/EventCommands/MovementRoute/Turn90DegLeft.hpp"
#include "Database/EventCommands/MovementRoute/Turn90DegLeftOrRight.hpp"
#include "Database/EventCommands/MovementRoute/Turn90DegRight.hpp"
#include "Database/EventCommands/MovementRoute/TurnAtRandom.hpp"
#include "Database/EventCommands/MovementRoute/TurnAwayFromPlayer.hpp"
#include "Database/EventCommands/MovementRoute/TurnDown.hpp"
#include "Database/EventCommands/MovementRoute/TurnLeft.hpp"
#include "Database/EventCommands/MovementRoute/TurnRight.hpp"
#include "Database/EventCommands/MovementRoute/TurnTowardPlayer.hpp"
#include "Database/EventCommands/MovementRoute/TurnUp.hpp"
#include "Database/EventCommands/MovementRoute/Wait.hpp"
#include "Database/EventCommands/MovementRoute/WalkingAnimationOFF.hpp"
#include "Database/EventCommands/MovementRoute/WalkingAnimationON.hpp"


code:
#include "Database/EventCommands/MovementRoute/BlendMode.hpp"

MovementChangeBlendModeCommand::MovementChangeBlendModeCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IMovementRouteStep(indent) {
  parameters.at(0).get_to(mode);
}

void MovementChangeBlendModeCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(mode); }


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementChangeBlendModeCommand final : IMovementRouteStep {
  MovementChangeBlendModeCommand() = default;
  explicit MovementChangeBlendModeCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~MovementChangeBlendModeCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Change_Blend_Mode; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementChangeBlendModeCommand>(*this); }

  Blend mode = Blend::Normal;
};


code:
#include "Database/EventCommands/MovementRoute/ChangeImage.hpp"

MovementChangeImageCommand::MovementChangeImageCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IMovementRouteStep(indent) {
  parameters.at(0).get_to(image);
  parameters.at(1).get_to(character);
}

void MovementChangeImageCommand::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(image);
  out.push_back(character);
}

std::string MovementChangeImageCommand::stringRep(const Database& db, const bool colored) const {
  return symbol(code()) + std::string("Image") + colon.data() + db.imageText(image) + " " + db.parentheses(std::to_string(character));
}


code:
#pragma once
#include "Database/Database.hpp"
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementChangeImageCommand final : IMovementRouteStep {
  MovementChangeImageCommand() = default;
  explicit MovementChangeImageCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~MovementChangeImageCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Change_Image; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementChangeImageCommand>(*this); }

  std::string image;
  int character{0};
};


code:
#include "Database/EventCommands/MovementRoute/ChangeOpacity.hpp"

MovementChangeOpacityCommand::MovementChangeOpacityCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IMovementRouteStep(indent) {
  parameters.at(0).get_to(opacity);
}

void MovementChangeOpacityCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(opacity); }

std::string MovementChangeOpacityCommand::stringRep(const Database& db, const bool colored) const { return symbol(code()) + std::string("Opacity") + colon.data() + std::to_string(opacity); }


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementChangeOpacityCommand final : IMovementRouteStep {
  MovementChangeOpacityCommand() = default;
  explicit MovementChangeOpacityCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~MovementChangeOpacityCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Change_Opacity; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementChangeOpacityCommand>(*this); }

  int opacity{255};
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementDirectionFixOFFCommand final : IMovementRouteStep {
  MovementDirectionFixOFFCommand() = default;
  explicit MovementDirectionFixOFFCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementDirectionFixOFFCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Direction_Fix_OFF; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementDirectionFixOFFCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementDirectionFixONCommand final : IMovementRouteStep {
  MovementDirectionFixONCommand() = default;
  explicit MovementDirectionFixONCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementDirectionFixONCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Direction_Fix_ON; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementDirectionFixONCommand>(*this); }
};


code:
#include "Database/EventCommands/MovementRoute/Frequency.hpp"

MovementFrequencyCommand::MovementFrequencyCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IMovementRouteStep(indent) {
  parameters.at(0).get_to(frequency);
}
void MovementFrequencyCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(frequency); }

std::string MovementFrequencyCommand::stringRep(const Database& db, const bool colored) const { return symbol(code()) + std::string("Frequency") + colon.data() + std::to_string(frequency); }


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementFrequencyCommand final : IMovementRouteStep {
  MovementFrequencyCommand() = default;
  explicit MovementFrequencyCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~MovementFrequencyCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Frequency; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementFrequencyCommand>(*this); }

  int frequency{3};
};


code:
#pragma once

#include "Database/EventCommands/IEventCommand.hpp"

struct IMovementRouteStep : IEventCommand {
  IMovementRouteStep() = default;
  explicit IMovementRouteStep(const std::optional<int>& indent)
  : IEventCommand(indent) {}
  [[nodiscard]] EventCode code() const override = 0;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override { return symbol(code()) + DecodeEnumName(code()); }
};


code:
#include "Database/EventCommands/MovementRoute/Jump.hpp"

MovementJumpCommand::MovementJumpCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IMovementRouteStep(indent) {
  parameters.at(0).get_to(x);
  parameters.at(1).get_to(y);
}

void MovementJumpCommand::serializeParameters(nlohmann::ordered_json& out) const {
  out.push_back(x);
  out.push_back(y);
}

std::string MovementJumpCommand::stringRep(const Database& db, const bool colored) const { return std::format("{}Jump{}{}, {}", symbol((code())), colon, x, y); }


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementJumpCommand final : IMovementRouteStep {
  MovementJumpCommand() = default;
  explicit MovementJumpCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~MovementJumpCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Jump; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementJumpCommand>(*this); }

  int x{0};
  int y{0};

  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMove1StepBackwardCommand final : IMovementRouteStep {
  MovementMove1StepBackwardCommand() = default;
  explicit MovementMove1StepBackwardCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMove1StepBackwardCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::_1_Step_Backward; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMove1StepBackwardCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMove1StepForwardCommand final : IMovementRouteStep {
  MovementMove1StepForwardCommand() = default;
  explicit MovementMove1StepForwardCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMove1StepForwardCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::_1_Step_Forward; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMove1StepForwardCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMoveAtRandomCommand final : IMovementRouteStep {
  MovementMoveAtRandomCommand() = default;
  explicit MovementMoveAtRandomCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMoveAtRandomCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_at_Random; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMoveAtRandomCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMoveAwayFromPlayerCommand final : IMovementRouteStep {
  MovementMoveAwayFromPlayerCommand() = default;
  explicit MovementMoveAwayFromPlayerCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMoveAwayFromPlayerCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_away_from_Player; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMoveAwayFromPlayerCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMoveDownCommand final : IMovementRouteStep {
  MovementMoveDownCommand() = default;
  explicit MovementMoveDownCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMoveDownCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_Down; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMoveDownCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMoveLeftCommand final : IMovementRouteStep {
  MovementMoveLeftCommand() = default;
  explicit MovementMoveLeftCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMoveLeftCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_Left; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMoveLeftCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMoveLowerLeftCommand final : IMovementRouteStep {
  MovementMoveLowerLeftCommand() = default;
  explicit MovementMoveLowerLeftCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMoveLowerLeftCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_Lower_Left; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMoveLowerLeftCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMoveLowerRightCommand final : IMovementRouteStep {
  MovementMoveLowerRightCommand() = default;
  explicit MovementMoveLowerRightCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMoveLowerRightCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_Lower_Right; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMoveLowerRightCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMoveRightCommand final : IMovementRouteStep {
  MovementMoveRightCommand() = default;
  explicit MovementMoveRightCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMoveRightCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_Right; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMoveRightCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMoveTowardPlayerCommand final : IMovementRouteStep {
  MovementMoveTowardPlayerCommand() = default;
  explicit MovementMoveTowardPlayerCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMoveTowardPlayerCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_toward_Player; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMoveTowardPlayerCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMoveUpCommand final : IMovementRouteStep {
  MovementMoveUpCommand() = default;
  explicit MovementMoveUpCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMoveUpCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_Up; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMoveUpCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMoveUpperLeftCommand final : IMovementRouteStep {
  MovementMoveUpperLeftCommand() = default;
  explicit MovementMoveUpperLeftCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMoveUpperLeftCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_Upper_Left; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMoveUpperLeftCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementMoveUpperRightCommand final : IMovementRouteStep {
  MovementMoveUpperRightCommand() = default;
  explicit MovementMoveUpperRightCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementMoveUpperRightCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Move_Upper_Right; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementMoveUpperRightCommand>(*this); }
};


code:
#include "Database/EventCommands/MovementRoute/PlaySE.hpp"
#include "Database/Database.hpp"

MovementPlaySECommand::MovementPlaySECommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IMovementRouteStep(indent) {
  parameters.at(0).get_to(se);
}

void MovementPlaySECommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(se); }

std::string MovementPlaySECommand::stringRep(const Database& db, const bool colored) const { return symbol(code()) + tr("SE") + colon.data() + db.audioText(se); }


code:
#pragma once
#include "Database/Audio.hpp"
#include "Database/Database.hpp"
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementPlaySECommand final : IMovementRouteStep {
  MovementPlaySECommand() = default;
  explicit MovementPlaySECommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~MovementPlaySECommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Play_SE_del_Movement; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementPlaySECommand>(*this); }
  bool hasStringReference(const std::string& text, SearchType type) override {
    if (type == SearchType::Audio) {
      return text.contains(se.name());
    }
    return false;
  };
  Audio se;
};


code:
#include "Database/EventCommands/MovementRoute/Script.hpp"

MovementScriptCommand::MovementScriptCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IMovementRouteStep(indent) {
  parameters.at(0).get_to(script);
}

void MovementScriptCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(script); }

std::string MovementScriptCommand::stringRep(const Database& db, const bool colored) const { return symbol(code()) + DecodeEnumName(code()) + colon.data() + script; }


code:
#pragma once
#include "Database/Database.hpp"
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementScriptCommand final : IMovementRouteStep {
  MovementScriptCommand() = default;
  explicit MovementScriptCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~MovementScriptCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Script_del_Movement; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementScriptCommand>(*this); }

  std::string script;
  bool hasReference(int targetId, SearchType type) override {
    if (type == SearchType::Variable) {
      std::string cnst = Database::instance()->gameConstants.variables[targetId];
      if (cnst.empty()) {
        return false;
      }
      if (script.contains("gameVariables") && script.contains(cnst)) {
        return true;
      }
    }
    if (type == SearchType::Switch) {
      std::string cnst = Database::instance()->gameConstants.switches[targetId];
      if (cnst.empty()) {
        return false;
      }
      if (script.contains("gameSwitches") && script.contains(cnst)) {
        return true;
      }
    }
    return false;
  };

  bool hasStringReference(const std::string& text, SearchType type) override {
    if (text == "") {
      return true;
    }
    if (script.contains(text)) {
      return true;
    }
    return false;
  }
};


code:
#include "Database/EventCommands/MovementRoute/Speed.hpp"

MovementSpeedCommand::MovementSpeedCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IMovementRouteStep(indent) {
  parameters.at(0).get_to(speed);
}

void MovementSpeedCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(speed); }

std::string MovementSpeedCommand::stringRep(const Database& db, const bool colored) const { return symbol(code()) + DecodeEnumName(code()) + colon.data() + std::to_string(speed); }


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementSpeedCommand final : IMovementRouteStep {
  MovementSpeedCommand() = default;
  explicit MovementSpeedCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~MovementSpeedCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Speed; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementSpeedCommand>(*this); }

  int speed{4};
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementSteppingAnimationOFFCommand final : IMovementRouteStep {
  MovementSteppingAnimationOFFCommand() = default;
  explicit MovementSteppingAnimationOFFCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
  : IMovementRouteStep(indent) {}
  ~MovementSteppingAnimationOFFCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Stepping_Animation_OFF; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementSteppingAnimationOFFCommand>(*this); }
};


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementSteppingAnimationONCommand final : IMovementRouteStep {
  MovementSteppingAnimationONCommand() = default;
  explicit MovementSteppingAnimationONCommand(const std::optional<int>& indent)
  : IMovementRouteStep(indent) {}
  ~MovementSteppingAnimationONCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Stepping_Animation_ON; }
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementSteppingAnimationONCommand>(*this); }
};


code:
#include "Database/EventCommands/MovementRoute/SwitchOFF.hpp"
#include "Database/Database.hpp"

MovementSwitchOFFCommand::MovementSwitchOFFCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IMovementRouteStep(indent) {
  parameters.at(0).get_to(id);
}

void MovementSwitchOFFCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(id); }

std::string MovementSwitchOFFCommand::stringRep(const Database& db, const bool colored) const { return symbol(code()) + DecodeEnumName(code()) + colon.data() + std::format("{:04}", id); }


code:
#pragma once
#include "Database/EventCommands/MovementRoute/IMovementRouteStep.hpp"
#include <format>

struct MovementSwitchOFFCommand final : IMovementRouteStep {
  MovementSwitchOFFCommand() = default;
  explicit MovementSwitchOFFCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters);
  ~MovementSwitchOFFCommand() override = default;
  [[nodiscard]] EventCode code() const override { return EventCode::Switch_OFF; }
  void serializeParameters(nlohmann::ordered_json& out) const override;
  [[nodiscard]] std::string stringRep(const Database& db, bool colored = true) const override;
  std::shared_ptr<IEventCommand> clone() const override { return std::make_shared<MovementSwitchOFFCommand>(*this); }
  bool hasReference(int targetId, SearchType type) override {
    if (type == SearchType::Switch) {
      return targetId == id;
    }
    return false;
  };
  bool setReference(int targetId, int newId, SearchType type) override {
    if (hasReference(targetId, type)) {
      id = newId;
      return true;
    }
    return false;
  }
  int id{1};
};


code:
#include "Database/EventCommands/MovementRoute/SwitchON.hpp"

MovementSwitchONCommand::MovementSwitchONCommand(const std::optional<int>& indent, const nlohmann::ordered_json& parameters)
: IMovementRouteStep(indent) {
  parameters.at(0).get_to(id);
}

void MovementSwitchONCommand::serializeParameters(nlohmann::ordered_json& out) const { out.push_back(id); }

std::string MovementSwitchONCommand::stringRep(const Database& db, const bool colored) const { return symbol(code()) + DecodeEnumName(code()) + colon.data() + std::format("{:04}", id); }