Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output JSON reports - part 1 #150

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GAMEMASTER.md
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ If you wanted to switch on quartermasters, and have their level affect
shipping costs, but not distance, you would set the variable in rules.cpp
like so:

Gamedefs::ALLOW_TRANSPORT | GameDefs::QM_AFFECT_COST, // TRANSPORT
GameDefs::ALLOW_TRANSPORT | GameDefs::QM_AFFECT_COST, // TRANSPORT
valdisz marked this conversation as resolved.
Show resolved Hide resolved

Note that the different values are set using a boolean OR |, not a
logical OR ||.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ENGINE_OBJECTS = alist.o aregion.o army.o astring.o battle.o economy.o \
events.o events-battle.o events-assassination.o mapgen.o simplex.o namegen.o \
indenter.o

UNITTEST_SRC = unittest/main.cpp $(wildcard unittest/*_test.cpp)
UNITTEST_SRC = unittest/main.cpp unittest/testhelper.cpp $(wildcard unittest/*_test.cpp)
UNITTEST_OBJECTS = $(patsubst unittest/%.cpp,unittest/obj/%.o,$(UNITTEST_SRC))

OBJECTS = $(patsubst %.o,obj/%.o,$(ENGINE_OBJECTS)) $(patsubst %.o,$(GAME)/obj/%.o,$(RULESET_OBJECTS))
Expand Down
8 changes: 8 additions & 0 deletions aregion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,14 @@ void ARegion::WriteExits(ostream& f, ARegionList *pRegs, int *exits_seen)
f << '\n';
}

void ARegion::write_json_report(json& j, Faction *fac, int month, ARegionList *pRegions) {
// for now, just set a name which would be the name of the region from a text report.
// ie "Alioth Plains (1, 2) in Alioth contains Alioth City [City]."
// This will get broken down and become more json-y when I flesh this code out.
j["name"] = Print(pRegions).const_str();
return;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is here solely so that the output shows that it is iterating the regions.. This is just a temp leaf.

}

void ARegion::WriteReport(ostream &f, Faction *fac, int month, ARegionList *pRegions)
{
Farsight *farsight = GetFarsight(&farsees, fac);
Expand Down
4 changes: 4 additions & 0 deletions aregion.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class ARegionArray;
#include "graphs.h"
#include "mapgen.h"

#include "external/nlohmann/json.hpp"
using json = nlohmann::json;

#include <map>
#include <vector>
#include <functional>
Expand Down Expand Up @@ -199,6 +202,7 @@ class ARegion : public AListElem
void WriteEconomy(ostream& f, Faction *, int);
void WriteExits(ostream& f, ARegionList *pRegs, int *exits_seen);
void WriteReport(ostream& f, Faction *fac, int month, ARegionList *pRegions);
void write_json_report(json& j, Faction *fac, int month, ARegionList *pRegions);
valdisz marked this conversation as resolved.
Show resolved Hide resolved
// DK
void WriteTemplate(ostream& f, Faction *, ARegionList *, int);
void WriteTemplateHeader(ostream& f, Faction *, ARegionList *, int);
Expand Down
1 change: 1 addition & 0 deletions basic/rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ static GameDefs g = {
200, // MIN_DESTROY_POINTS,
33, // MAX_DESTROY_PERCENT
0, // HALF_RIDING_BONUS
GameDefs::REPORT_FORMAT_TEXT, // REPORT_FORMAT
};

GameDefs *Globals = &g;
Loading