View Source Buzzword.Bingo.Game (Buzzword Bingo Game v0.1.43)
A game struct and functions for the Multi-Player Buzzword Bingo game.
The game struct contains the fields name
, size
, squares
, scores
and
winner
representing the properties of a game in the Multi-Player Buzzword
Bingo game.
Based on the course Multi-Player Bingo by Mike and Nicole Clark.
Summary
Types
Number of marked squares
Game name
A tuple of total points and number of marked squares
Total points
A map assigning a player score to a player
Game size
A game struct for the Multi-Player Buzzword Bingo game
Functions
Generates a unique, URL-friendly name such as "bold-frog-8249".
Marks the square having the given phrase
with the given player
,
updates the scores, and checks for a bingo!
Creates a game struct with size
x size
random buzzwords from buzzwords
.
The default value for buzzwords
is provided by function
Buzzword.Cache.get_buzzwords/0
.
Types
@type marked_count() :: pos_integer()
Number of marked squares
@type name() :: String.t()
Game name
@type player_score() :: {points_sum(), marked_count()}
A tuple of total points and number of marked squares
@type points_sum() :: pos_integer()
Total points
@type scores() :: %{required(Buzzword.Bingo.Player.t()) => player_score()}
A map assigning a player score to a player
@type size() :: pos_integer()
Game size
@type t() :: %Buzzword.Bingo.Game{ name: name(), scores: scores(), size: size(), squares: [Buzzword.Bingo.Square.t()], winner: Buzzword.Bingo.Player.t() | nil }
A game struct for the Multi-Player Buzzword Bingo game
Functions
@spec haiku_name() :: name()
Generates a unique, URL-friendly name such as "bold-frog-8249".
@spec mark_square(t(), Buzzword.Bingo.Square.phrase(), Buzzword.Bingo.Player.t()) :: t()
Marks the square having the given phrase
with the given player
,
updates the scores, and checks for a bingo!
@spec new(name(), size(), Buzzword.Cache.buzzwords() | [Buzzword.Cache.buzzword()]) :: t() | {:error, atom()}
Creates a game struct with size
x size
random buzzwords from buzzwords
.
The default value for buzzwords
is provided by function
Buzzword.Cache.get_buzzwords/0
.