Implement auth, persistence, typed responses, and injectable RNG
Auth: JWT tokens (sb-auth) with argon2 password hashing, login/register endpoints, Bearer token middleware protecting all routes except auth. Authorization checks ensure users can only access their own characters. Persistence: SQLite via rusqlite (sb-db) with write-through on all mutations. Optional via SB_DB_PATH env var; falls back to in-memory. Typed responses: ~20 response DTOs in sb-shared replacing ad-hoc JSON. Combat: Injectable RNG via &mut impl Rng for deterministic tests. Clean Architecture: Combat types and response DTOs in sb-shared; domain services in sb-core; auth in sb-auth; persistence in sb-db.
This commit is contained in:
parent
7a75a523f0
commit
6410e0a86d
39 changed files with 3450 additions and 48 deletions
59
crates/sb-core/src/songs.rs
Normal file
59
crates/sb-core/src/songs.rs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct SongDef {
|
||||
pub id: &'static str,
|
||||
pub name: &'static str,
|
||||
pub description: &'static str,
|
||||
pub combat_effect: &'static str,
|
||||
pub required_level: i32,
|
||||
}
|
||||
|
||||
pub const BARD_SONGS: &[SongDef] = &[
|
||||
SongDef {
|
||||
id: "seekers_ballad",
|
||||
name: "The Seeker's Ballad",
|
||||
description: "Produces light while exploring and increases the party's chance to hit in combat.",
|
||||
combat_effect: "accuracy",
|
||||
required_level: 1,
|
||||
},
|
||||
SongDef {
|
||||
id: "travellers_tune",
|
||||
name: "The Traveller's Tune",
|
||||
description: "Makes the party more dexterous and agile, harder to hit.",
|
||||
combat_effect: "defense",
|
||||
required_level: 1,
|
||||
},
|
||||
SongDef {
|
||||
id: "badhr_kilnfest",
|
||||
name: "Badh'r Kilnfest",
|
||||
description: "An ancient Elven melody that heals wounds during combat and while traveling.",
|
||||
combat_effect: "heal",
|
||||
required_level: 1,
|
||||
},
|
||||
SongDef {
|
||||
id: "waylands_watch",
|
||||
name: "Wayland's Watch",
|
||||
description: "Soothes foes, reducing the damage they deal in combat.",
|
||||
combat_effect: "weaken",
|
||||
required_level: 2,
|
||||
},
|
||||
SongDef {
|
||||
id: "falkentyne_fury",
|
||||
name: "Falkentyne's Fury",
|
||||
description: "Drives the party into a berserker rage, increasing melee damage.",
|
||||
combat_effect: "damage",
|
||||
required_level: 3,
|
||||
},
|
||||
SongDef {
|
||||
id: "lucklaran",
|
||||
name: "Lucklaran",
|
||||
description: "Sets up a partial anti-magic field, increasing protection against spells.",
|
||||
combat_effect: "magic_resist",
|
||||
required_level: 4,
|
||||
},
|
||||
];
|
||||
|
||||
pub fn available_songs(level: i32) -> Vec<&'static SongDef> {
|
||||
BARD_SONGS.iter().filter(|s| s.required_level <= level).collect()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue