Tarot readings: AI-written, drawn on the server, sold as units
CI / test (push) Successful in 1m29s
CI / build (push) Successful in 5m52s
CI / deploy (push) Skipped

A new Kártyajóslás page: choose a spread (1, 3 or 5 cards), ask a
question, pick the cards from the fanned deck and watch them turn over;
the reading is written by the detailed-analysis model from the cards,
their positions and base meanings, the question and the reader's Sun,
Moon and Ascendant. The server shuffles and draws, so nobody can draw
again for free. A reading is a 'tarot' analysis (worker, retries,
fallback, refunds and admin regeneration as for analyses), uses one
'tarot' unit, and survives recalculations; deleting the account
deletes it.

Packages carry 2/5/10 readings, the new +5 kártyajóslás addon costs
1 000 Ft. The card artwork comes from the tarot design studio
(celestial astrolabe style); the deck JSON is shared by the frontend
and the prompt. A public example is at /kartyajoslas/pelda.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-20 14:35:50 +00:00
co-authored by Claude Opus 5.5
parent 54af54cd39
commit b0fc547b73
36 changed files with 2957 additions and 46 deletions
+16 -7
View File
@@ -1,8 +1,8 @@
//! Analysis units: a detailed natal analysis uses one `natal` unit, a
//! synastry analysis one `synastry` unit, a yearly forecast one `forecast`
//! unit, a question about an analysis one `question` unit. Units come from
//! purchases or an admin; a failed analysis or answer gives its unit back
//! (the worker does that).
//! unit, a question about an analysis one `question` unit, a tarot reading one
//! `tarot` unit. Units come from purchases or an admin; a failed analysis or
//! answer gives its unit back (the worker does that).
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
@@ -22,6 +22,8 @@ pub enum Unit {
Person,
/// A question about a finished analysis (see `routes::questions`).
Question,
/// A tarot reading (see `routes::tarot`).
Tarot,
}
impl Unit {
@@ -32,6 +34,7 @@ impl Unit {
Unit::Forecast => "forecast",
Unit::Person => "person",
Unit::Question => "question",
Unit::Tarot => "tarot",
}
}
}
@@ -45,6 +48,7 @@ pub struct Balance {
/// Bought person slots (not the slots left; see [`crate::persons::slots`]).
pub person: i64,
pub question: i64,
pub tarot: i64,
}
impl Balance {
@@ -55,27 +59,32 @@ impl Balance {
Unit::Forecast => self.forecast,
Unit::Person => self.person,
Unit::Question => self.question,
Unit::Tarot => self.tarot,
}
}
pub fn view(self) -> Value {
json!({ "natal": self.natal, "synastry": self.synastry, "forecast": self.forecast, "question": self.question })
json!({
"natal": self.natal, "synastry": self.synastry, "forecast": self.forecast, "question": self.question,
"tarot": self.tarot,
})
}
}
pub async fn balance(conn: &mut PgConnection, user_id: Uuid) -> Result<Balance, ApiError> {
let (natal, synastry, forecast, person, question): (i64, i64, i64, i64, i64) = sqlx::query_as(
let (natal, synastry, forecast, person, question, tarot): (i64, i64, i64, i64, i64, i64) = sqlx::query_as(
"SELECT COALESCE(SUM(delta) FILTER (WHERE unit = 'natal'), 0)::bigint, \
COALESCE(SUM(delta) FILTER (WHERE unit = 'synastry'), 0)::bigint, \
COALESCE(SUM(delta) FILTER (WHERE unit = 'forecast'), 0)::bigint, \
COALESCE(SUM(delta) FILTER (WHERE unit = 'person' AND reason <> 'person'), 0)::bigint, \
COALESCE(SUM(delta) FILTER (WHERE unit = 'question'), 0)::bigint \
COALESCE(SUM(delta) FILTER (WHERE unit = 'question'), 0)::bigint, \
COALESCE(SUM(delta) FILTER (WHERE unit = 'tarot'), 0)::bigint \
FROM credit_ledger WHERE user_id = $1",
)
.bind(user_id)
.fetch_one(conn)
.await?;
Ok(Balance { natal, synastry, forecast, person, question })
Ok(Balance { natal, synastry, forecast, person, question, tarot })
}
/// Spends one unit inside the caller's transaction. The user row is locked