Documentation
¶
Index ¶
- Constants
- func GetStatisticString(provider ...func() string) (string, error)
- func Percent(wins int, losses int) float64
- func SecondsToTime(seconds int) string
- type Statistics
- func (stat *Statistics) CurrentPct() int
- func (stat *Statistics) LossesToNextLower() int
- func (stat *Statistics) NextHigher() int
- func (stat *Statistics) NextLower() int
- func (stat *Statistics) String() string
- func (stat *Statistics) StringLines() []string
- func (stat *Statistics) WinsToNextHigher() int
Constants ¶
const (
CONFIG_FILE_NAME = ".config/gnome-games/aisleriot"
)
Variables ¶
This section is empty.
Functions ¶
func GetStatisticString ¶
Loads the configuration from the default input file. This method can be replaced by a mock object in unit tests
A configuration file provider is a function returning either:
- A file name (such as the actual configuration file)
- A string containing the contents of a configuration file
The go-ini package will accept either one.
The default configuration file provider gets the name of the actual AisleRiot configuration file in the home directory.
func SecondsToTime ¶
Converts a number of seconds into a mm:ss string
Types ¶
type Statistics ¶
type Statistics struct {
// contains filtered or unexported fields
}
Captures the wins, losses, and percentages
func NewStatistics ¶
func NewStatistics(wins, total, best, worst int) *Statistics
Creates a new Statistics object from the basic integer values that AisleRiot keeps:
- wins
- total
- best
- worst
It then calculates the other two values:
- losses
- percentage of wins
func NewStatisticsFromString ¶
func NewStatisticsFromString(statString string) *Statistics
Creates a new Statistics object from the string representation that is in the configuration file, e.g., "99;150;144;208;"
func (*Statistics) CurrentPct ¶
func (stat *Statistics) CurrentPct() int
Returns the current win percentage (rounded to an int)
func (*Statistics) LossesToNextLower ¶
func (stat *Statistics) LossesToNextLower() int
Returns the number of losses needed to lower the winning percentage one point
func (*Statistics) NextHigher ¶
func (stat *Statistics) NextHigher() int
Returns the next higher percentage (rounded to an int)
func (*Statistics) NextLower ¶
func (stat *Statistics) NextLower() int
Returns the next lower percentage (rounded to an int)
func (*Statistics) String ¶
func (stat *Statistics) String() string
Returns a string representation of the structure
func (*Statistics) StringLines ¶
func (stat *Statistics) StringLines() []string
Returns an array of strings representing this structure
func (*Statistics) WinsToNextHigher ¶
func (stat *Statistics) WinsToNextHigher() int
Returns the number of wins needed to raise the winning percentage one point