Add to_json and from_json script functions

This commit is contained in:
GenevensiS
2025-08-07 18:45:12 +02:00
committed by GitHub
parent 12eb39b5e2
commit dc348b4812
18 changed files with 748 additions and 142 deletions
-1
View File
@@ -40,7 +40,6 @@ Field::~Field() {}
void Field::initDependencies(Context& ctx, const Dependency& dep) const {
sort_script.initDependencies(ctx, dep);
import_script.initDependencies(ctx, dep);
}
IMPLEMENT_REFLECTION(Field) {
+2 -3
View File
@@ -62,9 +62,9 @@ wxDataFormat CardsDataObject::format = _("application/x-mse-cards");
CardsDataObject::CardsDataObject(const SetP& set, const vector<CardP>& cards) {
// set the stylesheet, so when deserializing we know whos style options we are reading
bool* has_styling = new bool[cards.size()];
vector<bool> has_styling;
for (size_t i = 0 ; i < cards.size() ; ++i) {
has_styling[i] = cards[i]->has_styling && !cards[i]->stylesheet;
has_styling.push_back(cards[i]->has_styling && !cards[i]->stylesheet);
if (has_styling[i]) {
cards[i]->stylesheet = set->stylesheet;
}
@@ -78,7 +78,6 @@ CardsDataObject::CardsDataObject(const SetP& set, const vector<CardP>& cards) {
}
}
SetFormat(format);
delete [] has_styling;
}
CardsDataObject::CardsDataObject() {
+5 -5
View File
@@ -91,11 +91,11 @@ public:
Keyword() : fixed(false), valid(false) {}
String keyword; ///< The keyword, only for human use
String rules; ///< Rules/explanation
String match; ///< String to match, <atom-param> tags are used for parameters
vector<KeywordParamP> parameters; ///< The types of parameters
StringScript reminder; ///< Reminder text of the keyword
String mode; ///< Mode of use, can be used by scripts (only gives the name)
String rules; ///< Rules/explanation
String match; ///< String to match, <atom-param> tags are used for parameters
vector<KeywordParamP> parameters; ///< The types of parameters
StringScript reminder; ///< Reminder text of the keyword
String mode; ///< Mode of use, can be used by scripts (only gives the name)
/// Regular expression to match and split parameters, automatically generated.
/** The regex has exactly 2 * parameters.size() + 1 captures (excluding the entire match, caputure 0),
* captures 1,3,... capture the plain text of the match string
+1 -1
View File
@@ -94,7 +94,7 @@ bool PackType::update(Context& ctx) {
bool PackItem::update(Context& ctx) {
return amount.update(ctx)
| weight.update(ctx);
|| weight.update(ctx);
}
+1 -1
View File
@@ -50,7 +50,7 @@ public:
/// The values on the fields of the set
/** The indices should correspond to the set_fields in the Game */
IndexMap<FieldP, ValueP> data;
/// Extra values for specitic stylesheets, indexed by stylesheet name
/// Extra values for specific stylesheets, indexed by stylesheet name
DelayedIndexMaps<FieldP,ValueP> styling_data;
vector<CardP> cards; ///< The cards in the set
vector<KeywordP> keywords; ///< Additional keywords used in this set