game

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2018 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcTeamsBase

func CalcTeamsBase(database *sql.DB) (z float64, err error)

CalcTeamsBase calculate abstract amout of teams

func LastAccept

func LastAccept(teamID int, flags []db.Flag) int64

LastAccept returns last time of accepted flag for team

Types

type ByScoreAndLastAccept

type ByScoreAndLastAccept []TeamScoreInfo

ByScoreAndLastAccept sort by score and last accept

func (ByScoreAndLastAccept) Len

func (tr ByScoreAndLastAccept) Len() int

func (ByScoreAndLastAccept) Less

func (tr ByScoreAndLastAccept) Less(i, j int) bool

func (ByScoreAndLastAccept) Swap

func (tr ByScoreAndLastAccept) Swap(i, j int)

type CategoryInfo

type CategoryInfo struct {
	Name      string
	TasksInfo []TaskInfo
}

CategoryInfo provide information about categories and tasks

type Game

type Game struct {
	Start           time.Time
	End             time.Time
	OpenTimeout     time.Duration // after solve task
	AutoOpen        bool
	AutoOpenTimeout time.Duration // if task does not solved

	TaskPrice struct {
		TeamsBase              float64
		P500, P400, P300, P200 float64
	}
	// contains filtered or unexported fields
}

Game struct

func NewGame

func NewGame(database *sql.DB, start, end time.Time,
	teamBase float64) (g Game, err error)

NewGame create new game

func (Game) OpenNextTask

func (g Game) OpenNextTask(t db.Task) (err error)

OpenNextTask open next task by level

func (Game) RecalcScoreboard

func (g Game) RecalcScoreboard() (err error)

RecalcScoreboard update scoreboard

func (Game) Run

func (g Game) Run() (err error)

Run open first level tasks and start auto open routine

func (Game) Scoreboard

func (g Game) Scoreboard() (scores []TeamScoreInfo, err error)

Scoreboard returns sorted scoreboard

func (*Game) SetTaskPrice

func (g *Game) SetTaskPrice(p500, p400, p300, p200 int)

SetTaskPrice convert and set price of tasks

func (*Game) SetTeamsBase

func (g *Game) SetTeamsBase(teams int)

SetTeamsBase force set amount of teams for calc price task

func (Game) Solve

func (g Game) Solve(teamID, taskID int, flag string) (solved bool, err error)

Solve check flag for task and recalc scoreboard if flag correct

func (Game) Tasks

func (g Game) Tasks() (cats []CategoryInfo, err error)

Tasks returns categories with tasks

func (*Game) TeamsBaseUpdater

func (g *Game) TeamsBaseUpdater(database *sql.DB, updateTimeout time.Duration)

TeamsBaseUpdater auto update TeamsBase

type TaskInfo

type TaskInfo struct {
	ID          int
	Name        string
	Desc        string
	NameEn      string
	DescEn      string
	Tags        string
	Author      string
	Price       int
	Opened      bool
	Level       int
	ForceClosed bool
	SolvedBy    []int
	OpenedTime  time.Time
}

TaskInfo provide information about task

type TeamScoreInfo

type TeamScoreInfo struct {
	ID         int
	Name       string
	Desc       string
	Score      int
	LastAccept int64
}

TeamScoreInfo provide information about team score

Jump to

Keyboard shortcuts

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