scoreboard

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

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LeaderBoard

type LeaderBoard struct {
	Records []*Record `json:"records"`
}

LeaderBoard is a collection of records

func LoadHighScores

func LoadHighScores() *LeaderBoard

LoadHighScores from the scores.json file into a leaderboard

func (LeaderBoard) DeterminePosition

func (l LeaderBoard) DeterminePosition(score int) int

DeterminePosition takes the score and determines what position on the leaderboard it is. Returns -1 if the score does not fall on the leaderboard

func (*LeaderBoard) SaveHighScores

func (l *LeaderBoard) SaveHighScores() bool

SaveHighScores of the leaderboard to a json file

func (*LeaderBoard) SetPosition

func (l *LeaderBoard) SetPosition(index int, name string, score int) bool

SetPosition of the new Record at the given position in the leaderboard

type Record

type Record struct {
	Name  string `json:"name"`
	Score int    `json:"score"`
}

Record contains the name and score

Jump to

Keyboard shortcuts

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