CustomerState

model.entities.customers.CustomerState
trait CustomerState[T <: CustomerState[T]]

Defines the contract for an entity that possesses a customer state.

This trait tracks whether a customer is Playing a game or Idle, providing methods to change this state and query their current activity.

Type parameters

T

The concrete type of the entity that extends this trait, enabling F-bounded polymorphism for immutable updates.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Customer

Members list

Value members

Abstract methods

def withCustomerState(newState: CustState): T

Returns a new instance of the entity with the updated customer state. This method must be implemented by concrete classes to ensure immutability.

Returns a new instance of the entity with the updated customer state. This method must be implemented by concrete classes to ensure immutability.

Value parameters

newState

The new CustState for the customer.

Attributes

Returns

A new instance of the entity with the updated customer state.

Concrete methods

def changeState(newState: CustState): T

Changes the customer's state to a new specified state. This is a convenience method that delegates to withCustomerState.

Changes the customer's state to a new specified state. This is a convenience method that delegates to withCustomerState.

Value parameters

newState

The new CustState to apply.

Attributes

Returns

A new instance of the entity with the updated customer state.

def getGameOrElse: Option[Game]

Returns an Option containing the Game object if the customer is currently Playing, otherwise returns Option.empty.

Returns an Option containing the Game object if the customer is currently Playing, otherwise returns Option.empty.

Attributes

Returns

An Option[Game] representing the game the customer is playing, if any.

def isPlaying: Boolean

Checks if the customer is currently in the Playing state.

Checks if the customer is currently in the Playing state.

Attributes

Returns

true if the customer is playing a game, false otherwise.

Abstract fields

The current state of the customer (Playing or Idle).

The current state of the customer (Playing or Idle).

Attributes