From adb0a444577b59eb02788c782a3d04bc285be0ba Mon Sep 17 00:00:00 2001 From: garak Date: Sun, 30 Jun 2019 12:05:45 -0400 Subject: add field info to wild pokemon json --- tools/jsonproc/jsonproc.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'tools/jsonproc/jsonproc.cpp') diff --git a/tools/jsonproc/jsonproc.cpp b/tools/jsonproc/jsonproc.cpp index efe48f39f..c0d6e9434 100755 --- a/tools/jsonproc/jsonproc.cpp +++ b/tools/jsonproc/jsonproc.cpp @@ -36,7 +36,14 @@ int main(int argc, char *argv[]) // Add custom command callbacks. env.add_callback("doNotModifyHeader", 0, [jsonfilepath, templateFilepath](Arguments& args) { - return "//\n// DO NOT MODIFY THIS FILE! IT IS AUTO-GENERATED FROM " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n"; + return "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n"; + }); + + env.add_callback("subtract", 2, [](Arguments& args) { + int minuend = args.at(0)->get(); + int subtrahend = args.at(1)->get(); + + return minuend - subtrahend; }); env.add_callback("setVar", 2, [=](Arguments& args) { @@ -51,6 +58,21 @@ int main(int argc, char *argv[]) return get_custom_var(key); }); + env.add_callback("trackVar", 2, [](Arguments& args) { + static int counter = 0; + + int addValue = args.at(0)->get(); + int checkValue = args.at(1)->get(); + + bool over = false; + + counter = (counter + addValue) % (checkValue + 1); + + if (counter <= addValue) over = true; + + return over; + }); + env.add_callback("concat", 2, [](Arguments& args) { string first = args.at(0)->get(); string second = args.at(1)->get(); @@ -67,7 +89,6 @@ int main(int argc, char *argv[]) return rawValue.erase(0, prefix.length()); }); - // Add custom command callbacks. env.add_callback("removeSuffix", 2, [](Arguments& args) { string rawValue = args.at(0)->get(); string suffix = args.at(1)->get(); -- cgit v1.2.3 From 4594c955b4f2145891d6728b84e33489ee352a3a Mon Sep 17 00:00:00 2001 From: garak Date: Mon, 1 Jul 2019 23:47:45 -0400 Subject: create defines to support encounter index ratios --- tools/jsonproc/jsonproc.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tools/jsonproc/jsonproc.cpp') diff --git a/tools/jsonproc/jsonproc.cpp b/tools/jsonproc/jsonproc.cpp index c0d6e9434..15eae9dcb 100755 --- a/tools/jsonproc/jsonproc.cpp +++ b/tools/jsonproc/jsonproc.cpp @@ -5,7 +5,7 @@ #include #include -using std::string; +using std::string; using std::to_string; #include using namespace inja; @@ -53,6 +53,13 @@ int main(int argc, char *argv[]) return ""; }); + env.add_callback("setVarInt", 2, [=](Arguments& args) { + string key = args.at(0)->get(); + string value = to_string(args.at(1)->get()); + set_custom_var(key, value); + return ""; + }); + env.add_callback("getVar", 1, [=](Arguments& args) { string key = args.at(0)->get(); return get_custom_var(key); -- cgit v1.2.3