Rewards beyond titles: bundles on quests, achievements and rank milestones; panel-side money/chunks/badges; delivery queue
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DjMbLQujBHunCCu5GpsHaT
This commit is contained in:
11 files changed
+580
-6
No files matched your search
@@ -719,6 +719,46 @@ const MIGRATIONS: &[&str] = &[
|
||||
);
|
||||
CREATE INDEX guild_join_requests_player ON guild_join_requests(uuid);
|
||||
"#,
|
||||
// Rewards beyond XP and titles: what quests, achievements and rank milestones hand out (money, items, permissions,
|
||||
// claim chunks, commands…), the queue of earned bundles, and the deliveries waiting for a game server.
|
||||
r#"
|
||||
CREATE TABLE reward_bundles (
|
||||
source_type TEXT NOT NULL,
|
||||
source_id TEXT NOT NULL,
|
||||
actions TEXT NOT NULL DEFAULT '[]',
|
||||
PRIMARY KEY (source_type, source_id)
|
||||
);
|
||||
CREATE TABLE reward_queue (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
uuid TEXT NOT NULL,
|
||||
source_type TEXT NOT NULL,
|
||||
source_id TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
);
|
||||
CREATE TABLE reward_deliveries (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
uuid TEXT NOT NULL,
|
||||
server_id INTEGER REFERENCES game_servers(id) ON DELETE CASCADE,
|
||||
kind TEXT NOT NULL,
|
||||
payload TEXT NOT NULL DEFAULT '{}',
|
||||
source TEXT NOT NULL DEFAULT '',
|
||||
created_at TEXT NOT NULL,
|
||||
sent_at TEXT,
|
||||
delivered_at TEXT,
|
||||
attempts INTEGER NOT NULL DEFAULT 0,
|
||||
error TEXT
|
||||
);
|
||||
CREATE INDEX reward_deliveries_pending ON reward_deliveries(delivered_at, server_id);
|
||||
CREATE TABLE player_bonuses (
|
||||
uuid TEXT PRIMARY KEY,
|
||||
claim_chunks INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
CREATE TRIGGER reward_on_achievement AFTER INSERT ON user_achievements
|
||||
WHEN EXISTS (SELECT 1 FROM reward_bundles WHERE source_type = 'achievement' AND source_id = NEW.achievement_id) BEGIN
|
||||
INSERT INTO reward_queue (uuid, source_type, source_id, created_at)
|
||||
VALUES (NEW.user_uuid, 'achievement', NEW.achievement_id, strftime('%Y-%m-%dT%H:%M:%SZ', 'now'));
|
||||
END;
|
||||
"#,
|
||||
];
|
||||
|
||||
pub async fn connect(data_dir: &Path) -> Result<SqlitePool> {
|
||||
|
||||
Reference in new issue
Block a user