db

package
v0.0.0-...-5dfbc55 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

internal/db/queries_masquerade.go

Index

Constants

This section is empty.

Variables

View Source
var ErrDrawConflict = errors.New("draw conflict: another draw completed first")

Functions

This section is empty.

Types

type Adventure

type Adventure struct {
	ID          int64  `json:"id"`
	CampaignID  int64  `json:"campaign_id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Status      string `json:"status"`
	SortOrder   int    `json:"sort_order"`
	CreatedAt   string `json:"created_at"`
}

Adventure represents a story arc/chapter within a campaign.

type CalendarEvent

type CalendarEvent struct {
	ID          int64  `json:"id"`
	CampaignID  int64  `json:"campaign_id"`
	InGameYear  int    `json:"in_game_year"`
	InGameMonth int    `json:"in_game_month"`
	InGameDay   int    `json:"in_game_day"`
	Title       string `json:"title"`
	Description string `json:"description"`
	EventType   string `json:"event_type"`
	SessionID   *int64 `json:"session_id"`
	CreatedAt   string `json:"created_at"`
}

type Campaign

type Campaign struct {
	ID                     int64  `json:"id"`
	RulesetID              int64  `json:"ruleset_id"`
	Name                   string `json:"name"`
	Description            string `json:"description"`
	Active                 bool   `json:"active"`
	ChronicleNight         int    `json:"chronicle_night"`
	ChronicleNightStartDOW int    `json:"chronicle_night_start_dow"`
	GmNotes                string `json:"gm_notes"`
	SystemPromptOverride   string `json:"system_prompt_override"`
	ContentBoundaries      string `json:"content_boundaries"`
	NarrativeLocale        string `json:"narrative_locale"`
	CreatedAt              string `json:"created_at"`
}

type CampaignCalendarInfo

type CampaignCalendarInfo struct {
	InGameYear     int    `json:"in_game_year"`
	InGameMonth    int    `json:"in_game_month"`
	InGameDay      int    `json:"in_game_day"`
	CalendarConfig string `json:"calendar_config"`
}

CampaignCalendarInfo holds the calendar state for a campaign.

type CampaignStats

type CampaignStats struct {
	Sessions   int
	Characters int
	WorldNotes int
	Maps       int
}

CampaignStats holds row counts for the confirmation message in delete_campaign.

type Character

type Character struct {
	ID              int64  `json:"id"`
	CampaignID      int64  `json:"campaign_id"`
	Name            string `json:"name"`
	DataJSON        string `json:"data_json"`
	PortraitPath    string `json:"portrait_path"` // NOT NULL DEFAULT ” in schema; never nil
	CurrencyBalance int64  `json:"currency_balance"`
	CurrencyLabel   string `json:"currency_label"`
	CreatedAt       string `json:"created_at"`
}

type CombatEncounter

type CombatEncounter struct {
	ID              int64  `json:"id"`
	SessionID       int64  `json:"session_id"`
	Name            string `json:"name"`
	Active          bool   `json:"active"`
	ActiveTurnIndex int    `json:"active_turn_index"`
	RoundNumber     int    `json:"round_number"`
	CreatedAt       string `json:"created_at"`
}

type Combatant

type Combatant struct {
	ID                   int64  `json:"id"`
	EncounterID          int64  `json:"encounter_id"`
	CharacterID          *int64 `json:"character_id"`
	Name                 string `json:"name"`
	Initiative           int    `json:"initiative"`
	HPCurrent            int    `json:"hp_current"`
	HPMax                int    `json:"hp_max"`
	ConditionsJSON       string `json:"conditions_json"`
	IsPlayer             bool   `json:"is_player"`
	DamageSuperficial    int    `json:"damage_superficial"`
	DamageAggravated     int    `json:"damage_aggravated"`
	WillpowerSuperficial int    `json:"willpower_superficial"`
	WillpowerAggravated  int    `json:"willpower_aggravated"`
	Hunger               int    `json:"hunger"`
	SortOrder            int    `json:"sort_order"`
}

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB wraps sql.DB with typed query methods.

func Open

func Open(path string) (*DB, error)

Open opens (or creates) the SQLite database at path and runs pending migrations. Creates parent directories if they do not exist.

func OpenWithOptions

func OpenWithOptions(path string, opts OpenOptions) (*DB, error)

OpenWithOptions opens (or creates) the SQLite database at path, validates it, runs pending migrations, and rejects any remaining foreign-key violations.

func (*DB) AddCombatant

func (d *DB) AddCombatant(encounterID int64, name string, initiative, hpMax int, isPlayer bool, characterID *int64) (int64, error)

func (*DB) AddMapPin

func (d *DB) AddMapPin(mapID int64, x, y float64, label, note, color string) (int64, error)

func (*DB) AdvanceTurn

func (d *DB) AdvanceTurn(encounterID int64) (nextIdx int, roundNumber int, err error)

AdvanceTurn advances active_turn_index, increments round_number on wrap, and decays timed conditions on the newly-active combatant. Returns the new index and the current round number.

func (*DB) Close

func (d *DB) Close() error

Close closes the underlying database connection.

func (*DB) CloseCampaign

func (d *DB) CloseCampaign(id int64) error

CloseCampaign sets active = 0 for the given campaign. Returns an error if the campaign does not exist. Idempotent: closing an already-closed campaign is a no-op.

func (*DB) CreateAdventure

func (d *DB) CreateAdventure(campaignID int64, title, description, status string, sortOrder int) (int64, error)

CreateAdventure inserts a new adventure and returns its ID.

func (*DB) CreateCalendarEvent

func (db *DB) CreateCalendarEvent(campaignID int64, year, month, day int, title, description, eventType string, sessionID *int64) (int64, error)

CreateCalendarEvent inserts a new calendar event.

func (*DB) CreateCampaign

func (d *DB) CreateCampaign(rulesetID int64, name, description string) (int64, error)

func (*DB) CreateCharacter

func (d *DB) CreateCharacter(campaignID int64, name string) (int64, error)

func (*DB) CreateDeck

func (d *DB) CreateDeck(campaignID int64, name, cardsJSON string) (int64, error)

func (*DB) CreateEncounter

func (d *DB) CreateEncounter(sessionID int64, name string) (int64, error)

func (*DB) CreateFaction

func (db *DB) CreateFaction(campaignID int64, name, description, factionType string, influence int, resourcesJSON, color string) (int64, error)

CreateFaction inserts a new faction and returns its ID.

func (*DB) CreateItem

func (d *DB) CreateItem(characterID int64, name, description string, quantity int) (*Item, error)

CreateItem inserts a new item and returns it.

func (*DB) CreateMacro

func (d *DB) CreateMacro(characterID int64, label, actionText, color string) (int64, error)

func (*DB) CreateMap

func (d *DB) CreateMap(campaignID int64, name, imagePath string) (int64, error)

func (*DB) CreateMapZone

func (d *DB) CreateMapZone(mapID int64, name string, x, y, w, h float64) (int64, error)

func (*DB) CreateMessage

func (d *DB) CreateMessage(sessionID int64, role, content string, whisper bool, characterID *int64) (int64, error)

func (*DB) CreateNpcStat

func (d *DB) CreateNpcStat(campaignID int64, name, role, dataJSON string, hpMax int, armorClass *int, initiativeMod int, skills, abilities, loot, notes string) (int64, error)

CreateNpcStat inserts a new NPC stat block and returns its ID.

func (*DB) CreateObjective

func (d *DB) CreateObjective(campaignID int64, title, description string, parentID *int64) (*Objective, error)

CreateObjective inserts a new objective and returns it. parentID may be nil for top-level objectives.

func (*DB) CreateRelationship

func (db *DB) CreateRelationship(campaignID int64, fromName, toName, relType, description string) (int64, error)

CreateRelationship inserts a new relationship and returns its ID.

func (*DB) CreateRulebookChunks

func (d *DB) CreateRulebookChunks(rulesetID int64, chunks []RulebookChunk) error

CreateRulebookChunks inserts multiple chunks for a ruleset in a single transaction.

func (*DB) CreateRuleset

func (d *DB) CreateRuleset(name, schemaJSON, version string) (int64, error)

func (*DB) CreateSecret

func (db *DB) CreateSecret(campaignID int64, title, content, category string) (int64, error)

func (*DB) CreateSession

func (d *DB) CreateSession(campaignID int64, title, date string) (int64, error)

func (*DB) CreateSessionNPC

func (d *DB) CreateSessionNPC(sessionID int64, name, note string) (SessionNPC, error)

func (*DB) CreateWorldNote

func (d *DB) CreateWorldNote(campaignID int64, title, content, category string) (int64, error)

func (*DB) CreateXP

func (d *DB) CreateXP(sessionID int64, note string, amount *int) (*XPEntry, error)

CreateXP inserts an XP log entry and returns it.

func (*DB) DeduplicateObjectives

func (d *DB) DeduplicateObjectives(campaignID int64) (int, error)

DeduplicateObjectives removes duplicate objectives within a campaign, keeping the oldest copy of each title (lowest id). Returns the number deleted.

func (*DB) DeleteAdventure

func (d *DB) DeleteAdventure(id int64) error

DeleteAdventure removes an adventure by ID.

func (*DB) DeleteCalendarEvent

func (db *DB) DeleteCalendarEvent(id int64) error

DeleteCalendarEvent removes a calendar event by ID.

func (*DB) DeleteCampaign

func (d *DB) DeleteCampaign(id int64) error

func (*DB) DeleteCharacter

func (d *DB) DeleteCharacter(id int64) error

DeleteCharacter removes a character. Declared foreign-key actions cascade owned rows and clear optional references atomically with the parent delete.

func (*DB) DeleteDeck

func (d *DB) DeleteDeck(id int64) error

func (*DB) DeleteFaction

func (db *DB) DeleteFaction(id int64) error

DeleteFaction removes a faction by ID.

func (*DB) DeleteItem

func (d *DB) DeleteItem(id int64) error

DeleteItem removes an item by ID.

func (*DB) DeleteMacro

func (d *DB) DeleteMacro(id int64) error

func (*DB) DeleteMapZone

func (d *DB) DeleteMapZone(id int64) error

func (*DB) DeleteNpcStat

func (d *DB) DeleteNpcStat(id int64) error

DeleteNpcStat removes an NPC stat block by ID.

func (*DB) DeleteObjective

func (d *DB) DeleteObjective(id int64) error

DeleteObjective removes an objective. Its descendants are owned rows and cascade through the declared self-referential foreign key.

func (*DB) DeleteRelationship

func (db *DB) DeleteRelationship(id int64) error

DeleteRelationship removes a relationship by ID.

func (*DB) DeleteRulebookChunks

func (d *DB) DeleteRulebookChunks(rulesetID int64) error

DeleteRulebookChunks removes all chunks for a ruleset.

func (*DB) DeleteRulebookChunksBySource

func (d *DB) DeleteRulebookChunksBySource(rulesetID int64, source string) error

DeleteRulebookChunksBySource removes chunks for a specific source book within a ruleset.

func (*DB) DeleteSecret

func (db *DB) DeleteSecret(id int64) error

func (*DB) DeleteSession

func (d *DB) DeleteSession(id int64) error

func (*DB) DeleteSessionNPC

func (d *DB) DeleteSessionNPC(id int64) error

func (*DB) DeleteXP

func (d *DB) DeleteXP(id int64) error

DeleteXP removes an XP log entry.

func (*DB) DrawCard

func (d *DB) DrawCard(deckID int64, expectedDrawIndex, newDrawIndex int, sessionID int64, cardJSON string) error

func (*DB) EndEncounter

func (d *DB) EndEncounter(id int64) error

func (*DB) FindWorldNoteByTitle

func (d *DB) FindWorldNoteByTitle(campaignID int64, title string) (*WorldNote, error)

func (*DB) GetActiveEncounter

func (d *DB) GetActiveEncounter(sessionID int64) (*CombatEncounter, error)

func (*DB) GetAdventure

func (d *DB) GetAdventure(id int64) (*Adventure, error)

GetAdventure returns a single adventure by ID.

func (*DB) GetCalendarEvent

func (db *DB) GetCalendarEvent(id int64) (*CalendarEvent, error)

GetCalendarEvent returns a single calendar event by ID.

func (*DB) GetCampaign

func (d *DB) GetCampaign(id int64) (*Campaign, error)

func (*DB) GetCampaignDate

func (db *DB) GetCampaignDate(campaignID int64) (*CampaignCalendarInfo, error)

GetCampaignDate returns the current in-game date and calendar config for a campaign.

func (*DB) GetCampaignStats

func (d *DB) GetCampaignStats(id int64) (CampaignStats, error)

func (*DB) GetCharacter

func (d *DB) GetCharacter(id int64) (*Character, error)

func (*DB) GetDeck

func (d *DB) GetDeck(id int64) (*Deck, error)

func (*DB) GetFaction

func (db *DB) GetFaction(id int64) (*Faction, error)

GetFaction returns a single faction by ID.

func (*DB) GetItem

func (d *DB) GetItem(id int64) (*Item, error)

GetItem returns a single item by ID.

func (*DB) GetLatestMap

func (d *DB) GetLatestMap(campaignID int64) (*Map, error)

func (*DB) GetMap

func (d *DB) GetMap(id int64) (*Map, error)

func (*DB) GetMapZone

func (d *DB) GetMapZone(id int64) (*MapZone, error)

func (*DB) GetMasqueradeIntegrity

func (db *DB) GetMasqueradeIntegrity(sessionID int64) (int, error)

GetMasqueradeIntegrity returns the Masquerade integrity (0-10) for a session. Default is 10 (full Masquerade intact).

func (*DB) GetNpcStat

func (d *DB) GetNpcStat(id int64) (*NpcStat, error)

GetNpcStat returns a single NPC stat block by ID.

func (*DB) GetObjective

func (d *DB) GetObjective(id int64) (*Objective, error)

GetObjective returns a single objective by ID, or nil if not found.

func (*DB) GetRelationship

func (db *DB) GetRelationship(id int64) (*Relationship, error)

func (*DB) GetRuleset

func (d *DB) GetRuleset(id int64) (*Ruleset, error)

GetRuleset returns a single ruleset by ID.

func (*DB) GetRulesetByName

func (d *DB) GetRulesetByName(name string) (*Ruleset, error)

func (*DB) GetSecret

func (db *DB) GetSecret(id int64) (*Secret, error)

func (*DB) GetSession

func (d *DB) GetSession(id int64) (*Session, error)

func (*DB) GetSessionNPC

func (d *DB) GetSessionNPC(id int64) (*SessionNPC, error)

func (*DB) GetSessionTimeline

func (d *DB) GetSessionTimeline(sessionID int64) ([]TimelineEntry, error)

GetSessionTimeline returns all messages and dice rolls for the given session, merged and sorted by created_at ascending.

func (*DB) GetSetting

func (d *DB) GetSetting(key string) (string, error)

func (*DB) GetTension

func (db *DB) GetTension(sessionID int64) (int, error)

GetTension returns the tension level (1-10) for a session.

func (*DB) GetToken

func (d *DB) GetToken(id int64) (*MapToken, error)

func (*DB) GetWorldNote

func (d *DB) GetWorldNote(id int64) (*WorldNote, error)

func (*DB) ListAIVisibleMessages

func (d *DB) ListAIVisibleMessages(sessionID int64) ([]Message, error)

ListAIVisibleMessages returns the session transcript that may be shared with an AI provider. Whispers are excluded by the database query so callers cannot accidentally include private content while building context.

func (*DB) ListAdventures

func (d *DB) ListAdventures(campaignID int64) ([]Adventure, error)

ListAdventures returns all adventures for a campaign, ordered by sort_order.

func (*DB) ListAllChunks

func (d *DB) ListAllChunks(rulesetID int64) ([]RulebookChunk, error)

ListAllChunks returns all chunks for a ruleset, including those with embeddings.

func (*DB) ListCalendarEvents

func (db *DB) ListCalendarEvents(campaignID int64) ([]CalendarEvent, error)

ListCalendarEvents returns all calendar events for a campaign, ordered by date.

func (*DB) ListCampaigns

func (d *DB) ListCampaigns() ([]Campaign, error)

func (*DB) ListCharacters

func (d *DB) ListCharacters(campaignID int64) ([]Character, error)

func (*DB) ListChunksForEmbedding

func (d *DB) ListChunksForEmbedding(rulesetID int64) ([]RulebookChunk, error)

ListChunksForEmbedding returns chunks that have no embedding yet for a given ruleset.

func (*DB) ListCombatants

func (d *DB) ListCombatants(encounterID int64) ([]Combatant, error)

func (*DB) ListDeckDraws

func (d *DB) ListDeckDraws(sessionID int64) ([]DeckDraw, error)

func (*DB) ListDecks

func (d *DB) ListDecks(campaignID int64) ([]Deck, error)

func (*DB) ListDiceRolls

func (d *DB) ListDiceRolls(sessionID int64) ([]DiceRoll, error)

func (*DB) ListFactions

func (db *DB) ListFactions(campaignID int64) ([]Faction, error)

ListFactions returns all factions for a campaign.

func (*DB) ListItems

func (d *DB) ListItems(characterID int64) ([]Item, error)

ListItems returns all items for a character, ordered by created_at.

func (*DB) ListMacros

func (d *DB) ListMacros(characterID int64) ([]Macro, error)

func (*DB) ListMapPins

func (d *DB) ListMapPins(mapID int64) ([]MapPin, error)

func (*DB) ListMapTokens

func (d *DB) ListMapTokens(mapID int64) ([]MapToken, error)

func (*DB) ListMapZones

func (d *DB) ListMapZones(mapID int64) ([]MapZone, error)

func (*DB) ListMaps

func (d *DB) ListMaps(campaignID int64) ([]Map, error)

func (*DB) ListMessages

func (d *DB) ListMessages(sessionID int64) ([]Message, error)

func (*DB) ListNpcStats

func (d *DB) ListNpcStats(campaignID int64) ([]NpcStat, error)

ListNpcStats returns all NPC stat blocks for a campaign.

func (*DB) ListObjectives

func (d *DB) ListObjectives(campaignID int64) ([]Objective, error)

ListObjectives returns all objectives for a campaign, ordered by created_at DESC.

func (*DB) ListRecentWorldNotes

func (d *DB) ListRecentWorldNotes(campaignID int64, limit int) ([]WorldNote, error)

ListRecentWorldNotes returns the most recent n world notes for a campaign, ordered by created_at DESC.

func (*DB) ListRelationships

func (db *DB) ListRelationships(campaignID int64) ([]Relationship, error)

ListRelationships returns all relationships for a campaign.

func (*DB) ListRulebookSources

func (d *DB) ListRulebookSources(rulesetID int64) ([]RulebookSource, error)

ListRulebookSources returns each distinct source uploaded for a ruleset with its chunk count.

func (*DB) ListRulesets

func (d *DB) ListRulesets() ([]Ruleset, error)

func (*DB) ListSecretsByCampaign

func (db *DB) ListSecretsByCampaign(campaignID int64) ([]Secret, error)

func (*DB) ListSessionNPCs

func (d *DB) ListSessionNPCs(sessionID int64) ([]SessionNPC, error)

func (*DB) ListSessions

func (d *DB) ListSessions(campaignID int64) ([]Session, error)

func (*DB) ListSessionsByAdventure

func (d *DB) ListSessionsByAdventure(adventureID int64) ([]Session, error)

ListSessionsByAdventure returns sessions for a given adventure.

func (*DB) ListUnrevealedZones

func (d *DB) ListUnrevealedZones(mapID int64) ([]MapZone, error)

func (*DB) ListXP

func (d *DB) ListXP(sessionID int64) ([]XPEntry, error)

ListXP returns all XP log entries for a session, newest first.

func (*DB) LogDiceRoll

func (d *DB) LogDiceRoll(sessionID int64, expression string, result int, breakdownJSON string) (int64, error)

func (*DB) MoveToken

func (d *DB) MoveToken(id int64, x, y float64) error

func (*DB) PatchCombatantInitiative

func (d *DB) PatchCombatantInitiative(id int64, initiative int) error

func (*DB) PatchWorldNoteRevealed

func (d *DB) PatchWorldNoteRevealed(id int64, revealed bool) error

func (*DB) PlaceToken

func (d *DB) PlaceToken(mapID int64, entityType string, entityID int64, x, y float64) (int64, error)

func (*DB) RecentMessages

func (d *DB) RecentMessages(sessionID int64, limit int) ([]Message, error)

func (*DB) RemoveToken

func (d *DB) RemoveToken(id int64) error

func (*DB) ReopenCampaign

func (d *DB) ReopenCampaign(id int64) error

ReopenCampaign sets active = 1 for the given campaign. Returns an error if the campaign does not exist. Idempotent: reopening an already-open campaign is a no-op.

func (*DB) ReorderCombatants

func (d *DB) ReorderCombatants(encounterID int64, ids []int64) error

func (*DB) ReorderMacros

func (d *DB) ReorderMacros(characterID int64, ids []int64) error

func (*DB) RevealSecret

func (db *DB) RevealSecret(id int64, sessionID int64) error

func (*DB) RevealZone

func (d *DB) RevealZone(id int64, revealed bool) error

func (*DB) RollOracle

func (d *DB) RollOracle(rulesetID *int64, tableName string, roll int) (string, error)

RollOracle looks up an oracle table result for the given roll value. If rulesetID is provided, it first tries ruleset-specific rows, then falls back to generic (ruleset_id IS NULL). Returns empty string (no error) if no matching row is found.

func (*DB) SQL

func (d *DB) SQL() *sql.DB

SQL returns the underlying *sql.DB for use in tests.

func (*DB) SearchRulebookChunks

func (d *DB) SearchRulebookChunks(rulesetID int64, query string) ([]RulebookChunk, error)

SearchRulebookChunks returns up to 5 chunks matching query in heading or content (LIKE search).

func (*DB) SearchWorldNotes

func (d *DB) SearchWorldNotes(campaignID int64, query, category, tag string, revealed *bool) ([]WorldNote, error)

func (*DB) SetCampaignChronicleNightStartDOW

func (d *DB) SetCampaignChronicleNightStartDOW(id int64, dow int) error

func (*DB) SetSessionAdventure

func (d *DB) SetSessionAdventure(sessionID int64, adventureID *int64) error

SetSessionAdventure updates the adventure_id for a session. Pass nil to remove the session from an adventure.

func (*DB) SetSetting

func (d *DB) SetSetting(key, value string) error

func (*DB) ShuffleDeck

func (d *DB) ShuffleDeck(id int64, shuffledOrderJSON string) error

func (*DB) UpdateAdventure

func (d *DB) UpdateAdventure(id int64, title, description, status string, sortOrder int) error

UpdateAdventure updates an existing adventure's fields.

func (*DB) UpdateCampaignChronicleNight

func (d *DB) UpdateCampaignChronicleNight(id int64, night int) error

func (*DB) UpdateCampaignConfig

func (d *DB) UpdateCampaignConfig(id int64, description, gmNotes, systemPromptOverride, contentBoundaries, narrativeLocale *string) error

UpdateCampaignConfig updates the configurable text fields of a campaign. Only non-nil values are applied. Returns an error if the campaign does not exist.

func (*DB) UpdateCampaignDate

func (db *DB) UpdateCampaignDate(campaignID int64, year, month, day int, calendarConfig *string) error

UpdateCampaignDate sets the in-game date and optional calendar config for a campaign.

func (*DB) UpdateCharacterCurrencyBalance

func (d *DB) UpdateCharacterCurrencyBalance(id int64, balance int64) error

func (*DB) UpdateCharacterCurrencyLabel

func (d *DB) UpdateCharacterCurrencyLabel(id int64, label string) error

func (*DB) UpdateCharacterData

func (d *DB) UpdateCharacterData(id int64, dataJSON string) error

func (*DB) UpdateCharacterPortrait

func (d *DB) UpdateCharacterPortrait(id int64, portraitPath string) error

func (*DB) UpdateCombatant

func (d *DB) UpdateCombatant(id int64, hpCurrent int, conditionsJSON string) error

func (*DB) UpdateCombatantVtMDamage

func (d *DB) UpdateCombatantVtMDamage(id int64, superficialIn, aggravatedIn int, isVampire bool) error

UpdateCombatantVtMDamage applies VtM V5 damage to a combatant. isVampire=true halves superficial damage (round up). Superficial overflow beyond HPMax converts to aggravated.

func (*DB) UpdateFaction

func (db *DB) UpdateFaction(id int64, name, description, factionType string, influence int, resourcesJSON, color string) error

UpdateFaction updates an existing faction's fields.

func (*DB) UpdateItem

func (d *DB) UpdateItem(id int64, name, description string, quantity int, equipped bool) error

UpdateItem patches mutable fields (name, description, quantity, equipped).

func (*DB) UpdateMacro

func (d *DB) UpdateMacro(id int64, label, actionText, color string) error

func (*DB) UpdateMapZone

func (d *DB) UpdateMapZone(id int64, name string, x, y, w, h float64) error

func (*DB) UpdateMasqueradeIntegrity

func (db *DB) UpdateMasqueradeIntegrity(sessionID int64, level int) error

UpdateMasqueradeIntegrity sets the Masquerade integrity for a session, clamping to [0, 10].

func (*DB) UpdateNpcStats

func (d *DB) UpdateNpcStats(id int64, name, role, dataJSON string, hpMax int, armorClass *int, initiativeMod int, skills, abilities, loot, notes string) error

UpdateNpcStats updates an existing NPC stat block's fields.

func (*DB) UpdateObjectiveStatus

func (d *DB) UpdateObjectiveStatus(id int64, status string) error

UpdateObjectiveStatus sets the status for an objective.

func (*DB) UpdateRelationship

func (db *DB) UpdateRelationship(id int64, relType, description string) error

UpdateRelationship changes the type and description of an existing relationship.

func (*DB) UpdateSceneTags

func (d *DB) UpdateSceneTags(sessionID int64, tags string) error

func (*DB) UpdateSecret

func (db *DB) UpdateSecret(id int64, title, content, category string) error

func (*DB) UpdateSessionNPC

func (d *DB) UpdateSessionNPC(id int64, note string) error

func (*DB) UpdateSessionNotes

func (d *DB) UpdateSessionNotes(id int64, notes string) error

func (*DB) UpdateSessionSummary

func (d *DB) UpdateSessionSummary(id int64, summary string) error

func (*DB) UpdateTension

func (db *DB) UpdateTension(sessionID int64, level int) error

UpdateTension sets the tension level for a session, clamping to [1, 10].

func (*DB) UpdateWorldNote

func (d *DB) UpdateWorldNote(id int64, title, content, tagsJSON string) error

func (*DB) UpdateWorldNotePersonality

func (d *DB) UpdateWorldNotePersonality(noteID int64, personalityJSON string) error

func (*DB) UpsertChunkEmbedding

func (d *DB) UpsertChunkEmbedding(id int64, emb []float32) error

UpsertChunkEmbedding stores the embedding for a chunk by ID.

type Deck

type Deck struct {
	ID                int64  `json:"id"`
	CampaignID        int64  `json:"campaign_id"`
	Name              string `json:"name"`
	CardsJSON         string `json:"cards_json"`
	ShuffledOrderJSON string `json:"shuffled_order_json"`
	DrawIndex         int    `json:"draw_index"`
	CreatedAt         string `json:"created_at"`
}

type DeckDraw

type DeckDraw struct {
	ID        int64  `json:"id"`
	SessionID int64  `json:"session_id"`
	DeckID    int64  `json:"deck_id"`
	CardJSON  string `json:"card_json"`
	DrawnAt   string `json:"drawn_at"`
}

type DiceRoll

type DiceRoll struct {
	ID            int64  `json:"id"`
	SessionID     int64  `json:"session_id"`
	Expression    string `json:"expression"`
	Result        int    `json:"result"`
	BreakdownJSON string `json:"breakdown_json"`
	CreatedAt     string `json:"created_at"`
}

type Faction

type Faction struct {
	ID            int64     `json:"id"`
	CampaignID    int64     `json:"campaign_id"`
	Name          string    `json:"name"`
	Description   string    `json:"description"`
	FactionType   string    `json:"faction_type"`
	Influence     int       `json:"influence"`
	ResourcesJSON string    `json:"resources_json"`
	Color         string    `json:"color"`
	CreatedAt     time.Time `json:"created_at"`
}

Faction represents a named faction within a campaign.

type Item

type Item struct {
	ID          int64  `json:"id"`
	CharacterID int64  `json:"character_id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Quantity    int    `json:"quantity"`
	Equipped    bool   `json:"equipped"`
	CreatedAt   string `json:"created_at"`
}

Item represents an inventory item owned by a character.

type Macro

type Macro struct {
	ID          int64  `json:"id"`
	CharacterID int64  `json:"character_id"`
	Label       string `json:"label"`
	ActionText  string `json:"action_text"`
	Color       string `json:"color"`
	SortOrder   int    `json:"sort_order"`
	CreatedAt   string `json:"created_at"`
}

type Map

type Map struct {
	ID         int64  `json:"id"`
	CampaignID int64  `json:"campaign_id"`
	Name       string `json:"name"`
	ImagePath  string `json:"image_path"`
	CreatedAt  string `json:"created_at"`
}

type MapPin

type MapPin struct {
	ID        int64   `json:"id"`
	MapID     int64   `json:"map_id"`
	X         float64 `json:"x"`
	Y         float64 `json:"y"`
	Label     string  `json:"label"`
	Note      string  `json:"note"`
	Color     string  `json:"color"`
	CreatedAt string  `json:"created_at"`
}

type MapToken

type MapToken struct {
	ID         int64   `json:"id"`
	MapID      int64   `json:"map_id"`
	EntityType string  `json:"entity_type"`
	EntityID   int64   `json:"entity_id"`
	Name       string  `json:"name"`
	X          float64 `json:"x"`
	Y          float64 `json:"y"`
}

type MapZone

type MapZone struct {
	ID         int64   `json:"id"`
	MapID      int64   `json:"map_id"`
	Name       string  `json:"name"`
	X          float64 `json:"x"`
	Y          float64 `json:"y"`
	Width      float64 `json:"width"`
	Height     float64 `json:"height"`
	IsRevealed bool    `json:"is_revealed"`
}

type Message

type Message struct {
	ID          int64  `json:"id"`
	SessionID   int64  `json:"session_id"`
	Role        string `json:"role"` // "user" or "assistant"
	Content     string `json:"content"`
	Whisper     bool   `json:"whisper"`
	CharacterID *int64 `json:"character_id"`
	CreatedAt   string `json:"created_at"`
}

type NpcStat

type NpcStat struct {
	ID            int64  `json:"id"`
	CampaignID    int64  `json:"campaign_id"`
	Name          string `json:"name"`
	Role          string `json:"role"`
	DataJSON      string `json:"data_json"`
	HPMax         int    `json:"hp_max"`
	ArmorClass    *int   `json:"armor_class"`
	InitiativeMod int    `json:"initiative_mod"`
	Skills        string `json:"skills"`
	Abilities     string `json:"abilities"`
	Loot          string `json:"loot"`
	Notes         string `json:"notes"`
	CreatedAt     string `json:"created_at"`
}

NpcStat represents a reusable NPC combat stat block within a campaign.

type Objective

type Objective struct {
	ID          int64  `json:"id"`
	CampaignID  int64  `json:"campaign_id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Status      string `json:"status"`
	ParentID    *int64 `json:"parent_id"`
	CreatedAt   string `json:"created_at"`
}

Objective represents a campaign goal or quest being tracked.

type OpenOptions

type OpenOptions struct {
	BackupBeforeRepair bool
}

OpenOptions controls database startup behavior. A file-backed repair is refused when BackupBeforeRepair is false; the option exists so callers can make that policy explicit without permitting an unprotected repair.

type Relationship

type Relationship struct {
	ID               int64     `json:"id"`
	CampaignID       int64     `json:"campaign_id"`
	FromName         string    `json:"from_name"`
	ToName           string    `json:"to_name"`
	RelationshipType string    `json:"relationship_type"`
	Description      string    `json:"description"`
	CreatedAt        time.Time `json:"created_at"`
}

Relationship represents a named relationship between two characters/NPCs in a campaign.

type RulebookChunk

type RulebookChunk struct {
	ID        int64     `json:"id"`
	RulesetID int64     `json:"ruleset_id"`
	Source    string    `json:"source"`
	Heading   string    `json:"heading"`
	Content   string    `json:"content"`
	Embedding []byte    `json:"-"`
	CreatedAt time.Time `json:"created_at"`
}

RulebookChunk represents a parsed chunk of rulebook text for a given ruleset.

type RulebookSource

type RulebookSource struct {
	Source string `json:"source"`
	Chunks int    `json:"chunks"`
}

RulebookSource summarises one uploaded book for a ruleset.

type Ruleset

type Ruleset struct {
	ID         int64  `json:"id"`
	Name       string `json:"name"`
	SchemaJSON string `json:"schema_json"`
	Version    string `json:"version"`
	GMContext  string `json:"gm_context"`
}

type Secret

type Secret struct {
	ID                  int64     `json:"id"`
	CampaignID          int64     `json:"campaign_id"`
	Title               string    `json:"title"`
	Content             string    `json:"content"`
	Category            string    `json:"category"`
	Revealed            bool      `json:"revealed"`
	RevealedAtSessionID *int64    `json:"revealed_at_session_id,omitempty"`
	CreatedAt           time.Time `json:"created_at"`
}

type Session

type Session struct {
	ID          int64  `json:"id"`
	CampaignID  int64  `json:"campaign_id"`
	Title       string `json:"title"`
	Date        string `json:"date"`
	Summary     string `json:"summary"`
	Notes       string `json:"notes"`
	SceneTags   string `json:"scene_tags"`
	AdventureID *int64 `json:"adventure_id"`
	CreatedAt   string `json:"created_at"`
}

type SessionNPC

type SessionNPC struct {
	ID        int64  `json:"id"`
	SessionID int64  `json:"session_id"`
	Name      string `json:"name"`
	Note      string `json:"note"`
	CreatedAt string `json:"created_at"`
}

SessionNPC represents an NPC tracked within a session.

type TimelineEntry

type TimelineEntry struct {
	Type      string          `json:"type"`
	Timestamp string          `json:"timestamp"`
	Data      json.RawMessage `json:"data"`
}

TimelineEntry is a single chronological item in the session feed. Type is one of "message" or "dice_roll". Data is the raw JSON of the underlying record.

type WorldNote

type WorldNote struct {
	ID              int64  `json:"id"`
	CampaignID      int64  `json:"campaign_id"`
	Title           string `json:"title"`
	Content         string `json:"content"`
	Category        string `json:"category"`
	TagsJSON        string `json:"tags_json"`
	PersonalityJSON string `json:"personality_json"`
	IsRevealed      bool   `json:"is_revealed"`
	CreatedAt       string `json:"created_at"`
}

type XPEntry

type XPEntry struct {
	ID        int64  `json:"id"`
	SessionID int64  `json:"session_id"`
	Note      string `json:"note"`
	Amount    *int   `json:"amount"`
	CreatedAt string `json:"created_at"`
}

XPEntry records a story milestone or XP award for a session. Amount is optional — nil for rulesets without numeric XP.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL