Controller

controller.Controller
trait Controller extends Observable

The controller contains business logic. It holds a status which is updated through its methods executed by the observers. Upon a state update, all observers are notified. Observers can then read the status and reflect the changes. Methods which change

Attributes

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

Members list

Value members

Abstract methods

def attack(card: Card): Unit

Should be called when an attacking player attacks with the specified card. It is not checked whether Controller.canAttack returns true. The exact update depends on the implementation, normally base.command.AttackCommand. The method assumes to be called in a valid context and will update all observers

Should be called when an attacking player attacks with the specified card. It is not checked whether Controller.canAttack returns true. The exact update depends on the implementation, normally base.command.AttackCommand. The method assumes to be called in a valid context and will update all observers

Value parameters

card

The card to attack with.

Attributes

def byTurn(turn: Turn): Option[Player]

Returns the player who has the specified turn.

Returns the player who has the specified turn.

Attributes

Returns

the player who has the specified turn. If multiple players have the same turn, the first one is returned.

def canAttack(card: Card): Boolean

Checks whether a card can be used to attack with.

Checks whether a card can be used to attack with.

Value parameters

card

the card to attack with

Attributes

Returns

true when either Status.used, Status.undefended or Status.defended contain the specified card. Otherwise, false.

def canDefend(used: Card, undefended: Card): Boolean

Checks whether a card can be used to defend another.

Checks whether a card can be used to defend another.

Value parameters

undefended

the undefended card to defend

used

the card of the defending player

Attributes

Returns

true when Card.beats, called on used with undefended as the argument, returns true or when used is a trump card and undefended is not. Otherwise, false.

def current: Option[Player]

Returns the player who has the current turn.

Returns the player who has the current turn.

Attributes

Returns

the player who has the current turn. The current turn is determined by model.status.Status.turn.

def defend(used: Card, undefended: Card): Unit

Should be called when a defending player attacks an undefended card with one of their own. It is not checked whether controller.Controller.canDefend returns true. The exact update depends on the implementation, normally controller.base.command.DefendCommand. The method assumes to be called in a valid context and will update all observers

Should be called when a defending player attacks an undefended card with one of their own. It is not checked whether controller.Controller.canDefend returns true. The exact update depends on the implementation, normally controller.base.command.DefendCommand. The method assumes to be called in a valid context and will update all observers

Value parameters

undefended

The undefended card to defend

used

The card of the defending player

Attributes

def deny(): Unit

Should be called when an attacking player denies their attack. The exact update depends on the implementation, normally base.command.DenyCommand. The method assumes to be called in a valid context and will update all observers

Should be called when an attacking player denies their attack. The exact update depends on the implementation, normally base.command.DenyCommand. The method assumes to be called in a valid context and will update all observers

Attributes

def initialize(amount: Int, names: List[String]): Unit

Initializes the status with the specified card amount and player names. The first attacking player is chosen randomly. The exact update depends on the implementation, normally base.command.InitializeCommand. The method assumes to be called in a valid context and will update all observers

Initializes the status with the specified card amount and player names. The first attacking player is chosen randomly. The exact update depends on the implementation, normally base.command.InitializeCommand. The method assumes to be called in a valid context and will update all observers

Value parameters

amount

the card amount

names

the player names

Attributes

def initialize(amount: Int, names: List[String], attacking: String): Unit

Initializes the status with the specified card amount, player names and first attacking player. The exact update depends on the implementation, normally base.command.InitializeCommand. The method assumes to be called in a valid context and will update all observers

Initializes the status with the specified card amount, player names and first attacking player. The exact update depends on the implementation, normally base.command.InitializeCommand. The method assumes to be called in a valid context and will update all observers

Value parameters

amount

the card amount

attacking

the first attacking player

names

the player names

Attributes

def isOver: Boolean

Returns whether the game is over.

Returns whether the game is over.

Attributes

Returns

true when there is only one player whose turn is not model.Turn.Finished. Otherwise, false.

def load(): Unit

Loads the status from I/O, normally calling model.io.FileIo.load and thus might block. All exceptions will be caught. The method assumes to be called in a valid context and will update all observers

Loads the status from I/O, normally calling model.io.FileIo.load and thus might block. All exceptions will be caught. The method assumes to be called in a valid context and will update all observers

Attributes

def pickUp(): Unit

Should be called when a defending player picks cards up, thus failing to defend. The exact update depends on the implementation, normally base.command.DefendCommand. The method assumes to be called in a valid context and will update all observers

Should be called when a defending player picks cards up, thus failing to defend. The exact update depends on the implementation, normally base.command.DefendCommand. The method assumes to be called in a valid context and will update all observers

Attributes

def redo(): Unit

Redoes the last undone command. The method assumes to be called in a valid context and will update all observers

Redoes the last undone command. The method assumes to be called in a valid context and will update all observers

Attributes

def save(): Unit

Saves the status to I/O, normally calling model.io.FileIo.save and thus might block. All exceptions will be caught. The method assumes to be called in a valid context and will update all observers

Saves the status to I/O, normally calling model.io.FileIo.save and thus might block. All exceptions will be caught. The method assumes to be called in a valid context and will update all observers

Attributes

def unbind(): Unit

Unbinds any I/O, normally calling model.io.FileIo.unbind.

Unbinds any I/O, normally calling model.io.FileIo.unbind.

Attributes

def undo(): Unit

Undoes the last command. The method assumes to be called in a valid context and will update all observers

Undoes the last command. The method assumes to be called in a valid context and will update all observers

Attributes

Inherited methods

def add(observer: Observer): Unit

Adds an observer.

Adds an observer.

Value parameters

observer

the observer to add

Attributes

Inherited from:
Observable
def notifySubscribers(): Unit

Notifies all added observers.

Notifies all added observers.

Attributes

Inherited from:
Observable
def remove(observer: Observer): Unit

Removes an observer.

Removes an observer.

Value parameters

observer

the observer to remove

Attributes

Inherited from:
Observable

Abstract fields

var status: Status

The status contains the current state of the game. It is updated by the controller's methods.

The status contains the current state of the game. It is updated by the controller's methods.

Attributes