Documentation
¶
Index ¶
Constants ¶
const ( English = Language("English") Russian = Language("Russian") French = Language("French") )
Languages supported
const DefaultDeckName = "flashcardsDeck.db"
DefaultDeckName is the default deck db
Variables ¶
This section is empty.
Functions ¶
func ShuffleCards ¶
func ShuffleCards(cards []*Card)
ShuffleCards reorders items in the slice of cards using a PRNG
Types ¶
type Card ¶
Card is a single card in the deck
func (*Card) AttemptAnswer ¶
AttemptAnswer accepts an answer from a user and checks whether it is correct
func (*Card) PrintQuestion ¶
PrintQuestion is a pretty formatter for command line version of rendering the card
type Deck ¶
type Deck struct { ID ID `json:"-"` Last *Card `json:"-"` Current *Card `json:"-"` Know Language `json:"know,omitempty"` Learning Language `json:"learning,omitempty"` Cards []*Card `json:"cards,omitempty"` // contains filtered or unexported fields }
Deck is a parennt for a group of cards
func NewDeckWithSize ¶
NewDeckWithSize extracts a subset of NewDeck
func NewStandardDeck ¶
func NewStandardDeck() *Deck
NewStandardDeck returns a deck with sensible defaults
func (*Deck) GetIncorrectGuesses ¶
GetIncorrectGuesses gets a set of incorrect answers
type Phonetic ¶
type Phonetic struct { ID ID `json:"-"` Language `json:"language,omitempty"` Value string `json:"value,omitempty"` }
Phonetic is a helper on how to pronounce a phrase
func NewPhonetic ¶
NewPhonetic craetes a new Phonetic
type Phrase ¶
type Phrase struct { ID ID `json:"-"` Translations []*Translation `json:"translations,omitempty"` }
Phrase is a phrase from a languages that contains some translations in different languages
func (*Phrase) Language ¶
func (p *Phrase) Language(l Language) *Translation
Language gets the translation for the phrase in said language
func (*Phrase) WithTranslation ¶
func (p *Phrase) WithTranslation(t *Translation) *Phrase
WithTranslation adds a translation for a phrase
type Stats ¶
type Stats struct { ID ID `json:"-"` Attempts int `json:"attempts"` Correct int `json:"correct"` Percentage float64 `json:"percentage"` Weighting float64 `json:"weighting"` }
Stats contains info on how player is learning a specific phrase
func (*Stats) CorrectAttempt ¶
func (s *Stats) CorrectAttempt()
CorrectAttempt records a correct attempt
func (*Stats) WrongAttempt ¶
func (s *Stats) WrongAttempt()
WrongAttempt records an incorrect attempt
type Translation ¶
type Translation struct { ID ID `json:"-"` Language `json:"language,omitempty"` Value string `json:"value,omitempty"` Phonetics []*Phonetic `json:"phonetics,omitempty"` Stats *Stats `json:"stats,omitempty"` }
Translation represents how a specific phrase is representated in a given language
func NewTranslation ¶
func NewTranslation(l Language, value string) *Translation
NewTranslation generates a new translation
func (*Translation) GetPhonetic ¶
func (t *Translation) GetPhonetic(l Language) *Phonetic
GetPhonetic gets the phonetic for a given lanuage
func (*Translation) WithPhonetic ¶
func (t *Translation) WithPhonetic(p *Phonetic) *Translation
WithPhonetic adds a phonetic for a translation