mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-09 15:11:29 -07:00
Issue #10: rewards bootstrapping
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
-- Game-reward selections — the three-choice reward the client shows after a
|
||||
-- challenge or level-up. `/api/gamerewards/v1/request` mints one and pushes it to the
|
||||
-- player over the notifications hub; `/api/gamerewards/v1/select` consumes it.
|
||||
--
|
||||
-- The three offered drop ids are recorded so `select` can verify the player is
|
||||
-- claiming something they were actually offered, and `consumed` makes the selection
|
||||
-- single-use. Owned by the `econ` worker; generated from src/rewards-db.ts
|
||||
-- (SCHEMA_DDL) — keep in sync.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS reward_selection (
|
||||
reward_selection_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
account_id INTEGER NOT NULL,
|
||||
message TEXT NOT NULL DEFAULT '',
|
||||
gift_context INTEGER NOT NULL DEFAULT 0,
|
||||
reward_type INTEGER NOT NULL DEFAULT 0,
|
||||
gift_drop_1_id INTEGER NOT NULL,
|
||||
gift_drop_2_id INTEGER NOT NULL,
|
||||
gift_drop_3_id INTEGER NOT NULL,
|
||||
consumed INTEGER NOT NULL DEFAULT 0,
|
||||
created_at TEXT
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_reward_selection_account ON reward_selection (account_id);
|
||||
@@ -0,0 +1,22 @@
|
||||
-- Per-player objective progress — the daily/weekly challenge checklist. The client
|
||||
-- reports progress with `/api/objectives/v1/updateobjective` and reads it back from
|
||||
-- `/api/objectives/v1/myprogress`.
|
||||
--
|
||||
-- An objective is keyed by (account, group, index) — the client's own identifiers —
|
||||
-- so updates upsert on that triple. `has_claimed_reward` latches on first completion
|
||||
-- so a reward can't be paid twice. `group`/`index` are SQL keywords, hence the
|
||||
-- `group_id`/`idx` column names. Owned by the `econ` worker; generated from
|
||||
-- src/objectives-db.ts (SCHEMA_DDL) — keep in sync.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS objective (
|
||||
account_id INTEGER NOT NULL,
|
||||
group_id INTEGER NOT NULL,
|
||||
idx INTEGER NOT NULL,
|
||||
progress REAL NOT NULL DEFAULT 0,
|
||||
visual_progress REAL NOT NULL DEFAULT 0,
|
||||
is_completed INTEGER NOT NULL DEFAULT 0,
|
||||
is_rewarded INTEGER NOT NULL DEFAULT 0,
|
||||
has_claimed_reward INTEGER NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (account_id, group_id, idx)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_objective_account ON objective (account_id);
|
||||
@@ -0,0 +1,16 @@
|
||||
-- A player's objective *groups* — the daily/weekly sets their objectives belong to.
|
||||
-- The client clears a group when it's finished with it (`/api/objectives/v1/cleargroup`),
|
||||
-- which marks it completed and stamps the clear time; `myprogress` reads the groups
|
||||
-- back alongside the objectives themselves.
|
||||
--
|
||||
-- Keyed by (account, group), the client's own identifier. `group` is a SQL keyword,
|
||||
-- hence `group_id`. Owned by the `econ` worker; generated from src/objectives-db.ts
|
||||
-- (SCHEMA_DDL) — keep in sync.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS objective_group (
|
||||
account_id INTEGER NOT NULL,
|
||||
group_id INTEGER NOT NULL,
|
||||
is_completed INTEGER NOT NULL DEFAULT 0,
|
||||
cleared_at TEXT,
|
||||
PRIMARY KEY (account_id, group_id)
|
||||
);
|
||||
Reference in New Issue
Block a user