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

t()

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

marked_count()

@type marked_count() :: pos_integer()

Number of marked squares

name()

@type name() :: String.t()

Game name

player_score()

@type player_score() :: {points_sum(), marked_count()}

A tuple of total points and number of marked squares

points_sum()

@type points_sum() :: pos_integer()

Total points

scores()

@type scores() :: %{required(Buzzword.Bingo.Player.t()) => player_score()}

A map assigning a player score to a player

size()

@type size() :: pos_integer()

Game size

t()

@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

haiku_name()

@spec haiku_name() :: name()

Generates a unique, URL-friendly name such as "bold-frog-8249".

mark_square(game, phrase, player)

@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!

new(name, size, buzzwords \\ Buzzword.Cache.get_buzzwords())

@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.