storage

package
v0.0.0-...-53bf7d6 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDb

func InitDb() error

InitDb sets up a new DB

Types

type Board

type Board struct {
	gorm.Model

	Name    string
	Status  int
	UUID    string
	Created time.Time
	Started time.Time
	Ended   time.Time
	Events  []*Event
}

Board is the board model

type Db

type Db struct {
	Conn *gorm.DB
}

Db is the SQLite3 db handler ype

var Storage *Db

Storage is the db connection

func (*Db) Get

func (db *Db) Get() *gorm.DB

Get gets a db handle

type Event

type Event struct {
	gorm.Model

	BoardID uint `json:"board_id"`

	Date time.Time `json:"date_created"`

	SrcEntity   int    `json:"src_entity"`
	SrcEntityID string `json:"-"` // don't leak id in api
	SrcPos      int    `json:"src_pos"`

	DstEntity   int    `json:"dst_entity"`
	DstEntityID string `json:"-"` // don't leak id in api
	DstPos      int    `json:"dst_pos"`

	Action int    `json:"action"`
	Msg    string `json:"msg"`
}

Event is a game event

type Player

type Player struct {
	gorm.Model

	Name   string
	UUID   string
	Scores []PlayerGameScore
}

Player is the player model

type PlayerGameScore

type PlayerGameScore struct {
	gorm.Model

	PlayerID      uint   `json:"-"`
	BoardID       string `json:"board_id"`
	Position      int    `json:"position"`
	Score         int    `json:"score"`
	DamageTaken   int    `json:"damage_taken"`
	DamageDealt   int    `json:"damage_dealt"`
	CreepKilled   int    `json:"killed_creep"`
	PlayersKilled int    `json:"killed_players"`
}

PlayerGameScore records the score for a player per game played

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳