gcore

package
v0.0.0-...-33f903c Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DATAPATH = "data/"
View Source
const DEF_DBNAME = "data/gambot.db" // Default database filename
View Source
const DEF_PORT = 9001 // Default server port
View Source
const MAC_FILE = "static/mac.json" // Macro definition file
View Source
const NMAXLEN = 30 // Player name max length

Variables

View Source
var Abuc = []byte("abuc") // admin bucket
View Source
var Gbuc = []byte("gbuc") // game bucket
View Source
var Mac map[string]int // Global macro object
View Source
var Pbuc = []byte("pbuc") // player bucket
View Source
var Tbuc = []byte("tbuc") // tournament bucket

Functions

func Cherr

func Cherr(e error)

Check and log errors

func Rdb

func Rdb(db *bolt.DB, k int, cbuc []byte) (v []byte, e error)

Return JSON encoded byte slice from DB

func Setmac

func Setmac() map[string]int

Loads defaults from config file

func Wradmin

func Wradmin(a Admin, db *bolt.DB)

Stores admin object to database

func Wrdb

func Wrdb(db *bolt.DB, k int, v []byte, cbuc []byte) (e error)

Write byte slice to DB

Types

type Admin

type Admin struct {
	Skey   string
	Pass   []byte
	Pwin   int
	Pdraw  int
	Ploss  int
	Status int
	PPstat bool
}

func Getadmin

func Getadmin(db *bolt.DB) (Admin, error)

Retrieves admin object from database

type Apicall

type Apicall struct {
	Action      string
	Algo        string
	Pass        string
	Opass       string
	Skey        string
	Set         string
	Pwin        string
	Pdraw       string
	Ploss       string
	PPage       string
	N           string
	T           string
	I           string
	Tpt         string
	ID          string
	Game        string
	Name        string
	Fname       string
	Lname       string
	Gender      string
	Dbirth      string
	Email       string
	Postal      string
	Zip         string
	Phone       string
	Club        string
	LichessUser string
}

type Game

type Game struct {
	ID     string
	W      int
	B      int
	Winner int
	Compl  bool
	Start  time.Time
	End    time.Time
	Status int
}

type Hfn

type Hfn func(http.ResponseWriter, *http.Request, *bolt.DB)

Handler function definition

type Pdata

type Pdata struct {
	Name        string
	FName       string
	LName       string
	Dbirth      time.Time
	Email       string
	LichessUser string
	PostalAddr  string
	Zip         string
	Gender      string
	Phone       string
	Club        string
}

type Player

type Player struct {
	ID     int
	Uname  string
	ELO    float64
	Pass   []byte
	Pi     Pdata
	TN     Pstat
	AT     Pstat
	Active bool
	Pause  bool
	Status int
}

func Getallplayers

func Getallplayers(db *bolt.DB) []Player

Returns slice containing all player objects in db

type Pstat

type Pstat struct {
	Points  int
	Wpoints int
	Bpoints int
	Ngames  int
	APPG    float32
	WAPPG   float32
	BAPPG   float32
	Stat    []int
}

type Tournament

type Tournament struct {
	ID      int
	Algo    int
	Round   int
	P       []Player
	G       []Game
	Seeding bool
	Start   time.Time
	End     time.Time
	Status  int
}

func Getalltournaments

func Getalltournaments(db *bolt.DB) []Tournament

Returns slice containing all tournament objects in db

Jump to

Keyboard shortcuts

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