hedwig_trivia v0.1.0 HedwigTrivia.Logic View Source

A home for the business logic of fetching/answering questions.

Link to this section Summary

Functions

Build up the full response from the category, value, and question

Given a guess, return a string representing a response from the bot[]

Determine if the user-supplied guess matches the answer.

Given a guess, return a string representing a response from the bot[]

Fetch a new question if need be, but return a state with the correct game information.

Mark the question as answered and return the game state so the answer can be revelead

Link to this section Types

Link to this type

force_new()

View Source
force_new() :: boolean()

Link to this section Functions

Link to this function

compose_full_question(map)

View Source
compose_full_question(HedwigTrivia.GameState.t()) :: String.t()

Build up the full response from the category, value, and question

Given a guess, return a string representing a response from the bot[]

Link to this function

guess(state, guess)

View Source
guess(HedwigTrivia.GameState.t(), String.t()) ::
  {:ok | :error | :already_answered, HedwigTrivia.GameState.t()}

Determine if the user-supplied guess matches the answer.

Link to this function

incorrect(guess)

View Source
incorrect(String.t()) :: String.t()

Given a guess, return a string representing a response from the bot[]

Link to this function

question(state, bool)

View Source
question(HedwigTrivia.GameState.t(), force_new()) ::
  {:ok | :error | :not_answered, HedwigTrivia.GameState.t()}

Fetch a new question if need be, but return a state with the correct game information.

Mark the question as answered and return the game state so the answer can be revelead