mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 22:51:30 -07:00
[econ] reward scaffolding
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
-- Weekly-challenge progress, owned by the `econ` worker. One row per (account,
|
||||
-- challenge): the client evaluates a challenge's rule tree locally and posts its verdict
|
||||
-- to `/api/challenge/v2/updateProgress`, which upserts here; `/api/challenge/v2/getCurrent`
|
||||
-- reads the rows back to stamp each challenge's per-player `Complete`.
|
||||
--
|
||||
-- Only the completion flag is stored. The `Config` rule tree posted alongside it is the
|
||||
-- challenge's definition (static/weekly-challenge.json, identical for every player) plus
|
||||
-- the client's running count in `cc`; the server evaluates none of it, so a per-player copy
|
||||
-- would just be a staler duplicate of the catalog.
|
||||
--
|
||||
-- `challenge_map_id` is the rotation the report belongs to. It is not part of the key, but
|
||||
-- it scopes reads and resets the row when a challenge id comes back in a later rotation:
|
||||
-- ids are only unique within one. Kept in sync with CHALLENGE_STATUS_SCHEMA_DDL in
|
||||
-- src/challenge-db.ts.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS challenge_status (
|
||||
account_id INTEGER NOT NULL,
|
||||
challenge_id INTEGER NOT NULL,
|
||||
challenge_map_id INTEGER NOT NULL,
|
||||
complete INTEGER NOT NULL,
|
||||
updated_at TEXT NOT NULL,
|
||||
PRIMARY KEY (account_id, challenge_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_challenge_status_account_map ON challenge_status (account_id, challenge_map_id);
|
||||
@@ -0,0 +1,20 @@
|
||||
-- Game-reward eligibility, owned by the `econ` worker. One row per (account, reward type):
|
||||
-- the client asks for a reward whenever it thinks one is due (`POST
|
||||
-- /api/gamerewards/v1/request` with `rewardType`/`Message`), so this table is what decides
|
||||
-- whether one is actually owed and keeps a repeat ask from paying out twice.
|
||||
--
|
||||
-- `granted_at` is when the type was last claimed and `grant_count` how many times it has
|
||||
-- been; the claim is a conditional upsert, so the check and the write are one atomic
|
||||
-- statement (the client can fire two requests at once after a match).
|
||||
--
|
||||
-- The reward TYPE is the whole key. The client also sends a `giftContext` (the activity,
|
||||
-- e.g. `Soccer`), deliberately not keyed on: one cooldown per type, shared across
|
||||
-- activities. Kept in sync with REWARD_STATUS_SCHEMA_DDL in src/reward-db.ts.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS reward_status (
|
||||
account_id INTEGER NOT NULL,
|
||||
reward_type TEXT NOT NULL,
|
||||
granted_at TEXT NOT NULL,
|
||||
grant_count INTEGER NOT NULL,
|
||||
PRIMARY KEY (account_id, reward_type)
|
||||
);
|
||||
Reference in New Issue
Block a user