yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
project_plan.h
Go to the documentation of this file.
1#ifndef YAZE_CORE_PROJECT_PLAN_H_
2#define YAZE_CORE_PROJECT_PLAN_H_
3
4#include <string>
5#include <string_view>
6#include <vector>
7
8#include "absl/status/status.h"
9#include "absl/status/statusor.h"
10#include "nlohmann/json.hpp"
11
12namespace yaze::core {
13
14// A project plan: goals, milestones, the intended play route, open design
15// decisions and reference documents for a hack. Stored as a JSON sidecar
16// (schema "yaze.plan/1") named by the `.yaze` file's [planning] section; see
17// docs/public/usage/planning.md. Game-independent: nothing here reads a ROM.
18//
19// Every object keeps the keys this build does not model in `extra`, and the
20// top level keeps unknown sections (for example "overworld" or "concepts"), so
21// a plan written by a newer build or another tool survives a save.
22
23using PlanJson = nlohmann::ordered_json;
24
25inline constexpr std::string_view kProjectPlanSchema = "yaze.plan/1";
26
27// A link from plan data to something the editor can show. Written as
28// "<kind>:<id>", for example "room:0x0C", "map:0x4B", "area:D1", "step:D4",
29// "item:flippers", "decision:power-approach", "marker:abyss:m3".
30struct PlanTarget {
31 std::string kind;
32 std::string id;
33
34 static PlanTarget Parse(std::string_view text);
35 // Room or overworld map number for "room:" / "map:" targets, else -1.
36 int NumericId() const;
37};
38
39struct PlanGoal {
40 std::string title;
41 std::string detail;
42 std::string due; // YYYY-MM-DD, optional
43 PlanJson extra = PlanJson::object();
44};
45
47 std::string id;
48 std::string title;
49 std::string start; // YYYY-MM-DD, optional
50 std::string end; // YYYY-MM-DD, optional
51 std::string status; // planned | active | done
52 std::string detail;
53 PlanJson extra = PlanJson::object();
54};
55
57 std::string id;
58 std::string code; // short label such as "D4", optional
59 std::string title;
60 std::string note;
61 std::string group; // chapter or act heading, optional
62 std::string kind; // story | errand | dungeon | shrine | optional | boss
63 std::vector<std::string> targets;
64 PlanJson extra = PlanJson::object();
65};
66
67struct PlanNeed {
68 std::string step;
69 std::string what;
70 PlanJson extra = PlanJson::object();
71};
72
74 std::string id;
75 std::string name;
76 std::string step; // route step where the player gets it
77 std::string category; // gear | mask | song | quest | ...
78 bool required = false;
79 std::string status; // implemented | prototype | decided | proposed | open
80 std::string where;
81 std::string note;
82 std::vector<PlanNeed> needs; // later steps that require it
83 PlanJson extra = PlanJson::object();
84};
85
87 std::string id;
88 std::string title;
89 std::string status; // open | decided | dropped
90 int priority = 0; // 1 = most urgent; 0 = unranked
91 std::string recommendation;
92 std::string answer;
93 std::vector<std::string> targets;
94 std::vector<std::string> refs; // file paths or URLs
95 PlanJson extra = PlanJson::object();
96};
97
99 std::string label;
100 std::string path; // file path or URL
101 std::string author;
102 std::string date;
103 PlanJson extra = PlanJson::object();
104};
105
107 public:
108 static ProjectPlan CreateEmpty(std::string title);
109 static absl::StatusOr<ProjectPlan> Parse(std::string_view text);
110 static absl::StatusOr<ProjectPlan> LoadFromFile(const std::string& path);
111
112 std::string Serialize() const;
113 // Writes a sibling temporary file, then renames it over `path`.
114 absl::Status SaveToFile(const std::string& path) const;
115
116 // Index into route_steps, or -1.
117 int FindStep(std::string_view id) const;
118 std::vector<const PlanRouteItem*> ItemsAtStep(std::string_view step) const;
119 // Decisions with status "open", most urgent first (unranked last).
120 std::vector<const PlanDecision*> OpenDecisions() const;
121 // The milestone marked "active", else the first one whose dates contain
122 // `today` (YYYY-MM-DD), else nullptr.
123 const PlanMilestone* CurrentMilestone(std::string_view today) const;
124
125 std::string title;
126 std::string about;
128 std::vector<PlanMilestone> milestones;
129 std::vector<PlanRouteStep> route_steps;
130 std::vector<PlanRouteItem> route_items;
131 PlanJson route_extra = PlanJson::object();
132 std::vector<PlanDecision> decisions;
133 std::vector<PlanReference> references;
134 PlanJson extra = PlanJson::object();
135};
136
137} // namespace yaze::core
138
139#endif // YAZE_CORE_PROJECT_PLAN_H_
std::string Serialize() const
absl::Status SaveToFile(const std::string &path) const
static ProjectPlan CreateEmpty(std::string title)
static absl::StatusOr< ProjectPlan > Parse(std::string_view text)
std::vector< PlanReference > references
std::vector< const PlanRouteItem * > ItemsAtStep(std::string_view step) const
const PlanMilestone * CurrentMilestone(std::string_view today) const
std::vector< const PlanDecision * > OpenDecisions() const
std::vector< PlanMilestone > milestones
static absl::StatusOr< ProjectPlan > LoadFromFile(const std::string &path)
std::vector< PlanRouteItem > route_items
int FindStep(std::string_view id) const
std::vector< PlanRouteStep > route_steps
std::vector< PlanDecision > decisions
constexpr std::string_view kProjectPlanSchema
nlohmann::ordered_json PlanJson
std::vector< std::string > targets
std::vector< std::string > refs
std::vector< PlanNeed > needs
std::vector< std::string > targets
static PlanTarget Parse(std::string_view text)