freecell

package module
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: MIT Imports: 7 Imported by: 0

README

Source: https://github.com/philhanna/freecellstats

freecellstats

Command line tool in Python or Go to display the statistics for Aisleriot Freecell

Documentation

Index

Constants

View Source
const (
	CONFIG_FILE_NAME = ".config/gnome-games/aisleriot"
)

Variables

This section is empty.

Functions

func GetStatisticString

func GetStatisticString(provider ...func() string) (string, error)

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:

  1. A file name (such as the actual configuration file)
  2. 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 Percent

func Percent(wins int, losses int) float64

Finds the value of the winning percentage

func SecondsToTime

func SecondsToTime(seconds int) string

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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