BaseController

controller.base.BaseController
class BaseController(val fileIo: FileIo) extends Controller

This is the base implementation of controller.Controller. Every method that does not implement controller.Controller does not change the status directly, but rather often acts upon a model.status.StatusBuilder object.

Value parameters

fileIo

the model.io.FileIo used for saving and loading the status

Attributes

Graph
Supertypes
trait Controller
class Observable
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override 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

Definition Classes
override 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.

Definition Classes
override 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.

Definition Classes
override 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.

Definition Classes
def chooseAttacking(players: List[Player], index: Int): List[Player]

Sets the player at index to model.turn.FirstlyAttacking and all other players' turn accordingly.

Sets the player at index to model.turn.FirstlyAttacking and all other players' turn accordingly.

Value parameters

index

the index of the player to set to model.turn.FirstlyAttacking

players

all players, must contain previous

Attributes

Returns

a list of players with updated turns

def chooseNextAttacking(players: List[Player], previous: Player): List[Player]

Sets the specified player to model.turn.FirstlyAttacking and all other players' turn accordingly.

Sets the specified player to model.turn.FirstlyAttacking and all other players' turn accordingly.

Value parameters

players

all players, must contain previous

previous

the player to set to model.turn.FirstlyAttacking

Attributes

Returns

a list of players with updated turns

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

Definition Classes
override 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

Definition Classes
override 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

Definition Classes

Draws cards from the stack and fills every player's cards up to the set card amount. It will either start with model.status.StatusBuilder.getPassed or with the player who is Turn.FirstlyAttacking.

Draws cards from the stack and fills every player's cards up to the set card amount. It will either start with model.status.StatusBuilder.getPassed or with the player who is Turn.FirstlyAttacking.

Value parameters

statusBuilder

a model.status.StatusBuilder containing the initial status

Attributes

Returns

a model.status.StatusBuilder containing a status with cards drawn from the stack

def finish(finished: Player, statusBuilder: StatusBuilder): StatusBuilder

Sets a player to finished and updates all other data accordingly. This method does not check whether hasFinished returns true.

Sets a player to finished and updates all other data accordingly. This method does not check whether hasFinished returns true.

Value parameters

finished

the player to be set to finished

statusBuilder

a model.status.StatusBuilder containing the current status

Attributes

Returns

an updated model.status.StatusBuilder containing the changes made after the specified player was set to finished

def hasFinished(finished: Player, statusBuilder: StatusBuilder): Boolean

Checks whether the specified player is finished. A player is finished if he is attacking, having no cards left with the stack being empty. A player can also be finished if he is defending, has no cards left without there being undefended cards or cards on the stack.

Checks whether the specified player is finished. A player is finished if he is attacking, having no cards left with the stack being empty. A player can also be finished if he is defending, has no cards left without there being undefended cards or cards on the stack.

Value parameters

finished

the player to check for being finished

statusBuilder

a model.status.StatusBuilder containing the current status

Attributes

Returns

whether the specified player is finished

override 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

Definition Classes
override 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

Definition Classes
override 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.

Definition Classes
override 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

Definition Classes
override 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

Definition Classes
override 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

Definition Classes
override 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

Definition Classes
override def unbind(): Unit

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

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

Attributes

Definition Classes
override 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

Definition Classes
def updatePlayers(players: List[Player], old: Player, updated: Player): List[Player]

Replaces old with updated in players

Replaces old with updated in players

Value parameters

old

the player to be replaced with

players

list of players to update

updated

the player to replace old

Attributes

Returns

an updated list

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

Concrete fields

val fileIo: FileIo
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