| 26 | characterClass = charClass; |
| 27 | }; |
| 28 | bool serialize(FileInterface* const file) { |
| 29 | // recommend you start with this because it makes versioning way easier down the road |
| 30 | int version = 0; |
| 31 | file->property("version", version); |
| 32 | |
| 33 | file->property("CLASS", characterClass); |
| 34 | file->property("MAXHP", classStats->MAXHP); |
| 35 | file->property("MAXMP", classStats->MAXMP); |
| 36 | file->property("STR", classStats->STR); |
| 37 | file->property("DEX", classStats->DEX); |
| 38 | file->property("CON", classStats->CON); |
| 39 | file->property("INT", classStats->INT); |
| 40 | file->property("PER", classStats->PER); |
| 41 | file->property("CHR", classStats->CHR); |
| 42 | file->property("GOLD", classStats->GOLD); |
| 43 | |
| 44 | // doing a vector is automatic: |
| 45 | /*std::vector<Uint32> pros; |
| 46 | file->property("Proficiencies", pros); |
| 47 | }*/ |
| 48 | |
| 49 | // how to do an raw array: |
| 50 | /*file->propertyName("Proficiencies"); |
| 51 | Uint32 arrSize = NUMPROFICIENCIES; |
| 52 | file->beginArray(arrSize); |
| 53 | assert(arrSize == NUMPROFICIENCIES); // error out if the array size in json is not correct! |
| 54 | for (Uint32 c = 0; c < arrSize; ++c) { |
| 55 | file->value(classStats->PROFICIENCIES[c]); |
| 56 | } |
| 57 | file->endArray();*/ |
| 58 | |
| 59 | // how to do an inline object: |
| 60 | file->propertyName("Proficiencies"); |
| 61 | file->beginObject(); |
| 62 | int numProficiencies = NUMPROFICIENCIES; |
| 63 | file->property("NumProficiencies", numProficiencies); |
| 64 | for ( int i = 0; i < numProficiencies; ++i ) |
| 65 | { |
| 66 | char str[64]; |
| 67 | snprintf(str, 64, "%s", getSkillLangEntry(i)); |
| 68 | int prof = classStats->getProficiency(i); |
| 69 | file->property(str, prof); |
| 70 | } |
| 71 | file->endObject(); |
| 72 | return true; |
| 73 | } |
| 74 | |
| 75 | void writeToFile() |
| 76 | { |
nothing calls this directly
no test coverage detected