Report sign/house in significant transits; back up user.properties outside dist/
This commit is contained in:
+23
-4
@@ -57,6 +57,22 @@ static const char *aspect_display_name(AspectType type) {
|
||||
return names[type];
|
||||
}
|
||||
|
||||
static const char *sign_display_name(ZodiacSign sign) {
|
||||
static const char *const names[12] = {
|
||||
"Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo",
|
||||
"Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces",
|
||||
};
|
||||
return names[sign];
|
||||
}
|
||||
|
||||
/* pos->house is 0 when reading_load_json had no sign/house data for this
|
||||
* body (see parse_bodies() in reading_io.c) - a valid whole-sign house
|
||||
* is always 1-12, so this is a safe "unknown, say nothing" sentinel. */
|
||||
static void print_body_in_sign(const PlanetPosition *pos) {
|
||||
if (pos->house < 1 || pos->house > 12) return;
|
||||
printf(" in %s (house %d)", sign_display_name(pos->sign), pos->house);
|
||||
}
|
||||
|
||||
static const char *day_level_name(DaySignificance level) {
|
||||
switch (level) {
|
||||
case DAY_QUIET: return "Quiet";
|
||||
@@ -114,10 +130,13 @@ int main(int argc, char **argv) {
|
||||
interp.top_item_count == 1 ? "" : "s");
|
||||
for (int i = 0; i < interp.top_item_count; i++) {
|
||||
const SignificantItem *item = &interp.top_items[i];
|
||||
printf(" %d. Transiting %s %s natal %s (orb %.1f\xc2\xb0, score %.2f)\n", i + 1,
|
||||
body_display_name(item->aspect.transiting_planet),
|
||||
aspect_display_name(item->aspect.type),
|
||||
body_display_name(item->aspect.natal_planet), item->aspect.orb, item->score);
|
||||
const Aspect *a = &item->aspect;
|
||||
|
||||
printf(" %d. Transiting %s", i + 1, body_display_name(a->transiting_planet));
|
||||
print_body_in_sign(&reading.transits.bodies[a->transiting_planet]);
|
||||
printf(" %s natal %s", aspect_display_name(a->type), body_display_name(a->natal_planet));
|
||||
print_body_in_sign(&reading.natal.bodies[a->natal_planet]);
|
||||
printf(" (orb %.1f\xc2\xb0, score %.2f)\n", a->orb, item->score);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@ static const char *const k_aspect_slug[5] = {
|
||||
"conjunction", "sextile", "square", "trine", "opposition",
|
||||
};
|
||||
|
||||
static const char *const k_sign_slug[12] = {
|
||||
"aries", "taurus", "gemini", "cancer", "leo", "virgo",
|
||||
"libra", "scorpio", "sagittarius", "capricorn", "aquarius", "pisces",
|
||||
};
|
||||
|
||||
static bool body_from_slug(const char *slug, Body *out) {
|
||||
for (int i = 0; i < NUM_BODIES; i++) {
|
||||
if (strcmp(slug, k_body_slug[i]) == 0) {
|
||||
@@ -27,6 +32,41 @@ static bool body_from_slug(const char *slug, Body *out) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool sign_from_slug(const char *slug, ZodiacSign *out) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
if (strcmp(slug, k_sign_slug[i]) == 0) {
|
||||
*out = (ZodiacSign)i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Fills out[NUM_BODIES] from a "bodies" JSON array, the shape shared by
|
||||
* both "natal" and "transits" (see reading_print_json in engine/src/
|
||||
* reading.c). Used only for sign/house context in significant-event
|
||||
* reporting, not for scoring, so this is deliberately lenient: an entry
|
||||
* with an unrecognized/missing "body" slug is skipped, and a missing
|
||||
* "house" leaves that body's house at 0 - not a valid whole-sign house
|
||||
* number (always 1-12), so callers use house == 0 as "no position data
|
||||
* available" rather than this failing the whole load. */
|
||||
static void parse_bodies(const JsonValue *bodies, PlanetPosition out[NUM_BODIES]) {
|
||||
int count = json_array_count(bodies);
|
||||
for (int i = 0; i < count; i++) {
|
||||
const JsonValue *item = json_array_get(bodies, i);
|
||||
Body body;
|
||||
if (!body_from_slug(json_as_string(json_object_get(item, "body")), &body)) continue;
|
||||
|
||||
ZodiacSign sign;
|
||||
if (sign_from_slug(json_as_string(json_object_get(item, "sign")), &sign)) {
|
||||
out[body].sign = sign;
|
||||
}
|
||||
out[body].degree_in_sign = json_as_number(json_object_get(item, "degree_in_sign"));
|
||||
out[body].ecliptic_longitude = json_as_number(json_object_get(item, "ecliptic_longitude"));
|
||||
out[body].house = (int)json_as_number(json_object_get(item, "house"));
|
||||
}
|
||||
}
|
||||
|
||||
static bool aspect_type_from_slug(const char *slug, AspectType *out) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (strcmp(slug, k_aspect_slug[i]) == 0) {
|
||||
@@ -78,6 +118,10 @@ bool reading_load_json(const char *text, size_t length, DailyReading *out) {
|
||||
}
|
||||
out->transits.aspect_count = filled;
|
||||
|
||||
const JsonValue *natal = json_object_get(root, "natal");
|
||||
parse_bodies(natal ? json_object_get(natal, "bodies") : NULL, out->natal.bodies);
|
||||
parse_bodies(json_object_get(transits, "bodies"), out->transits.bodies);
|
||||
|
||||
json_free(root);
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -10,14 +10,18 @@
|
||||
|
||||
/* Parses deck-engine's `--format json` output (text, null-terminated at
|
||||
* text[length]) and fills *out with just enough of a DailyReading for
|
||||
* interpret_daily_reading() to work on: out->transits.aspects[]/
|
||||
* aspect_count. out->natal and out->spread are left zeroed - nothing
|
||||
* here reads them (see significance.c), so there's no reason to parse
|
||||
* the rest of the document yet.
|
||||
* interpret_daily_reading() to work on and for reporting sign/house
|
||||
* context around each significant event: out->transits.aspects[]/
|
||||
* aspect_count (used for scoring - see significance.c), and
|
||||
* out->natal.bodies[]/out->transits.bodies[] (sign + house per body,
|
||||
* used only for display). out->natal.ascendant_longitude/houses[] and
|
||||
* out->spread are left zeroed - nothing reads them yet.
|
||||
*
|
||||
* Returns false on malformed JSON, or if "transits"."aspects" isn't
|
||||
* present as an array (an empty array is fine - that's a real "no
|
||||
* aspects today" reading, not an error). */
|
||||
* aspects today" reading, not an error). A missing/unrecognized entry
|
||||
* in "natal"."bodies"/"transits"."bodies" is not an error - see
|
||||
* parse_bodies() in reading_io.c. */
|
||||
bool reading_load_json(const char *text, size_t length, DailyReading *out);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user