game

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChooseText

func ChooseText() (string, error)

ChooseText randomly chooses a text from the dataset

Types

type State

type State struct {
	// CurrWord is an index to State.Words
	CurrWord int
	// Words contains the text split by spaces
	Words []string
	// StartTime is a timestamp of the first keystroke
	StartTime time.Time
	// contains filtered or unexported fields
}

State describes the state of a game

func NewState

func NewState(text string) *State

NewState initializes State

func (*State) End

func (s *State) End()

End ends the mechanism

func (*State) IncError

func (s *State) IncError()

IncError increments the error count

func (*State) NextWord

func (s *State) NextWord()

NextWord saves stats of the current word and increments the counter

func (*State) PaintDiff

func (s *State) PaintDiff(differ string) (ansiWord string)

PaintDiff returns an ANSII-painted string displaying the difference

func (*State) Start

func (s *State) Start()

Start starts the mechanism

func (State) Wpm

func (s State) Wpm() float64

Wpm is the words per minute

Jump to

Keyboard shortcuts

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