persistence

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	ID        string `gorm:"primaryKey"`
	Name      string
	Image     string
	Wins      int
	Kills     int
	Deaths    int
	UpdatedAt time.Time
}

type Database

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

func NewDatabase

func NewDatabase(dbPath string) (*Database, error)

func (*Database) Close

func (d *Database) Close() error

func (*Database) CreateMatch

func (d *Database) CreateMatch(match *Match) error

func (*Database) GetEvents

func (d *Database) GetEvents(matchID string, startTick, endTick int64) ([]EventLog, error)

func (*Database) GetHighlights

func (d *Database) GetHighlights(matchID string) ([]EventLog, error)

func (*Database) IncrementBotWin

func (d *Database) IncrementBotWin(botID string) error

func (*Database) ListMatches

func (d *Database) ListMatches() ([]Match, error)

func (*Database) RecordBotStats

func (d *Database) RecordBotStats(botID string, kills, deaths int) error

func (*Database) SaveEvent

func (d *Database) SaveEvent(event *EventLog) error

func (*Database) SaveEvents

func (d *Database) SaveEvents(events []EventLog) error

func (*Database) UpdateMatch

func (d *Database) UpdateMatch(match *Match) error

func (*Database) UpsertBot

func (d *Database) UpsertBot(bot *Bot) error

type EventLog

type EventLog struct {
	gorm.Model
	MatchID string `gorm:"index"`
	Tick    int64
	Type    string
	Payload string // JSON
}

type Match

type Match struct {
	ID          string `gorm:"primaryKey"`
	Status      string
	WinnerID    string
	ArenaWidth  float32
	ArenaHeight float32
	CreatedAt   time.Time
	FinishedAt  *time.Time
	Events      []EventLog `gorm:"foreignKey:MatchID"`
}

Jump to

Keyboard shortcuts

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